Blender V5.0
blender::ed::asset::shelf Namespace Reference

Classes

class  AssetView
class  AssetViewItem
class  AssetDragController
class  AssetCatalogSelectorTree
class  StaticPopupShelves
class  AssetCatalogTreeView

Functions

void send_redraw_notifier (const bContext &C)
void build_asset_view (uiLayout &layout, const AssetLibraryReference &library_ref, const AssetShelf &shelf, const bContext &C)
void catalog_selector_panel_register (ARegionType *region_type)
void popover_panel_register (ARegionType *region_type)
void library_selector_draw (const bContext *C, uiLayout *layout, AssetShelf &shelf)
RegionAssetShelfregiondata_duplicate (const RegionAssetShelf *shelf_regiondata)
void regiondata_free (RegionAssetShelf *shelf_regiondata)
void regiondata_blend_write (BlendWriter *writer, const RegionAssetShelf *shelf_regiondata)
void regiondata_blend_read_data (BlendDataReader *reader, RegionAssetShelf **shelf_regiondata)
void settings_blend_write (BlendWriter *writer, const AssetShelfSettings &settings)
void settings_blend_read_data (BlendDataReader *reader, AssetShelfSettings &settings)
void settings_set_active_catalog (AssetShelfSettings &settings, const asset_system::AssetCatalogPath &path)
void settings_set_all_catalog_active (AssetShelfSettings &settings)
bool settings_is_active_catalog (const AssetShelfSettings &settings, const asset_system::AssetCatalogPath &path)
bool settings_is_all_catalog_active (const AssetShelfSettings &settings)
void settings_clear_enabled_catalogs (AssetShelf &shelf)
bool settings_is_catalog_path_enabled (const AssetShelf &shelf, const asset_system::AssetCatalogPath &path)
void settings_set_catalog_path_enabled (AssetShelf &shelf, const asset_system::AssetCatalogPath &path)
void settings_foreach_enabled_catalog_path (const AssetShelf &shelf, FunctionRef< void(const asset_system::AssetCatalogPath &catalog_path)> fn)
static std::optional< asset_system::AssetCatalogFiltercatalog_filter_from_shelf_settings (const AssetShelfSettings &shelf_settings, const asset_system::AssetLibrary &library)
static std::optional< wmOperatorCallParamscreate_asset_operator_params (const StringRefNull op_name, const asset_system::AssetRepresentation &asset)
static std::string filter_string_get (const AssetShelf &shelf)
static void catalog_selector_panel_draw (const bContext *C, Panel *panel)
static AssetShelflookup_shelf_for_popup (const bContext &C, const AssetShelfType &shelf_type)
static AssetShelfget_shelf_for_popup (const bContext &C, AssetShelfType &shelf_type)
static void catalog_tree_draw (const bContext &C, uiLayout &layout, AssetShelf &shelf)
static AssetShelfTypelookup_type_from_idname_in_context (const bContext *C)
static int layout_width_units_clamped (const wmWindow *win)
static void popover_panel_draw (const bContext *C, Panel *panel)
static bool popover_panel_poll (const bContext *C, PanelType *)
static bool use_enabled_catalogs_from_prefs (const AssetShelf &shelf)
static const ListBaseget_enabled_catalog_path_list (const AssetShelf &shelf)
static ListBaseget_enabled_catalog_path_list (AssetShelf &shelf)
Asset Shelf Regions
bool regions_poll (const RegionPollParams *params)
void * region_duplicate (void *regiondata)
void region_free (ARegion *region)
void region_init (wmWindowManager *wm, ARegion *region)
int region_snap (const ARegion *region, int size, int axis)
void region_on_user_resize (const ARegion *region)
void region_listen (const wmRegionListenerParams *params)
void region_message_subscribe (const wmRegionMessageSubscribeParams *params)
void region_layout (const bContext *C, ARegion *region)
void region_draw (const bContext *C, ARegion *region)
void region_on_poll_success (const bContext *C, ARegion *region)
void region_blend_read_data (BlendDataReader *reader, ARegion *region)
void region_blend_write (BlendWriter *writer, ARegion *region)
int region_prefsizey ()
void header_region_init (wmWindowManager *wm, ARegion *region)
void header_region (const bContext *C, ARegion *region)
void header_region_listen (const wmRegionListenerParams *params)
int header_region_size ()
void types_register (ARegionType *region_type, const int space_type)
int tile_width (const AssetShelfSettings &settings)
int tile_height (const AssetShelfSettings &settings)
static int asset_shelf_default_tile_height ()
static bool asset_shelf_space_poll (const bContext *C, const SpaceLink *space_link)
static void asset_shelf_region_listen (const wmRegionListenerParams *params)
static int main_region_padding_y ()
static int main_region_padding_x ()
static int current_tile_draw_height (const ARegion *region)
static int calculate_row_count_from_tile_draw_height (const int region_height_scaled, const int tile_draw_height)
static int calculate_scaled_region_height_from_row_count (const int row_count, const int tile_draw_height)
static void region_resize_to_preferred (ScrArea *area, ARegion *region)
Asset Shelf Type
void type_register (std::unique_ptr< AssetShelfType > type)
void type_unregister (const AssetShelfType &shelf_type)
bool type_poll_for_popup (const bContext &C, const AssetShelfType *shelf_type)
AssetShelfTypetype_find_from_idname (StringRef idname)
Asset Shelf Popup
void type_popup_unlink (const AssetShelfType &shelf_type)
void ensure_asset_library_fetched (const bContext &C, const AssetShelfType &shelf_type)
Asset Shelf Type (un)registration
void type_unlink (const Main &bmain, const AssetShelfType &shelf_type)
Asset Shelf Context
AssetShelfactive_shelf_from_area (const ScrArea *area)
int context (const bContext *C, const char *member, bContextDataResult *result)
static PointerRNA active_shelf_ptr_from_context (const bContext *C)
AssetShelfactive_shelf_from_context (const bContext *C)
External helpers
void show_catalog_in_visible_shelves (const bContext &C, const StringRefNull catalog_path)
Shelf Type
static Vector< std::unique_ptr< AssetShelfType > > & static_shelf_types ()
static bool type_poll_no_spacetype_check (const bContext &C, const AssetShelfType *shelf_type)
static bool type_poll_for_non_popup (const bContext &C, const AssetShelfType *shelf_type, const int space_type)
AssetShelfTypeensure_shelf_has_type (AssetShelf &shelf)
AssetShelfcreate_shelf_from_type (AssetShelfType &type)
Active Shelf Management
static void activate_shelf (RegionAssetShelf &shelf_regiondata, AssetShelf &shelf)
static AssetShelfupdate_active_shelf (const bContext &C, const eSpace_Type space_type, RegionAssetShelf &shelf_regiondata, FunctionRef< void(AssetShelf &new_shelf)> on_create, FunctionRef< void(AssetShelf &shelf)> on_reactivate)
Catalog toggle buttons
static uiButadd_tab_button (uiBlock &block, StringRefNull name)
static void add_catalog_tabs (AssetShelf &shelf, uiLayout &layout)
Asset Shelf Header Region
static void asset_shelf_header_draw (const bContext *C, Header *header)
static void header_regiontype_register (ARegionType *region_type, const int space_type)

