diff options
author | Campbell Barton <ideasman42@gmail.com> | 2013-01-13 20:18:35 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2013-01-13 20:18:35 +0400 |
commit | 4f2a65d34c41f3f3704be5f8c1023adaa7a04f2f (patch) | |
tree | 62b498371b4947e94b1bd66126a8ce1a8458077f | |
parent | 4f938bbbfe6e1a5d57e98e60c37c47582d904dc1 (diff) |
remove TRANSFORM_OT_snap_type, use WM_OT_context_menu_enum instead.
add Ctrl+Shift+Tab shortcut for selecting snap type to the UV editor too.
also added icon drawing to WM_OT_context_menu_enum() so it gets the icons from the enum to draw them in the menu.
-rw-r--r-- | release/scripts/startup/bl_operators/wm.py | 6 | ||||
-rw-r--r-- | source/blender/editors/transform/transform_ops.c | 41 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_rna.c | 12 |
3 files changed, 21 insertions, 38 deletions
diff --git a/release/scripts/startup/bl_operators/wm.py b/release/scripts/startup/bl_operators/wm.py index a76d8292a1d..b3414805427 100644 --- a/release/scripts/startup/bl_operators/wm.py +++ b/release/scripts/startup/bl_operators/wm.py @@ -506,10 +506,10 @@ class WM_MT_context_menu_enum(Menu): base_path, prop_string = data_path.rsplit(".", 1) value_base = context_path_validate(context, base_path) - values = [(i.name, i.identifier) for i in value_base.bl_rna.properties[prop_string].enum_items] + values = [(i.name, i.identifier, i.icon) for i in value_base.bl_rna.properties[prop_string].enum_items] - for name, identifier in values: - props = self.layout.operator("wm.context_set_enum", text=name) + for name, identifier, icon in values: + props = self.layout.operator("wm.context_set_enum", text=name, icon=icon) props.data_path = data_path props.value = identifier diff --git a/source/blender/editors/transform/transform_ops.c b/source/blender/editors/transform/transform_ops.c index f7c538b2dc7..f82625dcbe3 100644 --- a/source/blender/editors/transform/transform_ops.c +++ b/source/blender/editors/transform/transform_ops.c @@ -153,38 +153,6 @@ EnumPropertyItem transform_mode_types[] = {0, NULL, 0, NULL, NULL} }; -static int snap_type_exec(bContext *C, wmOperator *op) -{ - ToolSettings *ts = CTX_data_tool_settings(C); - - ts->snap_mode = RNA_enum_get(op->ptr, "type"); - - WM_event_add_notifier(C, NC_SCENE | ND_TOOLSETTINGS, NULL); /* header redraw */ - - return OPERATOR_FINISHED; -} - -static void TRANSFORM_OT_snap_type(wmOperatorType *ot) -{ - /* identifiers */ - ot->name = "Snap Type"; - ot->description = "Set the snap element type"; - ot->idname = "TRANSFORM_OT_snap_type"; - - /* api callbacks */ - ot->invoke = WM_menu_invoke; - ot->exec = snap_type_exec; - - ot->poll = ED_operator_areaactive; - - /* flags */ - ot->flag = OPTYPE_UNDO; - - /* props */ - ot->prop = RNA_def_enum(ot->srna, "type", snap_element_items, 0, "Type", "Set the snap element type"); - -} - static int select_orientation_exec(bContext *C, wmOperator *op) { int orientation = RNA_enum_get(op->ptr, "orientation"); @@ -914,8 +882,6 @@ void transform_operatortypes(void) WM_operatortype_append(TRANSFORM_OT_select_orientation); WM_operatortype_append(TRANSFORM_OT_create_orientation); WM_operatortype_append(TRANSFORM_OT_delete_orientation); - - WM_operatortype_append(TRANSFORM_OT_snap_type); } void transform_keymap_for_space(wmKeyConfig *keyconf, wmKeyMap *keymap, int spaceid) @@ -962,7 +928,9 @@ void transform_keymap_for_space(wmKeyConfig *keyconf, wmKeyMap *keymap, int spac kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle", TABKEY, KM_PRESS, KM_SHIFT, 0); RNA_string_set(kmi->ptr, "data_path", "tool_settings.use_snap"); - WM_keymap_add_item(keymap, "TRANSFORM_OT_snap_type", TABKEY, KM_PRESS, KM_SHIFT | KM_CTRL, 0); + kmi = WM_keymap_add_item(keymap, "WM_OT_context_menu_enum", TABKEY, KM_PRESS, KM_SHIFT | KM_CTRL, 0); + RNA_string_set(kmi->ptr, "data_path", "tool_settings.snap_element"); + kmi = WM_keymap_add_item(keymap, OP_TRANSLATION, TKEY, KM_PRESS, KM_SHIFT, 0); RNA_boolean_set(kmi->ptr, "texture_space", TRUE); @@ -1055,6 +1023,9 @@ void transform_keymap_for_space(wmKeyConfig *keyconf, wmKeyMap *keymap, int spac kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle", TABKEY, KM_PRESS, KM_SHIFT, 0); RNA_string_set(kmi->ptr, "data_path", "tool_settings.use_snap"); + + kmi = WM_keymap_add_item(keymap, "WM_OT_context_menu_enum", TABKEY, KM_PRESS, KM_SHIFT | KM_CTRL, 0); + RNA_string_set(kmi->ptr, "data_path", "tool_settings.snap_uv_element"); break; case SPACE_CLIP: WM_keymap_add_item(keymap, OP_TRANSLATION, GKEY, KM_PRESS, 0, 0); diff --git a/source/blender/makesrna/intern/rna_rna.c b/source/blender/makesrna/intern/rna_rna.c index 3f03445635f..c47718c681e 100644 --- a/source/blender/makesrna/intern/rna_rna.c +++ b/source/blender/makesrna/intern/rna_rna.c @@ -31,6 +31,7 @@ #include "RNA_access.h" #include "RNA_define.h" +#include "RNA_enum_types.h" #include "rna_internal.h" @@ -880,6 +881,11 @@ static int rna_EnumPropertyItem_value_get(PointerRNA *ptr) return ((EnumPropertyItem *)ptr->data)->value; } +static int rna_EnumPropertyItem_icon_get(PointerRNA *ptr) +{ + return ((EnumPropertyItem *)ptr->data)->icon; +} + static PointerRNA rna_PointerProperty_fixed_type_get(PointerRNA *ptr) { PropertyRNA *prop = (PropertyRNA *)ptr->data; @@ -1408,6 +1414,12 @@ static void rna_def_enum_property(BlenderRNA *brna, StructRNA *srna) RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_int_funcs(prop, "rna_EnumPropertyItem_value_get", NULL, NULL); RNA_def_property_ui_text(prop, "Value", "Value of the item"); + + 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_EnumPropertyItem_icon_get", NULL, NULL); + RNA_def_property_ui_text(prop, "Icon", "Icon of the item"); } static void rna_def_pointer_property(StructRNA *srna, PropertyType type) |