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)
This commit is contained in:
2009-10-14 21:05:35 +00:00
parent 7bed5e35b4
commit 1da4a06fc7
3 changed files with 21 additions and 17 deletions

View File

@@ -1333,12 +1333,11 @@ class VIEW3D_PT_transform_orientations(bpy.types.Panel):
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

View File

@@ -485,10 +485,12 @@ static void rna_def_transform_orientation(BlenderRNA *brna)
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)

View File

@@ -147,16 +147,20 @@ static StructRNA* rna_Space_refine(struct PointerRNA *ptr)
}
}
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 @@ EnumPropertyItem *rna_TransformOrientation_itemf(bContext *C, PointerRNA *ptr, i
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 @@ static void rna_def_space_3dview(BlenderRNA *brna)
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");