From bc0cdf9c6588a3e9aff448051ef3ff6c6f1687ad Mon Sep 17 00:00:00 2001 From: Harley Acheson Date: Fri, 2 Feb 2024 08:50:16 -0800 Subject: [PATCH 1/3] Recreating last (uncommitted) changes --- .../editors/interface/views/tree_view.cc | 55 ++++++++++--------- 1 file changed, 29 insertions(+), 26 deletions(-) diff --git a/source/blender/editors/interface/views/tree_view.cc b/source/blender/editors/interface/views/tree_view.cc index 017a6958acf..011b4971fba 100644 --- a/source/blender/editors/interface/views/tree_view.cc +++ b/source/blender/editors/interface/views/tree_view.cc @@ -26,6 +26,8 @@ namespace blender::ui { +#define UI_TREEVIEW_INDENT short(0.7f * UI_UNIT_X) + static int unpadded_item_height() { return UI_UNIT_Y; @@ -162,14 +164,14 @@ void AbstractTreeView::draw_hierarchy_lines_recursive(const ARegion ®ion, rcti last_child_rect; ui_but_to_pixelrect(&last_child_rect, ®ion, block, &last_child_but); - /* Small vertical padding. */ - const short line_padding = UI_UNIT_Y / 4.0f / aspect; const float x = first_child_rect.xmin + ((first_descendant->indent_width() - (0.5f * UI_ICON_SIZE) + U.pixelsize + UI_SCALE_FAC) / aspect); + const int first_child_top = first_child_rect.ymax - (2.0f * UI_SCALE_FAC / aspect); + const int last_child_bottom = last_child_rect.ymin + (4.0f * UI_SCALE_FAC / aspect); immBegin(GPU_PRIM_LINES, 2); - immVertex2f(pos, x, first_child_rect.ymax - line_padding); - immVertex2f(pos, x, last_child_rect.ymin + line_padding); + immVertex2f(pos, x, first_child_top); + immVertex2f(pos, x, last_child_bottom); immEnd(); } } @@ -180,20 +182,8 @@ void AbstractTreeView::draw_hierarchy_lines(const ARegion ®ion) const GPUVertFormat *format = immVertexFormat(); uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); - uchar col[4]; - - immBindBuiltinProgram(GPU_SHADER_3D_LINE_DASHED_UNIFORM_COLOR); - - float viewport_size[4]; - GPU_viewport_size_get_f(viewport_size); - immUniform2f("viewport_size", viewport_size[2] / UI_SCALE_FAC, viewport_size[3] / UI_SCALE_FAC); - immUniform1i("colors_len", 0); /* "simple" mode */ - immUniform1f("dash_width", 8.0f); - /* >= is 1.0 for un-dashed lines. */ - immUniform1f("udash_factor", 1.0f); - UI_GetThemeColorBlend3ubv(TH_BACK, TH_TEXT, 0.4f, col); - col[3] = 255; - immUniformColor4ubv(col); + immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); + immUniformThemeColorAlpha(TH_TEXT, 0.2f); GPU_line_width(1.0f / aspect); GPU_blend(GPU_BLEND_ALPHA); @@ -302,6 +292,9 @@ void AbstractTreeViewItem::tree_row_click_fn(bContext *C, void *but_arg1, void * AbstractTreeViewItem &tree_item = reinterpret_cast(*item_but->view_item); tree_item.activate(*C); + /* Not only activate the item, also show its children. Maybe this should be optional, or + * controlled by the specific tree-view. */ + tree_item.set_collapsed(false); } void AbstractTreeViewItem::add_treerow_button(uiBlock &block) @@ -317,7 +310,7 @@ void AbstractTreeViewItem::add_treerow_button(uiBlock &block) int AbstractTreeViewItem::indent_width() const { - return count_parents() * UI_ICON_SIZE; + return count_parents() * UI_TREEVIEW_INDENT; } void AbstractTreeViewItem::add_indent(uiLayout &row) const @@ -328,10 +321,9 @@ void AbstractTreeViewItem::add_indent(uiLayout &row) const uiDefBut(block, UI_BTYPE_SEPR, 0, "", 0, 0, indent_width(), 0, nullptr, 0.0, 0.0, 0, 0, ""); - /* Indent items without collapsing icon some more within their parent. Makes it clear that they - * are actually nested and not just a row at the same level without a chevron. */ - if (!is_collapsible() && parent_) { - uiDefBut(block, UI_BTYPE_SEPR, 0, "", 0, 0, 0.2f * UI_UNIT_X, 0, nullptr, 0.0, 0.0, 0, 0, ""); + if (!is_collapsible()) { + uiDefBut( + block, UI_BTYPE_SEPR, 0, "", 0, 0, UI_TREEVIEW_INDENT, 0, nullptr, 0.0, 0.0, 0, 0, ""); } /* Restore. */ @@ -369,9 +361,20 @@ void AbstractTreeViewItem::add_collapse_chevron(uiBlock &block) const } const BIFIconID icon = is_collapsed() ? ICON_RIGHTARROW : ICON_DOWNARROW_HLT; - uiBut *but = uiDefIconBut( - &block, UI_BTYPE_BUT_TOGGLE, 0, icon, 0, 0, UI_UNIT_X, UI_UNIT_Y, nullptr, 0, 0, 0, 0, ""); - /* Note that we're passing the tree-row button here, not the chevron one. */ + uiBut *but = uiDefIconBut(&block, + UI_BTYPE_BUT_TOGGLE, + 0, + icon, + 0, + 0, + UI_TREEVIEW_INDENT, + UI_UNIT_Y, + nullptr, + 0, + 0, + 0, + 0, + ""); UI_but_func_set(but, collapse_chevron_click_fn, nullptr, nullptr); UI_but_flag_disable(but, UI_BUT_UNDO); } -- 2.30.2 From 4bcd70202b04112fb21fae53863175608c82cc3c Mon Sep 17 00:00:00 2001 From: Harley Acheson Date: Fri, 2 Feb 2024 08:59:03 -0800 Subject: [PATCH 2/3] unintended change, probably merge problem. --- source/blender/editors/interface/views/tree_view.cc | 3 --- 1 file changed, 3 deletions(-) diff --git a/source/blender/editors/interface/views/tree_view.cc b/source/blender/editors/interface/views/tree_view.cc index 011b4971fba..6d6e8889b40 100644 --- a/source/blender/editors/interface/views/tree_view.cc +++ b/source/blender/editors/interface/views/tree_view.cc @@ -292,9 +292,6 @@ void AbstractTreeViewItem::tree_row_click_fn(bContext *C, void *but_arg1, void * AbstractTreeViewItem &tree_item = reinterpret_cast(*item_but->view_item); tree_item.activate(*C); - /* Not only activate the item, also show its children. Maybe this should be optional, or - * controlled by the specific tree-view. */ - tree_item.set_collapsed(false); } void AbstractTreeViewItem::add_treerow_button(uiBlock &block) -- 2.30.2 From 1e5a6968d98c2f740d57c05068dadf588cf208cd Mon Sep 17 00:00:00 2001 From: Harley Acheson Date: Fri, 2 Feb 2024 09:03:41 -0800 Subject: [PATCH 3/3] The current comment should stay in. --- source/blender/editors/interface/views/tree_view.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/source/blender/editors/interface/views/tree_view.cc b/source/blender/editors/interface/views/tree_view.cc index 6d6e8889b40..9739ff763ad 100644 --- a/source/blender/editors/interface/views/tree_view.cc +++ b/source/blender/editors/interface/views/tree_view.cc @@ -318,6 +318,8 @@ void AbstractTreeViewItem::add_indent(uiLayout &row) const uiDefBut(block, UI_BTYPE_SEPR, 0, "", 0, 0, indent_width(), 0, nullptr, 0.0, 0.0, 0, 0, ""); + /* Indent items without collapsing icon some more within their parent. Makes it clear that they + * are actually nested and not just a row at the same level without a chevron. */ if (!is_collapsible()) { uiDefBut( block, UI_BTYPE_SEPR, 0, "", 0, 0, UI_TREEVIEW_INDENT, 0, nullptr, 0.0, 0.0, 0, 0, ""); -- 2.30.2