From a2c839e71c9c28bb61ca52ce37c329d00cc906e9 Mon Sep 17 00:00:00 2001 From: Richard Antalik Date: Fri, 16 Feb 2024 18:05:23 +0100 Subject: [PATCH] Fix #118190: Tool shortcut does not show in tooltip fa6384eb39 introduced explicit setting of operator context as argument for function `ED_region_panels_ex()`. However, this did not work correctly, because `UiLayout` did not exist when `uiLayoutSetOperatorContext()` was called. This has to be done in `ed_panel_draw()`. Another issue is, that panel may be drawn, when mouse is over tool region, which means, that `sequencer_tools_region_draw()` must look for whether this is happening in preview or timeline region. Pull Request: https://projects.blender.org/blender/blender/pulls/118292 --- source/blender/editors/screen/area.cc | 22 ++++++++++++------- .../space_sequencer/space_sequencer.cc | 14 +++++++----- 2 files changed, 23 insertions(+), 13 deletions(-) diff --git a/source/blender/editors/screen/area.cc b/source/blender/editors/screen/area.cc index cc78c0c67fd..cb1bb332dc5 100644 --- a/source/blender/editors/screen/area.cc +++ b/source/blender/editors/screen/area.cc @@ -2873,7 +2873,8 @@ static void ed_panel_draw(const bContext *C, int w, int em, char *unique_panel_str, - const char *search_filter) + const char *search_filter, + wmOperatorCallContext op_context) { const uiStyle *style = UI_style_get_dpi(); @@ -2911,6 +2912,8 @@ static void ed_panel_draw(const bContext *C, 0, style); + uiLayoutSetOperatorContext(panel->layout, op_context); + pt->draw_header_preset(C, panel); UI_block_apply_search_filter(block, search_filter); @@ -2942,6 +2945,8 @@ static void ed_panel_draw(const bContext *C, block, UI_LAYOUT_HORIZONTAL, UI_LAYOUT_HEADER, labelx, labely, UI_UNIT_Y, 1, 0, style); } + uiLayoutSetOperatorContext(panel->layout, op_context); + pt->draw_header(C, panel); UI_block_apply_search_filter(block, search_filter); @@ -2979,6 +2984,8 @@ static void ed_panel_draw(const bContext *C, 0, style); + uiLayoutSetOperatorContext(panel->layout, op_context); + pt->draw(C, panel); const bool ends_with_layout_panel_header = uiLayoutEndsWithPanelHeader(*panel->layout); @@ -3014,7 +3021,8 @@ static void ed_panel_draw(const bContext *C, w, em, unique_panel_str, - search_filter); + search_filter, + op_context); } } } @@ -3186,11 +3194,8 @@ void ED_region_panels_layout_ex(const bContext *C, update_tot_size = false; } - if (panel && panel->layout) { - uiLayoutSetOperatorContext(panel->layout, op_context); - } - - ed_panel_draw(C, region, ®ion->panels, pt, panel, width, em, nullptr, search_filter); + ed_panel_draw( + C, region, ®ion->panels, pt, panel, width, em, nullptr, search_filter, op_context); } /* Draw "poly-instantiated" panels that don't have a 1 to 1 correspondence with their types. */ @@ -3225,7 +3230,8 @@ void ED_region_panels_layout_ex(const bContext *C, width, em, unique_panel_str, - search_filter); + search_filter, + op_context); } } diff --git a/source/blender/editors/space_sequencer/space_sequencer.cc b/source/blender/editors/space_sequencer/space_sequencer.cc index 86f2ec92f50..232f93da239 100644 --- a/source/blender/editors/space_sequencer/space_sequencer.cc +++ b/source/blender/editors/space_sequencer/space_sequencer.cc @@ -675,14 +675,18 @@ static void sequencer_tools_region_init(wmWindowManager *wm, ARegion *region) static void sequencer_tools_region_draw(const bContext *C, ARegion *region) { + ScrArea *area = CTX_wm_area(C); wmOperatorCallContext op_context = WM_OP_INVOKE_REGION_WIN; - switch (region->regiontype) { - case RGN_TYPE_CHANNELS: - op_context = WM_OP_INVOKE_REGION_CHANNELS; - break; - case RGN_TYPE_PREVIEW: + + LISTBASE_FOREACH (ARegion *, ar, &area->regionbase) { + if (ar->regiontype == RGN_TYPE_PREVIEW && region->regiontype == RGN_TYPE_TOOLS) { op_context = WM_OP_INVOKE_REGION_PREVIEW; break; + } + } + + if (region->regiontype == RGN_TYPE_CHANNELS) { + op_context = WM_OP_INVOKE_REGION_CHANNELS; } ED_region_panels_ex(C, region, op_context, nullptr);