Clip editor mode selection: show menu with modes on TAB
authorSergey Sharybin <sergey.vfx@gmail.com>
Thu, 12 Jul 2012 12:06:40 +0000 (12:06 +0000)
committerSergey Sharybin <sergey.vfx@gmail.com>
Thu, 12 Jul 2012 12:06:40 +0000 (12:06 +0000)
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
source/blender/editors/space_clip/clip_ops.c
source/blender/editors/space_clip/space_clip.c
source/blender/makesrna/RNA_enum_types.h
source/blender/makesrna/intern/rna_space.c

index a590a6cea94c8a6c43210d1f3aed7eae751751fc..d937837e5d1bdb25ef6301a834b23bdb02997e5b 100644 (file)
@@ -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"
 
index 948b6490331fa02b9066291a29781bf3024fa7fc..86d74ef4c78187935e283bc72336176d358bee62 100644 (file)
@@ -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 *********************/
index 13caf0b51fe9e12bd123e07208bb97fef4147c02..3623cd1d58b09c939cfe0946bb44721bcbe17222 100644 (file)
@@ -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);
 
index a0614a9d82a7cfef0118b27e8cfe9b2daa121c4b..2fbee1e9e1a78d17abfcaab3e0056d61c1d253dc 100644 (file)
@@ -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;
index d5bac7a8c26b284c1f1eb5ab79a10d9dc5344da9..4473a9ef0f6f46a98d43ad7d1e5c46028b09d076 100644 (file)
@@ -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");