Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/space_file/asset_catalog_tree_view.cc
| /* SPDX-License-Identifier: GPL-2.0-or-later | /* SPDX-License-Identifier: GPL-2.0-or-later | ||||
| * Copyright 2007 Blender Foundation. All rights reserved. */ | * Copyright 2007 Blender Foundation. All rights reserved. */ | ||||
| /** \file | /** \file | ||||
| * \ingroup spfile | * \ingroup spfile | ||||
| */ | */ | ||||
| #include "DNA_space_types.h" | #include "DNA_space_types.h" | ||||
| #include "AS_asset_library.hh" | |||||
| #include "AS_asset_catalog.hh" | |||||
| #include "BKE_asset.h" | #include "BKE_asset.h" | ||||
| #include "BKE_asset_catalog.hh" | |||||
| #include "BKE_asset_library.hh" | |||||
| #include "BLI_string_ref.hh" | #include "BLI_string_ref.hh" | ||||
| #include "BLT_translation.h" | #include "BLT_translation.h" | ||||
| #include "ED_asset.h" | #include "ED_asset.h" | ||||
| #include "ED_fileselect.h" | #include "ED_fileselect.h" | ||||
| #include "ED_undo.h" | #include "ED_undo.h" | ||||
| #include "RNA_access.h" | #include "RNA_access.h" | ||||
| #include "UI_interface.h" | #include "UI_interface.h" | ||||
| #include "UI_interface.hh" | #include "UI_interface.hh" | ||||
| #include "UI_resources.h" | #include "UI_resources.h" | ||||
| #include "UI_tree_view.hh" | #include "UI_tree_view.hh" | ||||
| #include "WM_api.h" | #include "WM_api.h" | ||||
| #include "WM_types.h" | #include "WM_types.h" | ||||
| #include "file_intern.h" | #include "file_intern.h" | ||||
| #include "filelist.h" | #include "filelist.h" | ||||
| using namespace blender; | using namespace blender; | ||||
| using namespace blender::bke; | using namespace blender::asset_system; | ||||
| namespace blender::ed::asset_browser { | namespace blender::ed::asset_browser { | ||||
| class AssetCatalogTreeViewAllItem; | class AssetCatalogTreeViewAllItem; | ||||
| class AssetCatalogTreeView : public ui::AbstractTreeView { | class AssetCatalogTreeView : public ui::AbstractTreeView { | ||||
| ::AssetLibrary *asset_library_; | ::AssetLibrary *asset_library_; | ||||
| /** The asset catalog tree this tree-view represents. */ | /** The asset catalog tree this tree-view represents. */ | ||||
| bke::AssetCatalogTree *catalog_tree_; | asset_system::AssetCatalogTree *catalog_tree_; | ||||
| FileAssetSelectParams *params_; | FileAssetSelectParams *params_; | ||||
| SpaceFile &space_file_; | SpaceFile &space_file_; | ||||
| friend class AssetCatalogTreeViewItem; | friend class AssetCatalogTreeViewItem; | ||||
| friend class AssetCatalogDropController; | friend class AssetCatalogDropController; | ||||
| friend class AssetCatalogTreeViewAllItem; | friend class AssetCatalogTreeViewAllItem; | ||||
| public: | public: | ||||
| ▲ Show 20 Lines • Show All 114 Lines • ▼ Show 20 Lines | |||||
| }; | }; | ||||
| /* ---------------------------------------------------------------------- */ | /* ---------------------------------------------------------------------- */ | ||||
| AssetCatalogTreeView::AssetCatalogTreeView(::AssetLibrary *library, | AssetCatalogTreeView::AssetCatalogTreeView(::AssetLibrary *library, | ||||
| FileAssetSelectParams *params, | FileAssetSelectParams *params, | ||||
| SpaceFile &space_file) | SpaceFile &space_file) | ||||
| : asset_library_(library), | : asset_library_(library), | ||||
| catalog_tree_(BKE_asset_library_get_catalog_tree(library)), | catalog_tree_(AS_asset_library_get_catalog_tree(library)), | ||||
| params_(params), | params_(params), | ||||
| space_file_(space_file) | space_file_(space_file) | ||||
| { | { | ||||
| } | } | ||||
| void AssetCatalogTreeView::build_tree() | void AssetCatalogTreeView::build_tree() | ||||
| { | { | ||||
| AssetCatalogTreeViewAllItem &all_item = add_all_item(); | AssetCatalogTreeViewAllItem &all_item = add_all_item(); | ||||
| ▲ Show 20 Lines • Show All 296 Lines • ▼ Show 20 Lines | |||||
| } | } | ||||
| AssetCatalog *AssetCatalogDropController::get_drag_catalog(const wmDrag &drag, | AssetCatalog *AssetCatalogDropController::get_drag_catalog(const wmDrag &drag, | ||||
| const ::AssetLibrary &asset_library) | const ::AssetLibrary &asset_library) | ||||
| { | { | ||||
| if (drag.type != WM_DRAG_ASSET_CATALOG) { | if (drag.type != WM_DRAG_ASSET_CATALOG) { | ||||
| return nullptr; | return nullptr; | ||||
| } | } | ||||
| const bke::AssetCatalogService *catalog_service = BKE_asset_library_get_catalog_service( | const AssetCatalogService *catalog_service = AS_asset_library_get_catalog_service( | ||||
| &asset_library); | &asset_library); | ||||
| const wmDragAssetCatalog *catalog_drag = WM_drag_get_asset_catalog_data(&drag); | const wmDragAssetCatalog *catalog_drag = WM_drag_get_asset_catalog_data(&drag); | ||||
| return catalog_service->find_catalog(catalog_drag->drag_catalog_id); | return catalog_service->find_catalog(catalog_drag->drag_catalog_id); | ||||
| } | } | ||||
| bool AssetCatalogDropController::has_droppable_asset(const wmDrag &drag, | bool AssetCatalogDropController::has_droppable_asset(const wmDrag &drag, | ||||
| const char **r_disabled_hint) | const char **r_disabled_hint) | ||||
| ▲ Show 20 Lines • Show All 205 Lines • ▼ Show 20 Lines | if (filter_settings->asset_catalog_visibility == FILE_SHOW_ASSETS_FROM_CATALOG && | ||||
| needs_update = true; | needs_update = true; | ||||
| } | } | ||||
| return needs_update; | return needs_update; | ||||
| } | } | ||||
| void file_ensure_updated_catalog_filter_data( | void file_ensure_updated_catalog_filter_data( | ||||
| FileAssetCatalogFilterSettingsHandle *filter_settings_handle, | FileAssetCatalogFilterSettingsHandle *filter_settings_handle, | ||||
| const bke::AssetLibrary *asset_library) | const asset_system::AssetLibrary *asset_library) | ||||
| { | { | ||||
| AssetCatalogFilterSettings *filter_settings = reinterpret_cast<AssetCatalogFilterSettings *>( | AssetCatalogFilterSettings *filter_settings = reinterpret_cast<AssetCatalogFilterSettings *>( | ||||
| filter_settings_handle); | filter_settings_handle); | ||||
| const AssetCatalogService *catalog_service = asset_library->catalog_service.get(); | const AssetCatalogService *catalog_service = asset_library->catalog_service.get(); | ||||
| if (filter_settings->asset_catalog_visibility != FILE_SHOW_ASSETS_ALL_CATALOGS) { | if (filter_settings->asset_catalog_visibility != FILE_SHOW_ASSETS_ALL_CATALOGS) { | ||||
| filter_settings->catalog_filter = std::make_unique<AssetCatalogFilter>( | filter_settings->catalog_filter = std::make_unique<AssetCatalogFilter>( | ||||
| catalog_service->create_catalog_filter(filter_settings->asset_catalog_id)); | catalog_service->create_catalog_filter(filter_settings->asset_catalog_id)); | ||||
| ▲ Show 20 Lines • Show All 44 Lines • Show Last 20 Lines | |||||