Variables

constexpr int LEFT_COL_WIDTH_UNITS = 10
constexpr int RIGHT_COL_WIDTH_UNITS_DEFAULT = 50

Function Documentation

◆ activate_shelf()

void blender::ed::asset::shelf::activate_shelf ( RegionAssetShelf & shelf_regiondata,
AssetShelf & shelf )
static

Activating a shelf means assigning it to RegionAssetShelf.active_shelf and (re-)inserting it at the beginning of the RegionAssetShelf.shelves list. This implies that after calling this, shelf is guaranteed to be owned by the shelves list.

Definition at line 179 of file asset_shelf.cc.

References RegionAssetShelf::active_shelf, BLI_addhead(), BLI_assert, BLI_findindex(), BLI_remlink(), and RegionAssetShelf::shelves.

Referenced by update_active_shelf().

◆ active_shelf_from_area()

AssetShelf * blender::ed::asset::shelf::active_shelf_from_area ( const ScrArea * area)

◆ active_shelf_from_context()

AssetShelf * blender::ed::asset::shelf::active_shelf_from_context ( const bContext * C)

Definition at line 763 of file asset_shelf.cc.

References active_shelf_ptr_from_context(), C, and PointerRNA::data.

Referenced by catalog_selector_panel_draw().

◆ active_shelf_ptr_from_context()

