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
path: root/source
diff options
context:
space:
mode:
authorSybren A. Stüvel <sybren@blender.org>2021-11-25 17:22:40 +0300
committerSybren A. Stüvel <sybren@blender.org>2021-11-25 17:22:40 +0300
commit3652f5f758aafa2103519c3c0663ba8643b554c1 (patch)
treecde6022d74747015518ffc8ae4c650176617fbf7 /source
parent9812a08848b8a5264948ae1e2a4b0343d2e7f9e2 (diff)
parentc91d1961596eb3ac0905010b63551951fc1fece7 (diff)
Merge remote-tracking branch 'origin/blender-v3.0-release'
Diffstat (limited to 'source')
-rw-r--r--source/blender/editors/include/UI_interface.h4
-rw-r--r--source/blender/editors/include/UI_tree_view.hh2
-rw-r--r--source/blender/editors/interface/interface_ops.c2
-rw-r--r--source/blender/editors/interface/tree_view.cc6
-rw-r--r--source/blender/editors/space_file/asset_catalog_tree_view.cc31
5 files changed, 30 insertions, 15 deletions
diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h
index d5d45068828..29d031ba13d 100644
--- a/source/blender/editors/include/UI_interface.h
+++ b/source/blender/editors/include/UI_interface.h
@@ -2782,7 +2782,9 @@ bool UI_tree_view_item_can_drop(const uiTreeViewItemHandle *item_,
const struct wmDrag *drag,
const char **r_disabled_hint);
char *UI_tree_view_item_drop_tooltip(const uiTreeViewItemHandle *item, const struct wmDrag *drag);
-bool UI_tree_view_item_drop_handle(uiTreeViewItemHandle *item_, const struct ListBase *drags);
+bool UI_tree_view_item_drop_handle(struct bContext *C,
+ uiTreeViewItemHandle *item_,
+ const struct ListBase *drags);
bool UI_tree_view_item_can_rename(const uiTreeViewItemHandle *item_handle);
void UI_tree_view_item_begin_rename(uiTreeViewItemHandle *item_handle);
diff --git a/source/blender/editors/include/UI_tree_view.hh b/source/blender/editors/include/UI_tree_view.hh
index 7682570a5c6..0a054101e81 100644
--- a/source/blender/editors/include/UI_tree_view.hh
+++ b/source/blender/editors/include/UI_tree_view.hh
@@ -407,7 +407,7 @@ class AbstractTreeViewItemDropController {
* Execute the logic to apply a drop of the data dragged with \a drag onto/into the item this
* controller is for.
*/
- virtual bool on_drop(const wmDrag &drag) = 0;
+ virtual bool on_drop(struct bContext *C, const wmDrag &drag) = 0;
template<class TreeViewType> inline TreeViewType &tree_view() const;
};
diff --git a/source/blender/editors/interface/interface_ops.c b/source/blender/editors/interface/interface_ops.c
index 9cce7dd5c85..e1fd7386408 100644
--- a/source/blender/editors/interface/interface_ops.c
+++ b/source/blender/editors/interface/interface_ops.c
@@ -1980,7 +1980,7 @@ static int ui_tree_view_drop_invoke(bContext *C, wmOperator *UNUSED(op), const w
const ARegion *region = CTX_wm_region(C);
uiTreeViewItemHandle *hovered_tree_item = UI_block_tree_view_find_item_at(region, event->xy);
- if (!UI_tree_view_item_drop_handle(hovered_tree_item, event->customdata)) {
+ if (!UI_tree_view_item_drop_handle(C, hovered_tree_item, event->customdata)) {
return OPERATOR_CANCELLED | OPERATOR_PASS_THROUGH;
}
diff --git a/source/blender/editors/interface/tree_view.cc b/source/blender/editors/interface/tree_view.cc
index 3ed027ddd9d..b8c07b15bdc 100644
--- a/source/blender/editors/interface/tree_view.cc
+++ b/source/blender/editors/interface/tree_view.cc
@@ -787,7 +787,9 @@ char *UI_tree_view_item_drop_tooltip(const uiTreeViewItemHandle *item_, const wm
* Let a tree-view item handle a drop event.
* \return True if the drop was handled by the tree-view item.
*/
-bool UI_tree_view_item_drop_handle(uiTreeViewItemHandle *item_, const ListBase *drags)
+bool UI_tree_view_item_drop_handle(struct bContext *C,
+ uiTreeViewItemHandle *item_,
+ const ListBase *drags)
{
AbstractTreeViewItem &item = reinterpret_cast<AbstractTreeViewItem &>(*item_);
std::unique_ptr<AbstractTreeViewItemDropController> drop_controller =
@@ -796,7 +798,7 @@ bool UI_tree_view_item_drop_handle(uiTreeViewItemHandle *item_, const ListBase *
const char *disabled_hint_dummy = nullptr;
LISTBASE_FOREACH (const wmDrag *, drag, drags) {
if (drop_controller->can_drop(*drag, &disabled_hint_dummy)) {
- return drop_controller->on_drop(*drag);
+ return drop_controller->on_drop(C, *drag);
}
}
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 35c671e8ea5..5d8bfbc0b79 100644
--- a/source/blender/editors/space_file/asset_catalog_tree_view.cc
+++ b/source/blender/editors/space_file/asset_catalog_tree_view.cc
@@ -33,6 +33,7 @@
#include "ED_asset.h"
#include "ED_fileselect.h"
+#include "ED_undo.h"
#include "RNA_access.h"
@@ -126,13 +127,14 @@ class AssetCatalogDropController : public ui::AbstractTreeViewItemDropController
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;
+ bool on_drop(struct bContext *C, const wmDrag &drag) override;
::AssetLibrary &get_asset_library() const;
static AssetCatalog *get_drag_catalog(const wmDrag &drag, const ::AssetLibrary &asset_library);
static bool has_droppable_asset(const wmDrag &drag, const char **r_disabled_hint);
- static bool drop_assets_into_catalog(const AssetCatalogTreeView &tree_view,
+ static bool drop_assets_into_catalog(struct bContext *C,
+ const AssetCatalogTreeView &tree_view,
const wmDrag &drag,
CatalogID catalog_id,
StringRefNull simple_name = "");
@@ -161,7 +163,7 @@ class AssetCatalogTreeViewAllItem : public ui::BasicTreeViewItem {
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;
+ bool on_drop(struct bContext *C, const wmDrag &drag) override;
};
std::unique_ptr<ui::AbstractTreeViewItemDropController> create_drop_controller() const override;
@@ -175,7 +177,7 @@ class AssetCatalogTreeViewUnassignedItem : public ui::BasicTreeViewItem {
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;
+ bool on_drop(struct bContext *C, const wmDrag &drag) override;
};
std::unique_ptr<ui::AbstractTreeViewItemDropController> create_drop_controller() const override;
@@ -426,13 +428,14 @@ std::string AssetCatalogDropController::drop_tooltip_asset_list(const wmDrag &dr
")";
}
-bool AssetCatalogDropController::on_drop(const wmDrag &drag)
+bool AssetCatalogDropController::on_drop(struct bContext *C, const wmDrag &drag)
{
if (drag.type == WM_DRAG_ASSET_CATALOG) {
return drop_asset_catalog_into_catalog(
drag, tree_view<AssetCatalogTreeView>(), catalog_item_.get_catalog_id());
}
- return drop_assets_into_catalog(tree_view<AssetCatalogTreeView>(),
+ return drop_assets_into_catalog(C,
+ tree_view<AssetCatalogTreeView>(),
drag,
catalog_item_.get_catalog_id(),
catalog_item_.get_simple_name());
@@ -452,7 +455,8 @@ bool AssetCatalogDropController::drop_asset_catalog_into_catalog(
return true;
}
-bool AssetCatalogDropController::drop_assets_into_catalog(const AssetCatalogTreeView &tree_view,
+bool AssetCatalogDropController::drop_assets_into_catalog(struct bContext *C,
+ const AssetCatalogTreeView &tree_view,
const wmDrag &drag,
CatalogID catalog_id,
StringRefNull simple_name)
@@ -463,11 +467,14 @@ bool AssetCatalogDropController::drop_assets_into_catalog(const AssetCatalogTree
return false;
}
+ bool did_update = false;
LISTBASE_FOREACH (wmDragAssetListItem *, asset_item, asset_drags) {
if (asset_item->is_external) {
/* Only internal assets can be modified! */
continue;
}
+
+ did_update = true;
BKE_asset_metadata_catalog_id_set(
asset_item->asset_data.local_id->asset_data, catalog_id, simple_name.c_str());
@@ -477,6 +484,9 @@ bool AssetCatalogDropController::drop_assets_into_catalog(const AssetCatalogTree
WM_main_add_notifier(NC_SPACE | ND_SPACE_FILE_LIST, nullptr);
}
+ if (did_update) {
+ ED_undo_push(C, "Assign Asset Catalog");
+ }
return true;
}
@@ -598,7 +608,7 @@ std::string AssetCatalogTreeViewAllItem::DropController::drop_tooltip(const wmDr
TIP_("to the top level of the tree");
}
-bool AssetCatalogTreeViewAllItem::DropController::on_drop(const wmDrag &drag)
+bool AssetCatalogTreeViewAllItem::DropController::on_drop(struct bContext *, const wmDrag &drag)
{
BLI_assert(drag.type == WM_DRAG_ASSET_CATALOG);
return AssetCatalogDropController::drop_asset_catalog_into_catalog(
@@ -641,11 +651,12 @@ std::string AssetCatalogTreeViewUnassignedItem::DropController::drop_tooltip(
TIP_("Move asset out of any catalog");
}
-bool AssetCatalogTreeViewUnassignedItem::DropController::on_drop(const wmDrag &drag)
+bool AssetCatalogTreeViewUnassignedItem::DropController::on_drop(struct bContext *C,
+ const wmDrag &drag)
{
/* Assign to nil catalog ID. */
return AssetCatalogDropController::drop_assets_into_catalog(
- tree_view<AssetCatalogTreeView>(), drag, CatalogID{});
+ C, tree_view<AssetCatalogTreeView>(), drag, CatalogID{});
}
} // namespace blender::ed::asset_browser