Clip editor: cleanup of View menu - do not show operators which doesn't make sense...
authorSergey Sharybin <sergey.vfx@gmail.com>
Wed, 2 May 2012 17:33:48 +0000 (17:33 +0000)
committerSergey Sharybin <sergey.vfx@gmail.com>
Wed, 2 May 2012 17:33:48 +0000 (17:33 +0000)
release/scripts/startup/bl_ui/space_clip.py
source/blender/editors/include/ED_clip.h
source/blender/editors/space_clip/clip_editor.c
source/blender/editors/space_clip/clip_graph_ops.c
source/blender/editors/space_clip/clip_ops.c

index 0b96ec772c83724f5441aa6c9baaa4aaddaecf1c..e2fa67e387353255a83fd4c1a9fba2049c851cea 100644 (file)
@@ -776,27 +776,28 @@ class CLIP_MT_view(Menu):
         layout = self.layout
         sc = context.space_data
 
-        layout.prop(sc, "show_seconds")
-        layout.separator()
-
-        layout.operator("clip.properties", icon='MENU_PANEL')
-        layout.operator("clip.tools", icon='MENU_PANEL')
-        layout.separator()
+        if sc.view == 'CLIP':
+            layout.operator("clip.properties", icon='MENU_PANEL')
+            layout.operator("clip.tools", icon='MENU_PANEL')
+            layout.separator()
 
-        layout.operator("clip.view_selected")
-        layout.operator("clip.view_all")
+            layout.operator("clip.view_selected")
+            layout.operator("clip.view_all")
 
-        layout.separator()
-        layout.operator("clip.view_zoom_in")
-        layout.operator("clip.view_zoom_out")
+            layout.separator()
+            layout.operator("clip.view_zoom_in")
+            layout.operator("clip.view_zoom_out")
 
-        layout.separator()
+            layout.separator()
 
-        ratios = ((1, 8), (1, 4), (1, 2), (1, 1), (2, 1), (4, 1), (8, 1))
+            ratios = ((1, 8), (1, 4), (1, 2), (1, 1), (2, 1), (4, 1), (8, 1))
 
-        for a, b in ratios:
-            text = "Zoom %d:%d" % (a, b)
-            layout.operator("clip.view_zoom_ratio", text=text).ratio = a / b
+            for a, b in ratios:
+                text = "Zoom %d:%d" % (a, b)
+                layout.operator("clip.view_zoom_ratio", text=text).ratio = a / b
+        else:
+            layout.prop(sc, "show_seconds")
+            layout.separator()
 
         layout.separator()
         layout.operator("screen.area_dupli")
index db6d9bbd0138a10ccc2fb6dbd64422f8a526e3c5..03e7bd62a2c0776958697d8263c5d5d67f6406a8 100644 (file)
@@ -42,6 +42,9 @@ struct wmEvent;
 
 /* clip_editor.c */
 int ED_space_clip_poll(struct bContext *C);
+
+int ED_space_clip_view_clip_poll(struct bContext *C);
+
 int ED_space_clip_tracking_poll(struct bContext *C);
 int ED_space_clip_tracking_size_poll(struct bContext *C);
 int ED_space_clip_tracking_frame_poll(struct bContext *C);
index 443cb8f7ef414225662d7a4451f98d14d8a8d9a1..c5c5628abb9d67c5e0924d037559312e2339a98b 100644 (file)
@@ -73,6 +73,17 @@ int ED_space_clip_poll(bContext *C)
        return FALSE;
 }
 
