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:
parent
5d6b695f00
commit
b973911fee
|
@ -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")
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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) */
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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 ------------------------------------------------ */
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue