show a title in menus triggered by WM_OT_context_menu_enum, also show an icon when...
authorCampbell Barton <ideasman42@gmail.com>
Thu, 17 Jan 2013 00:29:39 +0000 (00:29 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Thu, 17 Jan 2013 00:29:39 +0000 (00:29 +0000)
release/scripts/startup/bl_operators/wm.py
source/blender/makesrna/intern/rna_rna.c

index 6c41890..9a2328d 100644 (file)
@@ -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)
 
index c47718c..f86f601 100644 (file)
@@ -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);