+int ED_space_clip_view_clip_poll(bContext *C)
+{
+       SpaceClip *sc = CTX_wm_space_clip(C);
+
+       if (sc && sc->clip) {
+               return sc->view == SC_VIEW_CLIP;
+       }
+
+       return FALSE;
+}
+
 int ED_space_clip_tracking_poll(bContext *C)
 {
        SpaceClip *sc= CTX_wm_space_clip(C);
index 03557a0b2641a88ac58f89feb9a08f2121a2ea48..905aa2d11d4f0959b1d4926f688e44083d9b3eb8 100644 (file)
@@ -66,11 +66,7 @@ static int ED_space_clip_graph_poll(bContext *C)
        if (ED_space_clip_tracking_poll(C)) {
                SpaceClip *sc = CTX_wm_space_clip(C);
 
-               if (sc->view == SC_VIEW_GRAPH) {
-                       ARegion *ar = CTX_wm_region(C);
-
-                       return ar->regiontype == RGN_TYPE_PREVIEW;
-               }
+               return sc->view == SC_VIEW_GRAPH;
        }
 
        return FALSE;
index 2bfc7a1dec8100b3005daf670485138bd6b8181b..133c807a7ff624892e14ca4b55295ab209d43987 100644 (file)
@@ -408,7 +408,7 @@ void CLIP_OT_view_pan(wmOperatorType *ot)
        ot->invoke = view_pan_invoke;
        ot->modal = view_pan_modal;
        ot->cancel = view_pan_cancel;
-       ot->poll = ED_space_clip_poll;
+       ot->poll = ED_space_clip_view_clip_poll;
 
        /* flags */
        ot->flag = OPTYPE_BLOCKING;
@@ -534,7 +534,7 @@ void CLIP_OT_view_zoom(wmOperatorType *ot)
        ot->invoke = view_zoom_invoke;
        ot->modal = view_zoom_modal;
        ot->cancel = view_zoom_cancel;
-       ot->poll = ED_space_clip_poll;
+       ot->poll = ED_space_clip_view_clip_poll;
 
        /* flags */
        ot->flag = OPTYPE_BLOCKING|OPTYPE_GRAB_POINTER;
@@ -580,7 +580,7 @@ void CLIP_OT_view_zoom_in(wmOperatorType *ot)
        /* api callbacks */
        ot->exec = view_zoom_in_exec;
        ot->invoke = view_zoom_in_invoke;
-       ot->poll = ED_space_clip_poll;
+       ot->poll = ED_space_clip_view_clip_poll;
 
        /* properties */
        RNA_def_float_vector(ot->srna, "location", 2, NULL, -FLT_MAX, FLT_MAX, "Location", "Cursor location in screen coordinates", -10.0f, 10.0f);
@@ -620,7 +620,7 @@ void CLIP_OT_view_zoom_out(wmOperatorType *ot)
        /* api callbacks */
        ot->exec = view_zoom_out_exec;
        ot->invoke = view_zoom_out_invoke;
-       ot->poll = ED_space_clip_poll;
+       ot->poll = ED_space_clip_view_clip_poll;
 
        /* properties */
        RNA_def_float_vector(ot->srna, "location", 2, NULL, -FLT_MAX, FLT_MAX, "Location", "Cursor location in normalised (0.0-1.0) coordinates", -10.0f, 10.0f);
@@ -652,7 +652,7 @@ void CLIP_OT_view_zoom_ratio(wmOperatorType *ot)
 
        /* api callbacks */
        ot->exec = view_zoom_ratio_exec;
-       ot->poll = ED_space_clip_poll;
+       ot->poll = ED_space_clip_view_clip_poll;
 
        /* properties */
        RNA_def_float(ot->srna, "ratio", 0.0f, 0.0f, FLT_MAX,
@@ -719,7 +719,7 @@ void CLIP_OT_view_all(wmOperatorType *ot)
 
        /* api callbacks */
        ot->exec = view_all_exec;
-       ot->poll = ED_space_clip_poll;
+       ot->poll = ED_space_clip_view_clip_poll;
 
        /* properties */
        RNA_def_boolean(ot->srna, "fit_view", 0, "Fit View", "Fit frame to the viewport");
@@ -749,7 +749,7 @@ void CLIP_OT_view_selected(wmOperatorType *ot)
 
        /* api callbacks */
        ot->exec = view_selected_exec;
-       ot->poll = ED_space_clip_poll;
+       ot->poll = ED_space_clip_view_clip_poll;
 }
 
 /********************** change frame operator *********************/