PointerRNA blender::ed::asset::shelf::active_shelf_ptr_from_context ( const bContext * C)
static

Definition at line 758 of file asset_shelf.cc.

References C, and CTX_data_pointer_get_type().

Referenced by active_shelf_from_context(), and asset_shelf_header_draw().

◆ add_catalog_tabs()

◆ add_tab_button()

uiBut * blender::ed::asset::shelf::add_tab_button ( uiBlock & block,
StringRefNull name )
static

◆ asset_shelf_default_tile_height()

int blender::ed::asset::shelf::asset_shelf_default_tile_height ( )
static

◆ asset_shelf_header_draw()

◆ asset_shelf_region_listen()

void blender::ed::asset::shelf::asset_shelf_region_listen ( const wmRegionListenerParams * params)
static

◆ asset_shelf_space_poll()

bool blender::ed::asset::shelf::asset_shelf_space_poll ( const bContext * C,
const SpaceLink * space_link )
static

Check if there is any asset shelf type in this space returning true in its poll. If not, no asset shelf region should be displayed.

Definition at line 290 of file asset_shelf.cc.

References C, SpaceLink::spacetype, static_shelf_types(), and type_poll_for_non_popup().

Referenced by header_regiontype_register(), and regions_poll().

◆ build_asset_view()

◆ calculate_row_count_from_tile_draw_height()

int blender::ed::asset::shelf::calculate_row_count_from_tile_draw_height ( const int region_height_scaled,
const int tile_draw_height )
static

How many rows fit into the region (accounting for padding).

Definition at line 414 of file asset_shelf.cc.

References main_region_padding_y().

Referenced by region_on_user_resize(), region_resize_to_preferred(), and region_snap().

◆ calculate_scaled_region_height_from_row_count()

int blender::ed::asset::shelf::calculate_scaled_region_height_from_row_count ( const int row_count,
const int tile_draw_height )
static

Definition at line 420 of file asset_shelf.cc.

References main_region_padding_y().

Referenced by region_resize_to_preferred(), and region_snap().

◆ catalog_filter_from_shelf_settings()

◆ catalog_selector_panel_draw()

◆ catalog_selector_panel_register()

◆ catalog_tree_draw()

void blender::ed::asset::shelf::catalog_tree_draw ( const bContext & C,
uiLayout & layout,
AssetShelf & shelf )
static

◆ context()

◆ create_asset_operator_params()

◆ create_shelf_from_type()

◆ current_tile_draw_height()

◆ ensure_asset_library_fetched()

void blender::ed::asset::shelf::ensure_asset_library_fetched ( const bContext & C,
const AssetShelfType & shelf_type )

◆ ensure_shelf_has_type()

AssetShelfType * blender::ed::asset::shelf::ensure_shelf_has_type ( AssetShelf & shelf)

Definition at line 139 of file asset_shelf.cc.

References static_shelf_types(), and STREQ.

Referenced by lookup_shelf_for_popup(), and update_active_shelf().

◆ filter_string_get()

std::string blender::ed::asset::shelf::filter_string_get ( const AssetShelf & shelf)
static

◆ get_enabled_catalog_path_list() [1/2]

ListBase * blender::ed::asset::shelf::get_enabled_catalog_path_list ( AssetShelf & shelf)
static

Definition at line 128 of file asset_shelf_settings.cc.

References get_enabled_catalog_path_list().

◆ get_enabled_catalog_path_list() [2/2]

◆ get_shelf_for_popup()

◆ header_region()

void blender::ed::asset::shelf::header_region ( const bContext * C,
ARegion * region )

◆ header_region_init()

void blender::ed::asset::shelf::header_region_init ( wmWindowManager * wm,
ARegion * region )

◆ header_region_listen()

void blender::ed::asset::shelf::header_region_listen ( const wmRegionListenerParams * params)

Definition at line 620 of file asset_shelf.cc.

References asset_shelf_region_listen(), and params.

Referenced by ED_spacetype_image(), ED_spacetype_node(), and ED_spacetype_view3d().

◆ header_region_size()

int blender::ed::asset::shelf::header_region_size ( )

Definition at line 637 of file asset_shelf.cc.

References UI_BUTTON_SECTION_SEPERATOR_LINE_WITH, and UI_UNIT_Y.

Referenced by region_rect_recursive().

◆ header_regiontype_register()

void blender::ed::asset::shelf::header_regiontype_register ( ARegionType * region_type,
const int space_type )
static

◆ layout_width_units_clamped()

int blender::ed::asset::shelf::layout_width_units_clamped ( const wmWindow * win)
static

Ensure the popover width fits into the window: Clamp width by the window width, minus some padding.

Definition at line 217 of file asset_shelf_popover.cc.

References LEFT_COL_WIDTH_UNITS, RIGHT_COL_WIDTH_UNITS_DEFAULT, UI_UNIT_X, and WM_window_native_pixel_x().

Referenced by popover_panel_draw().

◆ library_selector_draw()

◆ lookup_shelf_for_popup()

AssetShelf * blender::ed::asset::shelf::lookup_shelf_for_popup ( const bContext & C,
const AssetShelfType & shelf_type )
static

◆ lookup_type_from_idname_in_context()

AssetShelfType * blender::ed::asset::shelf::lookup_type_from_idname_in_context ( const bContext * C)
static

Definition at line 201 of file asset_shelf_popover.cc.

References C, CTX_data_string_get(), and type_find_from_idname().

Referenced by popover_panel_draw(), and popover_panel_poll().

◆ main_region_padding_x()

int blender::ed::asset::shelf::main_region_padding_x ( )
static

Definition at line 391 of file asset_shelf.cc.

References main_region_padding_y().

Referenced by region_layout().

◆ main_region_padding_y()

int blender::ed::asset::shelf::main_region_padding_y ( )
static

◆ popover_panel_draw()

◆ popover_panel_poll()

bool blender::ed::asset::shelf::popover_panel_poll ( const bContext * C,
PanelType *  )
static

◆ popover_panel_register()

◆ region_blend_read_data()

void blender::ed::asset::shelf::region_blend_read_data ( BlendDataReader * reader,
ARegion * region )

Definition at line 647 of file asset_shelf.cc.

References ARegion::regiondata, and regiondata_blend_read_data().

Referenced by direct_link_region().

◆ region_blend_write()

void blender::ed::asset::shelf::region_blend_write ( BlendWriter * writer,
ARegion * region )

Definition at line 657 of file asset_shelf.cc.

References regiondata_blend_write().

Referenced by write_region().

◆ region_draw()

◆ region_duplicate()

void * blender::ed::asset::shelf::region_duplicate ( void * regiondata)

◆ region_free()

void blender::ed::asset::shelf::region_free ( ARegion * region)

◆ region_init()

◆ region_layout()

◆ region_listen()

void blender::ed::asset::shelf::region_listen ( const wmRegionListenerParams * params)

◆ region_message_subscribe()

◆ region_on_poll_success()

◆ region_on_user_resize()

◆ region_prefsizey()

int blender::ed::asset::shelf::region_prefsizey ( )

Definition at line 507 of file asset_shelf.cc.

References asset_shelf_default_tile_height(), and main_region_padding_y().

Referenced by region_rect_recursive().

◆ region_resize_to_preferred()

void blender::ed::asset::shelf::region_resize_to_preferred ( ScrArea * area,
ARegion * region )
static

Ensure the region height matches the preferred row count (see AssetShelf.preferred_row_count) as closely as possible while still fitting within the area. In any case, this will ensure the region height is snapped to a multiple of the row count (plus region padding).

Definition at line 450 of file asset_shelf.cc.

References RegionAssetShelf::active_shelf, AE_TOP_TO_BOTTOMRIGHT, BLI_assert, calculate_row_count_from_tile_draw_height(), calculate_scaled_region_height_from_row_count(), current_tile_draw_height(), ED_area_max_regionsize(), ED_area_tag_region_size_update(), AssetShelf::preferred_row_count, ARegion::sizey, tile_height(), and UI_SCALE_FAC.

Referenced by region_layout().

◆ region_snap()

int blender::ed::asset::shelf::region_snap ( const ARegion * region,
int size,
int axis )

◆ regiondata_blend_read_data()

void blender::ed::asset::shelf::regiondata_blend_read_data ( BlendDataReader * reader,
RegionAssetShelf ** shelf_regiondata )

