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-27 15:48:00 +0300
committerJulian Eisel <julian@blender.org>2021-10-27 15:56:57 +0300
commit1832e11f39a36681533c148de9300b290a8c309c (patch)
treee32c59f22eafc0428d190a6a903420832bfc386d /source/blender/editors/include
parent8507336e76902604a2128b23a4d8e52094031ab0 (diff)
UI: Support dragging tree-view items
Adds the needed bits to the UI tree-view API to support dragging tree-view items. This isn't used yet, but will be in the following commit for asset catalogs. There will probably be some further tweaks to the design at some point, for now this should work well enough for our use-cases.
Diffstat (limited to 'source/blender/editors/include')
-rw-r--r--source/blender/editors/include/UI_interface.h1
-rw-r--r--source/blender/editors/include/UI_tree_view.hh18
2 files changed, 19 insertions, 0 deletions
diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h
index 12fdda2092c..0f290d4255b 100644
--- a/source/blender/editors/include/UI_interface.h
+++ b/source/blender/editors/include/UI_interface.h
@@ -2777,6 +2777,7 @@ void UI_interface_tag_script_reload(void);
bool UI_tree_view_item_is_active(const uiTreeViewItemHandle *item);
bool UI_tree_view_item_matches(const uiTreeViewItemHandle *a, const uiTreeViewItemHandle *b);
+bool UI_tree_view_item_drag_start(struct bContext *C, uiTreeViewItemHandle *item_);
bool UI_tree_view_item_can_drop(const uiTreeViewItemHandle *item_,
const struct wmDrag *drag,
const char **r_disabled_hint);
diff --git a/source/blender/editors/include/UI_tree_view.hh b/source/blender/editors/include/UI_tree_view.hh
index 905181a7251..0990d844d48 100644
--- a/source/blender/editors/include/UI_tree_view.hh
+++ b/source/blender/editors/include/UI_tree_view.hh
@@ -49,6 +49,7 @@ namespace blender::ui {
class AbstractTreeView;
class AbstractTreeViewItem;
class AbstractTreeViewItemDropController;
+class AbstractTreeViewItemDragController;
/* ---------------------------------------------------------------------- */
/** \name Tree-View Item Container
@@ -274,6 +275,11 @@ class AbstractTreeViewItem : public TreeViewItemContainer {
virtual bool matches(const AbstractTreeViewItem &other) const;
/**
+ * If an item wants to support being dragged, it has to return a drag controller here.
+ * That is an object implementing #AbstractTreeViewItemDragController.
+ */
+ virtual std::unique_ptr<AbstractTreeViewItemDragController> create_drag_controller() const;
+ /**
* If an item wants to support dropping data into it, it has to return a drop controller here.
* That is an object implementing #AbstractTreeViewItemDropController.
*
@@ -348,6 +354,18 @@ class AbstractTreeViewItem : public TreeViewItemContainer {
* \{ */
/**
+ * Class to enable dragging a tree-item. An item can return a drop controller for itself via a
+ * custom implementation of #AbstractTreeViewItem::create_drag_controller().
+ */
+class AbstractTreeViewItemDragController {
+ public:
+ virtual ~AbstractTreeViewItemDragController() = default;
+
+ virtual int get_drag_type() const = 0;
+ virtual void *create_drag_data() const = 0;
+};
+
+/**
* Class to customize the drop behavior of a tree-item, plus the behavior when dragging over this
* item. An item can return a drop controller for itself via a custom implementation of
* #AbstractTreeViewItem::create_drop_controller().