UI: Asset Shelf (Experimental Feature) #104831
|
@ -8274,7 +8274,7 @@ class VIEW3D_AST_sculpt_brushes(bpy.types.AssetShelf):
|
|||
return bool(context.object and context.object.mode == 'SCULPT')
|
||||
|
||||
@classmethod
|
||||
def asset_poll__(cls, asset):
|
||||
def asset_poll_temp_api(cls, asset):
|
||||
return asset.file_data.id_type == 'BRUSH'
|
||||
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ class MyAssetShelf(bpy.types.AssetShelf):
|
|||
return bool(context.object and context.object.mode == 'OBJECT')
|
||||
|
||||
@classmethod
|
||||
def asset_poll__(cls, asset):
|
||||
def asset_poll_temp_api(cls, asset):
|
||||
return asset.file_data.id_type in {'MATERIAL', 'OBJECT'}
|
||||
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@ namespace blender::ed::asset::shelf {
|
|||
|
||||
void send_redraw_notifier(const bContext &C)
|
||||
{
|
||||
WM_event_add_notifier(&C, NC_SPACE | ND_SPACE_ASSET_SHELF, nullptr);
|
||||
WM_event_add_notifier(&C, NC_SPACE | ND_REGIONS_ASSET_SHELF, nullptr);
|
||||
}
|
||||
|
||||
} // namespace blender::ed::asset::shelf
|
||||
|
@ -206,7 +206,7 @@ static void asset_shelf_region_listen(const wmRegionListenerParams *params)
|
|||
|
||||
switch (wmn->category) {
|
||||
case NC_SPACE:
|
||||
if (wmn->data == ND_SPACE_ASSET_SHELF) {
|
||||
if (wmn->data == ND_REGIONS_ASSET_SHELF) {
|
||||
ED_region_tag_redraw(region);
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -1815,11 +1815,11 @@ struct PointerRNA *UI_but_extra_operator_icon_opptr_get(struct uiButExtraOpIcon
|
|||
|
||||
/**
|
||||
* Get the scaled size for a preview button (typically #UI_BTyPE_PREVIEW_TILE) based on \a
|
||||
* unscaled_size plus padding.
|
||||
* size_px plus padding.
|
||||
*/
|
||||
int UI_preview_tile_size_x(const int unscaled_size CPP_ARG_DEFAULT(96));
|
||||
int UI_preview_tile_size_y(const int unscaled_size CPP_ARG_DEFAULT(96));
|
||||
int UI_preview_tile_size_y_no_label(const int unscaled_size CPP_ARG_DEFAULT(96));
|
||||
int UI_preview_tile_size_x(const int size_px CPP_ARG_DEFAULT(96));
|
||||
int UI_preview_tile_size_y(const int size_px CPP_ARG_DEFAULT(96));
|
||||
int UI_preview_tile_size_y_no_label(const int size_px CPP_ARG_DEFAULT(96));
|
||||
|
||||
/* Autocomplete
|
||||
*
|
||||
|
|
|
@ -5013,26 +5013,26 @@ int UI_autocomplete_end(AutoComplete *autocpl, char *autoname)
|
|||
|
||||
#define PREVIEW_TILE_PAD (0.15f * UI_UNIT_X)
|
||||
|
||||
int UI_preview_tile_size_x(const int unscaled_size)
|
||||
int UI_preview_tile_size_x(const int size_px)
|
||||
{
|
||||
const float pad = PREVIEW_TILE_PAD;
|
||||
return round_fl_to_int((unscaled_size / 20.0f) * UI_UNIT_X + 2.0f * pad);
|
||||
return round_fl_to_int((size_px / 20.0f) * UI_UNIT_X + 2.0f * pad);
|
||||
}
|
||||
|
||||
int UI_preview_tile_size_y(const int unscaled_size)
|
||||
int UI_preview_tile_size_y(const int size_px)
|
||||
{
|
||||
const uiStyle *style = UI_style_get();
|
||||
const float font_height = style->widget.points * UI_SCALE_FAC;
|
||||
/* Add some extra padding to make things less tight vertically. */
|
||||
const float pad = PREVIEW_TILE_PAD;
|
||||
|
||||
return round_fl_to_int(UI_preview_tile_size_y_no_label(unscaled_size) + font_height + pad);
|
||||
return round_fl_to_int(UI_preview_tile_size_y_no_label(size_px) + font_height + pad);
|
||||
}
|
||||
|
||||
int UI_preview_tile_size_y_no_label(const int unscaled_size)
|
||||
int UI_preview_tile_size_y_no_label(const int size_px)
|
||||
{
|
||||
const float pad = PREVIEW_TILE_PAD;
|
||||
return round_fl_to_int((unscaled_size / 20.0f) * UI_UNIT_Y + 2.0f * pad);
|
||||
return round_fl_to_int((size_px / 20.0f) * UI_UNIT_Y + 2.0f * pad);
|
||||
}
|
||||
|
||||
#undef PREVIEW_TILE_PAD
|
||||
|
|
|
@ -1082,11 +1082,11 @@ static StructRNA *rna_Menu_refine(PointerRNA *mtr)
|
|||
|
||||
static bool asset_shelf_asset_poll(const AssetShelfType *shelf_type, const AssetHandle *asset)
|
||||
{
|
||||
extern FunctionRNA rna_AssetShelf_asset_poll___func;
|
||||
extern FunctionRNA rna_AssetShelf_asset_poll_temp_api_func;
|
||||
|
||||
PointerRNA ptr;
|
||||
RNA_pointer_create(nullptr, shelf_type->rna_ext.srna, nullptr, &ptr); /* dummy */
|
||||
FunctionRNA *func = &rna_AssetShelf_asset_poll___func;
|
||||
FunctionRNA *func = &rna_AssetShelf_asset_poll_temp_api_func;
|
||||
|
||||
ParameterList list;
|
||||
RNA_parameter_list_create(&list, &ptr, func);
|
||||
|
@ -1206,6 +1206,7 @@ static StructRNA *rna_AssetShelf_register(Main *bmain,
|
|||
|
||||
SpaceType *space_type = BKE_spacetype_from_id(dummy_shelf_type.space_type);
|
||||
if (!space_type) {
|
||||
JulianEisel marked this conversation as resolved
|
||||
BLI_assert_unreachable();
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
@ -2130,7 +2131,7 @@ static void rna_def_asset_shelf(BlenderRNA *brna)
|
|||
parm = RNA_def_pointer(func, "context", "Context", "", "");
|
||||
RNA_def_parameter_flags(parm, PropertyFlag(0), PARM_REQUIRED);
|
||||
|
||||
func = RNA_def_function(srna, "asset_poll__", NULL);
|
||||
func = RNA_def_function(srna, "asset_poll_temp_api", NULL);
|
||||
RNA_def_function_ui_description(
|
||||
func,
|
||||
"TEMPORARY DESIGN; Expect compatibility breakage. Determine if an asset should be visible "
|
||||
|
@ -2158,19 +2159,19 @@ static void rna_def_asset_shelf(BlenderRNA *brna)
|
|||
prop,
|
||||
"Show Names",
|
||||
"Show the asset name together with the preview. Otherwise only the preview will be visible");
|
||||
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_ASSET_SHELF, NULL);
|
||||
RNA_def_property_update(prop, NC_SPACE | ND_REGIONS_ASSET_SHELF, NULL);
|
||||
|
||||
prop = RNA_def_property(srna, "preview_size", PROP_INT, PROP_UNSIGNED);
|
||||
RNA_def_property_int_sdna(prop, nullptr, "settings.preview_size");
|
||||
RNA_def_property_range(prop, 32, 256);
|
||||
RNA_def_property_ui_text(prop, "Preview Size", "Size of the asset preview thumbnails in pixels");
|
||||
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_ASSET_SHELF, NULL);
|
||||
RNA_def_property_update(prop, NC_SPACE | ND_REGIONS_ASSET_SHELF, NULL);
|
||||
|
||||
prop = RNA_def_property(srna, "search_filter", PROP_STRING, PROP_NONE);
|
||||
RNA_def_property_string_sdna(prop, NULL, "settings.search_string");
|
||||
RNA_def_property_ui_text(prop, "Display Filter", "Filter assets by name");
|
||||
RNA_def_property_flag(prop, PROP_TEXTEDIT_UPDATE);
|
||||
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_ASSET_SHELF, NULL);
|
||||
RNA_def_property_update(prop, NC_SPACE | ND_REGIONS_ASSET_SHELF, NULL);
|
||||
}
|
||||
|
||||
void RNA_def_ui(BlenderRNA *brna)
|
||||
|
|
|
@ -496,7 +496,7 @@ typedef struct wmNotifier {
|
|||
#define ND_SPACE_FILE_PREVIEW (21 << 16)
|
||||
#define ND_SPACE_SPREADSHEET (22 << 16)
|
||||
/* Not a space itself, but a part of another space. */
|
||||
#define ND_SPACE_ASSET_SHELF (23 << 16)
|
||||
#define ND_REGIONS_ASSET_SHELF (23 << 16)
|
||||
JulianEisel marked this conversation as resolved
Outdated
Brecht Van Lommel
commented
Then call it Then call it `ND_REGION_ASSET_SHELF` instead, if it's not a space?
Julian Eisel
commented
No strong opinion, see above regarding the asset shelf not being a single region. Maybe No strong opinion, see above regarding the asset shelf not being a single region. Maybe `ND_REGIONS_ASSET_SHELF` (plural).
Brecht Van Lommel
commented
That sounds fine. That sounds fine.
|
||||
|
||||
/* NC_ASSET */
|
||||
/* Denotes that the AssetList is done reading some previews. NOT that the preview generation of
|
||||
|
|
Loading…
Reference in New Issue
Shouldn't this report an error?
EDIT or be impossible (that block could use
BLI_assert_unreachable()
).