◆ regiondata_blend_write()

void blender::ed::asset::shelf::regiondata_blend_write ( BlendWriter * writer,
const RegionAssetShelf * shelf_regiondata )

◆ regiondata_duplicate()

RegionAssetShelf * blender::ed::asset::shelf::regiondata_duplicate ( const RegionAssetShelf * shelf_regiondata)

Deep-copies shelf_regiondata into newly allocated memory. Must be freed using regiondata_free().

Definition at line 43 of file asset_shelf_regiondata.cc.

References RegionAssetShelf::active_shelf, BLI_addtail(), BLI_listbase_clear(), LISTBASE_FOREACH, MEM_callocN(), AssetShelf::settings, and RegionAssetShelf::shelves.

Referenced by region_duplicate().

◆ regiondata_free()

void blender::ed::asset::shelf::regiondata_free ( RegionAssetShelf * shelf_regiondata)

Frees the contained data and shelf_regiondata itself.

Definition at line 64 of file asset_shelf_regiondata.cc.

References LISTBASE_FOREACH_MUTABLE, MEM_freeN(), and RegionAssetShelf::shelves.

Referenced by region_free().

◆ regions_poll()

bool blender::ed::asset::shelf::regions_poll ( const RegionPollParams * params)

Definition at line 302 of file asset_shelf.cc.

References asset_shelf_space_poll(), and params.

Referenced by ED_spacetype_image(), ED_spacetype_node(), and ED_spacetype_view3d().

◆ send_redraw_notifier()

◆ settings_blend_read_data()

void blender::ed::asset::shelf::settings_blend_read_data ( BlendDataReader * reader,
AssetShelfSettings & settings )

◆ settings_blend_write()

void blender::ed::asset::shelf::settings_blend_write ( BlendWriter * writer,
const AssetShelfSettings & settings )

◆ settings_clear_enabled_catalogs()

void blender::ed::asset::shelf::settings_clear_enabled_catalogs ( AssetShelf & shelf)

Clears the list of enabled catalogs in either the Preferences (if any) or the asset shelf settings (if any), depending on the ASSET_SHELF_TYPE_FLAG_STORE_CATALOGS_IN_PREFS flag.

Definition at line 134 of file asset_shelf_settings.cc.

References BKE_asset_catalog_path_list_free(), BLI_assert, BLI_listbase_is_empty(), and get_enabled_catalog_path_list().

Referenced by blender::ed::asset::shelf::AssetCatalogSelectorTree::update_shelf_settings_from_enabled_catalogs().

◆ settings_foreach_enabled_catalog_path()

void blender::ed::asset::shelf::settings_foreach_enabled_catalog_path ( const AssetShelf & shelf,
FunctionRef< void(const asset_system::AssetCatalogPath &catalog_path)> fn )

Definition at line 172 of file asset_shelf_settings.cc.

References get_enabled_catalog_path_list(), and LISTBASE_FOREACH.

Referenced by add_catalog_tabs().

◆ settings_is_active_catalog()

◆ settings_is_all_catalog_active()

bool blender::ed::asset::shelf::settings_is_all_catalog_active ( const AssetShelfSettings & settings)

◆ settings_is_catalog_path_enabled()

bool blender::ed::asset::shelf::settings_is_catalog_path_enabled ( const AssetShelf & shelf,
const asset_system::AssetCatalogPath & path )

◆ settings_set_active_catalog()

◆ settings_set_all_catalog_active()

void blender::ed::asset::shelf::settings_set_all_catalog_active ( AssetShelfSettings & settings)

◆ settings_set_catalog_path_enabled()

◆ show_catalog_in_visible_shelves()

void blender::ed::asset::shelf::show_catalog_in_visible_shelves ( const bContext & C,
const StringRefNull catalog_path )

◆ static_shelf_types()

Vector< std::unique_ptr< AssetShelfType > > & blender::ed::asset::shelf::static_shelf_types ( )
static

◆ tile_height()

◆ tile_width()

int blender::ed::asset::shelf::tile_width ( const AssetShelfSettings & settings)

Definition at line 490 of file asset_shelf.cc.

References AssetShelfSettings::preview_size, and UI_preview_tile_size_x().

Referenced by build_asset_view().

◆ type_find_from_idname()

