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-26 19:48:24 +0300
committerJulian Eisel <julian@blender.org>2021-10-26 19:55:27 +0300
commit11e8a2ec5fc95524a59a7422d2715ef1116dbef4 (patch)
tree709a06d470a2810d140a72599624a7f46a3e6f50 /source/blender/editors/space_file
parent03c0581c6ed6eb98c4c4c7bf42c92d623880dfac (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/space_file')
-rw-r--r--source/blender/editors/space_file/asset_catalog_tree_view.cc19
1 files changed, 11 insertions, 8 deletions
diff --git a/source/blender/editors/space_file/asset_catalog_tree_view.cc b/source/blender/editors/space_file/asset_catalog_tree_view.cc
index 68df4cc0544..a7762008c47 100644
--- a/source/blender/editors/space_file/asset_catalog_tree_view.cc
+++ b/source/blender/editors/space_file/asset_catalog_tree_view.cc
@@ -106,11 +106,11 @@ class AssetCatalogDropController : public ui::AbstractTreeViewItemDropController
explicit AssetCatalogDropController(AssetCatalogTreeView &tree_view,
AssetCatalogTreeItem &catalog_item);
- bool can_drop(const wmDrag &drag) const override;
+ bool can_drop(const wmDrag &drag, const char **r_disabled_hint) const override;
std::string drop_tooltip(const wmDrag &drag) const override;
bool on_drop(const wmDrag &drag) override;
- static bool has_droppable_item(const wmDrag &drag);
+ static bool has_droppable_item(const wmDrag &drag, const char **r_disabled_hint);
static bool drop_into_catalog(const AssetCatalogTreeView &tree_view,
const wmDrag &drag,
CatalogID catalog_id,
@@ -131,7 +131,7 @@ class AssetCatalogTreeViewUnassignedItem : public ui::BasicTreeViewItem {
struct DropController : public ui::AbstractTreeViewItemDropController {
DropController(AssetCatalogTreeView &tree_view);
- bool can_drop(const wmDrag &drag) const override;
+ bool can_drop(const wmDrag &drag, const char **r_disabled_hint) const override;
std::string drop_tooltip(const wmDrag &drag) const override;
bool on_drop(const wmDrag &drag) override;
};
@@ -320,12 +320,12 @@ AssetCatalogDropController::AssetCatalogDropController(AssetCatalogTreeView &tre
{
}
-bool AssetCatalogDropController::can_drop(const wmDrag &drag) const
+bool AssetCatalogDropController::can_drop(const wmDrag &drag, const char **r_disabled_hint) const
{
if (drag.type != WM_DRAG_ASSET_LIST) {
return false;
}
- return has_droppable_item(drag);
+ return has_droppable_item(drag, r_disabled_hint);
}
std::string AssetCatalogDropController::drop_tooltip(const wmDrag &drag) const
@@ -377,10 +377,12 @@ bool AssetCatalogDropController::drop_into_catalog(const AssetCatalogTreeView &t
return true;
}
-bool AssetCatalogDropController::has_droppable_item(const wmDrag &drag)
+bool AssetCatalogDropController::has_droppable_item(const wmDrag &drag,
+ const char **r_disabled_hint)
{
const ListBase *asset_drags = WM_drag_asset_list_get(&drag);
+ *r_disabled_hint = nullptr;
/* There needs to be at least one asset from the current file. */
LISTBASE_FOREACH (const wmDragAssetListItem *, asset_item, asset_drags) {
if (!asset_item->is_external) {
@@ -421,12 +423,13 @@ AssetCatalogTreeViewUnassignedItem::DropController::DropController(AssetCatalogT
{
}
-bool AssetCatalogTreeViewUnassignedItem::DropController::can_drop(const wmDrag &drag) const
+bool AssetCatalogTreeViewUnassignedItem::DropController::can_drop(
+ const wmDrag &drag, const char **r_disabled_hint) const
{
if (drag.type != WM_DRAG_ASSET_LIST) {
return false;
}
- return AssetCatalogDropController::has_droppable_item(drag);
+ return AssetCatalogDropController::has_droppable_item(drag, r_disabled_hint);
}
std::string AssetCatalogTreeViewUnassignedItem::DropController::drop_tooltip(