Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulian Eisel <julian@blender.org>2021-10-06 17:15:12 +0300
committerJulian Eisel <julian@blender.org>2021-10-06 17:36:20 +0300
commit536109b4ec336e86de5a7e22e51804584bca74f5 (patch)
treedb9fac77268a34052c2afb8a5313a419e933ed67 /source/blender/editors/interface/tree_view.cc
parent2012d541ae3b9fb4ef099e7c490083b463e60d4f (diff)
Fix possibly wrong matching of tree-view item buttons
The UI code to ensure consistent button state over redraws was just comparing the name of the item, ignoring the parent names. So with multiple items of the same name, there might have been glitches (didn't see any myself though). There's a leftover to-do though, we don't check yet if the matched buttons are actually from the same tree. Added TODO comment.
Diffstat (limited to 'source/blender/editors/interface/tree_view.cc')
-rw-r--r--source/blender/editors/interface/tree_view.cc20
1 files changed, 19 insertions, 1 deletions
diff --git a/source/blender/editors/interface/tree_view.cc b/source/blender/editors/interface/tree_view.cc
index 8f272143b2c..d2971f791c2 100644
--- a/source/blender/editors/interface/tree_view.cc
+++ b/source/blender/editors/interface/tree_view.cc
@@ -419,6 +419,23 @@ void AbstractTreeViewItem::ensure_parents_uncollapsed()
}
}
+bool AbstractTreeViewItem::matches_including_parents(const AbstractTreeViewItem &other) const
+{
+ if (!matches(other)) {
+ return false;
+ }
+
+ for (AbstractTreeViewItem *parent = parent_, *other_parent = other.parent_;
+ parent && other_parent;
+ parent = parent->parent_, other_parent = other_parent->parent_) {
+ if (!parent->matches(*other_parent)) {
+ return false;
+ }
+ }
+
+ return true;
+}
+
void AbstractTreeViewItem::change_state_delayed()
{
if (is_active_fn_()) {
@@ -538,7 +555,8 @@ bool UI_tree_view_item_matches(const uiTreeViewItemHandle *a_handle,
{
const AbstractTreeViewItem &a = reinterpret_cast<const AbstractTreeViewItem &>(*a_handle);
const AbstractTreeViewItem &b = reinterpret_cast<const AbstractTreeViewItem &>(*b_handle);
- return a.matches(b);
+ /* TODO should match the tree-view as well. */
+ return a.matches_including_parents(b);
}
bool UI_tree_view_item_can_drop(const uiTreeViewItemHandle *item_, const wmDrag *drag)