Animation: Add "Frame Channel" operators #104523

Merged
Christoph Lendenfeld merged 27 commits from ChrisLend/blender:frame-channel-operator into main 2023-02-17 18:11:10 +01:00
6 changed files with 20 additions and 13 deletions
Showing only changes of commit 66d9dd510a - Show all commits

View File

@ -3508,6 +3508,9 @@ def km_animation_channels(params):
("anim.channels_ungroup", {"type": 'G', "value": 'PRESS', "ctrl": True, "alt": True}, None),
# Menus.
*_template_items_context_menu("DOPESHEET_MT_channel_context_menu", params.context_menu_event),
# View
("graph.view_channels", {"type": 'MIDDLEMOUSE', "value": 'PRESS', "alt": True}, None),
("graph.view_channels", {"type": 'NUMPAD_PERIOD', "value": 'PRESS'}, None),
])
return keymap

View File

@ -699,6 +699,9 @@ class DOPESHEET_MT_channel_context_menu(Menu):
layout.operator("anim.channels_group")
layout.operator("anim.channels_ungroup")
layout.separator()
layout.operator("graph.view_channels")
layout.separator()
layout.operator("anim.channels_editable_toggle")

View File

@ -204,9 +204,6 @@ class GRAPH_MT_channel(Menu):
def draw(self, context):
layout = self.layout
layout.separator()
layout.operator("graph.view_channel")
layout.operator_context = 'INVOKE_REGION_CHANNELS'
layout.operator("anim.channels_delete")
@ -241,6 +238,9 @@ class GRAPH_MT_channel(Menu):
layout.separator()
layout.operator("anim.channels_fcurves_enable")
layout.separator()
layout.operator("graph.view_channels")
class GRAPH_MT_key(Menu):
bl_label = "Key"
@ -455,9 +455,6 @@ class GRAPH_MT_channel_context_menu(Menu):
layout.operator("anim.channels_expand")
layout.operator("anim.channels_collapse")
layout.separator()
layout.operator("graph.view_channel")
layout.separator()
layout.operator_menu_enum("anim.channels_move", "direction", text="Move...")

View File

@ -101,7 +101,7 @@ void GRAPH_OT_previewrange_set(struct wmOperatorType *ot);
void GRAPH_OT_view_all(struct wmOperatorType *ot);
void GRAPH_OT_view_selected(struct wmOperatorType *ot);
void GRAPH_OT_view_frame(struct wmOperatorType *ot);
void GRAPH_OT_view_channel(struct wmOperatorType *ot);
void GRAPH_OT_view_channels(struct wmOperatorType *ot);
void GRAPH_OT_click_insert(struct wmOperatorType *ot);
void GRAPH_OT_keyframe_insert(struct wmOperatorType *ot);

View File

@ -423,7 +423,7 @@ void graphedit_operatortypes(void)
WM_operatortype_append(GRAPH_OT_view_all);
WM_operatortype_append(GRAPH_OT_view_selected);
WM_operatortype_append(GRAPH_OT_view_frame);
WM_operatortype_append(GRAPH_OT_view_channel);
WM_operatortype_append(GRAPH_OT_view_channels);
WM_operatortype_append(GRAPH_OT_ghost_curves_create);
WM_operatortype_append(GRAPH_OT_ghost_curves_clear);

View File

@ -444,21 +444,25 @@ static int graphkeys_view_channel_exec(bContext *C, wmOperator *op)
BLI_rctf_pad_y(&bounds, ac.region->winy, pad_bottom, pad_top);
const int smooth_viewtx = WM_operator_smooth_viewtx_get(op);
UI_view2d_smooth_view(C, ac.region, &bounds, smooth_viewtx);
LISTBASE_FOREACH (ARegion *, region, &ac.area->regionbase) {
if (region->regiontype == RGN_TYPE_WINDOW) {
UI_view2d_smooth_view(C, region, &bounds, smooth_viewtx);
}
}
return OPERATOR_FINISHED;
}
void GRAPH_OT_view_channel(wmOperatorType *ot)
void GRAPH_OT_view_channels(wmOperatorType *ot)
{
/* Identifiers */
ot->name = "Frame Channel";
ot->idname = "GRAPH_OT_view_channel";
ot->name = "Frame Selected Channels";
ot->idname = "GRAPH_OT_view_channels";
ot->description = "Reset viewable area to show the selected channels";
/* API callbacks */
ot->exec = graphkeys_view_channel_exec;
/* ot->poll = ED_operator_graphedit_active; */
ot->poll = ED_operator_graphedit_active;
ot->flag = 0;