Context: implement an active_action property that returns a single action.

Although e.g. in the dopesheet there is no specific concept of
active action, displaying panels requires singling out one action
reference. It is more efficient and clearer to implement this
natively in the context rather than using selected_visible_actions[0].

- In the Action Editor the action is taken from the header.
- In the Dope Sheet the first selected action is chosen, because
  there is no concept of an active channel or keyframe.
- In the Graph Editor the action associated with the active curve
  is used, which should also be associated with the active vertex.
  This case may be different from selected_visible_actions[0].

Differential Revision: https://developer.blender.org/D15412
This commit is contained in:
2022-07-10 12:28:44 +03:00
parent 935b7a6f65
commit cd21022b78
2 changed files with 40 additions and 18 deletions

View File

@@ -567,10 +567,10 @@ class DOPESHEET_PT_action(DopesheetActionPanelBase, Panel):
@classmethod
def poll(cls, context):
return bool(context.selected_visible_actions)
return bool(context.active_action)
def draw(self, context):
action = context.selected_visible_actions[0]
action = context.active_action
self.draw_generic_panel(context, self.layout, action)