Asset Browser: Move Asset Library selector to navigation bar

The menu to select the active Asset Library is now in the left bar (so called
"Source List", although I'd prefer "Navigation-Bar").

This has some benefits:
* All Asset Library navigation is in the left sidebar now, giving nice grouping
  and a top-to-bottom & left-to-right flow of the layout. The header is focused
  on view set-up now.
* Catalogs are stored inside the asset library. Makes sense to have them right
  under that.
* Less content in the header allows for less wide Asset Browsers without
  extensive scrolling.
* This location gives more space to add options or operators for Asset
  Libraries.

Main downside I see is that the side-bar needs to be opened to change
libraries, which takes quite some space. In practice there shouldn't be need to
do this often though.
This commit is contained in:
Julian Eisel 2021-10-07 16:15:39 +02:00
parent 9f9e2dd25d
commit c7b237e7d1
3 changed files with 17 additions and 7 deletions

View File

@ -36,12 +36,6 @@ class FILEBROWSER_HT_header(Header):
space_data = context.space_data
params = space_data.params
row = layout.row(align=True)
row.prop(params, "asset_library_ref", text="")
# External libraries don't auto-refresh, add refresh button.
if params.asset_library_ref != 'LOCAL':
row.operator("file.refresh", text="", icon='FILE_REFRESH')
layout.separator_spacer()
layout.prop(params, "import_type", text="")

View File

@ -479,6 +479,8 @@ void file_create_asset_catalog_tree_view_in_layout(::AssetLibrary *asset_library
{
uiBlock *block = uiLayoutGetBlock(layout);
UI_block_layout_set_current(block, layout);
ui::AbstractTreeView *tree_view = UI_block_add_view(
*block,
"asset catalog tree view",

View File

@ -232,13 +232,27 @@ void file_execute_region_panels_register(ARegionType *art)
static void file_panel_asset_catalog_buttons_draw(const bContext *C, Panel *panel)
{
bScreen *screen = CTX_wm_screen(C);
SpaceFile *sfile = CTX_wm_space_file(C);
/* May be null if the library wasn't loaded yet. */
struct AssetLibrary *asset_library = filelist_asset_library(sfile->files);
FileAssetSelectParams *params = ED_fileselect_get_asset_params(sfile);
BLI_assert(params != NULL);
file_create_asset_catalog_tree_view_in_layout(asset_library, panel->layout, sfile, params);
uiLayout *col = uiLayoutColumn(panel->layout, false);
uiLayout *row = uiLayoutRow(col, true);
PointerRNA params_ptr;
RNA_pointer_create(&screen->id, &RNA_FileAssetSelectParams, params, &params_ptr);
uiItemR(row, &params_ptr, "asset_library_ref", 0, "", ICON_NONE);
if (params->asset_library_ref.type != ASSET_LIBRARY_LOCAL) {
uiItemO(row, "", ICON_FILE_REFRESH, "FILE_OT_refresh");
}
uiItemS(col);
file_create_asset_catalog_tree_view_in_layout(asset_library, col, sfile, params);
}
void file_tools_region_panels_register(ARegionType *art)