diff options
author | Alexander Gavrilov <angavrilov@gmail.com> | 2021-05-03 00:03:00 +0300 |
---|---|---|
committer | Alexander Gavrilov <angavrilov@gmail.com> | 2021-11-24 15:58:32 +0300 |
commit | 5d59b38605d61b2aeabfa1cb572b5a0d9158424b (patch) | |
tree | 82b0a19eb0e5dd7290ae81c10427082576d8dfb5 /release | |
parent | 057cb7e5e77bcf932882292a774156b5d8c90ab4 (diff) |
Animation: allow manually setting the intended playback range for actions.
Some operations, e.g. adding a new action strip to NLA, require
knowing the active frame range of an action. However, currently it
can only be deduced by scanning the keyframes of the curves within
it. This is not ideal if e.g. curves are staggered for overlap.
As suggested by Nathan Vegdahl in comments to T54724, this patch adds
Action properties that allow manually specifying its active frame range.
The settings are exposed via a panel in the Dopesheet and Action Editor.
When enabled, the range is highlighted in the background using a striped
fill to distinguish it from the solid filled regular playback range.
When set, the frame range is used when adding or updating NLA tracks,
and by add-ons using `Action.frame_range`, e.g. FBX exporter.
Differential Revision: https://developer.blender.org/D11803
Diffstat (limited to 'release')
-rw-r--r-- | release/scripts/startup/bl_ui/space_dopesheet.py | 32 | ||||
-rw-r--r-- | release/scripts/startup/bl_ui/space_nla.py | 17 |
2 files changed, 49 insertions, 0 deletions
diff --git a/release/scripts/startup/bl_ui/space_dopesheet.py b/release/scripts/startup/bl_ui/space_dopesheet.py index 9b8f1cfeb0d..6e5eba7b734 100644 --- a/release/scripts/startup/bl_ui/space_dopesheet.py +++ b/release/scripts/startup/bl_ui/space_dopesheet.py @@ -539,6 +539,37 @@ class DOPESHEET_MT_key_transform(Menu): layout.operator("transform.transform", text="Scale").mode = 'TIME_SCALE' +class DopesheetActionPanelBase: + bl_region_type = 'UI' + bl_label = "Action" + + @classmethod + def draw_generic_panel(cls, context, layout, action): + layout.label(text=action.name, icon='ACTION') + + layout.prop(action, "use_frame_range") + + col = layout.column() + col.active = action.use_frame_range + + row = col.row(align=True) + row.prop(action, "frame_start", text="Start") + row.prop(action, "frame_end", text="End") + + +class DOPESHEET_PT_action(DopesheetActionPanelBase, Panel): + bl_space_type = 'DOPESHEET_EDITOR' + bl_category = "Item" + + @classmethod + def poll(cls, context): + return bool(context.selected_visible_actions) + + def draw(self, context): + action = context.selected_visible_actions[0] + self.draw_generic_panel(context, self.layout, action) + + ####################################### # Grease Pencil Editing @@ -792,6 +823,7 @@ classes = ( DOPESHEET_MT_snap_pie, DOPESHEET_MT_view_pie, DOPESHEET_PT_filters, + DOPESHEET_PT_action, DOPESHEET_PT_gpencil_mode, DOPESHEET_PT_gpencil_layer_masks, DOPESHEET_PT_gpencil_layer_transform, diff --git a/release/scripts/startup/bl_ui/space_nla.py b/release/scripts/startup/bl_ui/space_nla.py index 9507d8296a9..62c02799a9f 100644 --- a/release/scripts/startup/bl_ui/space_nla.py +++ b/release/scripts/startup/bl_ui/space_nla.py @@ -22,6 +22,7 @@ from bpy.types import Header, Menu, Panel from bpy.app.translations import contexts as i18n_contexts from bl_ui.space_dopesheet import ( DopesheetFilterPopoverBase, + DopesheetActionPanelBase, dopesheet_filter, ) @@ -66,6 +67,21 @@ class NLA_PT_filters(DopesheetFilterPopoverBase, Panel): DopesheetFilterPopoverBase.draw_standard_filters(context, layout) +class NLA_PT_action(DopesheetActionPanelBase, Panel): + bl_space_type = 'NLA_EDITOR' + bl_category = "Strip" + bl_options = {'DEFAULT_CLOSED'} + + @classmethod + def poll(cls, context): + strip = context.active_nla_strip + return strip and strip.type == 'CLIP' and strip.action + + def draw(self, context): + action = context.active_nla_strip.action + self.draw_generic_panel(context, self.layout, action) + + class NLA_MT_editor_menus(Menu): bl_idname = "NLA_MT_editor_menus" bl_label = "" @@ -316,6 +332,7 @@ classes = ( NLA_MT_context_menu, NLA_MT_channel_context_menu, NLA_PT_filters, + NLA_PT_action, ) if __name__ == "__main__": # only for live edit. |