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-04 00:58:20 +0300
committerJulian Eisel <julian@blender.org>2021-10-04 00:58:20 +0300
commitc4dca6522812670ab9782e4f90553c5054109f3d (patch)
tree24dc1e2c0eb55985e8e6543b131989da1ca4125e /source/blender/blenkernel
parent3b1a2430391a6c1e0ea2744cfce2cf0749c72c85 (diff)
Asset Browser: Support dragging assets into catalogs
With this it is possible to select any number of assets in the Asset Browser and drag them into catalogs. The assets will be moved to that catalog then. However, this will only work in the "Current File" asset library, since that is the only library that allows changing assets, which is what's done here. While dragging assets over the tree row, a tooltip is shown explaining what's going to happen. In preparation to this, the new UI tree-view API was already extended with custom drop support, see 4ee2d9df428d. ---- Changes here to the `wmDrag` code were needed to support dragging multiple assets. Some of it is considered temporary because a) a proper #AssetHandle design should replace some ugly parts of this patch and b) the multi-item support in `wmDrag` isn't that great yet. The entire API will have to be written anyway (see D4071). Maniphest Tasks: T91573 Differential Revision: https://developer.blender.org/D12713 Reviewed by: Sybren Stüvel
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r--source/blender/blenkernel/BKE_asset_catalog.hh6
-rw-r--r--source/blender/blenkernel/intern/asset_catalog.cc16
2 files changed, 17 insertions, 5 deletions
diff --git a/source/blender/blenkernel/BKE_asset_catalog.hh b/source/blender/blenkernel/BKE_asset_catalog.hh
index 8afc4fe2ad2..b6b90cff5fd 100644
--- a/source/blender/blenkernel/BKE_asset_catalog.hh
+++ b/source/blender/blenkernel/BKE_asset_catalog.hh
@@ -181,10 +181,12 @@ class AssetCatalogTreeItem {
AssetCatalogTreeItem(StringRef name,
CatalogID catalog_id,
+ StringRef simple_name,
const AssetCatalogTreeItem *parent = nullptr);
CatalogID get_catalog_id() const;
- StringRef get_name() const;
+ StringRefNull get_simple_name() const;
+ StringRefNull get_name() const;
/** Return the full catalog path, defined as the name of this catalog prefixed by the full
* catalog path of its parent and a separator. */
AssetCatalogPath catalog_path() const;
@@ -201,6 +203,8 @@ class AssetCatalogTreeItem {
/** The user visible name of this component. */
CatalogPathComponent name_;
CatalogID catalog_id_;
+ /** Copy of #AssetCatalog::simple_name. */
+ std::string simple_name_;
/** Pointer back to the parent item. Used to reconstruct the hierarchy from an item (e.g. to
* build a path). */
diff --git a/source/blender/blenkernel/intern/asset_catalog.cc b/source/blender/blenkernel/intern/asset_catalog.cc
index 2c7cf28d60d..577d916288a 100644
--- a/source/blender/blenkernel/intern/asset_catalog.cc
+++ b/source/blender/blenkernel/intern/asset_catalog.cc
@@ -426,8 +426,9 @@ void AssetCatalogService::create_missing_catalogs()
AssetCatalogTreeItem::AssetCatalogTreeItem(StringRef name,
CatalogID catalog_id,
+ StringRef simple_name,
const AssetCatalogTreeItem *parent)
- : name_(name), catalog_id_(catalog_id), parent_(parent)
+ : name_(name), catalog_id_(catalog_id), simple_name_(simple_name), parent_(parent)
{
}
@@ -436,11 +437,16 @@ CatalogID AssetCatalogTreeItem::get_catalog_id() const
return catalog_id_;
}
-StringRef AssetCatalogTreeItem::get_name() const
+StringRefNull AssetCatalogTreeItem::get_name() const
{
return name_;
}
+StringRefNull AssetCatalogTreeItem::get_simple_name() const
+{
+ return simple_name_;
+}
+
AssetCatalogPath AssetCatalogTreeItem::catalog_path() const
{
AssetCatalogPath current_path = name_;
@@ -482,8 +488,10 @@ void AssetCatalogTree::insert_item(const AssetCatalog &catalog)
/* Insert new tree element - if no matching one is there yet! */
auto [key_and_item, was_inserted] = current_item_children->emplace(
component_name,
- AssetCatalogTreeItem(
- component_name, is_last_component ? catalog.catalog_id : nil_id, parent));
+ AssetCatalogTreeItem(component_name,
+ is_last_component ? catalog.catalog_id : nil_id,
+ is_last_component ? catalog.simple_name : "",
+ parent));
AssetCatalogTreeItem &item = key_and_item->second;
/* If full path of this catalog already exists as parent path of a previously read catalog,