Fix #126896: Shape Key Editor can't browse actions
The new Action selector (51fd355c01) avoids the need to use
`space_data.action` in the dope sheet (that attribute was a bit of a
hack; the new Action selector was made to avoid that). It failed to take
the dope sheet's shape key mode into account properly, though. This is
now fixed.
Pull Request: https://projects.blender.org/blender/blender/pulls/127177
This commit is contained in:
@@ -306,20 +306,24 @@ class DOPESHEET_HT_editor_buttons:
|
||||
panel="DOPESHEET_PT_proportional_edit",
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def _draw_action_selector(context, layout):
|
||||
layout.template_action(context.object, new="action.new", unlink="action.unlink")
|
||||
@classmethod
|
||||
def _draw_action_selector(cls, context, layout):
|
||||
animated_id = cls._get_animated_id(context)
|
||||
if not animated_id:
|
||||
return
|
||||
|
||||
layout.template_action(animated_id, new="action.new", unlink="action.unlink")
|
||||
|
||||
if not context.preferences.experimental.use_animation_baklava:
|
||||
return
|
||||
|
||||
adt = context.object and context.object.animation_data
|
||||
adt = animated_id and animated_id.animation_data
|
||||
if not adt or not adt.action or not adt.action.is_action_layered:
|
||||
return
|
||||
|
||||
# Store the animated ID in the context, so that the new/unlink operators
|
||||
# have access to it.
|
||||
layout.context_pointer_set("animated_id", context.object)
|
||||
layout.context_pointer_set("animated_id", animated_id)
|
||||
layout.template_search(
|
||||
adt, "action_slot",
|
||||
adt, "action_slots",
|
||||
@@ -327,6 +331,18 @@ class DOPESHEET_HT_editor_buttons:
|
||||
unlink="anim.slot_unassign_from_id",
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def _get_animated_id(context):
|
||||
st = context.space_data
|
||||
match st.mode:
|
||||
case 'ACTION':
|
||||
return context.object
|
||||
case 'SHAPEKEY':
|
||||
return context.object.data and context.object.data.shape_keys
|
||||
case _:
|
||||
print("Dope Sheet mode '{}' not expected to have an Action selector".format(st.mode))
|
||||
return context.object
|
||||
|
||||
|
||||
class DOPESHEET_PT_snapping(Panel):
|
||||
bl_space_type = 'DOPESHEET_EDITOR'
|
||||
|
||||
Reference in New Issue
Block a user