[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [23849] trunk/blender: Don' t depend on context for transform_orientation enum
Martin Poirier
theeth at yahoo.com
Wed Oct 14 23:05:36 CEST 2009
Revision: 23849
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=23849
Author: theeth
Date: 2009-10-14 23:05:35 +0200 (Wed, 14 Oct 2009)
Log Message:
-----------
Don't depend on context for transform_orientation enum
New current_orientation property that returns the current transform orientation data (if any)
New UI elements to rename and remove custom orientation (visible only when needed)
Modified Paths:
--------------
trunk/blender/release/scripts/ui/space_view3d.py
trunk/blender/source/blender/makesrna/intern/rna_scene.c
trunk/blender/source/blender/makesrna/intern/rna_space.c
Modified: trunk/blender/release/scripts/ui/space_view3d.py
===================================================================
--- trunk/blender/release/scripts/ui/space_view3d.py 2009-10-14 20:09:21 UTC (rev 23848)
+++ trunk/blender/release/scripts/ui/space_view3d.py 2009-10-14 21:05:35 UTC (rev 23849)
@@ -1333,12 +1333,11 @@
col.itemR(view, "transform_orientation")
col.itemO("tfm.create_orientation", text="Create")
-# orientation_index = view.__rna__.properties["transform_orientation"].items[view.transform_orientation].value
-#
-# if orientation_index >= 4:
-# orientation = context.scene.orientations[orientation_index - 4]
-# col.itemR(orientation, "name")
- col.itemO("tfm.delete_orientation", text="Delete")
+ orientation = view.current_orientation
+
+ if orientation:
+ col.itemR(orientation, "name")
+ col.itemO("tfm.delete_orientation", text="Delete")
# Operators
Modified: trunk/blender/source/blender/makesrna/intern/rna_scene.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_scene.c 2009-10-14 20:09:21 UTC (rev 23848)
+++ trunk/blender/source/blender/makesrna/intern/rna_scene.c 2009-10-14 21:05:35 UTC (rev 23849)
@@ -485,10 +485,12 @@
prop= RNA_def_property(srna, "matrix", PROP_FLOAT, PROP_MATRIX);
RNA_def_property_float_sdna(prop, NULL, "mat");
RNA_def_property_multi_array(prop, 2, matrix_dimsize);
+ RNA_def_property_update(prop, NC_SPACE|ND_SPACE_VIEW3D, NULL);
prop= RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
RNA_def_property_string_sdna(prop, NULL, "name");
RNA_def_struct_name_property(srna, prop);
+ RNA_def_property_update(prop, NC_SPACE|ND_SPACE_VIEW3D, NULL);
}
static void rna_def_tool_settings(BlenderRNA *brna)
Modified: trunk/blender/source/blender/makesrna/intern/rna_space.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_space.c 2009-10-14 20:09:21 UTC (rev 23848)
+++ trunk/blender/source/blender/makesrna/intern/rna_space.c 2009-10-14 21:05:35 UTC (rev 23849)
@@ -147,16 +147,20 @@
}
}
-static int rna_TransformOrientation_getf(PointerRNA *ptr)
+static PointerRNA rna_CurrentOrientation_get(PointerRNA *ptr)
{
+ Scene *scene = ((bScreen*)ptr->id.data)->scene;
View3D *v3d= (View3D*)ptr->data;
-
- return v3d->twmode;
+
+ if (v3d->twmode < 4)
+ return rna_pointer_inherit_refine(ptr, &RNA_TransformOrientation, NULL);
+ else
+ return rna_pointer_inherit_refine(ptr, &RNA_TransformOrientation, BLI_findlink(&scene->transform_spaces, v3d->twmode - 4));
}
EnumPropertyItem *rna_TransformOrientation_itemf(bContext *C, PointerRNA *ptr, int *free)
{
- Scene *scene;
+ Scene *scene = ((bScreen*)ptr->id.data)->scene;
ListBase *transform_spaces;
TransformOrientation *ts= NULL;
EnumPropertyItem tmp = {0, "", 0, "", ""};
@@ -168,16 +172,10 @@
RNA_enum_items_add_value(&item, &totitem, transform_orientation_items, V3D_MANIP_LOCAL);
RNA_enum_items_add_value(&item, &totitem, transform_orientation_items, V3D_MANIP_VIEW);
- scene= CTX_data_scene(C);
-
if(scene) {
transform_spaces = &scene->transform_spaces;
ts = transform_spaces->first;
}
- else
- {
- printf("no scene\n");
- }
if(ts)
RNA_enum_item_add_separator(&item, &totitem);
@@ -783,10 +781,15 @@
prop= RNA_def_property(srna, "transform_orientation", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "twmode");
RNA_def_property_enum_items(prop, transform_orientation_items);
- RNA_def_property_enum_funcs(prop, "rna_TransformOrientation_getf", NULL, "rna_TransformOrientation_itemf");
+ RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_TransformOrientation_itemf");
RNA_def_property_ui_text(prop, "Transform Orientation", "Transformation orientation.");
RNA_def_property_update(prop, NC_SPACE|ND_SPACE_VIEW3D, NULL);
+ prop= RNA_def_property(srna, "current_orientation", PROP_POINTER, PROP_NONE);
+ RNA_def_property_struct_type(prop, "TransformOrientation");
+ RNA_def_property_pointer_funcs(prop, "rna_CurrentOrientation_get", NULL, NULL);
+ RNA_def_property_ui_text(prop, "Current Transform Orientation", "Current Transformation orientation.");
+
prop= RNA_def_property(srna, "lock_rotation", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, "RegionView3D", "viewlock", RV3D_LOCKED);
RNA_def_property_ui_text(prop, "Lock", "Lock View Rotation");
More information about the Bf-blender-cvs
mailing list