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:
authorCampbell Barton <ideasman42@gmail.com>2018-12-19 13:40:06 +0300
committerCampbell Barton <ideasman42@gmail.com>2018-12-19 13:41:39 +0300
commit543a34a0212411271054ced45fae416b1982156a (patch)
treeae71704a0487503fc4c597ce47440cf847135c74 /source/blender/makesrna/intern/rna_scene.c
parentf7dc6a63fb5a62eb6141fee375e30d94c1d83fa8 (diff)
RNA: convenience method for orientation name & icon
Avoids RNA introspection at draw time which is relatively slow (approx 5x).
Diffstat (limited to 'source/blender/makesrna/intern/rna_scene.c')
-rw-r--r--source/blender/makesrna/intern/rna_scene.c36
1 files changed, 35 insertions, 1 deletions
diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c
index 58bde163442..3a8cfbff3a1 100644
--- a/source/blender/makesrna/intern/rna_scene.c
+++ b/source/blender/makesrna/intern/rna_scene.c
@@ -1567,7 +1567,7 @@ static void rna_Scene_use_persistent_data_update(Main *UNUSED(bmain), Scene *UNU
RE_FreePersistentData();
}
-/* Scene.orientation_slots */
+/* Scene.transform_orientation_slots */
static void rna_Scene_transform_orientation_slots_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
{
Scene *scene = (Scene *)ptr->id.data;
@@ -2036,6 +2036,26 @@ const EnumPropertyItem *rna_TransformOrientation_itemf(
return item;
}
+void rna_TransformOrientationSlot_ui_info(
+ ID *scene_id, TransformOrientationSlot *orient_slot,
+ char *r_name, int *r_icon_value)
+{
+ Scene *scene = (Scene *)scene_id;
+
+ if (orient_slot->type < V3D_MANIP_CUSTOM) {
+ const EnumPropertyItem *items = rna_enum_transform_orientation_items;
+ const int i = RNA_enum_from_value(items, orient_slot->type);
+ strcpy(r_name, items[i].name);
+ *r_icon_value = items[i].icon;
+ }
+ else {
+ TransformOrientation *orientation = BKE_scene_transform_orientation_find(
+ scene, orient_slot->index_custom);
+ strcpy(r_name, orientation->name);
+ *r_icon_value = ICON_OBJECT_ORIGIN;
+ }
+}
+
static const EnumPropertyItem *get_unit_enum_items(int system, int type, bool *r_free)
{
const void *usys;
@@ -2221,6 +2241,20 @@ static void rna_def_transform_orientation_slot(BlenderRNA *brna)
RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", SELECT);
RNA_def_property_ui_text(prop, "Use", "Disable to unlink the orientation from the scene-setting");
RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
+
+ FunctionRNA *func;
+ PropertyRNA *parm;
+
+ /* UI access only (avoid slow RNA introspection). */
+ func = RNA_def_function(srna, "ui_info", "rna_TransformOrientationSlot_ui_info");
+ RNA_def_function_ui_description(func, "");
+ RNA_def_function_flag(func, FUNC_USE_SELF_ID);
+ parm = RNA_def_string(func, "name", NULL, sizeof(((TransformOrientation *)NULL)->name), "name", "");
+ RNA_def_parameter_flags(parm, PROP_THICK_WRAP, 0);
+ RNA_def_function_output(func, parm);
+ parm = RNA_def_property(func, "icon_value", PROP_INT, PROP_NONE);
+ RNA_def_property_ui_text(parm, "", "");
+ RNA_def_function_output(func, parm);
}