From 364b6b29ff2ea19a31fdfc8e08b75ce0d46df40b Mon Sep 17 00:00:00 2001 From: Antony Riakiotakis Date: Mon, 13 Apr 2015 14:30:17 +0200 Subject: New operator for action and graph editor that centers around current scene frame, bound to numberpad zero. --- source/blender/editors/space_action/action_edit.c | 25 +++++++++++++++++++++- .../blender/editors/space_action/action_intern.h | 1 + source/blender/editors/space_action/action_ops.c | 5 ++++- 3 files changed, 29 insertions(+), 2 deletions(-) (limited to 'source/blender/editors/space_action') diff --git a/source/blender/editors/space_action/action_edit.c b/source/blender/editors/space_action/action_edit.c index 4b8ddacb418..d83137d4cb0 100644 --- a/source/blender/editors/space_action/action_edit.c +++ b/source/blender/editors/space_action/action_edit.c @@ -425,7 +425,15 @@ static int actkeys_viewsel_exec(bContext *C, wmOperator *UNUSED(op)) /* only selected */ 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); + UI_view2d_center_frame(C, smooth_viewtx); + + return OPERATOR_FINISHED; +} + void ACTION_OT_view_all(wmOperatorType *ot) { /* identifiers */ @@ -456,6 +464,21 @@ void ACTION_OT_view_selected(wmOperatorType *ot) ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } +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... */ + + /* flags */ + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; +} + /* ************************************************************************** */ /* GENERAL STUFF */ diff --git a/source/blender/editors/space_action/action_intern.h b/source/blender/editors/space_action/action_intern.h index 9f9b15c3c26..17f1f404225 100644 --- a/source/blender/editors/space_action/action_intern.h +++ b/source/blender/editors/space_action/action_intern.h @@ -77,6 +77,7 @@ enum eActKeys_ColumnSelect_Mode { void ACTION_OT_previewrange_set(struct wmOperatorType *ot); void ACTION_OT_view_all(struct wmOperatorType *ot); void ACTION_OT_view_selected(struct wmOperatorType *ot); +void ACTION_OT_view_frame(struct wmOperatorType *ot); void ACTION_OT_copy(struct wmOperatorType *ot); void ACTION_OT_paste(struct wmOperatorType *ot); diff --git a/source/blender/editors/space_action/action_ops.c b/source/blender/editors/space_action/action_ops.c index 47a120007a5..59b147c6f6c 100644 --- a/source/blender/editors/space_action/action_ops.c +++ b/source/blender/editors/space_action/action_ops.c @@ -91,7 +91,8 @@ void action_operatortypes(void) WM_operatortype_append(ACTION_OT_previewrange_set); WM_operatortype_append(ACTION_OT_view_all); WM_operatortype_append(ACTION_OT_view_selected); - + WM_operatortype_append(ACTION_OT_view_frame); + WM_operatortype_append(ACTION_OT_markers_make_local); } @@ -228,6 +229,8 @@ static void action_keymap_keyframes(wmKeyConfig *keyconf, wmKeyMap *keymap) WM_keymap_add_item(keymap, "ACTION_OT_view_all", HOMEKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "ACTION_OT_view_all", NDOF_BUTTON_FIT, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "ACTION_OT_view_selected", PADPERIOD, KM_PRESS, 0, 0); + WM_keymap_add_item(keymap, "ACTION_OT_view_frame", PAD0, KM_PRESS, 0, 0); + /* animation module */ /* channels list -- cgit v1.2.3