WIP: Rewrite asset browser as separate editor #104978

Closed
Julian Eisel wants to merge 68 commits from asset-browser-grid-view into main

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
11 changed files with 51 additions and 49 deletions
Showing only changes of commit 8a31a872f3 - Show all commits

View File

@ -933,9 +933,9 @@ struct SpaceAssets *CTX_wm_space_assets(const bContext *C)
{
ScrArea *area = CTX_wm_area(C);
if (area && area->spacetype == SPACE_ASSETS) {
return area->spacedata.first;
return static_cast<SpaceAssets *>(area->spacedata.first);
}
return NULL;
return nullptr;
}
void CTX_wm_manager_set(bContext *C, wmWindowManager *wm)
@ -1509,7 +1509,8 @@ AssetHandle CTX_wm_asset_handle(const bContext *C, bool *r_is_valid)
*/
AssetHandle *CTX_wm_asset_handle_ptr(const bContext *C)
{
return CTX_data_pointer_get_type(C, "asset_handle", &RNA_AssetHandle).data;
return static_cast<AssetHandle *>(
CTX_data_pointer_get_type(C, "asset_handle", &RNA_AssetHandle).data);
}
Depsgraph *CTX_data_depsgraph_pointer(const bContext *C)

View File

@ -2666,6 +2666,7 @@ static void lib_link_workspace_layout_restore(IDNameLib_Map *id_map,
lib_link_restore_viewer_path(id_map, &sspreadsheet->viewer_path);
break;
}
case SPACE_ASSETS:
case SPACE_INFO:
case SPACE_IMASEL:
case SPACE_SOUND:

View File

