From 5e1470d1b3eb219bfabfab6cb524421fef8cec3d Mon Sep 17 00:00:00 2001 From: Christoph Lendenfeld Date: Thu, 4 May 2023 14:10:27 +0200 Subject: [PATCH] Animation: Clean up "Key" menu in Graph Editor * remove "Keyframe" label from the Key menu * "Jump To Keyframe" -> "Jump to Selected" * added a new menu "Density" with Decimate, Sample and Clean operators * removed the "Clean Channels" entry. It does the same as the "Clean" operator but also removes channels IF the remaining keys are at the default value. The feature is still available in the redo panel * Split the slider operators out by functionality * Move Euler filter to Channel menu * Remove "Add F-Curve modifier" from Key menu (it already is in the Channel menu) * Move Bake/Unbake Curve functions to Channel menu * Move "Bake Sound to FCurves" to Channel menu Pull Request: https://projects.blender.org/blender/blender/pulls/106113 --- scripts/startup/bl_ui/space_graph.py | 95 +++++++++++++++++++--------- 1 file changed, 64 insertions(+), 31 deletions(-) diff --git a/scripts/startup/bl_ui/space_graph.py b/scripts/startup/bl_ui/space_graph.py index 79d39731bfe..e6981a5897b 100644 --- a/scripts/startup/bl_ui/space_graph.py +++ b/scripts/startup/bl_ui/space_graph.py @@ -196,10 +196,11 @@ class GRAPH_MT_channel(Menu): def draw(self, context): layout = self.layout - + operator_context = layout.operator_context layout.operator_context = 'INVOKE_REGION_CHANNELS' layout.operator("anim.channels_delete") + if context.space_data.mode == 'DRIVERS': layout.operator("graph.driver_delete_invalid") @@ -215,7 +216,10 @@ class GRAPH_MT_channel(Menu): layout.separator() layout.operator("anim.channels_editable_toggle") layout.operator_menu_enum("graph.extrapolation_type", "type", text="Extrapolation Mode") - layout.operator_menu_enum("graph.fmodifier_add", "type", text="Add F-Curve Modifier").only_active = False + # To get it to display the hotkey. + layout.operator_context = operator_context + layout.operator_menu_enum("graph.fmodifier_add", "type").only_active = False + layout.operator_context = 'INVOKE_REGION_CHANNELS' layout.separator() layout.operator("graph.hide", text="Hide Selected Curves").unselected = False @@ -232,16 +236,61 @@ class GRAPH_MT_channel(Menu): layout.separator() layout.operator("anim.channels_fcurves_enable") + layout.separator() + layout.operator("graph.bake") + layout.operator("graph.unbake") + layout.operator("graph.sound_bake") + + layout.separator() + layout.operator("graph.euler_filter", text="Discontinuity (Euler) Filter") + layout.separator() layout.operator("anim.channels_view_selected") +class GRAPH_MT_key_density(Menu): + bl_label = "Density" + + def draw(self, _context): + from bl_ui_utils.layout import operator_context + layout = self.layout + layout.operator("graph.decimate", text="Decimate (Ratio)").mode = 'RATIO' + # Using the modal operation doesn't make sense for this variant + # as we do not have a modal mode for it, so just execute it. + with operator_context(layout, 'EXEC_REGION_WIN'): + layout.operator("graph.decimate", text="Decimate (Allowed Change)").mode = 'ERROR' + layout.operator("graph.sample") + + layout.separator() + layout.operator("graph.clean").channels = False + + +class GRAPH_MT_key_blending(Menu): + bl_label = "Blend" + + def draw(self, _context): + layout = self.layout + layout.operator_context = "INVOKE_DEFAULT" + layout.operator("graph.breakdown", text="Breakdown") + layout.operator("graph.blend_to_neighbor", text="Blend to Neighbor") + layout.operator("graph.blend_to_default", text="Blend to Default Value") + layout.operator("graph.ease", text="Ease") + + +class GRAPH_MT_key_smoothing(Menu): + bl_label = "Smooth" + + def draw(self, _context): + layout = self.layout + layout.operator_context = "INVOKE_DEFAULT" + layout.operator("graph.gaussian_smooth", text="Smooth (Gaussian)") + layout.operator("graph.smooth", text="Smooth (Legacy)") + + class GRAPH_MT_key(Menu): bl_label = "Key" def draw(self, _context): - from bl_ui_utils.layout import operator_context - layout = self.layout layout.menu("GRAPH_MT_key_transform", text="Transform") @@ -249,19 +298,15 @@ class GRAPH_MT_key(Menu): layout.operator_menu_enum("graph.mirror", "type", text="Mirror") layout.separator() - layout.operator_menu_enum("graph.keyframe_insert", "type") - layout.operator_menu_enum("graph.fmodifier_add", "type").only_active = False - layout.operator("graph.sound_bake") + layout.operator("graph.frame_jump", text="Jump to Selected") layout.separator() - layout.operator("graph.frame_jump") - - layout.separator() - layout.operator("graph.copy") - layout.operator("graph.paste") + layout.operator_menu_enum("graph.keyframe_insert", "type", text="Insert") + layout.operator("graph.copy", text="Copy") + layout.operator("graph.paste", text="Paste") layout.operator("graph.paste", text="Paste Flipped").flipped = True layout.operator("graph.duplicate_move") - layout.operator("graph.delete") + layout.operator("graph.delete", text="Delete") layout.separator() layout.operator_menu_enum("graph.handle_type", "type", text="Handle Type") @@ -270,24 +315,9 @@ class GRAPH_MT_key(Menu): layout.separator() - layout.operator("graph.decimate", text="Decimate (Ratio)").mode = 'RATIO' - - # Using the modal operation doesn't make sense for this variant - # as we do not have a modal mode for it, so just execute it. - with operator_context(layout, 'EXEC_REGION_WIN'): - layout.operator("graph.decimate", text="Decimate (Allowed Change)").mode = 'ERROR' - - layout.menu("GRAPH_MT_slider", text="Slider Operators") - - layout.operator("graph.clean").channels = False - layout.operator("graph.clean", text="Clean Channels").channels = True - layout.operator("graph.smooth") - layout.operator("graph.sample") - layout.operator("graph.bake") - layout.operator("graph.unbake") - - layout.separator() - layout.operator("graph.euler_filter", text="Discontinuity (Euler) Filter") + layout.menu("GRAPH_MT_key_density") + layout.menu("GRAPH_MT_key_blending") + layout.menu("GRAPH_MT_key_smoothing") class GRAPH_MT_key_transform(Menu): @@ -468,8 +498,11 @@ classes = ( GRAPH_MT_marker, GRAPH_MT_channel, GRAPH_MT_key, + GRAPH_MT_key_density, GRAPH_MT_key_transform, GRAPH_MT_key_snap, + GRAPH_MT_key_smoothing, + GRAPH_MT_key_blending, GRAPH_MT_slider, GRAPH_MT_delete, GRAPH_MT_context_menu,