From b8673bfbe28c57157a30aac93515c029c49f09f6 Mon Sep 17 00:00:00 2001 From: Julian Eisel Date: Fri, 13 Oct 2023 15:56:04 +0200 Subject: [PATCH] Fix spreadsheet tree-view icons too close to collapse icon There was a little hack to remove padding from buttons following the collapse icon by setting the `UI_BUT_NO_TEXT_PADDING` flag, since that added excessive, weird looking spacing. This shouldn't be done for buttons with icons, as it moves the icons too close to the collapse chevron, and is visibly inconsistent with other icon labels in the tree. Turns out, that the entire hack to set the `UI_BUT_NO_TEXT_PADDING` flag is unnecessary since 5c2330203e, which sets the flag everywhere for comparable situations. So the hack can be removed. --- .../blender/editors/include/UI_tree_view.hh | 1 - .../editors/interface/views/tree_view.cc | 28 ------------------- 2 files changed, 29 deletions(-) diff --git a/source/blender/editors/include/UI_tree_view.hh b/source/blender/editors/include/UI_tree_view.hh index a04d85fdc00..d37c2f07a5d 100644 --- a/source/blender/editors/include/UI_tree_view.hh +++ b/source/blender/editors/include/UI_tree_view.hh @@ -245,7 +245,6 @@ class AbstractTreeViewItem : public AbstractViewItem, public TreeViewItemContain private: static void tree_row_click_fn(bContext *, void *, void *); static void collapse_chevron_click_fn(bContext *, void *but_arg1, void *); - static bool is_collapse_chevron_but(const uiBut *but); /** * Override of #AbstractViewItem::set_state_active() that also ensures the parents of this diff --git a/source/blender/editors/interface/views/tree_view.cc b/source/blender/editors/interface/views/tree_view.cc index 816965064a0..c1180d5e7cd 100644 --- a/source/blender/editors/interface/views/tree_view.cc +++ b/source/blender/editors/interface/views/tree_view.cc @@ -361,12 +361,6 @@ void AbstractTreeViewItem::collapse_chevron_click_fn(bContext *C, } } -bool AbstractTreeViewItem::is_collapse_chevron_but(const uiBut *but) -{ - return but->type == UI_BTYPE_BUT_TOGGLE && ELEM(but->icon, ICON_TRIA_RIGHT, ICON_TRIA_DOWN) && - (but->func == collapse_chevron_click_fn); -} - void AbstractTreeViewItem::add_collapse_chevron(uiBlock &block) const { if (!is_collapsible()) { @@ -379,9 +373,6 @@ void AbstractTreeViewItem::add_collapse_chevron(uiBlock &block) const /* Note that we're passing the tree-row button here, not the chevron one. */ UI_but_func_set(but, collapse_chevron_click_fn, nullptr, nullptr); UI_but_flag_disable(but, UI_BUT_UNDO); - - /* Check if the query for the button matches the created button. */ - BLI_assert(is_collapse_chevron_but(but)); } void AbstractTreeViewItem::add_rename_button(uiLayout &row) @@ -577,8 +568,6 @@ class TreeViewLayoutBuilder { private: /* Created through #TreeViewBuilder (friend class). */ TreeViewLayoutBuilder(uiLayout &layout); - - static void polish_layout(const uiBlock &block); }; TreeViewLayoutBuilder::TreeViewLayoutBuilder(uiLayout &layout) : block_(*uiLayoutGetBlock(&layout)) @@ -599,22 +588,6 @@ void TreeViewLayoutBuilder::build_from_tree(const AbstractTreeView &tree_view) UI_block_layout_set_current(&block(), &parent_layout); } -void TreeViewLayoutBuilder::polish_layout(const uiBlock &block) -{ - LISTBASE_FOREACH_BACKWARD (uiBut *, but, &block.buttons) { - if (AbstractTreeViewItem::is_collapse_chevron_but(but) && but->next && - /* Embossed buttons with padding-less text padding look weird, so don't touch them. */ - ELEM(but->next->emboss, UI_EMBOSS_NONE, UI_EMBOSS_NONE_OR_STATUS)) - { - UI_but_drawflag_enable(static_cast(but->next), UI_BUT_NO_TEXT_PADDING); - } - - if (but->type == UI_BTYPE_VIEW_ITEM) { - break; - } - } -} - void TreeViewLayoutBuilder::build_row(AbstractTreeViewItem &item) const { uiBlock &block_ = block(); @@ -649,7 +622,6 @@ void TreeViewLayoutBuilder::build_row(AbstractTreeViewItem &item) const else { item.build_row(*row); } - polish_layout(block_); UI_block_emboss_set(&block_, previous_emboss); UI_block_layout_set_current(&block_, &prev_layout);