diff options
author | Julian Eisel <julian@blender.org> | 2021-10-26 19:48:24 +0300 |
---|---|---|
committer | Julian Eisel <julian@blender.org> | 2021-10-26 19:55:27 +0300 |
commit | 11e8a2ec5fc95524a59a7422d2715ef1116dbef4 (patch) | |
tree | 709a06d470a2810d140a72599624a7f46a3e6f50 /source/blender/editors/interface/tree_view.cc | |
parent | 03c0581c6ed6eb98c4c4c7bf42c92d623880dfac (diff) |
UI: Support disabled-hint for dropping in the tree-view API
A tree-view item's drop controller can now return a message for the user
explaining why dropping isn't possible with the dropped data. This is then
displayed in red text next to the cursor.
This isn't actually used yet, the follow up commit will do that.
Diffstat (limited to 'source/blender/editors/interface/tree_view.cc')
-rw-r--r-- | source/blender/editors/interface/tree_view.cc | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/source/blender/editors/interface/tree_view.cc b/source/blender/editors/interface/tree_view.cc index da95cad0fc7..0eeb32bcc69 100644 --- a/source/blender/editors/interface/tree_view.cc +++ b/source/blender/editors/interface/tree_view.cc @@ -675,7 +675,9 @@ bool UI_tree_view_item_matches(const uiTreeViewItemHandle *a_handle, return a.matches_including_parents(b); } -bool UI_tree_view_item_can_drop(const uiTreeViewItemHandle *item_, const wmDrag *drag) +bool UI_tree_view_item_can_drop(const uiTreeViewItemHandle *item_, + const wmDrag *drag, + const char **r_disabled_hint) { const AbstractTreeViewItem &item = reinterpret_cast<const AbstractTreeViewItem &>(*item_); const std::unique_ptr<AbstractTreeViewItemDropController> drop_controller = @@ -684,7 +686,7 @@ bool UI_tree_view_item_can_drop(const uiTreeViewItemHandle *item_, const wmDrag return false; } - return drop_controller->can_drop(*drag); + return drop_controller->can_drop(*drag, r_disabled_hint); } char *UI_tree_view_item_drop_tooltip(const uiTreeViewItemHandle *item_, const wmDrag *drag) @@ -709,8 +711,9 @@ bool UI_tree_view_item_drop_handle(uiTreeViewItemHandle *item_, const ListBase * std::unique_ptr<AbstractTreeViewItemDropController> drop_controller = item.create_drop_controller(); + const char *disabled_hint_dummy = nullptr; LISTBASE_FOREACH (const wmDrag *, drag, drags) { - if (drop_controller->can_drop(*drag)) { + if (drop_controller->can_drop(*drag, &disabled_hint_dummy)) { return drop_controller->on_drop(*drag); } } |