33#include "RNA_prototypes.hh"
69 shelf_types.
append(std::move(type));
75 auto *
const it = std::find_if(shelf_types.
begin(),
77 [&](
const std::unique_ptr<AssetShelfType> &iter_type) {
78 return iter_type.get() == &shelf_type;
95 [&](
const std::unique_ptr<AssetShelfType> &type) {
96 return type.get() == shelf_type;
97 }) != shelf_types.
end(),
98 "Asset shelf type is not registered");
101 return !shelf_type->
poll || shelf_type->
poll(&
C, shelf_type);
117 const int space_type)
132 if (idname == shelf_type->idname) {
133 return shelf_type.get();
146 if (
STREQ(
shelf.idname, shelf_type->idname)) {
147 shelf.type = shelf_type.get();
148 return shelf_type.get();
158 *
shelf = dna::shallow_zero_initialize();
163 shelf->preferred_row_count = 1;
237 on_reactivate(*
shelf);
251 on_create(*new_shelf);
270 if (!shelf_regiondata) {
279 RegionAssetShelf *shelf_regiondata = RegionAssetShelf::get_from_asset_shelf_region(*region);
280 if (shelf_regiondata) {
349 msg_sub_value_region_tag_redraw.
owner = region;
350 msg_sub_value_region_tag_redraw.
user_data = region;
353 mbus, &workspace->
id, workspace,
WorkSpace, tools, &msg_sub_value_region_tag_redraw);
359 RegionAssetShelf *shelf_regiondata = RegionAssetShelf::get_from_asset_shelf_region(*region);
362 "Region-data should've been created by a previously called `region_on_poll_success()`.");
399 const RegionAssetShelf *shelf_regiondata = RegionAssetShelf::get_from_asset_shelf_region(
408 (
IS_EQF(aspect, 0) ? 1.0f : aspect);
415 const int tile_draw_height)
421 const int tile_draw_height)
452 const RegionAssetShelf *shelf_regiondata = RegionAssetShelf::get_from_asset_shelf_region(
470 if (region->
sizey != new_size_y) {
471 region->
sizey = new_size_y;
478 const RegionAssetShelf *shelf_regiondata = RegionAssetShelf::get_from_asset_shelf_region(
515 RegionAssetShelf *shelf_regiondata = RegionAssetShelf::get_from_asset_shelf_region(*region);
518 "Region-data should've been created by a previously called `region_on_poll_success()`.");
535 region->
winx - 2 * padding_x,
580 RegionAssetShelf *shelf_regiondata = RegionAssetShelf::ensure_from_asset_shelf_region(*region);
581 if (!shelf_regiondata) {
586 const int old_region_flag = region->
flag;
596 SET_FLAG_FROM_TEST(region->flag,
597 (new_shelf.type->flag & ASSET_SHELF_TYPE_FLAG_DEFAULT_VISIBLE) == 0,
604 region->flag, shelf.instance_flag & ASSETSHELF_REGION_IS_HIDDEN, RGN_FLAG_HIDDEN);
607 if (old_region_flag != region->
flag) {
649 RegionAssetShelf *shelf_regiondata = RegionAssetShelf::get_from_asset_shelf_region(*region);
650 if (!shelf_regiondata) {
659 RegionAssetShelf *shelf_regiondata = RegionAssetShelf::get_from_asset_shelf_region(*region);
660 if (!shelf_regiondata) {
685 const RegionAssetShelf *shelf_regiondata = RegionAssetShelf::get_from_asset_shelf_region(
687 if (!shelf_regiondata) {
696 static const char *context_dir[] = {
698 "asset_library_reference",
728 &RNA_AssetLibraryReference,
746 but_context,
"asset", &RNA_AssetRepresentation);
780 const int but_width = std::min(string_width + 2 * pad_x,
UI_UNIT_X * 8);
794 TIP_(
"Enable catalog, making contained assets visible in the asset shelf"));
852 layout->
popover(
C,
"ASSETSHELF_PT_catalog_selector",
"", ICON_COLLAPSEMENU);
864 layout->
popover(
C,
"ASSETSHELF_PT_display",
"", ICON_IMGDISPLAY);
903 ListBase *regionbase = (sl == area->spacedata.first) ? &area->regionbase : &sl->regionbase;
909 RegionAssetShelf *shelf_regiondata = RegionAssetShelf::get_from_asset_shelf_region(
911 if (!shelf_regiondata) {
915 if (
shelf->type == &shelf_type) {
916 shelf->type =
nullptr;
void CTX_data_dir_set(bContextDataResult *result, const char **dir)
bool CTX_data_equals(const char *member, const char *str)
bScreen * CTX_wm_screen(const bContext *C)
void CTX_data_pointer_set(bContextDataResult *result, ID *id, StructRNA *type, void *data)
bool CTX_data_dir(const char *member)
PointerRNA CTX_data_pointer_get_type(const bContext *C, const char *member, StructRNA *type)
ScrArea * CTX_wm_area(const bContext *C)
const AssetLibraryReference * CTX_wm_asset_library_ref(const bContext *C)
const PointerRNA * CTX_store_ptr_lookup(const bContextStore *store, blender::StringRef name, const StructRNA *type=nullptr)
@ CTX_RESULT_MEMBER_NOT_FOUND
SpaceLink * CTX_wm_space_data(const bContext *C)
void CTX_data_pointer_set_ptr(bContextDataResult *result, const PointerRNA *ptr)
ARegion * CTX_wm_region(const bContext *C)
wmWindowManager * CTX_wm_manager(const bContext *C)
#define ASSET_SHELF_PREVIEW_SIZE_DEFAULT
ARegion * BKE_area_find_region_type(const ScrArea *area, int region_type)
#define BLI_assert_unreachable()
#define BLI_assert_msg(a, msg)
int BLI_findindex(const ListBase *listbase, const void *vlink) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
#define LISTBASE_FOREACH(type, var, list)
void BLI_addtail(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
void BLI_remlink(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
void BLI_addhead(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
BLI_INLINE int BLI_rcti_size_y(const struct rcti *rct)
BLI_INLINE float BLI_rctf_size_y(const struct rctf *rct)
#define STRNCPY_UTF8(dst, src)
#define SET_FLAG_FROM_TEST(value, test, flag)
@ RGN_TYPE_ASSET_SHELF_HEADER
@ RGN_FLAG_RESIZE_RESPECT_BUTTON_SECTIONS
@ RGN_FLAG_HIDDEN_BY_USER
@ ASSETSHELF_REGION_IS_HIDDEN
@ V2D_SCROLL_VERTICAL_HIDE
int ED_area_max_regionsize(const ScrArea *area, const ARegion *scale_region, const AZEdge edge)
void ED_region_clear(const bContext *C, const ARegion *region, int colorid)
void ED_region_header_init(ARegion *region)
void ED_region_tag_redraw_no_rebuild(ARegion *region)
void ED_region_header_with_button_sections(const bContext *C, ARegion *region, uiButtonSectionsAlign align)
void ED_area_tag_region_size_update(ScrArea *area, ARegion *changed_region)
void ED_region_visibility_change_update(bContext *C, ScrArea *area, ARegion *region)
void ED_region_tag_redraw(ARegion *region)
void ED_region_do_msg_notify_tag_redraw(bContext *C, wmMsgSubscribeKey *msg_key, wmMsgSubscribeValue *msg_val)
void UI_but_func_set(uiBut *but, std::function< void(bContext &)> func)
void UI_but_func_pushed_state_set(uiBut *but, std::function< bool(const uiBut &)> func)
void UI_but_flag_disable(uiBut *but, int flag)
void UI_blocklist_update_window_matrix(const bContext *C, const ListBase *lb)
void UI_block_emboss_set(uiBlock *block, blender::ui::EmbossType emboss)
uiBlock * UI_block_begin(const bContext *C, ARegion *region, std::string name, blender::ui::EmbossType emboss)
const uiStyle * UI_style_get_dpi()
int UI_preview_tile_size_y(const int size_px=96)
void UI_but_drawflag_enable(uiBut *but, int flag)
int UI_fontstyle_string_width(const uiFontStyle *fs, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1
void UI_blocklist_draw(const bContext *C, const ListBase *lb)
#define UI_BUTTON_SECTION_SEPERATOR_LINE_WITH
int UI_preview_tile_size_x(const int size_px=96)
const bContextStore * UI_but_context_get(const uiBut *but)
int UI_preview_tile_size_y_no_label(const int size_px=96)
void UI_block_end(const bContext *C, uiBlock *block)
uiBut * uiDefBut(uiBlock *block, uiButTypeWithPointerType but_and_ptr_type, int retval, blender::StringRef str, int x, int y, short width, short height, void *poin, float min, float max, std::optional< blender::StringRef > tip)
uiBut * UI_region_views_find_active_item_but(const ARegion *region)
void UI_view2d_curRect_validate(View2D *v2d)
void UI_view2d_scrollers_draw(View2D *v2d, const rcti *mask_custom)
void UI_view2d_view_restore(const bContext *C)
void UI_view2d_region_reinit(View2D *v2d, short type, int winx, int winy)
void UI_view2d_totRect_set(View2D *v2d, int width, int height)
void UI_view2d_view_ortho(const View2D *v2d)
void UI_view2d_offset_y_snap_to_closest_page(View2D *v2d)
@ V2D_COMMONVIEW_PANELS_UI
#define ND_REGIONS_ASSET_SHELF
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
constexpr const char * c_str() const
void append(const T &value)
void remove(const int64_t index)
StringRefNull name() const
void * MEM_callocN(size_t len, const char *str)
AssetLibraryReference all_library_reference()
void storage_fetch(const AssetLibraryReference *library_reference, const bContext *C)
bool listen(const wmNotifier *notifier)
static bool asset_shelf_space_poll(const bContext *C, const SpaceLink *space_link)
static int asset_shelf_default_tile_height()
void header_region(const bContext *C, ARegion *region)
AssetShelfType * type_find_from_idname(StringRef idname)
void region_init(wmWindowManager *wm, ARegion *region)
void region_blend_read_data(BlendDataReader *reader, ARegion *region)
static int current_tile_draw_height(const ARegion *region)
bool settings_is_all_catalog_active(const AssetShelfSettings &settings)
AssetShelf * create_shelf_from_type(AssetShelfType &type)
void type_popup_unlink(const AssetShelfType &shelf_type)
void popover_panel_register(ARegionType *region_type)
void types_register(ARegionType *region_type, const int space_type)
static Vector< std::unique_ptr< AssetShelfType > > & static_shelf_types()
void regiondata_free(RegionAssetShelf *shelf_regiondata)
static void header_regiontype_register(ARegionType *region_type, const int space_type)
void region_listen(const wmRegionListenerParams *params)
static int calculate_row_count_from_tile_draw_height(const int region_height_scaled, const int tile_draw_height)
void settings_foreach_enabled_catalog_path(const AssetShelf &shelf, FunctionRef< void(const asset_system::AssetCatalogPath &catalog_path)> fn)
void region_on_poll_success(const bContext *C, ARegion *region)
void catalog_selector_panel_register(ARegionType *region_type)
void header_region_listen(const wmRegionListenerParams *params)
static void asset_shelf_header_draw(const bContext *C, Header *header)
void settings_set_all_catalog_active(AssetShelfSettings &settings)
void type_unregister(const AssetShelfType &shelf_type)
void region_blend_write(BlendWriter *writer, ARegion *region)
void type_unlink(const Main &bmain, const AssetShelfType &shelf_type)
int tile_height(const AssetShelfSettings &settings)
static uiBut * add_tab_button(uiBlock &block, StringRefNull name)
AssetShelf * active_shelf_from_context(const bContext *C)
static AssetShelf * 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)
void regiondata_blend_write(BlendWriter *writer, const RegionAssetShelf *shelf_regiondata)
static PointerRNA active_shelf_ptr_from_context(const bContext *C)
static bool type_poll_for_non_popup(const bContext &C, const AssetShelfType *shelf_type, const int space_type)
void region_on_user_resize(const ARegion *region)
AssetShelfType * ensure_shelf_has_type(AssetShelf &shelf)
int context(const bContext *C, const char *member, bContextDataResult *result)
int tile_width(const AssetShelfSettings &settings)
int region_snap(const ARegion *region, int size, int axis)
void type_register(std::unique_ptr< AssetShelfType > type)
bool settings_is_active_catalog(const AssetShelfSettings &settings, const asset_system::AssetCatalogPath &path)
void show_catalog_in_visible_shelves(const bContext &C, const StringRefNull catalog_path)
void * region_duplicate(void *regiondata)
void send_redraw_notifier(const bContext &C)
bool type_poll_for_popup(const bContext &C, const AssetShelfType *shelf_type)
static void asset_shelf_region_listen(const wmRegionListenerParams *params)
void settings_set_catalog_path_enabled(AssetShelf &shelf, const asset_system::AssetCatalogPath &path)
AssetShelf * active_shelf_from_area(const ScrArea *area)
bool regions_poll(const RegionPollParams *params)
static void region_resize_to_preferred(ScrArea *area, ARegion *region)
void header_region_init(wmWindowManager *wm, ARegion *region)
static bool type_poll_no_spacetype_check(const bContext &C, const AssetShelfType *shelf_type)
static int main_region_padding_y()
void regiondata_blend_read_data(BlendDataReader *reader, RegionAssetShelf **shelf_regiondata)
void settings_set_active_catalog(AssetShelfSettings &settings, const asset_system::AssetCatalogPath &path)
static int main_region_padding_x()
void build_asset_view(uiLayout &layout, const AssetLibraryReference &library_ref, const AssetShelf &shelf, const bContext &C)
void region_draw(const bContext *C, ARegion *region)
void region_message_subscribe(const wmRegionMessageSubscribeParams *params)
RegionAssetShelf * regiondata_duplicate(const RegionAssetShelf *shelf_regiondata)
static int calculate_scaled_region_height_from_row_count(const int row_count, const int tile_draw_height)
static void activate_shelf(RegionAssetShelf &shelf_regiondata, AssetShelf &shelf)
void region_layout(const bContext *C, ARegion *region)
static void add_catalog_tabs(AssetShelf &shelf, uiLayout &layout)
void region_free(ARegion *region)
int2 block_layout_resolve(uiBlock *block)
uiLayout & block_layout(uiBlock *block, LayoutDirection direction, LayoutType type, int x, int y, int size, int em, int padding, const uiStyle *style)
ARegionRuntimeHandle * runtime
AssetLibraryReference asset_library_reference
short default_preview_size
char idname[BKE_ST_MAXNAME]
bool(* poll)(const bContext *C, const AssetShelfType *shelf_type)
struct AssetShelfType * type
AssetShelfSettings settings
short preferred_row_count
AssetShelf * active_shelf
void popover(const bContext *C, PanelType *pt, std::optional< blender::StringRef > name_opt, int icon)
void separator(float factor=1.0f, LayoutSeparatorType type=LayoutSeparatorType::Auto)
void ui_units_x_set(float width)
uiLayout & row(bool align)
void prop(PointerRNA *ptr, PropertyRNA *prop, int index, int value, eUI_Item_Flag flag, std::optional< blender::StringRef > name_opt, int icon, std::optional< blender::StringRef > placeholder=std::nullopt)
wmEventHandler_Keymap * WM_event_add_keymap_handler(ListBase *handlers, wmKeyMap *keymap)
void WM_event_add_notifier(const bContext *C, uint type, void *reference)
wmKeyMap * WM_keymap_ensure(wmKeyConfig *keyconf, const char *idname, int spaceid, int regionid)
#define WM_msg_subscribe_rna_prop(mbus, id_, data_, type_, prop_, value)
bScreen * WM_window_get_active_screen(const wmWindow *win)