Anim Editors: "View Frame" Operator - Code Cleanups/Reshuffling + NLA/Timeline Support
authorJoshua Leung <aligorith@gmail.com>
Sat, 16 Apr 2016 15:44:10 +0000 (03:44 +1200)
committerJoshua Leung <aligorith@gmail.com>
Sat, 16 Apr 2016 15:44:10 +0000 (03:44 +1200)
* Reshuffled code for existing "View Frame" implementations, and removed leftover
  comment from some of the the copy-and-paste used to build it.
* Added support for this operator in the NLA and Timeline

release/scripts/startup/bl_ui/space_nla.py
release/scripts/startup/bl_ui/space_time.py
source/blender/editors/space_action/action_edit.c
source/blender/editors/space_graph/graph_edit.c
source/blender/editors/space_nla/nla_edit.c
source/blender/editors/space_nla/nla_intern.h
source/blender/editors/space_nla/nla_ops.c
source/blender/editors/space_time/time_ops.c

index c083907f0170606228eb7c5d83ef908cb2b145eb..64d3b4272608c758e99a99feb8ecc4496cdd0fd6 100644 (file)
@@ -86,6 +86,7 @@ class NLA_MT_view(Menu):
         layout.separator()
         layout.operator("nla.view_all")
         layout.operator("nla.view_selected")
+        layout.operator("nla.view_frame")
 
         layout.separator()
         layout.operator("screen.area_dupli")
index 4e3dc92d14241a9ddbf410cf3a9599115806403e..5b0075b41479ec024671c50485b3b355c4f47255 100644 (file)
@@ -130,7 +130,6 @@ class TIME_MT_view(Menu):
 
         layout.prop(st, "show_seconds")
         layout.prop(st, "show_locked_time")
-        layout.operator("time.view_all")
 
         layout.separator()
 
@@ -143,6 +142,11 @@ class TIME_MT_view(Menu):
 
         layout.separator()
 
+        layout.operator("time.view_all")
+        layout.operator("time.view_frame")
+
+        layout.separator()
+
         layout.operator("marker.camera_bind")
 
         layout.separator()
index 9cc138b2cc4e1ab6c3f4dc0660996f65b9671220..b69547b050697186c92ef1c6cea983411930fd61 100644 (file)
@@ -431,13 +431,7 @@ static int actkeys_viewsel_exec(bContext *C, wmOperator *UNUSED(op))
        return actkeys_viewall(C, true);
 }
 
-static int actkeys_view_frame_exec(bContext *C, wmOperator *op)
-{
-       const int smooth_viewtx = WM_operator_smooth_viewtx_get(op);
-       ANIM_center_frame(C, smooth_viewtx);
-
-       return OPERATOR_FINISHED;
-}
+/* ......... */
 
 void ACTION_OT_view_all(wmOperatorType *ot)
 {
@@ -469,17 +463,27 @@ void ACTION_OT_view_selected(wmOperatorType *ot)
        ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
 }
 
+/* ****************** View-All Operator ****************** */
+
+static int actkeys_view_frame_exec(bContext *C, wmOperator *op)
+{
+       const int smooth_viewtx = WM_operator_smooth_viewtx_get(op);
+       ANIM_center_frame(C, smooth_viewtx);
+       
+       return OPERATOR_FINISHED;
+}
+
 void ACTION_OT_view_frame(wmOperatorType *ot)
 {
        /* identifiers */
        ot->name = "View Frame";
        ot->idname = "ACTION_OT_view_frame";
        ot->description = "Reset viewable area to show range around current frame";
-
+       
        /* api callbacks */
        ot->exec = actkeys_view_frame_exec;
-       ot->poll = ED_operator_action_active; /* XXX: unchecked poll to get fsamples working too, but makes modifier damage trickier... */
-
+       ot->poll = ED_operator_action_active;
+       
        /* flags */
        ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
 }
index 19325962adc8dd8dee6ecb04b4b6d9ef7d0c42f0..e1cd1da3a25eddeb139be9a3fa3e4d434d48bbae 100644 (file)
@@ -265,13 +265,7 @@ static int graphkeys_view_selected_exec(bContext *C, wmOperator *op)
        return graphkeys_viewall(C, true, include_handles, smooth_viewtx);
 }
 
-static int graphkeys_view_frame_exec(bContext *C, wmOperator *op)
-{
-       const int smooth_viewtx = WM_operator_smooth_viewtx_get(op);
-       ANIM_center_frame(C, smooth_viewtx);
-       return OPERATOR_FINISHED;
-}
-
+/* ......... */
 
 void GRAPH_OT_view_all(wmOperatorType *ot)
 {
@@ -311,17 +305,26 @@ void GRAPH_OT_view_selected(wmOperatorType *ot)
                                   "Include handles of keyframes when calculating extents");
 }
 
+/* ********************** View Frame Operator ****************************** */
+
+static int graphkeys_view_frame_exec(bContext *C, wmOperator *op)
+{
+       const int smooth_viewtx = WM_operator_smooth_viewtx_get(op);
+       ANIM_center_frame(C, smooth_viewtx);
+       return OPERATOR_FINISHED;
+}
+
 void GRAPH_OT_view_frame(wmOperatorType *ot)
 {
        /* identifiers */
        ot->name = "View Frame";
        ot->idname = "GRAPH_OT_view_frame";
        ot->description = "Reset viewable area to show range around current frame";
-
+       
        /* api callbacks */
        ot->exec = graphkeys_view_frame_exec;
-       ot->poll = ED_operator_graphedit_active; /* XXX: unchecked poll to get fsamples working too, but makes modifier damage trickier... */
-
+       ot->poll = ED_operator_graphedit_active;
+       
        /* flags */
        ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
 }
