From 8ef23c6743ce00176754597f60ae549093ab6339 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Thu, 12 Jul 2012 12:06:40 +0000 Subject: [PATCH] Clip editor mode selection: show menu with modes on TAB This seems to be the only straightforward way to switch fast between modes without keeping bunch of shortcuts and current mode in head. --- release/scripts/startup/bl_ui/space_clip.py | 11 ++++++++++ source/blender/editors/space_clip/clip_ops.c | 20 +++---------------- .../blender/editors/space_clip/space_clip.c | 8 +------- source/blender/makesrna/RNA_enum_types.h | 2 ++ source/blender/makesrna/intern/rna_space.c | 20 +++++++++---------- 5 files changed, 27 insertions(+), 34 deletions(-) diff --git a/release/scripts/startup/bl_ui/space_clip.py b/release/scripts/startup/bl_ui/space_clip.py index a590a6cea94..d937837e5d1 100644 --- a/release/scripts/startup/bl_ui/space_clip.py +++ b/release/scripts/startup/bl_ui/space_clip.py @@ -1301,6 +1301,17 @@ class CLIP_MT_mask(Menu): layout.menu("CLIP_MT_mask_animation") +class CLIP_MT_select_mode(Menu): + bl_label = "Select Mode" + + def draw(self, context): + layout = self.layout + + layout.operator_context = 'INVOKE_REGION_WIN' + + layout.operator_enum("clip.mode_set", "mode") + + class CLIP_MT_mask_visibility(Menu): bl_label = "Show/Hide" diff --git a/source/blender/editors/space_clip/clip_ops.c b/source/blender/editors/space_clip/clip_ops.c index 948b6490331..86d74ef4c78 100644 --- a/source/blender/editors/space_clip/clip_ops.c +++ b/source/blender/editors/space_clip/clip_ops.c @@ -62,6 +62,7 @@ #include "RNA_access.h" #include "RNA_define.h" +#include "RNA_enum_types.h" #include "UI_view2d.h" @@ -1074,15 +1075,8 @@ static int mode_set_exec(bContext *C, wmOperator *op) { SpaceClip *sc = CTX_wm_space_clip(C); int mode = RNA_enum_get(op->ptr, "mode"); - int toggle = RNA_boolean_get(op->ptr, "toggle"); - if (sc->mode == mode) { - if (toggle) - sc->mode = SC_MODE_TRACKING; - } - else { - sc->mode = mode; - } + sc->mode = mode; WM_event_add_notifier(C, NC_SPACE | ND_SPACE_CLIP, NULL); @@ -1091,13 +1085,6 @@ static int mode_set_exec(bContext *C, wmOperator *op) void CLIP_OT_mode_set(wmOperatorType *ot) { - static EnumPropertyItem mode_items[] = { - {SC_MODE_TRACKING, "TRACKING", 0, "Tracking", "Show tracking and solving tools"}, - {SC_MODE_RECONSTRUCTION, "RECONSTRUCTION", 0, "Reconstruction", "Show tracking/reconstruction tools"}, - {SC_MODE_DISTORTION, "DISTORTION", 0, "Distortion", "Show distortion tools"}, - {0, NULL, 0, NULL, NULL}}; - - /* identifiers */ ot->name = "Set Clip Mode"; ot->description = "Set the clip interaction mode"; @@ -1109,8 +1096,7 @@ void CLIP_OT_mode_set(wmOperatorType *ot) ot->poll = ED_space_clip_poll; /* properties */ - RNA_def_enum(ot->srna, "mode", mode_items, SC_MODE_TRACKING, "Mode", ""); - RNA_def_boolean(ot->srna, "toggle", 0, "Toggle", ""); + RNA_def_enum(ot->srna, "mode", clip_editor_mode_items, SC_MODE_TRACKING, "Mode", ""); } /********************** macroses *********************/ diff --git a/source/blender/editors/space_clip/space_clip.c b/source/blender/editors/space_clip/space_clip.c index 13caf0b51fe..3623cd1d58b 100644 --- a/source/blender/editors/space_clip/space_clip.c +++ b/source/blender/editors/space_clip/space_clip.c @@ -559,13 +559,7 @@ static void clip_keymap(struct wmKeyConfig *keyconf) RNA_boolean_set(kmi->ptr, "sequence", TRUE); /* mode */ - kmi = WM_keymap_add_item(keymap, "CLIP_OT_mode_set", TABKEY, KM_PRESS, 0, 0); - RNA_enum_set(kmi->ptr, "mode", SC_MODE_RECONSTRUCTION); - RNA_boolean_set(kmi->ptr, "toggle", TRUE); - - kmi = WM_keymap_add_item(keymap, "CLIP_OT_mode_set", TABKEY, KM_PRESS, KM_CTRL, 0); - RNA_enum_set(kmi->ptr, "mode", SC_MODE_DISTORTION); - RNA_boolean_set(kmi->ptr, "toggle", TRUE); + WM_keymap_add_menu(keymap, "CLIP_MT_select_mode", TABKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "CLIP_OT_solve_camera", SKEY, KM_PRESS, KM_SHIFT, 0); diff --git a/source/blender/makesrna/RNA_enum_types.h b/source/blender/makesrna/RNA_enum_types.h index a0614a9d82a..2fbee1e9e1a 100644 --- a/source/blender/makesrna/RNA_enum_types.h +++ b/source/blender/makesrna/RNA_enum_types.h @@ -127,6 +127,8 @@ extern EnumPropertyItem ramp_blend_items[]; extern EnumPropertyItem prop_dynamicpaint_type_items[]; +extern EnumPropertyItem clip_editor_mode_items[]; + struct bContext; struct PointerRNA; struct PropertyRNA; diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index d5bac7a8c26..4473a9ef0f6 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -118,6 +118,15 @@ EnumPropertyItem viewport_shade_items[] = { {0, NULL, 0, NULL, NULL} }; +EnumPropertyItem clip_editor_mode_items[] = { + {SC_MODE_TRACKING, "TRACKING", ICON_ANIM_DATA, "Tracking", "Show tracking and solving tools"}, + {SC_MODE_RECONSTRUCTION, "RECONSTRUCTION", ICON_SNAP_FACE, "Reconstruction", + "Show tracking/reconstruction tools"}, + {SC_MODE_DISTORTION, "DISTORTION", ICON_GRID, "Distortion", "Show distortion tools"}, + {SC_MODE_MASKEDIT, "MASKEDIT", ICON_MOD_MASK, "Mask editing", "Show mask editing tools"}, + {0, NULL, 0, NULL, NULL} +}; + #ifdef RNA_RUNTIME #include "DNA_anim_types.h" @@ -3011,15 +3020,6 @@ static void rna_def_space_clip(BlenderRNA *brna) StructRNA *srna; PropertyRNA *prop; - static EnumPropertyItem mode_items[] = { - {SC_MODE_TRACKING, "TRACKING", ICON_ANIM_DATA, "Tracking", "Show tracking and solving tools"}, - {SC_MODE_RECONSTRUCTION, "RECONSTRUCTION", ICON_SNAP_FACE, "Reconstruction", - "Show tracking/reconstruction tools"}, - {SC_MODE_DISTORTION, "DISTORTION", ICON_GRID, "Distortion", "Show distortion tools"}, - {SC_MODE_MASKEDIT, "MASKEDIT", ICON_MOD_MASK, "Mask editing", "Show mask editing tools"}, - {0, NULL, 0, NULL, NULL} - }; - static EnumPropertyItem view_items[] = { {SC_VIEW_CLIP, "CLIP", ICON_SEQUENCE, "Clip", "Show editing clip preview"}, {SC_VIEW_GRAPH, "GRAPH", ICON_IPO, "Graph", "Show graph view for active element"}, @@ -3086,7 +3086,7 @@ static void rna_def_space_clip(BlenderRNA *brna) /* mode */ prop = RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "mode"); - RNA_def_property_enum_items(prop, mode_items); + RNA_def_property_enum_items(prop, clip_editor_mode_items); RNA_def_property_ui_text(prop, "Mode", "Editing context being displayed"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_CLIP, "rna_SpaceClipEditor_clip_mode_update");