Override template: Add text and icon optional parameters
This commit is contained in:
parent
eb48eeba84
commit
6de28e7f90
|
@ -956,7 +956,11 @@ void uiTemplateHeader3D(uiLayout *layout, struct bContext *C);
|
|||
void uiTemplateEditModeSelection(uiLayout *layout, struct bContext *C);
|
||||
void uiTemplateReportsBanner(uiLayout *layout, struct bContext *C);
|
||||
void uiTemplateKeymapItemProperties(uiLayout *layout, struct PointerRNA *ptr);
|
||||
void uiTemplateOverrideProperty(uiLayout *layout, struct PointerRNA *collection_props_ptr, struct PointerRNA *scene_props_ptr, const char *name, const char *custom_template);
|
||||
void uiTemplateOverrideProperty(
|
||||
uiLayout *layout, struct PointerRNA *collection_props_ptr, struct PointerRNA *scene_props_ptr,
|
||||
const char *propname,
|
||||
const char *name, const char *text_ctxt, int translate, int icon,
|
||||
const char *custom_template);
|
||||
void uiTemplateComponentMenu(uiLayout *layout, struct PointerRNA *ptr, const char *propname, const char *name);
|
||||
void uiTemplateNodeSocket(uiLayout *layout, struct bContext *C, float *color);
|
||||
void uiTemplateCacheFile(uiLayout *layout, struct bContext *C, struct PointerRNA *ptr, const char *propname);
|
||||
|
|
|
@ -4000,7 +4000,10 @@ void uiTemplateKeymapItemProperties(uiLayout *layout, PointerRNA *ptr)
|
|||
|
||||
/********************************* Overrides *************************************/
|
||||
|
||||
void uiTemplateOverrideProperty(uiLayout *layout, struct PointerRNA *collection_props_ptr, struct PointerRNA *scene_props_ptr, const char *name, const char *custom_template)
|
||||
void uiTemplateOverrideProperty(
|
||||
uiLayout *layout, PointerRNA *collection_props_ptr, PointerRNA *scene_props_ptr, const char *propname,
|
||||
const char *name, const char *text_ctxt, int translate, int icon,
|
||||
const char *custom_template)
|
||||
{
|
||||
bool is_set = false;
|
||||
uiLayout *row, *col;
|
||||
|
@ -4010,27 +4013,30 @@ void uiTemplateOverrideProperty(uiLayout *layout, struct PointerRNA *collection_
|
|||
|
||||
IDProperty *collection_props = collection_props_ptr->data;
|
||||
|
||||
if (IDP_GetPropertyFromGroup(collection_props, name)) {
|
||||
prop = RNA_struct_find_property(collection_props_ptr, name);
|
||||
if (IDP_GetPropertyFromGroup(collection_props, propname)) {
|
||||
prop = RNA_struct_find_property(collection_props_ptr, propname);
|
||||
ptr = collection_props_ptr;
|
||||
is_set = RNA_property_is_set(ptr, prop);
|
||||
}
|
||||
else {
|
||||
/* property doesn't exist yet */
|
||||
prop = RNA_struct_find_property(scene_props_ptr, name);
|
||||
prop = RNA_struct_find_property(scene_props_ptr, propname);
|
||||
ptr = scene_props_ptr;
|
||||
}
|
||||
|
||||
/* Get translated name (label). */
|
||||
name = RNA_translate_ui_text(name, text_ctxt, NULL, prop, translate);
|
||||
|
||||
row = uiLayoutRow(layout, false);
|
||||
col = uiLayoutColumn(row, false);
|
||||
|
||||
uiLayoutSetEnabled(col, is_set);
|
||||
|
||||
if (custom_template && STREQ(custom_template, "icon_view")) {
|
||||
uiTemplateIconView(col, ptr, name, false, 5.0f);
|
||||
uiTemplateIconView(col, ptr, propname, false, 5.0f);
|
||||
}
|
||||
else {
|
||||
uiItemFullR(col, ptr, prop, -1, 0, 0, NULL, ICON_NONE);
|
||||
uiItemFullR(col, ptr, prop, -1, 0, 0, name, icon);
|
||||
}
|
||||
|
||||
col = uiLayoutColumn(row, false);
|
||||
|
|
|
@ -918,6 +918,7 @@ void RNA_api_ui_layout(StructRNA *srna)
|
|||
RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR);
|
||||
parm = RNA_def_string(func, "property", NULL, 0, "", "Identifier of property in collection_properties");
|
||||
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
|
||||
api_ui_item_common(func);
|
||||
parm = RNA_def_string(func, "custom_template", NULL, 0, "", "Optional template to use for property");
|
||||
|
||||
func = RNA_def_function(srna, "template_component_menu", "uiTemplateComponentMenu");
|
||||
|
|
Loading…
Reference in New Issue