Blender V4.3
blender::ed::asset::shelf Namespace Reference

Classes

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

Functions

void send_redraw_notifier (const bContext &C)
 
void build_asset_view (uiLayout &layout, const AssetLibraryReference &library_ref, const AssetShelf &shelf, const bContext &C, const ARegion &region)
 
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_activate_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 AssetShelfget_shelf_for_popup (const bContext &C, AssetShelfType &shelf_type)
 
static void catalog_tree_draw (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 (const StringRef idname)
 
Asset Shelf Popup
void type_popup_unlink (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)
 
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()

static 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 176 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 756 of file asset_shelf.cc.

References active_shelf_ptr_from_context(), and PointerRNA::data.

Referenced by catalog_selector_panel_draw().

◆ active_shelf_ptr_from_context()

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

Definition at line 751 of file asset_shelf.cc.

References CTX_data_pointer_get_type().

Referenced by active_shelf_from_context(), and asset_shelf_header_draw().

◆ add_catalog_tabs()

◆ add_tab_button()

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

◆ asset_shelf_default_tile_height()

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

◆ asset_shelf_header_draw()

◆ asset_shelf_region_listen()

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

◆ asset_shelf_space_poll()

static 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 287 of file asset_shelf.cc.

References 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()

static 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 411 of file asset_shelf.cc.

References main_region_padding_y().

Referenced by region_on_user_resize(), and region_snap().

◆ calculate_scaled_region_height_from_row_count()

static 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 417 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()

◆ context()

◆ create_activate_operator_params()

◆ create_shelf_from_type()

◆ current_tile_draw_height()

static int blender::ed::asset::shelf::current_tile_draw_height ( const ARegion * region)
static

◆ ensure_shelf_has_type()

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

◆ filter_string_get()

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

◆ get_enabled_catalog_path_list() [1/2]

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

Definition at line 118 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 )

Definition at line 624 of file asset_shelf.cc.

References Bottom, and ED_region_header_with_button_sections().

◆ 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 612 of file asset_shelf.cc.

References asset_shelf_region_listen(), and params.

◆ header_region_size()

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

Definition at line 629 of file asset_shelf.cc.

References UI_BUTTON_SECTION_SEPERATOR_LINE_WITH, and UI_UNIT_Y.

◆ header_regiontype_register()

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

◆ layout_width_units_clamped()

static 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 191 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_type_from_idname_in_context()

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

◆ main_region_padding_x()

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

Definition at line 388 of file asset_shelf.cc.

References main_region_padding_y().

Referenced by region_layout().

◆ main_region_padding_y()

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

◆ popover_panel_draw()

◆ popover_panel_poll()

static 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 639 of file asset_shelf.cc.

References 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 649 of file asset_shelf.cc.

References regiondata_blend_write().

Referenced by write_region().

◆ region_draw()

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

◆ region_duplicate()

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

Only needed for RGN_TYPE_ASSET_SHELF (not RGN_TYPE_ASSET_SHELF_HEADER).

Definition at line 264 of file asset_shelf.cc.

References regiondata_duplicate().

◆ region_free()

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

Definition at line 274 of file asset_shelf.cc.

References regiondata_free().

◆ region_init()

◆ region_layout()

◆ region_listen()

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

◆ region_message_subscribe()

void blender::ed::asset::shelf::region_message_subscribe ( const wmRegionMessageSubscribeParams * params)

◆ region_on_poll_success()

◆ region_on_user_resize()

void blender::ed::asset::shelf::region_on_user_resize ( const ARegion * region)

◆ region_prefsizey()

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

Definition at line 497 of file asset_shelf.cc.

References asset_shelf_default_tile_height(), and main_region_padding_y().

◆ region_resize_to_preferred()

static 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). In any case, this will ensure the region height is snapped to a multiple of the row count (plus region padding).

Definition at line 447 of file asset_shelf.cc.

References RegionAssetShelf::active_shelf, BLI_assert, calculate_scaled_region_height_from_row_count(), current_tile_draw_height(), ED_area_tag_region_size_update(), AssetShelf::preferred_row_count, 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, 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 299 of file asset_shelf.cc.

References asset_shelf_space_poll(), and params.

◆ 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 124 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 162 of file asset_shelf_settings.cc.

References get_enabled_catalog_path_list(), and LISTBASE_FOREACH.

Referenced by add_catalog_tabs().

◆ settings_is_active_catalog()

bool blender::ed::asset::shelf::settings_is_active_catalog ( const AssetShelfSettings & settings,
const asset_system::AssetCatalogPath & path )

◆ 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()

◆ static_shelf_types()

static 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 480 of file asset_shelf.cc.

References UI_preview_tile_size_x().

Referenced by build_asset_view().

◆ type_find_from_idname()

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

◆ type_poll_for_non_popup()

static 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 112 of file asset_shelf.cc.

References 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 101 of file asset_shelf.cc.

References type_poll_no_spacetype_check().

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

◆ type_poll_no_spacetype_check()

static 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()

static 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 205 of file asset_shelf.cc.

References activate_shelf(), RegionAssetShelf::active_shelf, BLI_addhead(), BLI_assert, 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()

static 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 185 of file asset_shelf_popover.cc.

Referenced by layout_width_units_clamped().