Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans Goudey <h.goudey@me.com>2021-07-15 22:24:02 +0300
committerHans Goudey <h.goudey@me.com>2021-07-15 22:24:02 +0300
commitcc39200bfc21c5a1d0bb45c78bfc72b456a12938 (patch)
tree802f43376c0590333f21022c753d4e4c883d4913 /source/blender/makesrna/intern
parent36ea32a3f03164b89db12d8d1f1ce6b8ec8d25a7 (diff)
parenteccd03a826b1c1465f28f93d35ca21359a6dc4e5 (diff)
Merge branch 'master' into temp-geometry-nodes-curve-sample
Diffstat (limited to 'source/blender/makesrna/intern')
-rw-r--r--source/blender/makesrna/intern/rna_ID.c91
-rw-r--r--source/blender/makesrna/intern/rna_access.c4
-rw-r--r--source/blender/makesrna/intern/rna_access_compare_override.c2
-rw-r--r--source/blender/makesrna/intern/rna_asset.c177
-rw-r--r--source/blender/makesrna/intern/rna_cloth.c1
-rw-r--r--source/blender/makesrna/intern/rna_context.c27
-rw-r--r--source/blender/makesrna/intern/rna_define.c2
-rw-r--r--source/blender/makesrna/intern/rna_internal.h11
-rw-r--r--source/blender/makesrna/intern/rna_mask.c2
-rw-r--r--source/blender/makesrna/intern/rna_nodetree.c4
-rw-r--r--source/blender/makesrna/intern/rna_object_force.c5
-rw-r--r--source/blender/makesrna/intern/rna_pose_api.c2
-rw-r--r--source/blender/makesrna/intern/rna_scene.c1
-rw-r--r--source/blender/makesrna/intern/rna_space.c277
-rw-r--r--source/blender/makesrna/intern/rna_ui.c39
-rw-r--r--source/blender/makesrna/intern/rna_ui_api.c182
-rw-r--r--source/blender/makesrna/intern/rna_wm.c4
-rw-r--r--source/blender/makesrna/intern/rna_wm_gizmo.c6
-rw-r--r--source/blender/makesrna/intern/rna_workspace.c20
19 files changed, 680 insertions, 177 deletions
diff --git a/source/blender/makesrna/intern/rna_ID.c b/source/blender/makesrna/intern/rna_ID.c
index 38b00afdc8f..6df03d19538 100644
--- a/source/blender/makesrna/intern/rna_ID.c
+++ b/source/blender/makesrna/intern/rna_ID.c
@@ -126,6 +126,97 @@ static const EnumPropertyItem rna_enum_override_library_property_operation_items
{0, NULL, 0, NULL, NULL},
};
+/**
+ * \note Uses #IDFilterEnumPropertyItem, not EnumPropertyItem, to support 64 bit items.
+ */
+const struct IDFilterEnumPropertyItem rna_enum_id_type_filter_items[] = {
+ /* Datablocks */
+ {FILTER_ID_AC, "filter_action", ICON_ANIM_DATA, "Actions", "Show Action data-blocks"},
+ {FILTER_ID_AR,
+ "filter_armature",
+ ICON_ARMATURE_DATA,
+ "Armatures",
+ "Show Armature data-blocks"},
+ {FILTER_ID_BR, "filter_brush", ICON_BRUSH_DATA, "Brushes", "Show Brushes data-blocks"},
+ {FILTER_ID_CA, "filter_camera", ICON_CAMERA_DATA, "Cameras", "Show Camera data-blocks"},
+ {FILTER_ID_CF, "filter_cachefile", ICON_FILE, "Cache Files", "Show Cache File data-blocks"},
+ {FILTER_ID_CU, "filter_curve", ICON_CURVE_DATA, "Curves", "Show Curve data-blocks"},
+ {FILTER_ID_GD,
+ "filter_grease_pencil",
+ ICON_GREASEPENCIL,
+ "Grease Pencil",
+ "Show Grease pencil data-blocks"},
+ {FILTER_ID_GR,
+ "filter_group",
+ ICON_OUTLINER_COLLECTION,
+ "Collections",
+ "Show Collection data-blocks"},
+ {FILTER_ID_HA, "filter_hair", ICON_HAIR_DATA, "Hairs", "Show/hide Hair data-blocks"},
+ {FILTER_ID_IM, "filter_image", ICON_IMAGE_DATA, "Images", "Show Image data-blocks"},
+ {FILTER_ID_LA, "filter_light", ICON_LIGHT_DATA, "Lights", "Show Light data-blocks"},
+ {FILTER_ID_LP,
+ "filter_light_probe",
+ ICON_OUTLINER_DATA_LIGHTPROBE,
+ "Light Probes",
+ "Show Light Probe data-blocks"},
+ {FILTER_ID_LS,
+ "filter_linestyle",
+ ICON_LINE_DATA,
+ "Freestyle Linestyles",
+ "Show Freestyle's Line Style data-blocks"},
+ {FILTER_ID_LT, "filter_lattice", ICON_LATTICE_DATA, "Lattices", "Show Lattice data-blocks"},
+ {FILTER_ID_MA,
+ "filter_material",
+ ICON_MATERIAL_DATA,
+ "Materials",
+ "Show Material data-blocks"},
+ {FILTER_ID_MB, "filter_metaball", ICON_META_DATA, "Metaballs", "Show Metaball data-blocks"},
+ {FILTER_ID_MC,
+ "filter_movie_clip",
+ ICON_TRACKER_DATA,
+ "Movie Clips",
+ "Show Movie Clip data-blocks"},
+ {FILTER_ID_ME, "filter_mesh", ICON_MESH_DATA, "Meshes", "Show Mesh data-blocks"},
+ {FILTER_ID_MSK, "filter_mask", ICON_MOD_MASK, "Masks", "Show Mask data-blocks"},
+ {FILTER_ID_NT, "filter_node_tree", ICON_NODETREE, "Node Trees", "Show Node Tree data-blocks"},
+ {FILTER_ID_OB, "filter_object", ICON_OBJECT_DATA, "Objects", "Show Object data-blocks"},
+ {FILTER_ID_PA,
+ "filter_particle_settings",
+ ICON_PARTICLE_DATA,
+ "Particles Settings",
+ "Show Particle Settings data-blocks"},
+ {FILTER_ID_PAL, "filter_palette", ICON_COLOR, "Palettes", "Show Palette data-blocks"},
+ {FILTER_ID_PC,
+ "filter_paint_curve",
+ ICON_CURVE_BEZCURVE,
+ "Paint Curves",
+ "Show Paint Curve data-blocks"},
+ {FILTER_ID_PT,
+ "filter_pointcloud",
+ ICON_POINTCLOUD_DATA,
+ "Point Clouds",
+ "Show/hide Point Cloud data-blocks"},
+ {FILTER_ID_SCE, "filter_scene", ICON_SCENE_DATA, "Scenes", "Show Scene data-blocks"},
+ {FILTER_ID_SIM,
+ "filter_simulation",
+ ICON_PHYSICS,
+ "Simulations",
+ "Show Simulation data-blocks"}, /* TODO: Use correct icon. */
+ {FILTER_ID_SPK, "filter_speaker", ICON_SPEAKER, "Speakers", "Show Speaker data-blocks"},
+ {FILTER_ID_SO, "filter_sound", ICON_SOUND, "Sounds", "Show Sound data-blocks"},
+ {FILTER_ID_TE, "filter_texture", ICON_TEXTURE_DATA, "Textures", "Show Texture data-blocks"},
+ {FILTER_ID_TXT, "filter_text", ICON_TEXT, "Texts", "Show Text data-blocks"},
+ {FILTER_ID_VF, "filter_font", ICON_FONT_DATA, "Fonts", "Show Font data-blocks"},
+ {FILTER_ID_VO, "filter_volume", ICON_VOLUME_DATA, "Volumes", "Show/hide Volume data-blocks"},
+ {FILTER_ID_WO, "filter_world", ICON_WORLD_DATA, "Worlds", "Show World data-blocks"},
+ {FILTER_ID_WS,
+ "filter_work_space",
+ ICON_WORKSPACE,
+ "Workspaces",
+ "Show workspace data-blocks"},
+ {0, NULL, 0, NULL, NULL},
+};
+
#ifdef RNA_RUNTIME
# include "DNA_anim_types.h"
diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c
index eb347987f87..0285ef44e17 100644
--- a/source/blender/makesrna/intern/rna_access.c
+++ b/source/blender/makesrna/intern/rna_access.c
@@ -5864,12 +5864,12 @@ ID *RNA_find_real_ID_and_path(Main *bmain, ID *id, const char **r_path)
*r_path = "collection";
break;
default:
- BLI_assert(!"Missing handling of embedded id type.");
+ BLI_assert_msg(0, "Missing handling of embedded id type.");
}
}
if (id_type->owner_get == NULL) {
- BLI_assert(!"Missing handling of embedded id type.");
+ BLI_assert_msg(0, "Missing handling of embedded id type.");
return id;
}
return id_type->owner_get(bmain, id);
diff --git a/source/blender/makesrna/intern/rna_access_compare_override.c b/source/blender/makesrna/intern/rna_access_compare_override.c
index c4d35140423..3912c873fd0 100644
--- a/source/blender/makesrna/intern/rna_access_compare_override.c
+++ b/source/blender/makesrna/intern/rna_access_compare_override.c
@@ -867,7 +867,7 @@ bool RNA_struct_override_matches(Main *bmain,
else {
/* Too noisy for now, this triggers on runtime props like transform matrices etc. */
#if 0
- BLI_assert(!"We have differences between reference and "
+ BLI_assert_msg(0, "We have differences between reference and "
"overriding data on non-editable property.");
#endif
matching = false;
diff --git a/source/blender/makesrna/intern/rna_asset.c b/source/blender/makesrna/intern/rna_asset.c
index 55f680c736d..497f4f37ea3 100644
--- a/source/blender/makesrna/intern/rna_asset.c
+++ b/source/blender/makesrna/intern/rna_asset.c
@@ -25,6 +25,7 @@
#include "DNA_asset_types.h"
#include "DNA_defs.h"
+#include "DNA_space_types.h"
#include "rna_internal.h"
@@ -35,6 +36,8 @@
# include "BLI_listbase.h"
+# include "ED_asset.h"
+
# include "RNA_access.h"
static AssetTag *rna_AssetMetaData_tag_new(AssetMetaData *asset_data,
@@ -123,6 +126,105 @@ static void rna_AssetMetaData_active_tag_range(
*max = *softmax = MAX2(asset_data->tot_tags - 1, 0);
}
+static PointerRNA rna_AssetHandle_file_data_get(PointerRNA *ptr)
+{
+ AssetHandle *asset_handle = ptr->data;
+ return rna_pointer_inherit_refine(ptr, &RNA_FileSelectEntry, asset_handle->file_data);
+}
+
+static void rna_AssetHandle_get_full_library_path(
+ // AssetHandle *asset,
+ bContext *C,
+ FileDirEntry *asset_file,
+ AssetLibraryReference *library,
+ char r_result[FILE_MAX_LIBEXTRA])
+{
+ AssetHandle asset = {.file_data = asset_file};
+ ED_asset_handle_get_full_library_path(C, library, &asset, r_result);
+}
+
+static PointerRNA rna_AssetHandle_local_id_get(PointerRNA *ptr)
+{
+ const AssetHandle *asset = ptr->data;
+ ID *id = ED_assetlist_asset_local_id_get(asset);
+ return rna_pointer_inherit_refine(ptr, &RNA_ID, id);
+}
+
+static void rna_AssetHandle_file_data_set(PointerRNA *ptr,
+ PointerRNA value,
+ struct ReportList *UNUSED(reports))
+{
+ AssetHandle *asset_handle = ptr->data;
+ asset_handle->file_data = value.data;
+}
+
+int rna_asset_library_reference_get(const AssetLibraryReference *library)
+{
+ return ED_asset_library_reference_to_enum_value(library);
+}
+
+void rna_asset_library_reference_set(AssetLibraryReference *library, int value)
+{
+ *library = ED_asset_library_reference_from_enum_value(value);
+}
+
+const EnumPropertyItem *rna_asset_library_reference_itemf(bContext *UNUSED(C),
+ PointerRNA *UNUSED(ptr),
+ PropertyRNA *UNUSED(prop),
+ bool *r_free)
+{
+ const EnumPropertyItem predefined_items[] = {
+ /* For the future. */
+ // {ASSET_REPO_BUNDLED, "BUNDLED", 0, "Bundled", "Show the default user assets"},
+ {ASSET_LIBRARY_LOCAL,
+ "LOCAL",
+ ICON_BLENDER,
+ "Current File",
+ "Show the assets currently available in this Blender session"},
+ {0, NULL, 0, NULL, NULL},
+ };
+
+ EnumPropertyItem *item = NULL;
+ int totitem = 0;
+
+ /* Add separator if needed. */
+ if (!BLI_listbase_is_empty(&U.asset_libraries)) {
+ const EnumPropertyItem sepr = {0, "", 0, "Custom", NULL};
+ RNA_enum_item_add(&item, &totitem, &sepr);
+ }
+
+ int i = 0;
+ for (bUserAssetLibrary *user_library = U.asset_libraries.first; user_library;
+ user_library = user_library->next, i++) {
+ /* Note that the path itself isn't checked for validity here. If an invalid library path is
+ * used, the Asset Browser can give a nice hint on what's wrong. */
+ const bool is_valid = (user_library->name[0] && user_library->path[0]);
+ if (!is_valid) {
+ continue;
+ }
+
+ /* Use library path as description, it's a nice hint for users. */
+ EnumPropertyItem tmp = {ASSET_LIBRARY_CUSTOM + i,
+ user_library->name,
+ ICON_NONE,
+ user_library->name,
+ user_library->path};
+ RNA_enum_item_add(&item, &totitem, &tmp);
+ }
+
+ if (totitem) {
+ const EnumPropertyItem sepr = {0, "", 0, "Built-in", NULL};
+ RNA_enum_item_add(&item, &totitem, &sepr);
+ }
+
+ /* Add predefined items. */
+ RNA_enum_items_add(&item, &totitem, predefined_items);
+
+ RNA_enum_item_end(&item, &totitem);
+ *r_free = true;
+ return item;
+}
+
#else
static void rna_def_asset_tag(BlenderRNA *brna)
@@ -209,12 +311,87 @@ static void rna_def_asset_data(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Active Tag", "Index of the tag set for editing");
}
+static void rna_def_asset_handle_api(StructRNA *srna)
+{
+ FunctionRNA *func;
+ PropertyRNA *parm;
+
+ func = RNA_def_function(srna, "get_full_library_path", "rna_AssetHandle_get_full_library_path");
+ RNA_def_function_flag(func, FUNC_USE_CONTEXT);
+ /* TODO temporarily static function, for until .py can receive the asset handle from context
+ * properly. `asset_file_handle` should go away too then. */
+ RNA_def_function_flag(func, FUNC_NO_SELF);
+ parm = RNA_def_pointer(func, "asset_file_handle", "FileSelectEntry", "", "");
+ RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
+ parm = RNA_def_pointer(func,
+ "asset_library",
+ "AssetLibraryReference",
+ "",
+ "The asset library containing the given asset, only valid if the asset "
+ "library is external (i.e. not the \"Current File\" one");
+ RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
+ parm = RNA_def_string(func, "result", NULL, FILE_MAX_LIBEXTRA, "result", "");
+ RNA_def_parameter_flags(parm, PROP_THICK_WRAP, 0);
+ RNA_def_function_output(func, parm);
+}
+
+static void rna_def_asset_handle(BlenderRNA *brna)
+{
+ StructRNA *srna;
+ PropertyRNA *prop;
+
+ srna = RNA_def_struct(brna, "AssetHandle", "PropertyGroup");
+ RNA_def_struct_ui_text(srna, "Asset Handle", "Reference to some asset");
+
+ /* TODO why is this editable? There probably shouldn't be a setter. */
+ prop = RNA_def_property(srna, "file_data", PROP_POINTER, PROP_NONE);
+ RNA_def_property_flag(prop, PROP_EDITABLE);
+ RNA_def_property_struct_type(prop, "FileSelectEntry");
+ RNA_def_property_pointer_funcs(
+ prop, "rna_AssetHandle_file_data_get", "rna_AssetHandle_file_data_set", NULL, NULL);
+ RNA_def_property_ui_text(prop, "File Entry", "File data used to refer to the asset");
+
+ prop = RNA_def_property(srna, "local_id", PROP_POINTER, PROP_NONE);
+ RNA_def_property_struct_type(prop, "ID");
+ RNA_def_property_pointer_funcs(prop, "rna_AssetHandle_local_id_get", NULL, NULL, NULL);
+ RNA_def_property_ui_text(prop,
+ "",
+ "The local data-block this asset represents; only valid if that is a "
+ "data-block in this file");
+ RNA_def_property_flag(prop, PROP_HIDDEN);
+
+ rna_def_asset_handle_api(srna);
+}
+
+static void rna_def_asset_library_reference(BlenderRNA *brna)
+{
+ StructRNA *srna = RNA_def_struct(brna, "AssetLibraryReference", NULL);
+ RNA_def_struct_ui_text(
+ srna, "Asset Library Reference", "Identifier to refere to the asset library");
+}
+
+/**
+ * \note the UI text and updating has to be set by the caller.
+ */
+PropertyRNA *rna_def_asset_library_reference_common(struct StructRNA *srna,
+ const char *get,
+ const char *set)
+{
+ PropertyRNA *prop = RNA_def_property(srna, "active_asset_library", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_items(prop, DummyRNA_NULL_items);
+ RNA_def_property_enum_funcs(prop, get, set, "rna_asset_library_reference_itemf");
+
+ return prop;
+}
+
void RNA_def_asset(BlenderRNA *brna)
{
RNA_define_animate_sdna(false);
rna_def_asset_tag(brna);
rna_def_asset_data(brna);
+ rna_def_asset_library_reference(brna);
+ rna_def_asset_handle(brna);
RNA_define_animate_sdna(true);
}
diff --git a/source/blender/makesrna/intern/rna_cloth.c b/source/blender/makesrna/intern/rna_cloth.c
index 9e57368f8f9..2bc00dd5af5 100644
--- a/source/blender/makesrna/intern/rna_cloth.c
+++ b/source/blender/makesrna/intern/rna_cloth.c
@@ -652,7 +652,6 @@ static void rna_def_cloth_sim_settings(BlenderRNA *brna)
prop = RNA_def_property(srna, "mass", PROP_FLOAT, PROP_UNIT_MASS);
RNA_def_property_range(prop, 0.0f, FLT_MAX);
RNA_def_property_ui_text(prop, "Vertex Mass", "The mass of each vertex on the cloth material");
- RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_update(prop, 0, "rna_cloth_update");
prop = RNA_def_property(srna, "vertex_group_mass", PROP_STRING, PROP_NONE);
diff --git a/source/blender/makesrna/intern/rna_context.c b/source/blender/makesrna/intern/rna_context.c
index 4079406e64b..9da08de2168 100644
--- a/source/blender/makesrna/intern/rna_context.c
+++ b/source/blender/makesrna/intern/rna_context.c
@@ -58,6 +58,8 @@ const EnumPropertyItem rna_enum_context_mode_items[] = {
#ifdef RNA_RUNTIME
+# include "DNA_asset_types.h"
+
# ifdef WITH_PYTHON
# include "BPY_extern.h"
# endif
@@ -134,6 +136,20 @@ static PointerRNA rna_Context_gizmo_group_get(PointerRNA *ptr)
return newptr;
}
+static PointerRNA rna_Context_asset_file_handle_get(PointerRNA *ptr)
+{
+ bContext *C = (bContext *)ptr->data;
+ bool is_handle_valid;
+ AssetHandle asset_handle = CTX_wm_asset_handle(C, &is_handle_valid);
+ if (!is_handle_valid) {
+ return PointerRNA_NULL;
+ }
+
+ PointerRNA newptr;
+ RNA_pointer_create(NULL, &RNA_FileSelectEntry, asset_handle.file_data, &newptr);
+ return newptr;
+}
+
static PointerRNA rna_Context_main_get(PointerRNA *ptr)
{
bContext *C = (bContext *)ptr->data;
@@ -281,6 +297,17 @@ void RNA_def_context(BlenderRNA *brna)
RNA_def_property_struct_type(prop, "GizmoGroup");
RNA_def_property_pointer_funcs(prop, "rna_Context_gizmo_group_get", NULL, NULL, NULL);
+ /* TODO can't expose AssetHandle, since there is no permanent storage to it (so we can't
+ * return a pointer). Instead provide the FileDirEntry pointer it wraps. */
+ prop = RNA_def_property(srna, "asset_file_handle", PROP_POINTER, PROP_NONE);
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+ RNA_def_property_struct_type(prop, "FileSelectEntry");
+ RNA_def_property_pointer_funcs(prop, "rna_Context_asset_file_handle_get", NULL, NULL, NULL);
+ RNA_def_property_ui_text(prop,
+ "",
+ "The file of an active asset. Avoid using this, it will be replaced by "
+ "a proper AssetHandle design");
+
/* Data */
prop = RNA_def_property(srna, "blend_data", PROP_POINTER, PROP_NONE);
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
diff --git a/source/blender/makesrna/intern/rna_define.c b/source/blender/makesrna/intern/rna_define.c
index 1a0d4ebb7e6..fadce9e3c89 100644
--- a/source/blender/makesrna/intern/rna_define.c
+++ b/source/blender/makesrna/intern/rna_define.c
@@ -52,7 +52,7 @@ static CLG_LogRef LOG = {"rna.define"};
# define ASSERT_SOFT_HARD_LIMITS \
if (softmin < hardmin || softmax > hardmax) { \
CLOG_ERROR(&LOG, "error with soft/hard limits: %s.%s", CONTAINER_RNA_ID(cont), identifier); \
- BLI_assert(!"invalid soft/hard limits"); \
+ BLI_assert_msg(0, "invalid soft/hard limits"); \
} \
(void)0
#else
diff --git a/source/blender/makesrna/intern/rna_internal.h b/source/blender/makesrna/intern/rna_internal.h
index f15368bcc77..9dc08430307 100644
--- a/source/blender/makesrna/intern/rna_internal.h
+++ b/source/blender/makesrna/intern/rna_internal.h
@@ -30,6 +30,7 @@
#define RNA_MAGIC ((int)~0)
+struct AssetLibraryReference;
struct FreestyleSettings;
struct ID;
struct IDOverrideLibrary;
@@ -266,6 +267,16 @@ void rna_def_mtex_common(struct BlenderRNA *brna,
void rna_def_texpaint_slots(struct BlenderRNA *brna, struct StructRNA *srna);
void rna_def_view_layer_common(struct BlenderRNA *brna, struct StructRNA *srna, const bool scene);
+PropertyRNA *rna_def_asset_library_reference_common(struct StructRNA *srna,
+ const char *get,
+ const char *set);
+int rna_asset_library_reference_get(const struct AssetLibraryReference *library);
+void rna_asset_library_reference_set(struct AssetLibraryReference *library, int value);
+const EnumPropertyItem *rna_asset_library_reference_itemf(struct bContext *C,
+ struct PointerRNA *ptr,
+ struct PropertyRNA *prop,
+ bool *r_free);
+
void rna_def_actionbone_group_common(struct StructRNA *srna,
int update_flag,
const char *update_cb);
diff --git a/source/blender/makesrna/intern/rna_mask.c b/source/blender/makesrna/intern/rna_mask.c
index 896e253049b..8c7d9698a67 100644
--- a/source/blender/makesrna/intern/rna_mask.c
+++ b/source/blender/makesrna/intern/rna_mask.c
@@ -505,7 +505,7 @@ static void rna_MaskSpline_points_add(ID *id, MaskSpline *spline, int count)
if (!layer) {
/* Shall not happen actually */
- BLI_assert(!"No layer found for the spline");
+ BLI_assert_msg(0, "No layer found for the spline");
return;
}
diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c
index 582bc40a142..198ee107231 100644
--- a/source/blender/makesrna/intern/rna_nodetree.c
+++ b/source/blender/makesrna/intern/rna_nodetree.c
@@ -4388,7 +4388,7 @@ static int point_density_particle_color_source_from_shader(
case SHD_POINTDENSITY_COLOR_PARTVEL:
return TEX_PD_COLOR_PARTVEL;
default:
- BLI_assert(!"Unknown color source");
+ BLI_assert_msg(0, "Unknown color source");
return TEX_PD_COLOR_CONSTANT;
}
}
@@ -4404,7 +4404,7 @@ static int point_density_vertex_color_source_from_shader(
case SHD_POINTDENSITY_COLOR_VERTNOR:
return TEX_PD_COLOR_VERTNOR;
default:
- BLI_assert(!"Unknown color source");
+ BLI_assert_msg(0, "Unknown color source");
return TEX_PD_COLOR_CONSTANT;
}
}
diff --git a/source/blender/makesrna/intern/rna_object_force.c b/source/blender/makesrna/intern/rna_object_force.c
index f8a98eb1753..98d59bf3a1a 100644
--- a/source/blender/makesrna/intern/rna_object_force.c
+++ b/source/blender/makesrna/intern/rna_object_force.c
@@ -133,8 +133,9 @@ static bool rna_Cache_get_valid_owner_ID(PointerRNA *ptr, Object **ob, Scene **s
*scene = (Scene *)ptr->owner_id;
break;
default:
- BLI_assert(!"Trying to get PTCacheID from an invalid ID type "
- "(Only scenes and objects are supported).");
+ BLI_assert_msg(0,
+ "Trying to get PTCacheID from an invalid ID type "
+ "(Only scenes and objects are supported).");
break;
}
diff --git a/source/blender/makesrna/intern/rna_pose_api.c b/source/blender/makesrna/intern/rna_pose_api.c
index 0d35365c2d8..1e1667f0ae8 100644
--- a/source/blender/makesrna/intern/rna_pose_api.c
+++ b/source/blender/makesrna/intern/rna_pose_api.c
@@ -117,7 +117,7 @@ static void rna_Pose_apply_pose_from_action(ID *pose_owner,
Object *pose_owner_ob = (Object *)pose_owner;
AnimationEvalContext anim_eval_context = {CTX_data_depsgraph_pointer(C), evaluation_time};
- BKE_pose_apply_action(pose_owner_ob, action, &anim_eval_context);
+ BKE_pose_apply_action_selected_bones(pose_owner_ob, action, &anim_eval_context);
/* Do NOT tag with ID_RECALC_ANIMATION, as that would overwrite the just-applied pose. */
DEG_id_tag_update(pose_owner, ID_RECALC_GEOMETRY);
diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c
index 0a91d5f01bc..5c9c7b50339 100644
--- a/source/blender/makesrna/intern/rna_scene.c
+++ b/source/blender/makesrna/intern/rna_scene.c
@@ -3116,6 +3116,7 @@ static void rna_def_tool_settings(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Use Snapping", "Snap to strip edges or current frame");
RNA_def_property_ui_icon(prop, ICON_SNAP_OFF, 1);
RNA_def_property_boolean_default(prop, true);
+ RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); /* Publish message-bus. */
prop = RNA_def_property(srna, "snap_elements", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_bitflag_sdna(prop, NULL, "snap_mode");
diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c
index 7366934695e..0019f315bbe 100644
--- a/source/blender/makesrna/intern/rna_space.c
+++ b/source/blender/makesrna/intern/rna_space.c
@@ -509,6 +509,7 @@ static const EnumPropertyItem rna_enum_curve_display_handle_items[] = {
#ifdef RNA_RUNTIME
# include "DNA_anim_types.h"
+# include "DNA_asset_types.h"
# include "DNA_scene_types.h"
# include "DNA_screen_types.h"
# include "DNA_userdef_types.h"
@@ -2561,6 +2562,8 @@ static PointerRNA rna_FileSelectParams_filter_id_get(PointerRNA *ptr)
return rna_pointer_inherit_refine(ptr, &RNA_FileSelectIDFilter, ptr->data);
}
+/* TODO use rna_def_asset_library_reference_common() */
+
static int rna_FileAssetSelectParams_asset_library_get(PointerRNA *ptr)
{
FileAssetSelectParams *params = ptr->data;
@@ -2568,7 +2571,7 @@ static int rna_FileAssetSelectParams_asset_library_get(PointerRNA *ptr)
BLI_assert(ptr->type == &RNA_FileAssetSelectParams);
/* Simple case: Predefined repo, just set the value. */
- if (params->asset_library.type < FILE_ASSET_LIBRARY_CUSTOM) {
+ if (params->asset_library.type < ASSET_LIBRARY_CUSTOM) {
return params->asset_library.type;
}
@@ -2577,11 +2580,11 @@ static int rna_FileAssetSelectParams_asset_library_get(PointerRNA *ptr)
const bUserAssetLibrary *user_library = BKE_preferences_asset_library_find_from_index(
&U, params->asset_library.custom_library_index);
if (user_library) {
- return FILE_ASSET_LIBRARY_CUSTOM + params->asset_library.custom_library_index;
+ return ASSET_LIBRARY_CUSTOM + params->asset_library.custom_library_index;
}
BLI_assert(0);
- return FILE_ASSET_LIBRARY_LOCAL;
+ return ASSET_LIBRARY_LOCAL;
}
static void rna_FileAssetSelectParams_asset_library_set(PointerRNA *ptr, int value)
@@ -2589,26 +2592,26 @@ static void rna_FileAssetSelectParams_asset_library_set(PointerRNA *ptr, int val
FileAssetSelectParams *params = ptr->data;
/* Simple case: Predefined repo, just set the value. */
- if (value < FILE_ASSET_LIBRARY_CUSTOM) {
+ if (value < ASSET_LIBRARY_CUSTOM) {
params->asset_library.type = value;
params->asset_library.custom_library_index = -1;
- BLI_assert(ELEM(value, FILE_ASSET_LIBRARY_LOCAL));
+ BLI_assert(ELEM(value, ASSET_LIBRARY_LOCAL));
return;
}
const bUserAssetLibrary *user_library = BKE_preferences_asset_library_find_from_index(
- &U, value - FILE_ASSET_LIBRARY_CUSTOM);
+ &U, value - ASSET_LIBRARY_CUSTOM);
/* Note that the path isn't checked for validity here. If an invalid library path is used, the
* Asset Browser can give a nice hint on what's wrong. */
const bool is_valid = (user_library->name[0] && user_library->path[0]);
if (!user_library) {
- params->asset_library.type = FILE_ASSET_LIBRARY_LOCAL;
+ params->asset_library.type = ASSET_LIBRARY_LOCAL;
params->asset_library.custom_library_index = -1;
}
else if (user_library && is_valid) {
- params->asset_library.custom_library_index = value - FILE_ASSET_LIBRARY_CUSTOM;
- params->asset_library.type = FILE_ASSET_LIBRARY_CUSTOM;
+ params->asset_library.custom_library_index = value - ASSET_LIBRARY_CUSTOM;
+ params->asset_library.type = ASSET_LIBRARY_CUSTOM;
}
}
@@ -2617,8 +2620,8 @@ static const EnumPropertyItem *rna_FileAssetSelectParams_asset_library_itemf(
{
const EnumPropertyItem predefined_items[] = {
/* For the future. */
- // {FILE_ASSET_REPO_BUNDLED, "BUNDLED", 0, "Bundled", "Show the default user assets"},
- {FILE_ASSET_LIBRARY_LOCAL,
+ // {ASSET_REPO_BUNDLED, "BUNDLED", 0, "Bundled", "Show the default user assets"},
+ {ASSET_LIBRARY_LOCAL,
"LOCAL",
ICON_BLENDER,
"Current File",
@@ -2646,7 +2649,7 @@ static const EnumPropertyItem *rna_FileAssetSelectParams_asset_library_itemf(
}
/* Use library path as description, it's a nice hint for users. */
- EnumPropertyItem tmp = {FILE_ASSET_LIBRARY_CUSTOM + i,
+ EnumPropertyItem tmp = {ASSET_LIBRARY_CUSTOM + i,
user_library->name,
ICON_NONE,
user_library->name,
@@ -2691,6 +2694,32 @@ static int rna_FileBrowser_FileSelectEntry_name_length(PointerRNA *ptr)
return (int)strlen(entry->name);
}
+static const EnumPropertyItem *rna_FileBrowser_FileSelectEntry_id_type_itemf(
+ bContext *UNUSED(C), PointerRNA *ptr, PropertyRNA *UNUSED(prop), bool *UNUSED(r_free))
+{
+ const FileDirEntry *entry = ptr->data;
+ if (entry->blentype == 0) {
+ const static EnumPropertyItem none_items[] = {
+ {0, "NONE", 0, "None", ""},
+ };
+ return none_items;
+ }
+
+ return rna_enum_id_type_items;
+}
+
+static int rna_FileBrowser_FileSelectEntry_id_type_get(PointerRNA *ptr)
+{
+ const FileDirEntry *entry = ptr->data;
+ return entry->blentype;
+}
+
+static PointerRNA rna_FileBrowser_FileSelectEntry_local_id_get(PointerRNA *ptr)
+{
+ const FileDirEntry *entry = ptr->data;
+ return rna_pointer_inherit_refine(ptr, &RNA_ID, entry->id);
+}
+
static int rna_FileBrowser_FileSelectEntry_preview_icon_id_get(PointerRNA *ptr)
{
const FileDirEntry *entry = ptr->data;
@@ -2715,7 +2744,7 @@ static StructRNA *rna_FileBrowser_params_typef(PointerRNA *ptr)
return &RNA_FileAssetSelectParams;
}
- BLI_assert(!"Could not identify file select parameters");
+ BLI_assert_msg(0, "Could not identify file select parameters");
return NULL;
}
@@ -3188,6 +3217,45 @@ static const EnumPropertyItem dt_uv_items[] = {
{0, NULL, 0, NULL, NULL},
};
+static struct IDFilterEnumPropertyItem rna_enum_space_file_id_filter_categories[] = {
+ /* Categories */
+ {FILTER_ID_SCE, "category_scene", ICON_SCENE_DATA, "Scenes", "Show scenes"},
+ {FILTER_ID_AC, "category_animation", ICON_ANIM_DATA, "Animations", "Show animation data"},
+ {FILTER_ID_OB | FILTER_ID_GR,
+ "category_object",
+ ICON_OUTLINER_COLLECTION,
+ "Objects & Collections",
+ "Show objects and collections"},
+ {FILTER_ID_AR | FILTER_ID_CU | FILTER_ID_LT | FILTER_ID_MB | FILTER_ID_ME | FILTER_ID_HA |
+ FILTER_ID_PT | FILTER_ID_VO,
+ "category_geometry",
+ ICON_NODETREE,
+ "Geometry",
+ "Show meshes, curves, lattice, armatures and metaballs data"},
+ {FILTER_ID_LS | FILTER_ID_MA | FILTER_ID_NT | FILTER_ID_TE,
+ "category_shading",
+ ICON_MATERIAL_DATA,
+ "Shading",
+ "Show materials, nodetrees, textures and Freestyle's linestyles"},
+ {FILTER_ID_IM | FILTER_ID_MC | FILTER_ID_MSK | FILTER_ID_SO,
+ "category_image",
+ ICON_IMAGE_DATA,
+ "Images & Sounds",
+ "Show images, movie clips, sounds and masks"},
+ {FILTER_ID_CA | FILTER_ID_LA | FILTER_ID_LP | FILTER_ID_SPK | FILTER_ID_WO,
+ "category_environment",
+ ICON_WORLD_DATA,
+ "Environment",
+ "Show worlds, lights, cameras and speakers"},
+ {FILTER_ID_BR | FILTER_ID_GD | FILTER_ID_PA | FILTER_ID_PAL | FILTER_ID_PC | FILTER_ID_TXT |
+ FILTER_ID_VF | FILTER_ID_CF | FILTER_ID_WS,
+ "category_misc",
+ ICON_GREASEPENCIL,
+ "Miscellaneous",
+ "Show other data types"},
+ {0, NULL, 0, NULL, NULL},
+};
+
static void rna_def_space_generic_show_region_toggles(StructRNA *srna, int region_type_mask)
{
PropertyRNA *prop;
@@ -6135,142 +6203,6 @@ static void rna_def_space_console(BlenderRNA *brna)
/* Filter for datablock types in link/append. */
static void rna_def_fileselect_idfilter(BlenderRNA *brna)
{
- struct IDFilterBoolean {
- /* 64 bit, so we can't use bitflag enum. */
- const uint64_t flag;
- const char *identifier;
- const int icon;
- const char *name;
- const char *description;
- };
-
- static const struct IDFilterBoolean booleans[] = {
- /* Datablocks */
- {FILTER_ID_AC, "filter_action", ICON_ANIM_DATA, "Actions", "Show Action data-blocks"},
- {FILTER_ID_AR,
- "filter_armature",
- ICON_ARMATURE_DATA,
- "Armatures",
- "Show Armature data-blocks"},
- {FILTER_ID_BR, "filter_brush", ICON_BRUSH_DATA, "Brushes", "Show Brushes data-blocks"},
- {FILTER_ID_CA, "filter_camera", ICON_CAMERA_DATA, "Cameras", "Show Camera data-blocks"},
- {FILTER_ID_CF, "filter_cachefile", ICON_FILE, "Cache Files", "Show Cache File data-blocks"},
- {FILTER_ID_CU, "filter_curve", ICON_CURVE_DATA, "Curves", "Show Curve data-blocks"},
- {FILTER_ID_GD,
- "filter_grease_pencil",
- ICON_GREASEPENCIL,
- "Grease Pencil",
- "Show Grease pencil data-blocks"},
- {FILTER_ID_GR,
- "filter_group",
- ICON_OUTLINER_COLLECTION,
- "Collections",
- "Show Collection data-blocks"},
- {FILTER_ID_HA, "filter_hair", ICON_HAIR_DATA, "Hairs", "Show/hide Hair data-blocks"},
- {FILTER_ID_IM, "filter_image", ICON_IMAGE_DATA, "Images", "Show Image data-blocks"},
- {FILTER_ID_LA, "filter_light", ICON_LIGHT_DATA, "Lights", "Show Light data-blocks"},
- {FILTER_ID_LP,
- "filter_light_probe",
- ICON_OUTLINER_DATA_LIGHTPROBE,
- "Light Probes",
- "Show Light Probe data-blocks"},
- {FILTER_ID_LS,
- "filter_linestyle",
- ICON_LINE_DATA,
- "Freestyle Linestyles",
- "Show Freestyle's Line Style data-blocks"},
- {FILTER_ID_LT, "filter_lattice", ICON_LATTICE_DATA, "Lattices", "Show Lattice data-blocks"},
- {FILTER_ID_MA,
- "filter_material",
- ICON_MATERIAL_DATA,
- "Materials",
- "Show Material data-blocks"},
- {FILTER_ID_MB, "filter_metaball", ICON_META_DATA, "Metaballs", "Show Metaball data-blocks"},
- {FILTER_ID_MC,
- "filter_movie_clip",
- ICON_TRACKER_DATA,
- "Movie Clips",
- "Show Movie Clip data-blocks"},
- {FILTER_ID_ME, "filter_mesh", ICON_MESH_DATA, "Meshes", "Show Mesh data-blocks"},
- {FILTER_ID_MSK, "filter_mask", ICON_MOD_MASK, "Masks", "Show Mask data-blocks"},
- {FILTER_ID_NT,
- "filter_node_tree",
- ICON_NODETREE,
- "Node Trees",
- "Show Node Tree data-blocks"},
- {FILTER_ID_OB, "filter_object", ICON_OBJECT_DATA, "Objects", "Show Object data-blocks"},
- {FILTER_ID_PA,
- "filter_particle_settings",
- ICON_PARTICLE_DATA,
- "Particles Settings",
- "Show Particle Settings data-blocks"},
- {FILTER_ID_PAL, "filter_palette", ICON_COLOR, "Palettes", "Show Palette data-blocks"},
- {FILTER_ID_PC,
- "filter_paint_curve",
- ICON_CURVE_BEZCURVE,
- "Paint Curves",
- "Show Paint Curve data-blocks"},
- {FILTER_ID_PT,
- "filter_pointcloud",
- ICON_POINTCLOUD_DATA,
- "Point Clouds",
- "Show/hide Point Cloud data-blocks"},
- {FILTER_ID_SCE, "filter_scene", ICON_SCENE_DATA, "Scenes", "Show Scene data-blocks"},
- {FILTER_ID_SIM,
- "filter_simulation",
- ICON_PHYSICS,
- "Simulations",
- "Show Simulation data-blocks"}, /* TODO: Use correct icon. */
- {FILTER_ID_SPK, "filter_speaker", ICON_SPEAKER, "Speakers", "Show Speaker data-blocks"},
- {FILTER_ID_SO, "filter_sound", ICON_SOUND, "Sounds", "Show Sound data-blocks"},
- {FILTER_ID_TE, "filter_texture", ICON_TEXTURE_DATA, "Textures", "Show Texture data-blocks"},
- {FILTER_ID_TXT, "filter_text", ICON_TEXT, "Texts", "Show Text data-blocks"},
- {FILTER_ID_VF, "filter_font", ICON_FONT_DATA, "Fonts", "Show Font data-blocks"},
- {FILTER_ID_VO, "filter_volume", ICON_VOLUME_DATA, "Volumes", "Show/hide Volume data-blocks"},
- {FILTER_ID_WO, "filter_world", ICON_WORLD_DATA, "Worlds", "Show World data-blocks"},
- {FILTER_ID_WS,
- "filter_work_space",
- ICON_WORKSPACE,
- "Workspaces",
- "Show workspace data-blocks"},
-
- /* Categories */
- {FILTER_ID_SCE, "category_scene", ICON_SCENE_DATA, "Scenes", "Show scenes"},
- {FILTER_ID_AC, "category_animation", ICON_ANIM_DATA, "Animations", "Show animation data"},
- {FILTER_ID_OB | FILTER_ID_GR,
- "category_object",
- ICON_OUTLINER_COLLECTION,
- "Objects & Collections",
- "Show objects and collections"},
- {FILTER_ID_AR | FILTER_ID_CU | FILTER_ID_LT | FILTER_ID_MB | FILTER_ID_ME | FILTER_ID_HA |
- FILTER_ID_PT | FILTER_ID_VO,
- "category_geometry",
- ICON_NODETREE,
- "Geometry",
- "Show meshes, curves, lattice, armatures and metaballs data"},
- {FILTER_ID_LS | FILTER_ID_MA | FILTER_ID_NT | FILTER_ID_TE,
- "category_shading",
- ICON_MATERIAL_DATA,
- "Shading",
- "Show materials, nodetrees, textures and Freestyle's linestyles"},
- {FILTER_ID_IM | FILTER_ID_MC | FILTER_ID_MSK | FILTER_ID_SO,
- "category_image",
- ICON_IMAGE_DATA,
- "Images & Sounds",
- "Show images, movie clips, sounds and masks"},
- {FILTER_ID_CA | FILTER_ID_LA | FILTER_ID_LP | FILTER_ID_SPK | FILTER_ID_WO,
- "category_environment",
- ICON_WORLD_DATA,
- "Environment",
- "Show worlds, lights, cameras and speakers"},
- {FILTER_ID_BR | FILTER_ID_GD | FILTER_ID_PA | FILTER_ID_PAL | FILTER_ID_PC | FILTER_ID_TXT |
- FILTER_ID_VF | FILTER_ID_CF | FILTER_ID_WS,
- "category_misc",
- ICON_GREASEPENCIL,
- "Miscellaneous",
- "Show other data types"},
-
- {0, NULL, 0, NULL, NULL}};
StructRNA *srna = RNA_def_struct(brna, "FileSelectIDFilter", NULL);
RNA_def_struct_sdna(srna, "FileSelectParams");
@@ -6278,12 +6210,23 @@ static void rna_def_fileselect_idfilter(BlenderRNA *brna)
RNA_def_struct_ui_text(
srna, "File Select ID Filter", "Which ID types to show/hide, when browsing a library");
- for (int i = 0; booleans[i].identifier; i++) {
- PropertyRNA *prop = RNA_def_property(srna, booleans[i].identifier, PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "filter_id", booleans[i].flag);
- RNA_def_property_ui_text(prop, booleans[i].name, booleans[i].description);
- RNA_def_property_ui_icon(prop, booleans[i].icon, 0);
- RNA_def_property_update(prop, NC_SPACE | ND_SPACE_FILE_PARAMS, NULL);
+ const struct IDFilterEnumPropertyItem *individual_ids_and_categories[] = {
+ rna_enum_id_type_filter_items,
+ rna_enum_space_file_id_filter_categories,
+ NULL,
+ };
+ for (uint i = 0; individual_ids_and_categories[i]; i++) {
+ for (int j = 0; individual_ids_and_categories[i][j].identifier; j++) {
+ PropertyRNA *prop = RNA_def_property(
+ srna, individual_ids_and_categories[i][j].identifier, PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(
+ prop, NULL, "filter_id", individual_ids_and_categories[i][j].flag);
+ RNA_def_property_ui_text(prop,
+ individual_ids_and_categories[i][j].name,
+ individual_ids_and_categories[i][j].description);
+ RNA_def_property_ui_icon(prop, individual_ids_and_categories[i][j].icon, 0);
+ RNA_def_property_update(prop, NC_SPACE | ND_SPACE_FILE_PARAMS, NULL);
+ }
}
}
@@ -6303,6 +6246,28 @@ static void rna_def_fileselect_entry(BlenderRNA *brna)
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_struct_name_property(srna, prop);
+ prop = RNA_def_property(srna, "id_type", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_items(prop, rna_enum_id_type_items);
+ RNA_def_property_enum_funcs(prop,
+ "rna_FileBrowser_FileSelectEntry_id_type_get",
+ NULL,
+ "rna_FileBrowser_FileSelectEntry_id_type_itemf");
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+ RNA_def_property_ui_text(
+ prop,
+ "Data-block Type",
+ "The type of the data-block, if the file represents one ('NONE' otherwise)");
+
+ prop = RNA_def_property(srna, "local_id", PROP_POINTER, PROP_NONE);
+ RNA_def_property_struct_type(prop, "ID");
+ RNA_def_property_pointer_funcs(
+ prop, "rna_FileBrowser_FileSelectEntry_local_id_get", NULL, NULL, NULL);
+ RNA_def_property_ui_text(prop,
+ "",
+ "The local data-block this file represents; only valid if that is a "
+ "data-block in this file");
+ RNA_def_property_flag(prop, PROP_HIDDEN);
+
prop = RNA_def_int(
srna,
"preview_icon_id",
@@ -6539,7 +6504,7 @@ static void rna_def_fileselect_asset_params(BlenderRNA *brna)
StructRNA *srna;
PropertyRNA *prop;
- /* XXX copied from rna_def_fileselect_idfilter. */
+ /* XXX copied from rna_enum_id_type_filter_items. */
static const EnumPropertyItem asset_category_items[] = {
{FILTER_ID_SCE, "SCENES", ICON_SCENE_DATA, "Scenes", "Show scenes"},
{FILTER_ID_AC, "ANIMATIONS", ICON_ANIM_DATA, "Animations", "Show animation data"},
diff --git a/source/blender/makesrna/intern/rna_ui.c b/source/blender/makesrna/intern/rna_ui.c
index d4ae5f1ecfc..a88b100435a 100644
--- a/source/blender/makesrna/intern/rna_ui.c
+++ b/source/blender/makesrna/intern/rna_ui.c
@@ -458,6 +458,27 @@ static IDProperty **rna_UIList_idprops(PointerRNA *ptr)
return &ui_list->properties;
}
+static void rna_UIList_list_id_get(PointerRNA *ptr, char *value)
+{
+ uiList *ui_list = (uiList *)ptr->data;
+ if (!ui_list->type) {
+ value[0] = '\0';
+ return;
+ }
+
+ strcpy(value, WM_uilisttype_list_id_get(ui_list->type, ui_list));
+}
+
+static int rna_UIList_list_id_length(PointerRNA *ptr)
+{
+ uiList *ui_list = (uiList *)ptr->data;
+ if (!ui_list->type) {
+ return 0;
+ }
+
+ return strlen(WM_uilisttype_list_id_get(ui_list->type, ui_list));
+}
+
static void uilist_draw_item(uiList *ui_list,
bContext *C,
uiLayout *layout,
@@ -633,7 +654,7 @@ static void uilist_filter_items(uiList *ui_list,
RNA_parameter_list_free(&list);
}
-static void rna_UIList_unregister(Main *UNUSED(bmain), StructRNA *type)
+static void rna_UIList_unregister(Main *bmain, StructRNA *type)
{
uiListType *ult = RNA_struct_blender_type_get(type);
@@ -644,7 +665,7 @@ static void rna_UIList_unregister(Main *UNUSED(bmain), StructRNA *type)
RNA_struct_free_extension(type, &ult->rna_ext);
RNA_struct_free(&BLENDER_RNA, type);
- WM_uilisttype_freelink(ult);
+ WM_uilisttype_remove_ptr(bmain, ult);
/* update while blender is running */
WM_main_add_notifier(NC_WINDOW, NULL);
@@ -1014,7 +1035,7 @@ static void rna_Panel_bl_description_set(PointerRNA *ptr, const char *value)
BLI_strncpy(str, value, RNA_DYN_DESCR_MAX); /* utf8 already ensured */
}
else {
- BLI_assert(!"setting the bl_description on a non-builtin panel");
+ BLI_assert_msg(0, "setting the bl_description on a non-builtin panel");
}
}
@@ -1026,7 +1047,7 @@ static void rna_Menu_bl_description_set(PointerRNA *ptr, const char *value)
BLI_strncpy(str, value, RNA_DYN_DESCR_MAX); /* utf8 already ensured */
}
else {
- BLI_assert(!"setting the bl_description on a non-builtin menu");
+ BLI_assert_msg(0, "setting the bl_description on a non-builtin menu");
}
}
@@ -1535,6 +1556,16 @@ static void rna_def_uilist(BlenderRNA *brna)
"script, then bl_idname = \"OBJECT_UL_vgroups\")");
/* Data */
+ /* Note that this is the "non-full" list-ID as obtained through #WM_uilisttype_list_id_get(),
+ * which differs from the (internal) `uiList.list_id`. */
+ prop = RNA_def_property(srna, "list_id", PROP_STRING, PROP_NONE);
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+ RNA_def_property_string_funcs(prop, "rna_UIList_list_id_get", "rna_UIList_list_id_length", NULL);
+ RNA_def_property_ui_text(prop,
+ "List Name",
+ "Identifier of the list, if any was passed to the \"list_id\" "
+ "parameter of \"template_list()\"");
+
prop = RNA_def_property(srna, "layout_type", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_items(prop, rna_enum_uilist_layout_type_items);
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
diff --git a/source/blender/makesrna/intern/rna_ui_api.c b/source/blender/makesrna/intern/rna_ui_api.c
index aa235b599b7..e06cc39a88b 100644
--- a/source/blender/makesrna/intern/rna_ui_api.c
+++ b/source/blender/makesrna/intern/rna_ui_api.c
@@ -50,6 +50,8 @@ const EnumPropertyItem rna_enum_icon_items[] = {
#ifdef RNA_RUNTIME
+# include "DNA_asset_types.h"
+
const char *rna_translate_ui_text(
const char *text, const char *text_ctxt, StructRNA *type, PropertyRNA *prop, bool translate)
{
@@ -525,6 +527,46 @@ static void rna_uiTemplateAnyID(uiLayout *layout,
uiTemplateAnyID(layout, ptr, propname, proptypename, name);
}
+void rna_uiTemplateList(uiLayout *layout,
+ struct bContext *C,
+ const char *listtype_name,
+ const char *list_id,
+ struct PointerRNA *dataptr,
+ const char *propname,
+ struct PointerRNA *active_dataptr,
+ const char *active_propname,
+ const char *item_dyntip_propname,
+ const int rows,
+ const int maxrows,
+ const int layout_type,
+ const int columns,
+ const bool sort_reverse,
+ const bool sort_lock)
+{
+ int flags = UI_TEMPLATE_LIST_FLAG_NONE;
+ if (sort_reverse) {
+ flags |= UI_TEMPLATE_LIST_SORT_REVERSE;
+ }
+ if (sort_lock) {
+ flags |= UI_TEMPLATE_LIST_SORT_LOCK;
+ }
+
+ uiTemplateList(layout,
+ C,
+ listtype_name,
+ list_id,
+ dataptr,
+ propname,
+ active_dataptr,
+ active_propname,
+ item_dyntip_propname,
+ rows,
+ maxrows,
+ layout_type,
+ columns,
+ flags);
+}
+
static void rna_uiTemplateCacheFile(uiLayout *layout,
bContext *C,
PointerRNA *ptr,
@@ -570,6 +612,69 @@ static void rna_uiTemplateEventFromKeymapItem(
uiTemplateEventFromKeymapItem(layout, name, kmi, true);
}
+static void rna_uiTemplateAssetView(uiLayout *layout,
+ bContext *C,
+ const char *list_id,
+ PointerRNA *asset_library_dataptr,
+ const char *asset_library_propname,
+ PointerRNA *assets_dataptr,
+ const char *assets_propname,
+ PointerRNA *active_dataptr,
+ const char *active_propname,
+ int filter_id_types,
+ const char *activate_opname,
+ PointerRNA *r_activate_op_properties,
+ const char *drag_opname,
+ PointerRNA *r_drag_op_properties)
+{
+ AssetFilterSettings filter_settings = {
+ .id_types = filter_id_types ? filter_id_types : FILTER_ID_ALL,
+ };
+ uiTemplateAssetView(layout,
+ C,
+ list_id,
+ asset_library_dataptr,
+ asset_library_propname,
+ assets_dataptr,
+ assets_propname,
+ active_dataptr,
+ active_propname,
+ &filter_settings,
+ activate_opname,
+ r_activate_op_properties,
+ drag_opname,
+ r_drag_op_properties);
+}
+
+/**
+ * XXX Remove filter items that require more than 32 bits for storage. RNA enums don't support
+ * that currently.
+ */
+static const EnumPropertyItem *rna_uiTemplateAssetView_filter_id_types_itemf(
+ bContext *UNUSED(C), PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), bool *r_free)
+{
+ EnumPropertyItem *items = NULL;
+ int totitem = 0;
+
+ for (int i = 0; rna_enum_id_type_filter_items[i].identifier; i++) {
+ if (rna_enum_id_type_filter_items[i].flag > (1ULL << 31)) {
+ continue;
+ }
+
+ EnumPropertyItem tmp = {0, "", 0, "", ""};
+ tmp.value = rna_enum_id_type_filter_items[i].flag;
+ tmp.identifier = rna_enum_id_type_filter_items[i].identifier;
+ tmp.icon = rna_enum_id_type_filter_items[i].icon;
+ tmp.name = rna_enum_id_type_filter_items[i].name;
+ tmp.description = rna_enum_id_type_filter_items[i].description;
+ RNA_enum_item_add(&items, &totitem, &tmp);
+ }
+ RNA_enum_item_end(&items, &totitem);
+
+ *r_free = true;
+ return items;
+}
+
static uiLayout *rna_uiLayoutRowWithHeading(
uiLayout *layout, bool align, const char *heading, const char *heading_ctxt, bool translate)
{
@@ -1508,7 +1613,7 @@ void RNA_api_ui_layout(StructRNA *srna)
parm = RNA_def_pointer(func, "clip_user", "MovieClipUser", "", "");
RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR);
- func = RNA_def_function(srna, "template_list", "uiTemplateList");
+ func = RNA_def_function(srna, "template_list", "rna_uiTemplateList");
RNA_def_function_ui_description(func, "Item. A list widget to display data, e.g. vertexgroups.");
RNA_def_function_flag(func, FUNC_USE_CONTEXT);
parm = RNA_def_string(func, "listtype_name", NULL, 0, "", "Identifier of the list type to use");
@@ -1689,6 +1794,81 @@ void RNA_api_ui_layout(StructRNA *srna)
RNA_def_property_ui_text(parm, "Item", "");
RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
api_ui_item_common_text(func);
+
+ func = RNA_def_function(srna, "template_asset_view", "rna_uiTemplateAssetView");
+ RNA_def_function_ui_description(func, "Item. A scrollable list of assets in a grid view");
+ RNA_def_function_flag(func, FUNC_USE_CONTEXT);
+ parm = RNA_def_string(func,
+ "list_id",
+ NULL,
+ 0,
+ "",
+ "Identifier of this asset view. Necessary to tell apart different asset "
+ "views and to idenify an asset view read from a .blend");
+ RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
+ parm = RNA_def_pointer(func,
+ "asset_library_dataptr",
+ "AnyType",
+ "",
+ "Data from which to take the active asset library property");
+ RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR);
+ parm = RNA_def_string(
+ func, "asset_library_propname", NULL, 0, "", "Identifier of the asset library property");
+ RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
+ parm = RNA_def_pointer(
+ func, "assets_dataptr", "AnyType", "", "Data from which to take the asset list property");
+ RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR);
+ parm = RNA_def_string(
+ func, "assets_propname", NULL, 0, "", "Identifier of the asset list property");
+ RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
+ parm = RNA_def_pointer(func,
+ "active_dataptr",
+ "AnyType",
+ "",
+ "Data from which to take the integer property, index of the active item");
+ RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR);
+ parm = RNA_def_string(
+ func,
+ "active_propname",
+ NULL,
+ 0,
+ "",
+ "Identifier of the integer property in active_data, index of the active item");
+ RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
+ parm = RNA_def_property(func, "filter_id_types", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_items(parm, DummyRNA_NULL_items);
+ RNA_def_property_enum_funcs(parm, NULL, NULL, "rna_uiTemplateAssetView_filter_id_types_itemf");
+ RNA_def_property_flag(parm, PROP_ENUM_FLAG);
+ RNA_def_string(func,
+ "activate_operator",
+ NULL,
+ 0,
+ "",
+ "Name of a custom operator to invoke when activating an item");
+ parm = RNA_def_pointer(
+ func,
+ "activate_operator_properties",
+ "OperatorProperties",
+ "",
+ "Operator properties to fill in for the custom activate operator passed to the template");
+ RNA_def_parameter_flags(parm, 0, PARM_RNAPTR);
+ RNA_def_function_output(func, parm);
+ RNA_def_string(func,
+ "drag_operator",
+ NULL,
+ 0,
+ "",
+ "Name of a custom operator to invoke when starting to drag an item. Never "
+ "invoked together with the `active_operator` (if set), it's either the drag or "
+ "the activate one");
+ parm = RNA_def_pointer(
+ func,
+ "drag_operator_properties",
+ "OperatorProperties",
+ "",
+ "Operator properties to fill in for the custom drag operator passed to the template");
+ RNA_def_parameter_flags(parm, 0, PARM_RNAPTR);
+ RNA_def_function_output(func, parm);
}
#endif
diff --git a/source/blender/makesrna/intern/rna_wm.c b/source/blender/makesrna/intern/rna_wm.c
index afbde26e59e..2a4abac04f8 100644
--- a/source/blender/makesrna/intern/rna_wm.c
+++ b/source/blender/makesrna/intern/rna_wm.c
@@ -1765,7 +1765,7 @@ static void rna_Operator_bl_idname_set(PointerRNA *ptr, const char *value)
BLI_strncpy(str, value, OP_MAX_TYPENAME); /* utf8 already ensured */
}
else {
- BLI_assert(!"setting the bl_idname on a non-builtin operator");
+ BLI_assert_msg(0, "setting the bl_idname on a non-builtin operator");
}
}
@@ -1777,7 +1777,7 @@ static void rna_Operator_bl_label_set(PointerRNA *ptr, const char *value)
BLI_strncpy(str, value, OP_MAX_TYPENAME); /* utf8 already ensured */
}
else {
- BLI_assert(!"setting the bl_label on a non-builtin operator");
+ BLI_assert_msg(0, "setting the bl_label on a non-builtin operator");
}
}
diff --git a/source/blender/makesrna/intern/rna_wm_gizmo.c b/source/blender/makesrna/intern/rna_wm_gizmo.c
index 076a77d4fb5..6a1574f3dbe 100644
--- a/source/blender/makesrna/intern/rna_wm_gizmo.c
+++ b/source/blender/makesrna/intern/rna_wm_gizmo.c
@@ -244,7 +244,7 @@ static void rna_Gizmo_bl_idname_set(PointerRNA *ptr, const char *value)
BLI_strncpy(str, value, MAX_NAME); /* utf8 already ensured */
}
else {
- BLI_assert(!"setting the bl_idname on a non-builtin operator");
+ BLI_assert_msg(0, "setting the bl_idname on a non-builtin operator");
}
}
@@ -643,7 +643,7 @@ static void rna_GizmoGroup_bl_idname_set(PointerRNA *ptr, const char *value)
BLI_strncpy(str, value, MAX_NAME); /* utf8 already ensured */
}
else {
- BLI_assert(!"setting the bl_idname on a non-builtin operator");
+ BLI_assert_msg(0, "setting the bl_idname on a non-builtin operator");
}
}
@@ -655,7 +655,7 @@ static void rna_GizmoGroup_bl_label_set(PointerRNA *ptr, const char *value)
BLI_strncpy(str, value, MAX_NAME); /* utf8 already ensured */
}
else {
- BLI_assert(!"setting the bl_label on a non-builtin operator");
+ BLI_assert_msg(0, "setting the bl_label on a non-builtin operator");
}
}
diff --git a/source/blender/makesrna/intern/rna_workspace.c b/source/blender/makesrna/intern/rna_workspace.c
index 6b52a38c2da..b053bb0ff62 100644
--- a/source/blender/makesrna/intern/rna_workspace.c
+++ b/source/blender/makesrna/intern/rna_workspace.c
@@ -107,6 +107,18 @@ static void rna_WorkSpace_owner_ids_clear(WorkSpace *workspace)
WM_main_add_notifier(NC_OBJECT | ND_MODIFIER | NA_REMOVED, workspace);
}
+static int rna_WorkSpace_active_asset_library_get(PointerRNA *ptr)
+{
+ const WorkSpace *workspace = ptr->data;
+ return rna_asset_library_reference_get(&workspace->active_asset_library);
+}
+
+static void rna_WorkSpace_active_asset_library_set(PointerRNA *ptr, int value)
+{
+ WorkSpace *workspace = ptr->data;
+ rna_asset_library_reference_set(&workspace->active_asset_library, value);
+}
+
static bToolRef *rna_WorkSpace_tools_from_tkey(WorkSpace *workspace,
const bToolKey *tkey,
bool create)
@@ -407,6 +419,14 @@ static void rna_def_workspace(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Use UI Tags", "Filter the UI by tags");
RNA_def_property_update(prop, 0, "rna_window_update_all");
+ prop = rna_def_asset_library_reference_common(
+ srna, "rna_WorkSpace_active_asset_library_get", "rna_WorkSpace_active_asset_library_set");
+ RNA_def_property_ui_text(prop,
+ "Asset Library",
+ "Active asset library to show in the UI, not used by the Asset Browser "
+ "(which has its own active asset library)");
+ RNA_def_property_update(prop, NC_ASSET | ND_ASSET_LIST_READING, NULL);
+
RNA_api_workspace(srna);
}