From ebe23745281e8675a6b45c39f79441a4f896963e Mon Sep 17 00:00:00 2001 From: Dalai Felinto Date: Fri, 8 Oct 2021 11:43:52 +0200 Subject: [PATCH] User Interface: Make the background inside a node group brighter The breadcrumbs alone may not be enough to indicate that a user is inside a nodegroup. The original dark green color was a bit overwhelming but having a different background helps. This is a follow up to 919e513fa8f9f. --- .../blender/editors/space_node/node_draw.cc | 24 ++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/source/blender/editors/space_node/node_draw.cc b/source/blender/editors/space_node/node_draw.cc index b5e2434f3d8..bcebd73e9a7 100644 --- a/source/blender/editors/space_node/node_draw.cc +++ b/source/blender/editors/space_node/node_draw.cc @@ -2176,6 +2176,28 @@ static void draw_nodetree(const bContext *C, node_draw_nodetree(C, region, snode, ntree, parent_key); } +/** + * Make the background slightly brighter to indicate that users are inside a nodegroup. + **/ +static void draw_background_color(const SpaceNode *snode) +{ + const int max_depth = 2; + const float bright_factor = 0.25f; + + float color[3]; + UI_GetThemeColor3fv(TH_BACK, color); + + int depth = 0; + bNodeTreePath *path = (bNodeTreePath *)snode->treepath.last; + while (path->prev && depth < max_depth) { + path = path->prev; + depth++; + } + + mul_v3_fl(color, 1.0f + bright_factor * depth); + GPU_clear_color(color[0], color[1], color[2], 1.0); +} + void node_draw_space(const bContext *C, ARegion *region) { wmWindow *win = CTX_wm_window(C); @@ -2189,7 +2211,7 @@ void node_draw_space(const bContext *C, ARegion *region) GPU_framebuffer_bind_no_srgb(framebuffer_overlay); UI_view2d_view_ortho(v2d); - UI_ThemeClearColor(TH_BACK); + draw_background_color(snode); GPU_depth_test(GPU_DEPTH_NONE); GPU_scissor_test(true);