UI: Asset Shelf (Experimental Feature) #104831
|
@ -81,7 +81,7 @@ class AssetDragController : public ui::AbstractViewItemDragController {
|
|||
AssetDragController(ui::AbstractGridView &view, asset_system::AssetRepresentation &asset);
|
||||
|
||||
eWM_DragDataType get_drag_type() const override;
|
||||
void *create_drag_data(bContext &C) const override;
|
||||
void *create_drag_data() const override;
|
||||
};
|
||||
|
||||
AssetView::AssetView(const AssetLibraryReference &library_ref, const AssetShelf &shelf)
|
||||
|
@ -281,7 +281,7 @@ eWM_DragDataType AssetDragController::get_drag_type() const
|
|||
return asset_.is_local_id() ? WM_DRAG_ID : WM_DRAG_ASSET;
|
||||
}
|
||||
|
||||
void *AssetDragController::create_drag_data(bContext &C) const
|
||||
void *AssetDragController::create_drag_data() const
|
||||
{
|
||||
ID *local_id = asset_.local_id();
|
||||
if (local_id) {
|
||||
|
@ -291,7 +291,7 @@ void *AssetDragController::create_drag_data(bContext &C) const
|
|||
const eAssetImportMethod import_method = asset_.get_import_method().value_or(
|
||||
ASSET_IMPORT_APPEND_REUSE);
|
||||
|
||||
return WM_drag_create_asset_data(&asset_, import_method, &C);
|
||||
return WM_drag_create_asset_data(&asset_, import_method);
|
||||
}
|
||||
|
||||
} // namespace blender::ed::asset::shelf
|
||||
|
|
|
@ -328,7 +328,7 @@ class AbstractViewItemDragController {
|
|||
virtual ~AbstractViewItemDragController() = default;
|
||||
|
||||
virtual eWM_DragDataType get_drag_type() const = 0;
|
||||
virtual void *create_drag_data(bContext &C) const = 0;
|
||||
virtual void *create_drag_data() const = 0;
|
||||
virtual void on_drag_start();
|
||||
|
||||
/** Request the view the item is registered for as type #ViewType. Throws a `std::bad_cast`
|
||||
|
|
|
@ -36,8 +36,7 @@ void UI_but_drag_set_asset(uiBut *but,
|
|||
const ImBuf *imb,
|
||||
float scale)
|
||||
{
|
||||
wmDragAsset *asset_drag = WM_drag_create_asset_data(
|
||||
asset, import_type, static_cast<bContext *>(but->block->evil_C));
|
||||
wmDragAsset *asset_drag = WM_drag_create_asset_data(asset, import_type);
|
||||
|
||||
but->dragtype = WM_DRAG_ASSET;
|
||||
ui_def_but_icon(but, icon, 0); /* no flag UI_HAS_ICON, so icon doesn't draw in button */
|
||||
|
|
|
@ -138,7 +138,7 @@ class LayerViewItemDragController : public AbstractViewItemDragController {
|
|||
return WM_DRAG_GREASE_PENCIL_LAYER;
|
||||
}
|
||||
|
||||
void *create_drag_data(bContext & /*C*/) const override
|
||||
void *create_drag_data() const override
|
||||
{
|
||||
wmDragGreasePencilLayer *drag_data = MEM_new<wmDragGreasePencilLayer>(__func__);
|
||||
drag_data->layer = &dragged_layer_;
|
||||
|
|
|
@ -379,7 +379,7 @@ class ViewItemAPIWrapper {
|
|||
WM_event_start_drag(&C,
|
||||
ICON_NONE,
|
||||
drag_controller->get_drag_type(),
|
||||
drag_controller->create_drag_data(C),
|
||||
drag_controller->create_drag_data(),
|
||||
0,
|
||||
WM_DRAG_FREE_DATA);
|
||||
drag_controller->on_drag_start();
|
||||
|
|
|
@ -104,7 +104,7 @@ class AssetCatalogDragController : public ui::AbstractViewItemDragController {
|
|||
AssetCatalogTreeItem &catalog_item);
|
||||
|
||||
eWM_DragDataType get_drag_type() const override;
|
||||
void *create_drag_data(bContext &C) const override;
|
||||
void *create_drag_data() const override;
|
||||
void on_drag_start() override;
|
||||
};
|
||||
|
||||
|
@ -552,7 +552,7 @@ eWM_DragDataType AssetCatalogDragController::get_drag_type() const
|
|||
return WM_DRAG_ASSET_CATALOG;
|
||||
}
|
||||
|
||||
void *AssetCatalogDragController::create_drag_data(bContext & /*C*/) const
|
||||
void *AssetCatalogDragController::create_drag_data() const
|
||||
{
|
||||
wmDragAssetCatalog *drag_catalog = (wmDragAssetCatalog *)MEM_callocN(sizeof(*drag_catalog),
|
||||
__func__);
|
||||
|
|
|
@ -1470,8 +1470,7 @@ bool WM_drag_is_ID_type(const struct wmDrag *drag, int idcode);
|
|||
* \note Does not store \a asset in any way, so it's fine to pass a temporary.
|
||||
*/
|
||||
wmDragAsset *WM_drag_create_asset_data(const blender::asset_system::AssetRepresentation *asset,
|
||||
int /* #eAssetImportMethod */ import_type,
|
||||
bContext *evil_C);
|
||||
int /* #eAssetImportMethod */ import_type);
|
||||
#endif
|
||||
|
||||
struct wmDragAsset *WM_drag_get_asset_data(const struct wmDrag *drag, int idcode);
|
||||
|
@ -1506,8 +1505,7 @@ struct wmDragAssetCatalog *WM_drag_get_asset_catalog_data(const struct wmDrag *d
|
|||
* \note Does not store \a asset in any way, so it's fine to pass a temporary.
|
||||
*/
|
||||
void WM_drag_add_asset_list_item(wmDrag *drag,
|
||||
const blender::asset_system::AssetRepresentation *asset,
|
||||
bContext *evil_C);
|
||||
const blender::asset_system::AssetRepresentation *asset);
|
||||
#endif
|
||||
|
||||
const ListBase *WM_drag_asset_list_get(const wmDrag *drag);
|
||||
|
|
|
@ -215,7 +215,7 @@ wmDrag *WM_drag_data_create(
|
|||
LISTBASE_FOREACH (const CollectionPointerLink *, link, &asset_file_links) {
|
||||
const FileDirEntry *asset_file = static_cast<const FileDirEntry *>(link->ptr.data);
|
||||
const AssetHandle asset_handle = {asset_file};
|
||||
WM_drag_add_asset_list_item(drag, ED_asset_handle_get_representation(&asset_handle), C);
|
||||
WM_drag_add_asset_list_item(drag, ED_asset_handle_get_representation(&asset_handle));
|
||||
}
|
||||
BLI_freelistN(&asset_file_links);
|
||||
break;
|
||||
|
@ -570,19 +570,12 @@ bool WM_drag_is_ID_type(const wmDrag *drag, int idcode)
|
|||
}
|
||||
|
||||
wmDragAsset *WM_drag_create_asset_data(const blender::asset_system::AssetRepresentation *asset,
|
||||
int import_type,
|
||||
bContext *evil_C)
|
||||
int import_type)
|
||||
{
|
||||
wmDragAsset *asset_drag = MEM_new<wmDragAsset>(__func__);
|
||||
|
||||
asset_drag->asset = asset;
|
||||
asset_drag->import_method = import_type;
|
||||
/* FIXME: This is temporary evil solution to get scene/view-layer/etc in the copy callback of the
|
||||
* #wmDropBox.
|
||||
* TODO: Handle link/append in operator called at the end of the drop process, and NOT in its
|
||||
* copy callback.
|
||||
* */
|
||||
asset_drag->evil_C = static_cast<bContext *>(evil_C);
|
||||
|
||||
return asset_drag;
|
||||
}
|
||||
|
@ -739,8 +732,7 @@ wmDragAssetCatalog *WM_drag_get_asset_catalog_data(const wmDrag *drag)
|
|||
}
|
||||
|
||||
void WM_drag_add_asset_list_item(wmDrag *drag,
|
||||
const blender::asset_system::AssetRepresentation *asset,
|
||||
bContext *evil_C)
|
||||
const blender::asset_system::AssetRepresentation *asset)
|
||||
{
|
||||
BLI_assert(drag->type == WM_DRAG_ASSET_LIST);
|
||||
|
||||
|
@ -755,8 +747,7 @@ void WM_drag_add_asset_list_item(wmDrag *drag,
|
|||
}
|
||||
else {
|
||||
drag_asset->is_external = true;
|
||||
drag_asset->asset_data.external_info = WM_drag_create_asset_data(
|
||||
asset, ASSET_IMPORT_APPEND, evil_C);
|
||||
drag_asset->asset_data.external_info = WM_drag_create_asset_data(asset, ASSET_IMPORT_APPEND);
|
||||
}
|
||||
BLI_addtail(&drag->asset_items, drag_asset);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue