show a title in menus triggered by WM_OT_context_menu_enum, also show an icon when available.
This commit is contained in:
@@ -505,6 +505,10 @@ class WM_MT_context_menu_enum(Menu):
|
||||
return {'PASS_THROUGH'}
|
||||
base_path, prop_string = data_path.rsplit(".", 1)
|
||||
value_base = context_path_validate(context, base_path)
|
||||
prop = value_base.bl_rna.properties[prop_string]
|
||||
|
||||
layout = self.layout
|
||||
layout.label(prop.name, icon=prop.icon)
|
||||
col = self.layout.column()
|
||||
col.prop(value_base, prop_string, expand=True)
|
||||
|
||||
|
@@ -523,6 +523,13 @@ static int rna_Property_unit_get(PointerRNA *ptr)
|
||||
return RNA_SUBTYPE_UNIT(prop->subtype);
|
||||
}
|
||||
|
||||
static int rna_Property_icon_get(PointerRNA *ptr)
|
||||
{
|
||||
PropertyRNA *prop = (PropertyRNA *)ptr->data;
|
||||
rna_idproperty_check(&prop, ptr);
|
||||
return prop->icon;
|
||||
}
|
||||
|
||||
static int rna_Property_readonly_get(PointerRNA *ptr)
|
||||
{
|
||||
PropertyRNA *prop = (PropertyRNA *)ptr->data;
|
||||
@@ -1137,6 +1144,12 @@ static void rna_def_property(BlenderRNA *brna)
|
||||
RNA_def_property_enum_funcs(prop, "rna_Property_unit_get", NULL, NULL);
|
||||
RNA_def_property_ui_text(prop, "Unit", "Type of units for this property");
|
||||
|
||||
prop = RNA_def_property(srna, "icon", PROP_ENUM, PROP_NONE);
|
||||
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
||||
RNA_def_property_enum_items(prop, icon_items);
|
||||
RNA_def_property_enum_funcs(prop, "rna_Property_icon_get", NULL, NULL);
|
||||
RNA_def_property_ui_text(prop, "Icon", "Icon of the item");
|
||||
|
||||
prop = RNA_def_property(srna, "is_readonly", PROP_BOOLEAN, PROP_NONE);
|
||||
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
||||
RNA_def_property_boolean_funcs(prop, "rna_Property_readonly_get", NULL);
|
||||
|
Reference in New Issue
Block a user