diff options
Diffstat (limited to 'source/blender/editors')
-rw-r--r-- | source/blender/editors/screen/screen_ops.c | 100 |
1 files changed, 48 insertions, 52 deletions
diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index d2fc1d6fc0b..2e5f93ff521 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -1762,55 +1762,9 @@ static int area_split_modal(bContext *C, wmOperator *op, const wmEvent *event) /* execute the events */ switch (event->type) { case MOUSEMOVE: - { - const int dir = RNA_property_enum_get(op->ptr, prop_dir); - - sd->delta = (dir == 'v') ? event->x - sd->origval : event->y - sd->origval; - - if (sd->previewmode == 0) { - if (sd->do_snap) { - const int snap_loc = area_snap_calc_location( - CTX_wm_screen(C), sd->delta, sd->origval, dir, sd->bigger, sd->smaller); - sd->delta = snap_loc - sd->origval; - } - area_move_apply_do(C, sd->delta, sd->origval, dir, sd->bigger, sd->smaller, false); - } - else { - if (sd->sarea) { - ED_area_tag_redraw(sd->sarea); - } - /* area context not set */ - sd->sarea = BKE_screen_find_area_xy(CTX_wm_screen(C), SPACE_TYPE_ANY, event->x, event->y); - - if (sd->sarea) { - ScrArea *sa = sd->sarea; - if (dir == 'v') { - sd->origsize = sa->winx; - sd->origmin = sa->totrct.xmin; - } - else { - sd->origsize = sa->winy; - sd->origmin = sa->totrct.ymin; - } - - if (sd->do_snap) { - sa->v1->editflag = sa->v2->editflag = sa->v3->editflag = sa->v4->editflag = 1; - - const int snap_loc = area_snap_calc_location( - CTX_wm_screen(C), sd->delta, sd->origval, dir, sd->origmin + sd->origsize, -sd->origmin); - - sa->v1->editflag = sa->v2->editflag = sa->v3->editflag = sa->v4->editflag = 0; - sd->delta = snap_loc - sd->origval; - } - - update_factor = true; - } - - CTX_wm_window(C)->screen->do_draw = true; - - } + update_factor = true; break; - } + case LEFTMOUSE: if (sd->previewmode) { area_split_apply(C, op); @@ -1855,12 +1809,54 @@ static int area_split_modal(bContext *C, wmOperator *op, const wmEvent *event) } if (update_factor) { - float fac = (float)(sd->delta + sd->origval - sd->origmin) / sd->origsize; - RNA_float_set(op->ptr, "factor", fac); + const int dir = RNA_property_enum_get(op->ptr, prop_dir); + + sd->delta = (dir == 'v') ? event->x - sd->origval : event->y - sd->origval; + + if (sd->previewmode == 0) { + if (sd->do_snap) { + const int snap_loc = area_snap_calc_location( + CTX_wm_screen(C), sd->delta, sd->origval, dir, sd->bigger, sd->smaller); + sd->delta = snap_loc - sd->origval; + } + area_move_apply_do(C, sd->delta, sd->origval, dir, sd->bigger, sd->smaller, false); + } + else { + if (sd->sarea) { + ED_area_tag_redraw(sd->sarea); + } + /* area context not set */ + sd->sarea = BKE_screen_find_area_xy(CTX_wm_screen(C), SPACE_TYPE_ANY, event->x, event->y); + + if (sd->sarea) { + ScrArea *sa = sd->sarea; + if (dir == 'v') { + sd->origsize = sa->winx; + sd->origmin = sa->totrct.xmin; + } + else { + sd->origsize = sa->winy; + sd->origmin = sa->totrct.ymin; + } - if (sd->sarea) { - ED_area_tag_redraw(sd->sarea); + if (sd->do_snap) { + sa->v1->editflag = sa->v2->editflag = sa->v3->editflag = sa->v4->editflag = 1; + + const int snap_loc = area_snap_calc_location( + CTX_wm_screen(C), sd->delta, sd->origval, dir, sd->origmin + sd->origsize, -sd->origmin); + + sa->v1->editflag = sa->v2->editflag = sa->v3->editflag = sa->v4->editflag = 0; + sd->delta = snap_loc - sd->origval; + } + + ED_area_tag_redraw(sd->sarea); + } + + CTX_wm_window(C)->screen->do_draw = true; } + + float fac = (float)(sd->delta + sd->origval - sd->origmin) / sd->origsize; + RNA_float_set(op->ptr, "factor", fac); } return OPERATOR_RUNNING_MODAL; |