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.
This commit is contained in:
@@ -316,7 +316,7 @@ class IMAGE_HT_header(bpy.types.Header):
|
||||
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
|
||||
|
||||
@@ -53,7 +53,7 @@ class OUTLINER_HT_header(bpy.types.Header):
|
||||
|
||||
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')
|
||||
|
||||
@@ -77,7 +77,7 @@ class TIME_HT_header(bpy.types.Header):
|
||||
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')
|
||||
|
||||
|
||||
@@ -363,7 +363,7 @@ class InputKeyMapPanel(bpy.types.Panel):
|
||||
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')
|
||||
|
||||
|
||||
@@ -717,7 +717,6 @@ void uiItemEnumR(uiLayout *layout, char *name, int icon, struct PointerRNA *ptr,
|
||||
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 */
|
||||
|
||||
@@ -1263,66 +1263,6 @@ void uiItemPointerR(uiLayout *layout, struct PointerRNA *ptr, char *propname, st
|
||||
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)
|
||||
{
|
||||
|
||||
@@ -189,12 +189,6 @@ void RNA_api_ui_layout(StructRNA *srna)
|
||||
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);
|
||||
|
||||
@@ -1016,6 +1016,8 @@ int pyrna_py_to_prop(PointerRNA *ptr, PropertyRNA *prop, ParameterList *parms, v
|
||||
}
|
||||
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 @@ int pyrna_py_to_prop(PointerRNA *ptr, PropertyRNA *prop, ParameterList *parms, v
|
||||
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 @@ int pyrna_py_to_prop(PointerRNA *ptr, PropertyRNA *prop, ParameterList *parms, v
|
||||
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 @@ int pyrna_py_to_prop(PointerRNA *ptr, PropertyRNA *prop, ParameterList *parms, v
|
||||
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:
|
||||
|
||||
Reference in New Issue
Block a user