1 # SPDX-FileCopyrightText: 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
3 # SPDX-License-Identifier: GPL-3.0-or-later
7 from .utils
.global_settings
import SequenceTypes
8 from .utils
.doc
import doc_name
, doc_idname
, doc_brief
, doc_description
11 class POWER_SEQUENCER_OT_crossfade_edit(bpy
.types
.Operator
):
13 *brief* Adjust the location of the crossfade between 2 strips
16 Selects the handles of both inputs of a crossfade strip's input and
17 calls the grab operator. Allows you to quickly change the location
18 of a fade transition between two strips.
22 "name": doc_name(__qualname__
),
23 "demo": "https://i.imgur.com/rCmLhg6.gif",
24 "description": doc_description(__doc__
),
26 "keymap": "Sequencer",
28 bl_idname
= doc_idname(__qualname__
)
29 bl_label
= doc
["name"]
30 bl_description
= doc_brief(doc
["description"])
31 bl_options
= {"REGISTER", "UNDO"}
33 crossfade_types
= ["CROSS", "GAMMA_CROSS"]
36 def poll(cls
, context
):
37 return context
.scene
.sequence_editor
.active_strip
and context
.selected_sequences
39 def execute(self
, context
):
40 active
= context
.scene
.sequence_editor
.active_strip
41 if active
.type not in self
.crossfade_types
:
42 effect
= self
.find_cross_effect(context
, active
)
45 active
= context
.scene
.sequence_editor
.active_strip
= effect
47 bpy
.ops
.sequencer
.select_all(action
="DESELECT")
49 active
.input_1
.select_right_handle
= True
50 active
.input_2
.select_left_handle
= True
51 active
.input_1
.select
= True
52 active
.input_2
.select
= True
53 bpy
.ops
.transform
.seq_slide("INVOKE_DEFAULT")
56 def find_cross_effect(self
, sequence
):
58 Takes a single strip and finds effect strips that use it as input
59 Returns the effect strip(s) found as a list, ordered by starting frame
60 Returns None if no effect was found
62 if sequence
.type not in SequenceTypes
.VIDEO
+ SequenceTypes
.IMAGE
:
65 effect_sequences
= (s
for s
in context
.sequences
if s
.type in SequenceTypes
.EFFECT
)
66 found_effect_strips
= []
67 for s
in effect_sequences
:
68 if s
.input_1
.name
== sequence
.name
:
69 found_effect_strips
.append(s
)
70 if s
.input_count
== 2:
71 if s
.input_2
.name
== sequence
.name
:
72 found_effect_strips
.append(s
)
73 for e
in found_effect_strips
:
74 if e
.type not in self
.crossfade_types
: