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:
Diffstat (limited to 'source/blender/makesrna/intern/rna_ID.c')
-rw-r--r--source/blender/makesrna/intern/rna_ID.c52
1 files changed, 30 insertions, 22 deletions
diff --git a/source/blender/makesrna/intern/rna_ID.c b/source/blender/makesrna/intern/rna_ID.c
index 88065d29a50..63ea836e3de 100644
--- a/source/blender/makesrna/intern/rna_ID.c
+++ b/source/blender/makesrna/intern/rna_ID.c
@@ -47,7 +47,7 @@
/* enum of ID-block types
* NOTE: need to keep this in line with the other defines for these
*/
-EnumPropertyItem id_type_items[] = {
+EnumPropertyItem rna_enum_id_type_items[] = {
{ID_AC, "ACTION", ICON_ACTION, "Action", ""},
{ID_AR, "ARMATURE", ICON_ARMATURE_DATA, "Armature", ""},
{ID_BR, "BRUSH", ICON_BRUSH_DATA, "Brush", ""},
@@ -90,9 +90,11 @@ EnumPropertyItem id_type_items[] = {
#include "BKE_font.h"
#include "BKE_idprop.h"
#include "BKE_library.h"
+#include "BKE_library_query.h"
#include "BKE_animsys.h"
#include "BKE_material.h"
#include "BKE_depsgraph.h"
+#include "BKE_global.h" /* XXX, remove me */
#include "WM_api.h"
@@ -113,7 +115,7 @@ void rna_ID_name_set(PointerRNA *ptr, const char *value)
{
ID *id = (ID *)ptr->data;
BLI_strncpy_utf8(id->name + 2, value, sizeof(id->name) - 2);
- test_idbutton(id->name);
+ BLI_libblock_ensure_unique_name(G.main, id->name);
}
static int rna_ID_name_editable(PointerRNA *ptr)
@@ -126,7 +128,7 @@ static int rna_ID_name_editable(PointerRNA *ptr)
return false;
}
- return true;
+ return PROP_EDITABLE;
}
short RNA_type_to_ID_code(StructRNA *type)
@@ -223,13 +225,11 @@ void rna_ID_fake_user_set(PointerRNA *ptr, int value)
{
ID *id = (ID *)ptr->data;
- if (value && !(id->flag & LIB_FAKEUSER)) {
- id->flag |= LIB_FAKEUSER;
- id_us_plus(id);
+ if (value) {
+ id_fake_user_set(id);
}
- else if (!value && (id->flag & LIB_FAKEUSER)) {
- id->flag &= ~LIB_FAKEUSER;
- id_us_min(id);
+ else {
+ id_fake_user_clear(id);
}
}
@@ -329,8 +329,8 @@ static void rna_ID_update_tag(ID *id, ReportList *reports, int flag)
static void rna_ID_user_clear(ID *id)
{
+ id_fake_user_clear(id);
id->us = 0; /* don't save */
- id->flag &= ~LIB_FAKEUSER;
}
static AnimData * rna_ID_animation_data_create(ID *id, Main *bmain)
@@ -911,14 +911,14 @@ static void rna_def_ID(BlenderRNA *brna)
srna = RNA_def_struct(brna, "ID", NULL);
RNA_def_struct_ui_text(srna, "ID",
- "Base type for datablocks, defining a unique name, linking from other libraries "
+ "Base type for data-blocks, defining a unique name, linking from other libraries "
"and garbage collection");
RNA_def_struct_flag(srna, STRUCT_ID | STRUCT_ID_REFCOUNT);
RNA_def_struct_refine_func(srna, "rna_ID_refine");
RNA_def_struct_idprops_func(srna, "rna_ID_idprops");
prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
- RNA_def_property_ui_text(prop, "Name", "Unique datablock ID name");
+ RNA_def_property_ui_text(prop, "Name", "Unique data-block ID name");
RNA_def_property_string_funcs(prop, "rna_ID_name_get", "rna_ID_name_length", "rna_ID_name_set");
RNA_def_property_string_maxlength(prop, MAX_ID_NAME - 2);
RNA_def_property_editable_func(prop, "rna_ID_name_editable");
@@ -928,55 +928,63 @@ static void rna_def_ID(BlenderRNA *brna)
prop = RNA_def_property(srna, "users", PROP_INT, PROP_UNSIGNED);
RNA_def_property_int_sdna(prop, NULL, "us");
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
- RNA_def_property_ui_text(prop, "Users", "Number of times this datablock is referenced");
+ RNA_def_property_ui_text(prop, "Users", "Number of times this data-block is referenced");
prop = RNA_def_property(srna, "use_fake_user", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", LIB_FAKEUSER);
- RNA_def_property_ui_text(prop, "Fake User", "Save this datablock even if it has no users");
+ RNA_def_property_ui_text(prop, "Fake User", "Save this data-block even if it has no users");
RNA_def_property_boolean_funcs(prop, NULL, "rna_ID_fake_user_set");
prop = RNA_def_property(srna, "tag", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "flag", LIB_DOIT);
+ RNA_def_property_boolean_sdna(prop, NULL, "tag", LIB_TAG_DOIT);
RNA_def_property_flag(prop, PROP_LIB_EXCEPTION);
RNA_def_property_ui_text(prop, "Tag",
"Tools can use this to tag data for their own purposes "
"(initial state is undefined)");
prop = RNA_def_property(srna, "is_updated", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "flag", LIB_ID_RECALC);
+ RNA_def_property_boolean_sdna(prop, NULL, "tag", LIB_TAG_ID_RECALC);
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(prop, "Is Updated", "Datablock is tagged for recalculation");
prop = RNA_def_property(srna, "is_updated_data", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "flag", LIB_ID_RECALC_DATA);
+ RNA_def_property_boolean_sdna(prop, NULL, "tag", LIB_TAG_ID_RECALC_DATA);
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(prop, "Is Updated Data", "Datablock data is tagged for recalculation");
prop = RNA_def_property(srna, "is_library_indirect", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "flag", LIB_INDIRECT);
+ RNA_def_property_boolean_sdna(prop, NULL, "tag", LIB_TAG_INDIRECT);
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(prop, "Is Indirect", "Is this ID block linked indirectly");
prop = RNA_def_property(srna, "library", PROP_POINTER, PROP_NONE);
RNA_def_property_pointer_sdna(prop, NULL, "lib");
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
- RNA_def_property_ui_text(prop, "Library", "Library file the datablock is linked from");
+ RNA_def_property_ui_text(prop, "Library", "Library file the data-block is linked from");
prop = RNA_def_pointer(srna, "preview", "ImagePreview", "Preview",
- "Preview image and icon of this datablock (None if not supported for this type of data)");
+ "Preview image and icon of this data-block (None if not supported for this type of data)");
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_pointer_funcs(prop, "rna_IDPreview_get", NULL, NULL, NULL);
/* functions */
func = RNA_def_function(srna, "copy", "rna_ID_copy");
- RNA_def_function_ui_description(func, "Create a copy of this datablock (not supported for all datablocks)");
+ RNA_def_function_ui_description(func, "Create a copy of this data-block (not supported for all data-blocks)");
parm = RNA_def_pointer(func, "id", "ID", "", "New copy of the ID");
RNA_def_function_return(func, parm);
func = RNA_def_function(srna, "user_clear", "rna_ID_user_clear");
- RNA_def_function_ui_description(func, "Clear the user count of a datablock so its not saved, "
+ RNA_def_function_ui_description(func, "Clear the user count of a data-block so its not saved, "
"on reload the data will be removed");
+ func = RNA_def_function(srna, "user_of_id", "BKE_library_ID_use_ID");
+ RNA_def_function_ui_description(func, "Count the number of times that ID uses/references given one");
+ parm = RNA_def_pointer(func, "id", "ID", "", "ID to count usages");
+ RNA_def_property_flag(parm, PROP_NEVER_NULL);
+ parm = RNA_def_int(func, "count", 0, 0, INT_MAX,
+ "", "Number of usages/references of given id by current datablock", 0, INT_MAX);
+ RNA_def_function_return(func, parm);
+
func = RNA_def_function(srna, "animation_data_create", "rna_ID_animation_data_create");
RNA_def_function_flag(func, FUNC_USE_MAIN);
RNA_def_function_ui_description(func, "Create animation data to this ID, note that not all ID types support this");