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
This commit is contained in:
Richard Antalik
2024-02-16 18:05:23 +01:00
committed by Richard Antalik
parent 17ca22ae9f
commit a2c839e71c
2 changed files with 23 additions and 13 deletions

View File

@@ -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, &region->panels, pt, panel, width, em, nullptr, search_filter);
ed_panel_draw(
C, region, &region->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);
}
}

View File

@@ -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);