31#include "RNA_prototypes.hh"
66 shelf_types.
append(std::move(type));
72 auto *
const it = std::find_if(shelf_types.
begin(),
74 [&](
const std::unique_ptr<AssetShelfType> &iter_type) {
75 return iter_type.get() == &shelf_type;
92 [&](
const std::unique_ptr<AssetShelfType> &type) {
93 return type.get() == shelf_type;
94 }) != shelf_types.
end(),
95 "Asset shelf type is not registered");
98 return !shelf_type->
poll || shelf_type->
poll(&C, shelf_type);
114 const int space_type)
129 if (idname == shelf_type->idname) {
130 return shelf_type.get();
144 shelf.
type = shelf_type.get();
145 return shelf_type.get();
154 AssetShelf *shelf = MEM_new<AssetShelf>(__func__);
155 *shelf = dna::shallow_zero_initialize();
234 on_reactivate(*shelf);
248 on_create(*new_shelf);
267 if (!shelf_regiondata) {
276 RegionAssetShelf *shelf_regiondata = RegionAssetShelf::get_from_asset_shelf_region(*region);
277 if (shelf_regiondata) {
280 region->regiondata =
nullptr;
346 msg_sub_value_region_tag_redraw.
owner = region;
347 msg_sub_value_region_tag_redraw.user_data = region;
350 mbus, &workspace->
id, workspace,
WorkSpace, tools, &msg_sub_value_region_tag_redraw);
356 RegionAssetShelf *shelf_regiondata = RegionAssetShelf::get_from_asset_shelf_region(*region);
359 "Region-data should've been created by a previously called `region_on_poll_success()`.");
396 const RegionAssetShelf *shelf_regiondata = RegionAssetShelf::get_from_asset_shelf_region(
405 (
IS_EQF(aspect, 0) ? 1.0f : aspect);
412 const int tile_draw_height)
418 const int tile_draw_height)
449 const RegionAssetShelf *shelf_regiondata = RegionAssetShelf::get_from_asset_shelf_region(
460 if (region->sizey != new_size_y) {
461 region->sizey = new_size_y;
468 const RegionAssetShelf *shelf_regiondata = RegionAssetShelf::get_from_asset_shelf_region(
505 RegionAssetShelf *shelf_regiondata = RegionAssetShelf::get_from_asset_shelf_region(*region);
508 "Region-data should've been created by a previously called `region_on_poll_success()`.");
525 region->winx - 2 * padding_x,
572 RegionAssetShelf *shelf_regiondata = RegionAssetShelf::ensure_from_asset_shelf_region(*region);
573 if (!shelf_regiondata) {
578 const int old_region_flag = region->flag;
588 SET_FLAG_FROM_TEST(region->flag,
589 (new_shelf.type->flag & ASSET_SHELF_TYPE_FLAG_DEFAULT_VISIBLE) == 0,
596 region->flag, shelf.instance_flag & ASSETSHELF_REGION_IS_HIDDEN, RGN_FLAG_HIDDEN);
599 if (old_region_flag != region->flag) {
641 RegionAssetShelf *shelf_regiondata = RegionAssetShelf::get_from_asset_shelf_region(*region);
642 if (!shelf_regiondata) {
646 region->regiondata = shelf_regiondata;
651 RegionAssetShelf *shelf_regiondata = RegionAssetShelf::get_from_asset_shelf_region(*region);
652 if (!shelf_regiondata) {
677 const RegionAssetShelf *shelf_regiondata = RegionAssetShelf::get_from_asset_shelf_region(
679 if (!shelf_regiondata) {
688 static const char *context_dir[] = {
690 "asset_library_reference",
720 &RNA_AssetLibraryReference,
739 but_context,
"active_file", &RNA_FileSelectEntry);
773 const int but_width = std::min(string_width + 2 * pad_x,
UI_UNIT_X * 8);
787 TIP_(
"Enable catalog, making contained assets visible in the asset shelf"));
845 uiItemPopoverPanel(layout, C,
"ASSETSHELF_PT_catalog_selector",
"", ICON_COLLAPSEMENU);
866 HeaderType *ht = MEM_cnew<HeaderType>(__func__);
896 ListBase *regionbase = (sl == area->spacedata.first) ? &area->regionbase : &sl->regionbase;
902 RegionAssetShelf *shelf_regiondata = RegionAssetShelf::get_from_asset_shelf_region(
904 if (!shelf_regiondata) {
908 if (shelf->type == &shelf_type) {
909 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)
@ CTX_RESULT_MEMBER_NOT_FOUND
SpaceLink * CTX_wm_space_data(const bContext *C)
const PointerRNA * CTX_store_ptr_lookup(const bContextStore *store, blender::StringRefNull name, const StructRNA *type=nullptr)
void CTX_data_pointer_set_ptr(bContextDataResult *result, const PointerRNA *ptr)
ARegion * CTX_wm_region(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)
void BLI_addhead(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
#define LISTBASE_FOREACH(type, var, list)
void BLI_addtail(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
void BLI_remlink(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
int BLI_findindex(const struct ListBase *listbase, const void *vlink) ATTR_WARN_UNUSED_RESULT 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(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
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)
uiBut * uiDefBut(uiBlock *block, int type, int retval, blender::StringRef str, int x, int y, short width, short height, void *poin, float min, float max, const char *tip)
uiBlock * uiLayoutGetBlock(uiLayout *layout)
uiLayout * uiLayoutRow(uiLayout *layout, bool align)
uiLayout * UI_block_layout(uiBlock *block, int dir, int type, int x, int y, int size, int em, int padding, const uiStyle *style)
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)
uiBlock * UI_block_begin(const bContext *C, ARegion *region, std::string name, eUIEmbossType emboss)
void uiItemS(uiLayout *layout)
void uiLayoutSetUnitsX(uiLayout *layout, float unit)
void UI_block_emboss_set(uiBlock *block, eUIEmbossType emboss)
void uiItemSpacer(uiLayout *layout)
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
void UI_block_layout_resolve(uiBlock *block, int *r_x, int *r_y)
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)
void uiItemPopoverPanel(uiLayout *layout, const bContext *C, const char *panel_type, const char *name, int icon)
uiBut * UI_region_views_find_active_item_but(const ARegion *region)
void uiItemR(uiLayout *layout, PointerRNA *ptr, const char *propname, eUI_Item_Flag flag, const char *name, int icon)
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)
void append(const T &value)
void remove(const int64_t index)
StringRefNull name() const
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)
void region_init(wmWindowManager *wm, ARegion *region)
AssetShelfType * type_find_from_idname(const StringRef idname)
void region_blend_read_data(BlendDataReader *reader, ARegion *region)
void build_asset_view(uiLayout &layout, const AssetLibraryReference &library_ref, const AssetShelf &shelf, const bContext &C, const ARegion ®ion)
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 * 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)
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 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)
AssetLibraryReference asset_library_reference
bool(* poll)(const bContext *C, const AssetShelfType *shelf_type)
struct AssetShelfType * type
AssetShelfSettings settings
short preferred_row_count
AssetShelf * active_shelf
struct wmKeyConfig * defaultconf
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)