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 /source/blender | |
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.
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/editors/transform/transform_ops.c | 41 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_rna.c | 12 |
2 files changed, 18 insertions, 35 deletions
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) |