@ -10,6 +10,7 @@
extern "C" {
#endif
struct AssetCatalogFilterSettings;
struct AssetHandle;
struct AssetLibrary;
struct AssetLibraryReference;

View File

@ -13,6 +13,7 @@
#include <string>
#include "AS_asset_library.hh"
#include "AS_asset_representation.hh"
#include "BKE_context.h"
@ -464,8 +465,8 @@ PreviewImage *ED_assetlist_asset_preview_request(const AssetLibraryReference *li
else {
const char *asset_identifier = ED_asset_handle_get_identifier(asset_handle);
const int source = filelist_preview_source_get(asset_handle->file_data->typeflag);
const std::string asset_path = ED_assetlist_asset_filepath_get(
nullptr, *library_reference, *asset_handle);
const std::string asset_path = AS_asset_representation_full_path_get(
asset_handle->file_data->asset);
asset_handle->preview = BKE_previewimg_cached_thumbnail_read(
asset_identifier, asset_path.c_str(), source, false);
@ -515,20 +516,11 @@ AssetHandle *ED_assetlist_asset_get_from_index(const AssetLibraryReference *libr
return asset;
}
const char *ED_assetlist_library_path(const AssetLibraryReference *library_reference)
{
AssetList *list = AssetListStorage::lookup_list(*library_reference);
if (list) {
return list->filepath().data();
}
return nullptr;
}
AssetLibrary *ED_assetlist_library_get(const AssetLibraryReference *library_reference)
{
AssetList *list = AssetListStorage::lookup_list(*library_reference);
if (list) {
return list->asset_library();
return reinterpret_cast<AssetLibrary *>(list->asset_library());
}
return nullptr;
}

View File

@ -6,18 +6,18 @@
#include <memory>
#include "DNA_space_types.h"
#include "AS_asset_catalog.hh"
#include "AS_asset_library.hh"
#include "BKE_asset_catalog.hh"
#include "BKE_asset_library.hh"
#include "DNA_space_types.h"
#include "ED_asset_view_catalog_filter.h"
namespace bke = blender::bke;
namespace asset_system = blender::asset_system;
struct AssetViewCatalogFilter {
AssetCatalogFilterSettings filter_settings;
std::unique_ptr<bke::AssetCatalogFilter> catalog_filter;
std::unique_ptr<asset_system::AssetCatalogFilter> catalog_filter;
};
AssetViewCatalogFilterSettingsHandle *asset_view_create_catalog_filter_settings()
@ -64,11 +64,11 @@ void asset_view_ensure_updated_catalog_filter_data(
{
AssetViewCatalogFilter *filter_settings = reinterpret_cast<AssetViewCatalogFilter *>(
filter_settings_handle);
const bke::AssetCatalogService *catalog_service = BKE_asset_library_get_catalog_service(
const asset_system::AssetCatalogService *catalog_service = AS_asset_library_get_catalog_service(
asset_library);
if (filter_settings->filter_settings.filter_mode != ASSET_CATALOG_SHOW_ALL_ASSETS) {
filter_settings->catalog_filter = std::make_unique<bke::AssetCatalogFilter>(
filter_settings->catalog_filter = std::make_unique<asset_system::AssetCatalogFilter>(
catalog_service->create_catalog_filter(
filter_settings->filter_settings.active_catalog_id));
}

View File

@ -36,7 +36,9 @@ struct AssetViewListData {
bool show_names;
};
static void asset_view_item_but_drag_set(uiBut *but, AssetHandle *asset_handle)
static void asset_view_item_but_drag_set(uiBut *but,
AssetViewListData *list_data,
AssetHandle *asset_handle)
{
ID *id = ED_asset_handle_get_local_id(asset_handle);
if (id != nullptr) {
@ -54,13 +56,14 @@ static void asset_view_item_but_drag_set(uiBut *but, AssetHandle *asset_handle)
if (blend_path[0]) {
ImBuf *imbuf = ED_assetlist_asset_image_get(asset_handle);
UI_but_drag_set_asset(but,
asset_handle,
BLI_strdup(blend_path),
import_method,
ED_assetlist_asset_preview_icon_id_request(&list_data->asset_library_ref, asset_handle),
imbuf,
1.0f);
UI_but_drag_set_asset(
but,
asset_handle,
BLI_strdup(blend_path),
import_method,
ED_assetlist_asset_preview_icon_id_request(&list_data->asset_library_ref, asset_handle),
imbuf,
1.0f);
}
}
@ -108,7 +111,7 @@ static void asset_view_draw_item(uiList *ui_list,
/* NOLINTNEXTLINE: bugprone-suspicious-enum-usage */
UI_HAS_ICON | UI_BUT_ICON_PREVIEW);
if (!ui_list->dyn_data->custom_drag_optype) {
asset_view_item_but_drag_set(but, asset_handle);
asset_view_item_but_drag_set(but, list_data, asset_handle);
}
}

View File

@ -2,6 +2,7 @@
set(INC
../include
../../asset_system
../../blenfont
../../blenkernel
../../blenlib

View File

@ -4,11 +4,13 @@
* \ingroup spassets
*/
#include "AS_asset_catalog.hh"
#include "AS_asset_catalog_tree.hh"
#include "AS_asset_library.hh"
#include "DNA_space_types.h"
#include "BKE_asset.h"
#include "BKE_asset_catalog.hh"
#include "BKE_asset_library.hh"
#include "BLI_string_ref.hh"
@ -24,6 +26,8 @@
#include "UI_resources.h"
#include "UI_tree_view.hh"
#include "RNA_prototypes.h"
#include "WM_api.h"
#include "WM_message.h"
#include "WM_types.h"
@ -31,7 +35,7 @@
#include "asset_browser_intern.hh"
using namespace blender;
using namespace blender::bke;
using namespace blender::asset_system;
namespace blender::ed::asset_browser {
@ -42,7 +46,7 @@ class AssetCatalogTreeView : public ui::AbstractTreeView {
* before the library was read. */
::AssetLibrary *asset_library_;
/** The asset catalog tree this tree-view represents. */
bke::AssetCatalogTree *catalog_tree_;
AssetCatalogTree *catalog_tree_;
PointerRNA catalog_filter_owner_;
PropertyRNA &catalog_filter_prop_;
@ -62,7 +66,7 @@ class AssetCatalogTreeView : public ui::AbstractTreeView {
void build_tree() override;
bool listen(const wmNotifier &notifier) const override;
void activate_catalog_by_id(CatalogID catalog_id);
void activate_catalog_by_id(asset_system::CatalogID catalog_id);
private:
ui::BasicTreeViewItem &build_catalog_items_recursive(ui::TreeViewOrItem &view_parent_item,
@ -184,7 +188,7 @@ AssetCatalogTreeView::AssetCatalogTreeView(::AssetLibrary *library,
PropertyRNA &catalog_filter_prop,
wmMsgBus *msg_bus)
: asset_library_(library),
catalog_tree_(BKE_asset_library_get_catalog_tree(library)),
catalog_tree_(AS_asset_library_get_catalog_tree(library)),
catalog_filter_owner_(catalog_filter_owner),
catalog_filter_prop_(catalog_filter_prop),
msg_bus_(msg_bus)
@ -537,7 +541,7 @@ AssetCatalog *AssetCatalogDropController::get_drag_catalog(const wmDrag &drag,
if (drag.type != WM_DRAG_ASSET_CATALOG) {
return nullptr;
}
const bke::AssetCatalogService *catalog_service = BKE_asset_library_get_catalog_service(
const asset_system::AssetCatalogService *catalog_service = AS_asset_library_get_catalog_service(
&asset_library);
const wmDragAssetCatalog *catalog_drag = WM_drag_get_asset_catalog_data(&drag);
@ -649,7 +653,7 @@ std::string AssetCatalogTreeViewAllItem::DropController::drop_tooltip(const wmDr
TIP_("to the top level of the tree");
}
bool AssetCatalogTreeViewAllItem::DropController::on_drop(struct bContext *UNUSED(C),
bool AssetCatalogTreeViewAllItem::DropController::on_drop(struct bContext * /*C*/,
const wmDrag &drag)
{
BLI_assert(drag.type == WM_DRAG_ASSET_CATALOG);

View File

@ -35,7 +35,7 @@
/* ---------------------------------------------------------------------- */
/* Asset Browser Space */
static SpaceLink *asset_browser_create(const ScrArea *UNUSED(area), const Scene *UNUSED(scene))
static SpaceLink *asset_browser_create(const ScrArea * /*area*/, const Scene * /*scene*/)
{
SpaceAssets *assets_space = MEM_cnew<SpaceAssets>("asset browser space");
assets_space->spacetype = SPACE_ASSETS;
@ -85,11 +85,11 @@ static SpaceLink *asset_browser_create(const ScrArea *UNUSED(area), const Scene
return (SpaceLink *)assets_space;
}
static void asset_browser_free(SpaceLink *UNUSED(sl))
static void asset_browser_free(SpaceLink * /*sl*/)
{
}
static void asset_browser_init(wmWindowManager *UNUSED(wm), ScrArea *UNUSED(area))
static void asset_browser_init(wmWindowManager * /*wm*/, ScrArea * /*area*/)
{
}
@ -199,12 +199,12 @@ static void asset_browser_main_region_message_subscribe(
/* ---------------------------------------------------------------------- */
/* Header Region */
static void asset_browser_header_init(wmWindowManager *UNUSED(wm), ARegion *region)
static void asset_browser_header_init(wmWindowManager * /*wm*/, ARegion *region)
{
ED_region_header_init(region);
}
static void asset_browser_header_listener(const wmRegionListenerParams *UNUSED(params))
static void asset_browser_header_listener(const wmRegionListenerParams * /*params*/)
{
}
@ -228,7 +228,7 @@ static void asset_browser_navigation_region_draw(const bContext *C, ARegion *reg
}
static void asset_browser_navigation_region_listener(
const wmRegionListenerParams *UNUSED(listener_params))
const wmRegionListenerParams * /*listener_params*/)
{
}
@ -252,7 +252,7 @@ static void asset_browser_sidebar_region_draw(const bContext *C, ARegion *region
}
static void asset_browser_sidebar_region_listener(
const wmRegionListenerParams *UNUSED(listener_params))
const wmRegionListenerParams * /*listener_params*/)
{
}

View File

@ -85,7 +85,6 @@ static AssetItemTree build_catalog_tree(const bContext &C, const bNodeTree *node
const AssetLibraryReference all_library_ref = all_library_reference();
ED_assetlist_storage_fetch(&all_library_ref, &C);
ED_assetlist_ensure_previews_job(&all_library_ref, &C);
asset_system::AssetLibrary *all_library = ED_assetlist_library_get_once_available(
all_library_ref);

View File

@ -3361,7 +3361,7 @@ static void rna_FileAssetSelectParams_catalog_id_set(PointerRNA *ptr, const char
if (value[0] == '\0') {
params->catalog_id = BLI_uuid_nil();
params->asset_catalog_visibility = FILE_SHOW_ASSETS_ALL_CATALOGS;
params->asset_catalog_visibility = ASSET_CATALOG_SHOW_ALL_ASSETS;
return;
}
@ -3372,7 +3372,7 @@ static void rna_FileAssetSelectParams_catalog_id_set(PointerRNA *ptr, const char
}
params->catalog_id = new_uuid;
params->asset_catalog_visibility = FILE_SHOW_ASSETS_FROM_CATALOG;
params->asset_catalog_visibility = ASSET_CATALOG_SHOW_ASSETS_FROM_CATALOG;
}
static int RNA_SpaceAssetBrowser_asset_library_get(PointerRNA *ptr)