From 6f3400ca521e84b1b627f2b5a53835d73e3ed2ea Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Wed, 2 May 2012 17:33:48 +0000 Subject: [PATCH] Clip editor: cleanup of View menu - do not show operators which doesn't make sense in dopesheet/curve view --- release/scripts/startup/bl_ui/space_clip.py | 33 ++++++++++--------- source/blender/editors/include/ED_clip.h | 3 ++ .../blender/editors/space_clip/clip_editor.c | 11 +++++++ .../editors/space_clip/clip_graph_ops.c | 6 +--- source/blender/editors/space_clip/clip_ops.c | 14 ++++---- 5 files changed, 39 insertions(+), 28 deletions(-) diff --git a/release/scripts/startup/bl_ui/space_clip.py b/release/scripts/startup/bl_ui/space_clip.py index 0b96ec772c8..e2fa67e3873 100644 --- a/release/scripts/startup/bl_ui/space_clip.py +++ b/release/scripts/startup/bl_ui/space_clip.py @@ -776,27 +776,28 @@ class CLIP_MT_view(Menu): layout = self.layout sc = context.space_data - layout.prop(sc, "show_seconds") - 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.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") diff --git a/source/blender/editors/include/ED_clip.h b/source/blender/editors/include/ED_clip.h index db6d9bbd013..03e7bd62a2c 100644 --- a/source/blender/editors/include/ED_clip.h +++ b/source/blender/editors/include/ED_clip.h @@ -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); diff --git a/source/blender/editors/space_clip/clip_editor.c b/source/blender/editors/space_clip/clip_editor.c index 443cb8f7ef4..c5c5628abb9 100644 --- a/source/blender/editors/space_clip/clip_editor.c +++ b/source/blender/editors/space_clip/clip_editor.c @@ -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); diff --git a/source/blender/editors/space_clip/clip_graph_ops.c b/source/blender/editors/space_clip/clip_graph_ops.c index 03557a0b264..905aa2d11d4 100644 --- a/source/blender/editors/space_clip/clip_graph_ops.c +++ b/source/blender/editors/space_clip/clip_graph_ops.c @@ -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; diff --git a/source/blender/editors/space_clip/clip_ops.c b/source/blender/editors/space_clip/clip_ops.c index 2bfc7a1dec8..133c807a7ff 100644 --- a/source/blender/editors/space_clip/clip_ops.c +++ b/source/blender/editors/space_clip/clip_ops.c @@ -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 *********************/