forked from bartvdbraak/blender
new UI rna function
layout.prop_search_self(), the same as layout.prop_search() except it uses an attribute of the collection. A number of collections have an 'active' member which couldnt be used with prop_search() and meant we had a mix of active properties being in collections and directly added as properties.
This commit is contained in:
parent
b844792bd5
commit
69067cc2d5
@ -717,6 +717,7 @@ 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 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 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 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 uiItemsFullEnumO(uiLayout *layout, char *opname, char *propname, struct IDProperty *properties, int context, int flag);
|
||||||
|
|
||||||
void uiItemL(uiLayout *layout, char *name, int icon); /* label */
|
void uiItemL(uiLayout *layout, char *name, int icon); /* label */
|
||||||
|
@ -1263,6 +1263,66 @@ void uiItemPointerR(uiLayout *layout, struct PointerRNA *ptr, char *propname, st
|
|||||||
ui_but_add_search(but, ptr, prop, searchptr, searchprop);
|
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 */
|
/* menu item */
|
||||||
static void ui_item_menutype_func(bContext *C, uiLayout *layout, void *arg_mt)
|
static void ui_item_menutype_func(bContext *C, uiLayout *layout, void *arg_mt)
|
||||||
{
|
{
|
||||||
|
@ -190,6 +190,12 @@ void RNA_api_ui_layout(StructRNA *srna)
|
|||||||
RNA_def_property_flag(parm, PROP_REQUIRED);
|
RNA_def_property_flag(parm, PROP_REQUIRED);
|
||||||
api_ui_item_common(func);
|
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");
|
func= RNA_def_function(srna, "operator", "rna_uiItemO");
|
||||||
api_ui_item_op_common(func);
|
api_ui_item_op_common(func);
|
||||||
RNA_def_boolean(func, "emboss", 1, "", "Draw the button itself, just the icon/text.");
|
RNA_def_boolean(func, "emboss", 1, "", "Draw the button itself, just the icon/text.");
|
||||||
|
Loading…
Reference in New Issue
Block a user