[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [31543] trunk/blender: remove recently added rna function uilayout.prop_search_self() and instead allow collections to be coerced into rna structs when they define a type .
Campbell Barton
ideasman42 at gmail.com
Tue Aug 24 05:02:30 CEST 2010
Revision: 31543
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=31543
Author: campbellbarton
Date: 2010-08-24 05:02:27 +0200 (Tue, 24 Aug 2010)
Log Message:
-----------
remove recently added rna function uilayout.prop_search_self() and instead allow collections to be coerced into rna structs when they define a type.
eg:
row.prop_search_self(scene, "active", "keying_sets", text="")
...becomes
row.prop_search(scene.keying_sets, "active", scene, "keying_sets", text="")
This is more flexible since it works for other UI functions too.
Modified Paths:
--------------
trunk/blender/release/scripts/ui/space_image.py
trunk/blender/release/scripts/ui/space_outliner.py
trunk/blender/release/scripts/ui/space_time.py
trunk/blender/release/scripts/ui/space_userpref_keymap.py
trunk/blender/source/blender/editors/include/UI_interface.h
trunk/blender/source/blender/editors/interface/interface_layout.c
trunk/blender/source/blender/makesrna/intern/rna_ui_api.c
trunk/blender/source/blender/python/intern/bpy_rna.c
Modified: trunk/blender/release/scripts/ui/space_image.py
===================================================================
--- trunk/blender/release/scripts/ui/space_image.py 2010-08-24 02:12:09 UTC (rev 31542)
+++ trunk/blender/release/scripts/ui/space_image.py 2010-08-24 03:02:27 UTC (rev 31543)
@@ -316,7 +316,7 @@
row.prop(toolsettings, "snap_element", text="", icon_only=True)
# mesh = context.edit_object.data
- # row.prop_search_self(mesh, "active", "uv_textures")
+ # row.prop_search(mesh.uv_textures, "active", mesh, "uv_textures")
if ima:
# layers
Modified: trunk/blender/release/scripts/ui/space_outliner.py
===================================================================
--- trunk/blender/release/scripts/ui/space_outliner.py 2010-08-24 02:12:09 UTC (rev 31542)
+++ trunk/blender/release/scripts/ui/space_outliner.py 2010-08-24 03:02:27 UTC (rev 31543)
@@ -53,7 +53,7 @@
if ks:
row = layout.row(align=False)
- row.prop_search_self(scene, "active", "keying_sets", text="")
+ row.prop_search(scene.keying_sets, "active", scene, "keying_sets", text="")
row = layout.row(align=True)
row.operator("anim.keyframe_insert", text="", icon='KEY_HLT')
Modified: trunk/blender/release/scripts/ui/space_time.py
===================================================================
--- trunk/blender/release/scripts/ui/space_time.py 2010-08-24 02:12:09 UTC (rev 31542)
+++ trunk/blender/release/scripts/ui/space_time.py 2010-08-24 03:02:27 UTC (rev 31543)
@@ -77,7 +77,7 @@
layout.separator()
row = layout.row(align=True)
- row.prop_search_self(scene, "active", "keying_sets", text="")
+ row.prop_search(scene.keying_sets, "active", scene, "keying_sets", text="")
row.operator("anim.keyframe_insert", text="", icon='KEY_HLT')
row.operator("anim.keyframe_delete", text="", icon='KEY_DEHLT')
Modified: trunk/blender/release/scripts/ui/space_userpref_keymap.py
===================================================================
--- trunk/blender/release/scripts/ui/space_userpref_keymap.py 2010-08-24 02:12:09 UTC (rev 31542)
+++ trunk/blender/release/scripts/ui/space_userpref_keymap.py 2010-08-24 03:02:27 UTC (rev 31543)
@@ -363,7 +363,7 @@
subcol = subsplit.column()
row = subcol.row()
- row.prop_search_self(wm, "active", "keyconfigs", text="Key Config:")
+ row.prop_search(wm.keyconfigs, "active", wm, "keyconfigs", text="Key Config:")
layout.set_context_pointer("keyconfig", wm.keyconfigs.active)
row.operator("wm.keyconfig_remove", text="", icon='X')
Modified: trunk/blender/source/blender/editors/include/UI_interface.h
===================================================================
--- trunk/blender/source/blender/editors/include/UI_interface.h 2010-08-24 02:12:09 UTC (rev 31542)
+++ trunk/blender/source/blender/editors/include/UI_interface.h 2010-08-24 03:02:27 UTC (rev 31543)
@@ -717,7 +717,6 @@
void uiItemEnumR_string(uiLayout *layout, struct PointerRNA *ptr, char *propname, char *value, char *name, int icon);
void uiItemsEnumR(uiLayout *layout, struct PointerRNA *ptr, char *propname);
void uiItemPointerR(uiLayout *layout, struct PointerRNA *ptr, char *propname, struct PointerRNA *searchptr, char *searchpropname, char *name, int icon);
-void uiItemPointerSubR(uiLayout *layout, struct PointerRNA *ptr, char *propname, char *searchpropname, char *name, int icon);
void uiItemsFullEnumO(uiLayout *layout, char *opname, char *propname, struct IDProperty *properties, int context, int flag);
void uiItemL(uiLayout *layout, char *name, int icon); /* label */
Modified: trunk/blender/source/blender/editors/interface/interface_layout.c
===================================================================
--- trunk/blender/source/blender/editors/interface/interface_layout.c 2010-08-24 02:12:09 UTC (rev 31542)
+++ trunk/blender/source/blender/editors/interface/interface_layout.c 2010-08-24 03:02:27 UTC (rev 31543)
@@ -1263,66 +1263,6 @@
ui_but_add_search(but, ptr, prop, searchptr, searchprop);
}
-/* almost the same as uiItemPointerR except the collection is used to get the propname */
-void uiItemPointerSubR(uiLayout *layout, struct PointerRNA *ptr, char *propname, char *searchpropname, char *name, int icon)
-{
- PropertyRNA *prop, *searchprop;
- PropertyType type;
- PointerRNA c_ptr;
- uiBut *but;
- uiBlock *block;
- StructRNA *icontype;
- int w, h;
-
- /* validate arguments */
- searchprop= RNA_struct_find_property(ptr, searchpropname);
-
- if(!searchprop || RNA_property_type(searchprop) != PROP_COLLECTION) {
- printf("uiItemCollectionPointerR: search collection property not found: %s.%s\n", RNA_struct_identifier(ptr->type), searchpropname);
- return;
- }
-
- if(!RNA_property_collection_type_get(ptr, searchprop, &c_ptr)) {
- printf("uiItemCollectionPointerR: search collection sub-property not found1: %s.%s.%s\n", RNA_struct_identifier(ptr->type), searchpropname, propname);
- return;
- }
-
- if ((prop = RNA_struct_find_property(&c_ptr, propname))) {
- /* don't need this, pass */
- /* d_ptr= RNA_property_pointer_get(ptr, prop); */
- }
- else {
- printf("uiItemCollectionPointerR: search collection sub-property not found2: %s.%s.%s\n", RNA_struct_identifier(ptr->type), searchpropname, propname);
- return;
- }
-
- type= RNA_property_type(prop);
- if(!ELEM(type, PROP_POINTER, PROP_STRING)) {
- printf("uiItemCollectionPointerR: property %s must be a pointer or string.\n", propname);
- return;
- }
-
- /* get icon & name */
- if(!icon) {
- if(type == PROP_POINTER)
- icontype= RNA_property_pointer_type(&c_ptr, prop);
- else
- icontype= RNA_property_pointer_type(ptr, searchprop);
-
- icon= RNA_struct_ui_icon(icontype);
- }
- if(!name)
- name= (char*)RNA_property_ui_name(prop);
-
- /* create button */
- block= uiLayoutGetBlock(layout);
-
- ui_item_rna_size(layout, name, icon, &c_ptr, prop, 0, 0, &w, &h);
- but= ui_item_with_label(layout, block, name, icon, &c_ptr, prop, 0, 0, 0, w, h, 0);
-
- ui_but_add_search(but, &c_ptr, prop, ptr, searchprop);
-}
-
/* menu item */
static void ui_item_menutype_func(bContext *C, uiLayout *layout, void *arg_mt)
{
Modified: trunk/blender/source/blender/makesrna/intern/rna_ui_api.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_ui_api.c 2010-08-24 02:12:09 UTC (rev 31542)
+++ trunk/blender/source/blender/makesrna/intern/rna_ui_api.c 2010-08-24 03:02:27 UTC (rev 31543)
@@ -189,12 +189,6 @@
parm= RNA_def_string(func, "search_property", "", 0, "", "Identifier of search collection property.");
RNA_def_property_flag(parm, PROP_REQUIRED);
api_ui_item_common(func);
-
- func= RNA_def_function(srna, "prop_search_self", "uiItemPointerSubR");
- api_ui_item_rna_common(func);
- parm= RNA_def_string(func, "search_property", "", 0, "", "Identifier of search collection property.");
- RNA_def_property_flag(parm, PROP_REQUIRED);
- api_ui_item_common(func);
func= RNA_def_function(srna, "operator", "rna_uiItemO");
api_ui_item_op_common(func);
Modified: trunk/blender/source/blender/python/intern/bpy_rna.c
===================================================================
--- trunk/blender/source/blender/python/intern/bpy_rna.c 2010-08-24 02:12:09 UTC (rev 31542)
+++ trunk/blender/source/blender/python/intern/bpy_rna.c 2010-08-24 03:02:27 UTC (rev 31543)
@@ -1016,6 +1016,8 @@
}
case PROP_POINTER:
{
+ PyObject *value_new= NULL;
+
StructRNA *ptype= RNA_property_pointer_type(ptr, prop);
int flag = RNA_property_flag(prop);
@@ -1025,15 +1027,29 @@
return pyrna_pydict_to_props(&opptr, value, 0, error_prefix);
}
+ /* another exception, allow to pass a collection as an RNA property */
+ if(Py_TYPE(value)==&pyrna_prop_collection_Type) {
+ PointerRNA c_ptr;
+ BPy_PropertyRNA *value_prop= (BPy_PropertyRNA *)value;
+ if(RNA_property_collection_type_get(&value_prop->ptr, value_prop->prop, &c_ptr)) {
+ value= pyrna_struct_CreatePyObject(&c_ptr);
+ value_new= value;
+ }
+ else {
+ PyErr_Format(PyExc_TypeError, "%.200s %.200s.%.200s collection has no type, cant be used as a %.200s type", error_prefix, RNA_struct_identifier(ptr->type), RNA_property_identifier(prop), RNA_struct_identifier(ptype));
+ return -1;
+ }
+ }
+
if(!BPy_StructRNA_Check(value) && value != Py_None) {
PyErr_Format(PyExc_TypeError, "%.200s %.200s.%.200s expected a %.200s type", error_prefix, RNA_struct_identifier(ptr->type), RNA_property_identifier(prop), RNA_struct_identifier(ptype));
- return -1;
+ Py_XDECREF(value_new); return -1;
} else if((flag & PROP_NEVER_NULL) && value == Py_None) {
PyErr_Format(PyExc_TypeError, "%.200s %.200s.%.200s does not support a 'None' assignment %.200s type", error_prefix, RNA_struct_identifier(ptr->type), RNA_property_identifier(prop), RNA_struct_identifier(ptype));
- return -1;
+ Py_XDECREF(value_new); return -1;
} else if(value != Py_None && ((flag & PROP_ID_SELF_CHECK) && ptr->id.data == ((BPy_StructRNA*)value)->ptr.id.data)) {
PyErr_Format(PyExc_TypeError, "%.200s %.200s.%.200s ID type does not support assignment to its self", error_prefix, RNA_struct_identifier(ptr->type), RNA_property_identifier(prop));
- return -1;
+ Py_XDECREF(value_new); return -1;
} else {
BPy_StructRNA *param= (BPy_StructRNA*)value;
int raise_error= FALSE;
@@ -1069,7 +1085,7 @@
PointerRNA tmp;
RNA_pointer_create(NULL, ptype, NULL, &tmp);
PyErr_Format(PyExc_TypeError, "%.200s %.200s.%.200s expected a %.200s type", error_prefix, RNA_struct_identifier(ptr->type), RNA_property_identifier(prop), RNA_struct_identifier(tmp.type));
- return -1;
+ Py_XDECREF(value_new); return -1;
}
}
@@ -1077,9 +1093,10 @@
PointerRNA tmp;
RNA_pointer_create(NULL, ptype, NULL, &tmp);
PyErr_Format(PyExc_TypeError, "%.200s %.200s.%.200s expected a %.200s type", error_prefix, RNA_struct_identifier(ptr->type), RNA_property_identifier(prop), RNA_struct_identifier(tmp.type));
- return -1;
+ Py_XDECREF(value_new); return -1;
}
}
+
break;
}
case PROP_COLLECTION:
More information about the Bf-blender-cvs
mailing list