Anim Editors: "View Frame" Operator - Code Cleanups/Reshuffling + NLA/Timeline Support

* 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
This commit is contained in:
Joshua Leung 2016-04-17 03:44:10 +12:00
parent 5d6b695f00
commit b973911fee
8 changed files with 88 additions and 21 deletions

View 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")

View 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()

View 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;
}

View 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;
}

View 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) */

View 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);

View 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 ------------------------------------------------ */

View 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);
}