From eb6ca6cf9f28d8b30996e1dfd7c2fc7e4fcbc768 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 3 Jan 2020 16:25:50 +1100 Subject: Fix gizmos flickering when resizing regions --- source/blender/editors/screen/screen_ops.c | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) (limited to 'source/blender/editors/screen/screen_ops.c') diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index 7c47f7439ab..f5ce026e6d6 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; @@ -2727,8 +2742,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 +2758,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) -- cgit v1.2.3 From 846c034323784ac938249b08ad622753d4f3dd34 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 3 Jan 2020 16:40:10 +1100 Subject: UI: scale region hide threshold by zoom level Resolves issue were it wasn't possible to have a single column toolbar when zoomed out. --- source/blender/editors/screen/screen_ops.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'source/blender/editors/screen/screen_ops.c') diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index f5ce026e6d6..dd09def2df6 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -2666,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); @@ -2676,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); @@ -2698,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); @@ -2711,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); -- cgit v1.2.3 From d52551401e185a3e1092fb07edebd07d552e04e2 Mon Sep 17 00:00:00 2001 From: Julian Eisel Date: Thu, 16 Jan 2020 15:55:49 +0100 Subject: Fix wrong usages of region align enumerations `ARegion.alignment` unfortunately is a mixture of value and bitflag enumerations. When checking for left/right/top/bottom region alignment, the flags have to be masked out usually. Most of the fixed cases here probably didn't cause issues in practice, but could in fact break at any point when surrounding logic changes. In fact the assert in #region_visible_rect_calc() failed in an older file from https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=949035. This fixes it. --- source/blender/editors/screen/screen_ops.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'source/blender/editors/screen/screen_ops.c') diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index dd09def2df6..9ea8c8293d4 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -4114,8 +4114,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); @@ -4160,8 +4161,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); @@ -4186,8 +4188,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); -- cgit v1.2.3 From 084f072aae73de39fecc35ac97d602b1db7d0d98 Mon Sep 17 00:00:00 2001 From: Julian Eisel Date: Wed, 22 Jan 2020 17:54:18 +0100 Subject: Fix T73191: Buttons in lower left of Preferences broken I'm still not entirely sure what was going on - I know that the execute region didn't get initialized correctly, but doing that at a later point didn't fix the issue. Apparently forcing the header region to re-initialize does fix it, even though I was sure this was redundant. Also fixes a memory leak in UI code after preferences were opened. --- source/blender/editors/screen/screen_ops.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'source/blender/editors/screen/screen_ops.c') diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index 9ea8c8293d4..0e1ae03fd20 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -4843,7 +4843,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 { -- cgit v1.2.3 From b7075049732a0df53be6483ab5fc2333398b9ebb Mon Sep 17 00:00:00 2001 From: Harley Acheson Date: Tue, 28 Jan 2020 09:33:41 -0800 Subject: UI: Edit Menu - Undo History List and Operator Polling Enable and Disable Edit Menu items based on whether those actions are currently applicable. https://developer.blender.org/D4846 Reviewed by Brecht Van Lommel --- source/blender/editors/screen/screen_ops.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'source/blender/editors/screen/screen_ops.c') diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index 0e1ae03fd20..14ea3aca623 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -3643,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); @@ -3676,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; } /** \} */ @@ -3743,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); } @@ -3775,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; } /** \} */ -- cgit v1.2.3