index 02814e385c0aad262bef62ee299856b358abda90..baf87f3fee5a7a57fb3a17e976255f6db6d519df 100644 (file)
@@ -541,6 +541,30 @@ void NLA_OT_view_selected(wmOperatorType *ot)
        ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
 }
 
+/* *********************************************** */
+
+static int nlaedit_viewframe_exec(bContext *C, wmOperator *op)
+{
+       const int smooth_viewtx = WM_operator_smooth_viewtx_get(op);
+       ANIM_center_frame(C, smooth_viewtx);
+       return OPERATOR_FINISHED;
+}
+
+void NLA_OT_view_frame(wmOperatorType *ot)
+{
+       /* identifiers */
+       ot->name = "View Frame";
+       ot->idname = "NLA_OT_view_frame";
+       ot->description = "Reset viewable area to show range around current frame";
+       
+       /* api callbacks */
+       ot->exec = nlaedit_viewframe_exec;
+       ot->poll = ED_operator_nla_active;
+       
+       /* flags */
+       ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+}
+
 /* *********************************************** */
 /* NLA Editing Operations (Constructive/Destructive) */
 
index 344580c0d15e6bac265053d77e67adc0c20c0431..806fbe90ff20535f15a0cfbb07ff1e765c6cd76c 100644 (file)
@@ -94,6 +94,7 @@ void NLA_OT_previewrange_set(wmOperatorType *ot);
 
 void NLA_OT_view_all(wmOperatorType *ot);
 void NLA_OT_view_selected(wmOperatorType *ot);
+void NLA_OT_view_frame(wmOperatorType *ot);
 
 void NLA_OT_actionclip_add(wmOperatorType *ot);
 void NLA_OT_transition_add(wmOperatorType *ot);
index 98da10470f8e818cdf30104df7ff1b55e2d84227..386950ead3a919d4b20116d68e6c7046e0799a61 100644 (file)
@@ -130,6 +130,7 @@ void nla_operatortypes(void)
        /* view */
        WM_operatortype_append(NLA_OT_view_all);
        WM_operatortype_append(NLA_OT_view_selected);
+       WM_operatortype_append(NLA_OT_view_frame);
        
        WM_operatortype_append(NLA_OT_previewrange_set);
        
@@ -243,6 +244,7 @@ static void nla_keymap_main(wmKeyConfig *keyconf, wmKeyMap *keymap)
        WM_keymap_add_item(keymap, "NLA_OT_view_all", HOMEKEY, KM_PRESS, 0, 0);
        WM_keymap_add_item(keymap, "NLA_OT_view_all", NDOF_BUTTON_FIT, KM_PRESS, 0, 0);
        WM_keymap_add_item(keymap, "NLA_OT_view_selected", PADPERIOD, KM_PRESS, 0, 0);
+       WM_keymap_add_item(keymap, "NLA_OT_view_frame", PAD0, KM_PRESS, 0, 0);
        
        /* editing ------------------------------------------------ */
        
index e2e861fda38625e2e943d205b554f886f09466ae..35f17ee4f00d31923700fb68b203ec02183138f5 100644 (file)
@@ -39,6 +39,7 @@
 
 #include "BKE_context.h"
 
+#include "ED_anim_api.h"
 #include "ED_screen.h"
 
 #include "WM_api.h"
@@ -176,6 +177,31 @@ static void TIME_OT_view_all(wmOperatorType *ot)
        ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
 }
 
+/* ************************ View Frame Operator *******************************/
+
+static int time_view_frame_exec(bContext *C, wmOperator *op)
+{
+       const int smooth_viewtx = WM_operator_smooth_viewtx_get(op);
+       ANIM_center_frame(C, smooth_viewtx);
+       
+       return OPERATOR_FINISHED;
+}
+
+static void TIME_OT_view_frame(wmOperatorType *ot)
+{
+       /* identifiers */
+       ot->name = "View Frame";
+       ot->idname = "TIME_OT_view_frame";
+       ot->description = "Show the entire playable frame range";
+       
+       /* api callbacks */
+       ot->exec = time_view_frame_exec;
+       ot->poll = ED_operator_timeline_active;
+       
+       /* flags */
+       ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+}
+
 /* ************************** registration **********************************/
 
 void time_operatortypes(void)
@@ -183,6 +209,7 @@ void time_operatortypes(void)
        WM_operatortype_append(TIME_OT_start_frame_set);
        WM_operatortype_append(TIME_OT_end_frame_set);
        WM_operatortype_append(TIME_OT_view_all);
+       WM_operatortype_append(TIME_OT_view_frame);
 }
 
 void time_keymap(wmKeyConfig *keyconf)
@@ -193,5 +220,6 @@ void time_keymap(wmKeyConfig *keyconf)
        WM_keymap_add_item(keymap, "TIME_OT_end_frame_set", EKEY, KM_PRESS, 0, 0);
        WM_keymap_add_item(keymap, "TIME_OT_view_all", HOMEKEY, KM_PRESS, 0, 0);
        WM_keymap_add_item(keymap, "TIME_OT_view_all", NDOF_BUTTON_FIT, KM_PRESS, 0, 0);
+       WM_keymap_add_item(keymap, "TIME_OT_view_frame", PAD0, KM_PRESS, 0, 0);
 }