Fix #111969: Remove gaps between panels and fill in the background #112078

Merged
Lukas Tönne merged 1 commits from LukasTonne/blender:node-panels-remove-gaps into main 2023-09-07 15:07:13 +02:00
1 changed files with 24 additions and 12 deletions

View File

@ -526,7 +526,6 @@ static void node_update_basis_from_declaration(
if (!is_parent_collapsed) {
locy -= NODE_DY;
is_first = false;
need_spacer_after_item = true;
}
SET_FLAG_FROM_TEST(
@ -1758,6 +1757,12 @@ static void node_draw_panels_background(const bNode &node, uiBlock &block)
const nodes::NodeDeclaration &decl = *node.declaration();
const rctf &rct = node.runtime->totr;
float color_panel[4];
UI_GetThemeColorBlend4f(TH_BACK, TH_NODE, 0.2f, color_panel);
/* True if the last panel is open, draw bottom gap as background. */
bool is_last_panel_visible = false;
float last_panel_content_y = 0.0f;
int panel_i = 0;
for (const nodes::ItemDeclarationPtr &item_decl : decl.items) {
@ -1769,25 +1774,21 @@ static void node_draw_panels_background(const bNode &node, uiBlock &block)
}
const bNodePanelState &state = node.panel_states()[panel_i];
const bke::bNodePanelRuntime &runtime = node.runtime->panels[panel_i];
/* Don't draw hidden or collapsed panels. */
if (state.is_collapsed() || state.is_parent_collapsed()) {
const bool is_visible = !(state.is_collapsed() || state.is_parent_collapsed());
is_last_panel_visible = is_visible;
last_panel_content_y = runtime.max_content_y;
if (!is_visible) {
++panel_i;
continue;
}
const bke::bNodePanelRuntime &runtime = node.runtime->panels[panel_i];
const rctf content_rect = {
rct.xmin,
rct.xmax,
runtime.min_content_y,
runtime.max_content_y,
};
UI_block_emboss_set(&block, UI_EMBOSS_NONE);
/* Panel background. */
float color_panel[4];
UI_GetThemeColorBlend4f(TH_BACK, TH_NODE, 0.2f, color_panel);
const rctf content_rect = {rct.xmin, rct.xmax, runtime.min_content_y, runtime.max_content_y};
UI_draw_roundbox_corner_set(UI_CNR_NONE);
UI_draw_roundbox_4fv(&content_rect, true, BASIS_RAD, color_panel);
@ -1795,6 +1796,17 @@ static void node_draw_panels_background(const bNode &node, uiBlock &block)
++panel_i;
}
/* If last item is an open panel, extend the panel background to cover the bottom border. */
if (is_last_panel_visible) {
UI_block_emboss_set(&block, UI_EMBOSS_NONE);
const rctf content_rect = {rct.xmin, rct.xmax, rct.ymin, last_panel_content_y};
UI_draw_roundbox_corner_set(UI_CNR_BOTTOM_RIGHT | UI_CNR_BOTTOM_LEFT);
UI_draw_roundbox_4fv(&content_rect, true, BASIS_RAD, color_panel);
UI_block_emboss_set(&block, UI_EMBOSS);
}
}
static void node_draw_panels(bNodeTree &ntree, const bNode &node, uiBlock &block)