From c8f2a5cc4255a9c059c0a3ac835735d44418d136 Mon Sep 17 00:00:00 2001 From: Jesse Yurkovich Date: Fri, 16 Feb 2024 08:40:32 +0100 Subject: [PATCH] UI: Fix FILE_PT_operator drawing when using UI layout panels The `FILE_PT_operator` panel used in the file browser does not correctly allow the new UI layout panels to be drawn correctly. The layout panels depend on drawing the background so that different colors can denote each panel section. In the case of `FILE_PT_operator`, this background drawing is skipped entirely leading to a situation where there's no panel delineation at all. Forcing the background to be drawn leads to a second problem where the "typical" panel colors are not used in this part of the file browser. We need to match the surrounding area otherwise a much lighter shade of gray will be used and look out of place. The fix is to extend the processing for PANEL_TYPE_NO_HEADER to account for both of the above situations. Pull Request: https://projects.blender.org/blender/blender/pulls/118231 --- .../blender/editors/interface/interface_panel.cc | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/source/blender/editors/interface/interface_panel.cc b/source/blender/editors/interface/interface_panel.cc index 3daa6241d8e..72c73fc6124 100644 --- a/source/blender/editors/interface/interface_panel.cc +++ b/source/blender/editors/interface/interface_panel.cc @@ -1167,8 +1167,9 @@ static void panel_draw_aligned_backdrop(const ARegion *region, const rcti *rect, const rcti *header_rect) { - const bool is_subpanel = panel->type->parent != nullptr; const bool is_open = !UI_panel_is_closed(panel); + const bool is_subpanel = panel->type->parent != nullptr; + const bool has_header = (panel->type->flag & PANEL_TYPE_NO_HEADER) == 0; if (is_subpanel && !is_open) { return; @@ -1182,10 +1183,15 @@ static void panel_draw_aligned_backdrop(const ARegion *region, GPU_blend(GPU_BLEND_ALPHA); /* Panel backdrop. */ - if (is_open || panel->type->flag & PANEL_TYPE_NO_HEADER) { + if (is_open || !has_header) { float panel_backcolor[4]; UI_draw_roundbox_corner_set(is_open ? UI_CNR_BOTTOM_RIGHT | UI_CNR_BOTTOM_LEFT : UI_CNR_ALL); - UI_GetThemeColor4fv((is_subpanel ? TH_PANEL_SUB_BACK : TH_PANEL_BACK), panel_backcolor); + if (!has_header) { + UI_GetThemeColor4fv(TH_BACK, panel_backcolor); + } + else { + UI_GetThemeColor4fv((is_subpanel ? TH_PANEL_SUB_BACK : TH_PANEL_BACK), panel_backcolor); + } rctf box_rect; box_rect.xmin = rect->xmin; @@ -1222,7 +1228,7 @@ static void panel_draw_aligned_backdrop(const ARegion *region, } /* Panel header backdrops for non sub-panels. */ - if (!is_subpanel) { + if (!is_subpanel && has_header) { float panel_headercolor[4]; UI_GetThemeColor4fv(UI_panel_matches_search_filter(panel) ? TH_MATCH : TH_PANEL_HEADER, panel_headercolor); @@ -1259,7 +1265,7 @@ void ui_draw_aligned_panel(const ARegion *region, rect->ymax + int(floor(PNL_HEADER / block->aspect + 0.001f)), }; - if (show_background) { + if (show_background || (panel->type->flag & PANEL_TYPE_NO_HEADER)) { panel_draw_aligned_backdrop(region, panel, rect, &header_rect); }