AssetShelfType * blender::ed::asset::shelf::type_find_from_idname ( StringRef idname)

◆ type_poll_for_non_popup()

bool blender::ed::asset::shelf::type_poll_for_non_popup ( const bContext & C,
const AssetShelfType * shelf_type,
const int space_type )
static

Poll an asset shelf type for display as a permanent region in a space of a given type (the type's #bl_space_type).

Popup asset shelves should use type_poll_for_popup() instead.

Definition at line 115 of file asset_shelf.cc.

References C, AssetShelfType::space_type, and type_poll_no_spacetype_check().

Referenced by asset_shelf_space_poll(), and update_active_shelf().

◆ type_poll_for_popup()

bool blender::ed::asset::shelf::type_poll_for_popup ( const bContext & C,
const AssetShelfType * shelf_type )

Poll an asset shelf type for display as a popup. Doesn't check for space-type (the type's #bl_space_type) since popups should ignore this to allow displaying in any space.

Permanent/non-popup asset shelf regions should use #type_poll_for_space_type() instead.

Definition at line 104 of file asset_shelf.cc.

References C, and type_poll_no_spacetype_check().

Referenced by blender::ui::asset_shelf_popover_invoke(), get_shelf_for_popup(), lookup_shelf_for_popup(), and popover_panel_poll().

◆ type_poll_no_spacetype_check()

bool blender::ed::asset::shelf::type_poll_no_spacetype_check ( const bContext & C,
const AssetShelfType * shelf_type )
static

◆ type_popup_unlink()

void blender::ed::asset::shelf::type_popup_unlink ( const AssetShelfType & shelf_type)

◆ type_register()

void blender::ed::asset::shelf::type_register ( std::unique_ptr< AssetShelfType > type)

◆ type_unlink()

void blender::ed::asset::shelf::type_unlink ( const Main & bmain,
const AssetShelfType & shelf_type )

◆ type_unregister()

◆ types_register()

void blender::ed::asset::shelf::types_register ( ARegionType * region_type,
const int space_type )

◆ update_active_shelf()

AssetShelf * blender::ed::asset::shelf::update_active_shelf ( const bContext & C,
const eSpace_Type space_type,
RegionAssetShelf & shelf_regiondata,
FunctionRef< void(AssetShelf &new_shelf)> on_create,
FunctionRef< void(AssetShelf &shelf)> on_reactivate )
static

Determine and set the currently active asset shelf, creating a new shelf if needed.

The heuristic works as follows: 1) If the currently active shelf is still valid (poll succeeds), keep it active. 2) Otherwise, check for previously activated shelves in shelf_regiondata and activate the first valid one (first with a succeeding poll). 3) If none is valid, check all shelf-types available for space_type, create a new shelf for the first type that is valid (poll succeeds), and activate it. 4) If no shelf-type is valid, RegionAssetShelf.active_shelf is set to null.

When activating a shelf, it is moved to the beginning of the RegionAssetShelf.shelves list, so that recently activated shelves are also the first ones to be reactivated.

The returned shelf is guaranteed to have its AssetShelf.type pointer set.

Parameters
on_createFunction called when a new asset shelf is created (case 3).
Returns
A non-owning pointer to the now active shelf. Might be null if no shelf is valid in current context (all polls failed).

Definition at line 208 of file asset_shelf.cc.

References activate_shelf(), RegionAssetShelf::active_shelf, BLI_addhead(), BLI_assert, C, create_shelf_from_type(), ensure_shelf_has_type(), ListBase::first, LISTBASE_FOREACH, RegionAssetShelf::shelves, static_shelf_types(), and type_poll_for_non_popup().

Referenced by region_on_poll_success().

◆ use_enabled_catalogs_from_prefs()

bool blender::ed::asset::shelf::use_enabled_catalogs_from_prefs ( const AssetShelf & shelf)
static

Variable Documentation

◆ LEFT_COL_WIDTH_UNITS

int blender::ed::asset::shelf::LEFT_COL_WIDTH_UNITS = 10
constexpr

◆ RIGHT_COL_WIDTH_UNITS_DEFAULT

int blender::ed::asset::shelf::RIGHT_COL_WIDTH_UNITS_DEFAULT = 50
constexpr

Definition at line 211 of file asset_shelf_popover.cc.

Referenced by layout_width_units_clamped().