35#include "RNA_prototypes.hh"
71 shelf_types.
append(std::move(type));
77 auto *
const it = std::find_if(shelf_types.
begin(),
79 [&](
const std::unique_ptr<AssetShelfType> &iter_type) {
80 return iter_type.get() == &shelf_type;
97 [&](
const std::unique_ptr<AssetShelfType> &type) {
98 return type.get() == shelf_type;
99 }) != shelf_types.
end(),
100 "Asset shelf type is not registered");
103 return !shelf_type->
poll || shelf_type->
poll(&
C, shelf_type);
119 const int space_type)
152 if (idname == shelf_type->idname) {
153 return shelf_type.get();
166 if (
STREQ(
shelf.idname, shelf_type->idname)) {
167 shelf.type = shelf_type.get();
168 return shelf_type.get();
183 shelf->preferred_row_count = 1;
257 on_reactivate(
shelf);
271 on_create(*new_shelf);
290 if (!shelf_regiondata) {
299 RegionAssetShelf *shelf_regiondata = RegionAssetShelf::get_from_asset_shelf_region(*region);
300 if (shelf_regiondata) {
368 msg_sub_value_region_tag_redraw.
owner = region;
369 msg_sub_value_region_tag_redraw.
user_data = region;
372 mbus, &workspace->
id, workspace,
WorkSpace, tools, &msg_sub_value_region_tag_redraw);
376 msg_sub_value_region_clear_remote_libraries.
owner = region;
377 msg_sub_value_region_clear_remote_libraries.
user_data = region;
378 msg_sub_value_region_clear_remote_libraries.
notify = [](
383 RegionAssetShelf *shelf_regiondata = RegionAssetShelf::get_from_asset_shelf_region(*region);
396 &msg_sub_value_region_clear_remote_libraries);
400 PreferencesExperimental,
401 use_remote_asset_libraries,
402 &msg_sub_value_region_clear_remote_libraries);
409 RegionAssetShelf *shelf_regiondata = RegionAssetShelf::get_from_asset_shelf_region(*region);
412 "Region-data should've been created by a previously called `region_on_poll_success()`.");
448 const RegionAssetShelf *shelf_regiondata = RegionAssetShelf::get_from_asset_shelf_region(
457 (
IS_EQF(aspect, 0) ? 1.0f : aspect);
464 const int tile_draw_height)
470 const int tile_draw_height)
501 const RegionAssetShelf *shelf_regiondata = RegionAssetShelf::get_from_asset_shelf_region(
519 if (region->
sizey != new_size_y) {
520 region->
sizey = new_size_y;
527 const RegionAssetShelf *shelf_regiondata = RegionAssetShelf::get_from_asset_shelf_region(
564 RegionAssetShelf *shelf_regiondata = RegionAssetShelf::get_from_asset_shelf_region(*region);
567 "Region-data should've been created by a previously called `region_on_poll_success()`.");
586 region->
winx - 2 * padding_x,
631 RegionAssetShelf *shelf_regiondata = RegionAssetShelf::ensure_from_asset_shelf_region(*region);
632 if (!shelf_regiondata) {
637 const int old_region_flag = region->
flag;
647 SET_FLAG_FROM_TEST(region->flag,
648 (new_shelf.type->flag & ASSET_SHELF_TYPE_FLAG_DEFAULT_VISIBLE) == 0,
655 region->flag, shelf.instance_flag & ASSETSHELF_REGION_IS_HIDDEN, RGN_FLAG_HIDDEN);
658 if (old_region_flag != region->
flag) {
700 RegionAssetShelf *shelf_regiondata = RegionAssetShelf::get_from_asset_shelf_region(*region);
701 if (!shelf_regiondata) {
710 RegionAssetShelf *shelf_regiondata = RegionAssetShelf::get_from_asset_shelf_region(*region);
711 if (!shelf_regiondata) {
736 const RegionAssetShelf *shelf_regiondata = RegionAssetShelf::get_from_asset_shelf_region(
738 if (!shelf_regiondata) {
747 static const char *context_dir[] = {
749 "asset_library_reference",
794 but_context,
"asset", RNA_AssetRepresentation);
828 const int but_width = std::min(string_width + 2 * pad_x,
UI_UNIT_X * 8);
841 TIP_(
"Enable catalog, making contained assets visible in the asset shelf"));
857 button_func_set(but, [&shelf_settings](
bContext &
C) {
861 button_func_pushed_state_set(but, [&shelf_settings](
const ui::Button &) ->
bool {
872 button_func_set(but, [&shelf_settings, path](
bContext &
C) {
876 button_func_pushed_state_set(but, [&shelf_settings, path](
const ui::Button &) ->
bool {
899 layout.
popover(
C,
"ASSETSHELF_PT_catalog_selector",
"", ICON_COLLAPSEMENU);
911 layout.
popover(
C,
"ASSETSHELF_PT_display",
"", ICON_IMGDISPLAY);
952 for (
ARegion ®ion : *regionbase) {
957 RegionAssetShelf *shelf_regiondata = RegionAssetShelf::get_from_asset_shelf_region(
959 if (!shelf_regiondata) {
963 if (
shelf.type == &shelf_type) {
964 shelf.type =
nullptr;
Main runtime representation of an asset.
#define ASSET_SHELF_PREVIEW_SIZE_DEFAULT
#define STRNCPY_UTF8(dst, src)
#define UI_BUTTON_SECTION_SEPERATOR_LINE_WITH
#define ND_REGIONS_ASSET_SHELF
#define BLI_assert_unreachable()
#define SET_FLAG_FROM_TEST(value, test, flag)
#define BLI_assert_msg(a, msg)
constexpr const char * c_str() const
void append(const T &value)
void remove(const int64_t index)
StringRefNull name() const
AssetLibraryReference all_library_reference()
bool is_or_contains_remote_libraries(const AssetLibraryReference &reference)
internal::ShallowZeroInitializeTag shallow_zero_initialize()
void storage_fetch(const AssetLibraryReference *library_reference, const bContext *C)
void clear(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)
AssetLibraryReference & settings_ensure_valid_library_ref(AssetShelfSettings &settings)
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)
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)
void build_asset_view(ui::Layout &layout, const AssetLibraryReference &library_ref, const AssetShelf &shelf, const bContext &C)
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)
static void add_catalog_tabs(AssetShelf &shelf, ui::Layout &layout)
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 ui::Button * add_tab_button(ui::Block &block, StringRefNull name)
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)
bool type_asset_poll(const AssetShelfType &shelf_type, const asset_system::AssetRepresentation &asset)
void region_layout(const bContext *C, ARegion *region)
void region_free(ARegion *region)
void view2d_view_ortho(const View2D *v2d)
void view2d_totRect_set(View2D *v2d, int width, int height)
void view2d_curRect_validate(View2D *v2d)
void blocklist_update_window_matrix(const bContext *C, const ListBaseT< ui::Block > *lb)
void view2d_offset_y_snap_to_closest_page(View2D *v2d)
int fontstyle_string_width(const uiFontStyle *fs, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1
void view2d_view_restore(const bContext *C)
int preview_tile_size_y_no_label(const int size_px=96)
void blocklist_draw(const bContext *C, const ListBaseT< ui::Block > *lb)
const uiStyle * style_get_dpi()
void view2d_scrollers_draw(View2D *v2d, const rcti *mask_custom)
int2 block_layout_resolve(Block *block)
Button * region_views_find_active_item_but(const ARegion *region)
@ V2D_COMMONVIEW_PANELS_UI
int preview_tile_size_y(const int size_px=96)
Layout & block_layout(Block *block, LayoutDirection direction, LayoutType type, int x, int y, int size, int em, int padding, const uiStyle *style)
int preview_tile_size_x(const int size_px=96)
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
uint64_t BKE_idtype_idcode_to_idfilter(short idcode)
unsigned __int64 uint64_t
ScrArea * CTX_wm_area(const bContext *C)
const PointerRNA * CTX_store_ptr_lookup(const bContextStore *store, StringRef name, const StructRNA *type=nullptr)
void CTX_data_dir_set(bContextDataResult *result, const char **dir)
int ED_area_max_regionsize(const ScrArea *area, const ARegion *scale_region, const AZEdge edge)
void BLI_addhead(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
@ RGN_TYPE_ASSET_SHELF_HEADER
bool CTX_data_equals(const char *member, const char *str)
void ED_region_tag_redraw(ARegion *region)
void ED_region_clear(const bContext *C, const ARegion *region, int colorid)
int BLI_findindex(const ListBase *listbase, const void *vlink) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
BLI_INLINE int BLI_rcti_size_y(const struct rcti *rct)
void * MEM_new_zeroed(size_t len, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1) ATTR_NONNULL(2)
void BLI_remlink(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
void ED_region_header_with_button_sections(const bContext *C, ARegion *region, ui::ButtonSectionsAlign align)
BLI_INLINE float BLI_rctf_size_y(const struct rctf *rct)
wmWindowManager * CTX_wm_manager(const bContext *C)
void CTX_data_pointer_set_ptr(bContextDataResult *result, const PointerRNA *ptr)
void CTX_data_pointer_set(bContextDataResult *result, ID *id, StructRNA *type, void *data)
wmKeyMap * WM_keymap_ensure(wmKeyConfig *keyconf, const char *idname, int spaceid, int regionid)
void ED_area_tag_region_size_update(ScrArea *area, ARegion *changed_region)
wmEventHandler_Keymap * WM_event_add_keymap_handler(ListBaseT< wmEventHandler > *handlers, wmKeyMap *keymap)
void WM_event_add_notifier(const bContext *C, uint type, void *reference)
bool CTX_data_dir(const char *member)
@ ASSETSHELF_REGION_IS_HIDDEN
void ED_region_visibility_change_update(bContext *C, ScrArea *area, ARegion *region)
ARegion * BKE_area_find_region_type(const ScrArea *area, int region_type)
SpaceLink * CTX_wm_space_data(const bContext *C)
@ V2D_SCROLL_VERTICAL_HIDE
void BLI_addtail(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
void ED_region_header_init(ARegion *region)
bScreen * CTX_wm_screen(const bContext *C)
@ RGN_FLAG_HIDDEN_BY_USER
@ RGN_FLAG_RESIZE_RESPECT_BUTTON_SECTIONS
@ CTX_RESULT_MEMBER_NOT_FOUND
void ED_region_do_msg_notify_tag_redraw(bContext *C, wmMsgSubscribeKey *msg_key, wmMsgSubscribeValue *msg_val)
bScreen * WM_window_get_active_screen(const wmWindow *win)
ARegion * CTX_wm_region(const bContext *C)
void ED_region_tag_redraw_no_rebuild(ARegion *region)
PointerRNA CTX_data_pointer_get_type(const bContext *C, const char *member, StructRNA *type)
const AssetLibraryReference * CTX_wm_asset_library_ref(const bContext *C)
ListBaseT< HeaderType > headertypes
bke::ARegionRuntime * runtime
eRegion_Alignment alignment
AssetLibraryReference asset_library_reference
AssetShelfSettings_DisplayFlag display_flag
bool(*) poll(const bContext *C, const AssetShelfType *shelf_type)
bool(*) asset_poll(const AssetShelfType *shelf_type, const asset_system::AssetRepresentation *asset)
uint64_t id_types_prefilter
char idname[BKE_ST_MAXNAME]
short default_preview_size
short preferred_row_count
AssetShelf_InstanceFlag instance_flag
struct AssetShelfType * type
AssetShelfSettings settings
ListBaseT< bScreen > screens
ListBaseT< AssetShelf > shelves
AssetShelf * active_shelf
ListBaseT< ARegion > regionbase
ListBaseT< SpaceLink > spacedata
ListBaseT< ARegion > regionbase
eView2D_KeepZoom keepzoom
ListBaseT< struct ScrArea > areabase
ListBaseT< wmEventHandler > handlers
ListBaseT< ui::Block > uiblocks
void ui_units_x_set(float width)
void prop(PointerRNA *ptr, PropertyRNA *prop, int index, int value, eUI_Item_Flag flag, std::optional< StringRef > name_opt, int icon, std::optional< StringRef > placeholder=std::nullopt)
void separator(float factor=1.0f, LayoutSeparatorType type=LayoutSeparatorType::Auto)
void popover(const bContext *C, PanelType *pt, std::optional< StringRef > name_opt, int icon)
const wmNotifier * notifier
#define WM_msg_subscribe_rna_prop(mbus, id_, data_, type_, prop_, value)