diff options
Diffstat (limited to 'source/blender/editors/screen/screen_ops.c')
-rw-r--r-- | source/blender/editors/screen/screen_ops.c | 73 |
1 files changed, 51 insertions, 22 deletions
diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index 7c47f7439ab..14ea3aca623 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -929,6 +929,8 @@ static void actionzone_exit(wmOperator *op) MEM_freeN(op->customdata); } op->customdata = NULL; + + G.moving &= ~G_TRANSFORM_WM; } /* send EVT_ACTIONZONE event */ @@ -986,9 +988,11 @@ static int actionzone_invoke(bContext *C, wmOperator *op, const wmEvent *event) return OPERATOR_FINISHED; } else { + BLI_assert(ELEM(sad->az->type, AZONE_AREA, AZONE_REGION_SCROLL)); + /* add modal handler */ + G.moving |= G_TRANSFORM_WM; WM_event_add_modal_handler(C, op); - return OPERATOR_RUNNING_MODAL; } } @@ -1807,9 +1811,8 @@ static int area_move_invoke(bContext *C, wmOperator *op, const wmEvent *event) return OPERATOR_PASS_THROUGH; } - G.moving |= G_TRANSFORM_WM; - /* add temp handler */ + G.moving |= G_TRANSFORM_WM; WM_event_add_modal_handler(C, op); return OPERATOR_RUNNING_MODAL; @@ -2115,6 +2118,8 @@ static void area_split_exit(bContext *C, wmOperator *op) /* this makes sure aligned edges will result in aligned grabbing */ BKE_screen_remove_double_scrverts(CTX_wm_screen(C)); BKE_screen_remove_double_scredges(CTX_wm_screen(C)); + + G.moving &= ~G_TRANSFORM_WM; } static void area_split_preview_update_cursor(bContext *C, wmOperator *op) @@ -2247,6 +2252,7 @@ static int area_split_invoke(bContext *C, wmOperator *op, const wmEvent *event) area_move_set_limits(win, sc, dir, &sd->bigger, &sd->smaller, NULL); /* add temp handler for edge move or cancel */ + G.moving |= G_TRANSFORM_WM; WM_event_add_modal_handler(C, op); return OPERATOR_RUNNING_MODAL; @@ -2526,6 +2532,14 @@ static bool is_split_edge(const int alignment, const AZEdge edge) ((alignment == RGN_ALIGN_RIGHT) && (edge == AE_LEFT_TO_TOPRIGHT)); } +static void region_scale_exit(wmOperator *op) +{ + MEM_freeN(op->customdata); + op->customdata = NULL; + + G.moving &= ~G_TRANSFORM_WM; +} + static int region_scale_invoke(bContext *C, wmOperator *op, const wmEvent *event) { sActionzoneData *sad = event->customdata; @@ -2579,6 +2593,7 @@ static int region_scale_invoke(bContext *C, wmOperator *op, const wmEvent *event CLAMP(rmd->maxsize, 0, 1000); /* add temp handler */ + G.moving |= G_TRANSFORM_WM; WM_event_add_modal_handler(C, op); return OPERATOR_RUNNING_MODAL; @@ -2651,7 +2666,8 @@ static int region_scale_modal(bContext *C, wmOperator *op, const wmEvent *event) /* region sizes now get multiplied */ delta /= UI_DPI_FAC; - rmd->ar->sizex = rmd->origval + delta; + const int size_no_snap = rmd->origval + delta; + rmd->ar->sizex = size_no_snap; if (rmd->ar->type->snap_size) { short sizex_test = rmd->ar->type->snap_size(rmd->ar, rmd->ar->sizex, 0); @@ -2661,7 +2677,7 @@ static int region_scale_modal(bContext *C, wmOperator *op, const wmEvent *event) } CLAMP(rmd->ar->sizex, 0, rmd->maxsize); - if (rmd->ar->sizex < UI_UNIT_X) { + if (size_no_snap < UI_UNIT_X / aspect) { rmd->ar->sizex = rmd->origval; if (!(rmd->ar->flag & RGN_FLAG_HIDDEN)) { region_scale_toggle_hidden(C, rmd); @@ -2683,7 +2699,8 @@ static int region_scale_modal(bContext *C, wmOperator *op, const wmEvent *event) /* region sizes now get multiplied */ delta /= UI_DPI_FAC; - rmd->ar->sizey = rmd->origval + delta; + const int size_no_snap = rmd->origval + delta; + rmd->ar->sizey = size_no_snap; if (rmd->ar->type->snap_size) { short sizey_test = rmd->ar->type->snap_size(rmd->ar, rmd->ar->sizey, 1); @@ -2696,7 +2713,7 @@ static int region_scale_modal(bContext *C, wmOperator *op, const wmEvent *event) /* note, 'UI_UNIT_Y/4' means you need to drag the footer and execute region * almost all the way down for it to become hidden, this is done * otherwise its too easy to do this by accident */ - if (rmd->ar->sizey < UI_UNIT_Y / 4) { + if (size_no_snap < (UI_UNIT_Y / 4) / aspect) { rmd->ar->sizey = rmd->origval; if (!(rmd->ar->flag & RGN_FLAG_HIDDEN)) { region_scale_toggle_hidden(C, rmd); @@ -2727,8 +2744,8 @@ static int region_scale_modal(bContext *C, wmOperator *op, const wmEvent *event) ED_area_tag_redraw(rmd->sa); WM_event_add_notifier(C, NC_SCREEN | NA_EDITED, NULL); } - MEM_freeN(op->customdata); - op->customdata = NULL; + + region_scale_exit(op); return OPERATOR_FINISHED; } @@ -2743,8 +2760,7 @@ static int region_scale_modal(bContext *C, wmOperator *op, const wmEvent *event) static void region_scale_cancel(bContext *UNUSED(C), wmOperator *op) { - MEM_freeN(op->customdata); - op->customdata = NULL; + region_scale_exit(op); } static void SCREEN_OT_region_scale(wmOperatorType *ot) @@ -3627,6 +3643,15 @@ static void SCREEN_OT_spacedata_cleanup(wmOperatorType *ot) /** \name Repeat Last Operator * \{ */ +static bool repeat_history_poll(bContext *C) +{ + if (!ED_operator_screenactive(C)) { + return false; + } + wmWindowManager *wm = CTX_wm_manager(C); + return !BLI_listbase_is_empty(&wm->operators); +} + static int repeat_last_exec(bContext *C, wmOperator *UNUSED(op)) { wmWindowManager *wm = CTX_wm_manager(C); @@ -3660,7 +3685,7 @@ static void SCREEN_OT_repeat_last(wmOperatorType *ot) /* api callbacks */ ot->exec = repeat_last_exec; - ot->poll = ED_operator_screenactive; + ot->poll = repeat_history_poll; } /** \} */ @@ -3727,8 +3752,7 @@ static void SCREEN_OT_repeat_history(wmOperatorType *ot) /* api callbacks */ ot->invoke = repeat_history_invoke; ot->exec = repeat_history_exec; - - ot->poll = ED_operator_screenactive; + ot->poll = repeat_history_poll; RNA_def_int(ot->srna, "index", 0, 0, INT_MAX, "Index", "", 0, 1000); } @@ -3759,8 +3783,7 @@ static void SCREEN_OT_redo_last(wmOperatorType *ot) /* api callbacks */ ot->invoke = redo_last_invoke; - - ot->poll = ED_operator_screenactive; + ot->poll = repeat_history_poll; } /** \} */ @@ -4098,8 +4121,9 @@ void ED_screens_header_tools_menu_create(bContext *C, uiLayout *layout, void *UN { ScrArea *sa = CTX_wm_area(C); ARegion *ar = CTX_wm_region(C); - const char *but_flip_str = (ar->alignment == RGN_ALIGN_TOP) ? IFACE_("Flip to Bottom") : - IFACE_("Flip to Top"); + const char *but_flip_str = (RGN_ALIGN_ENUM_FROM_MASK(ar->alignment) == RGN_ALIGN_TOP) ? + IFACE_("Flip to Bottom") : + IFACE_("Flip to Top"); { PointerRNA ptr; RNA_pointer_create((ID *)CTX_wm_screen(C), &RNA_Space, sa->spacedata.first, &ptr); @@ -4144,8 +4168,9 @@ void ED_screens_footer_tools_menu_create(bContext *C, uiLayout *layout, void *UN { ScrArea *sa = CTX_wm_area(C); ARegion *ar = CTX_wm_region(C); - const char *but_flip_str = (ar->alignment == RGN_ALIGN_TOP) ? IFACE_("Flip to Bottom") : - IFACE_("Flip to Top"); + const char *but_flip_str = (RGN_ALIGN_ENUM_FROM_MASK(ar->alignment) == RGN_ALIGN_TOP) ? + IFACE_("Flip to Bottom") : + IFACE_("Flip to Top"); { PointerRNA ptr; RNA_pointer_create((ID *)CTX_wm_screen(C), &RNA_Space, sa->spacedata.first, &ptr); @@ -4170,8 +4195,9 @@ void ED_screens_footer_tools_menu_create(bContext *C, uiLayout *layout, void *UN void ED_screens_navigation_bar_tools_menu_create(bContext *C, uiLayout *layout, void *UNUSED(arg)) { const ARegion *ar = CTX_wm_region(C); - const char *but_flip_str = (ar->alignment == RGN_ALIGN_LEFT) ? IFACE_("Flip to Right") : - IFACE_("Flip to Left"); + const char *but_flip_str = (RGN_ALIGN_ENUM_FROM_MASK(ar->alignment) == RGN_ALIGN_LEFT) ? + IFACE_("Flip to Right") : + IFACE_("Flip to Left"); /* default is WM_OP_INVOKE_REGION_WIN, which we don't want here. */ uiLayoutSetOperatorContext(layout, WM_OP_INVOKE_DEFAULT); @@ -4824,7 +4850,10 @@ static int userpref_show_invoke(bContext *C, wmOperator *op, const wmEvent *even * So hiding in the temp window makes sense. */ ScrArea *area = CTX_wm_area(C); ARegion *region = BKE_area_find_region_type(area, RGN_TYPE_HEADER); + region->flag |= RGN_FLAG_HIDDEN; + ED_region_visibility_change_update(C, area, region); + return OPERATOR_FINISHED; } else { |