1 # SPDX-FileCopyrightText: 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
3 # SPDX-License-Identifier: GPL-3.0-or-later
5 from operator
import attrgetter
9 from .utils
.doc
import doc_brief
, doc_description
, doc_idname
, doc_name
12 class POWER_SEQUENCER_OT_trim_left_or_right_handles(bpy
.types
.Operator
):
14 Trims or extends the handle closest to the time cursor for all selected strips.
16 If you keep the Shift key down, the edit will ripple through the timeline.
17 Auto selects sequences under the time cursor when you don't have a selection
21 "name": doc_name(__qualname__
),
23 "description": doc_description(__doc__
),
26 {"type": "K", "value": "PRESS", "alt": True},
27 {"side": "RIGHT", "ripple": False},
31 {"type": "K", "value": "PRESS", "alt": True, "shift": True},
32 {"side": "RIGHT", "ripple": True},
33 "Smart Snap Right With Ripple",
36 {"type": "K", "value": "PRESS", "ctrl": True},
37 {"side": "LEFT", "ripple": False},
41 {"type": "K", "value": "PRESS", "ctrl": True, "shift": True},
42 {"side": "LEFT", "ripple": True},
43 "Smart Snap Left With Ripple",
46 "keymap": "Sequencer",
48 bl_idname
= doc_idname(__qualname__
)
49 bl_label
= doc
["name"]
50 bl_description
= doc_brief(doc
["description"])
51 bl_options
= {"REGISTER", "UNDO"}
53 side
: bpy
.props
.EnumProperty(
54 items
=[("LEFT", "Left", "Left side"), ("RIGHT", "Right", "Right side")],
56 description
="Handle side to use for the snap",
59 ripple
: bpy
.props
.BoolProperty(name
="Ripple", default
=False)
62 def poll(cls
, context
):
63 return context
.sequences
65 def execute(self
, context
):
66 frame_current
= context
.scene
.frame_current
68 # Only select sequences under the time cursor
69 sequences
= context
.selected_sequences
if context
.selected_sequences
else context
.sequences
71 s
.select
= s
.frame_final_start
<= frame_current
and s
.frame_final_end
>= frame_current
72 sequences
= [s
for s
in sequences
if s
.select
]
77 if self
.side
== "LEFT":
78 s
.select_left_handle
= True
79 if self
.side
== "RIGHT":
80 s
.select_right_handle
= True
82 # If trimming from the left, we need to save the start frame before trimming
83 ripple_start_frame
= 0
84 if self
.ripple
and self
.side
== "LEFT":
85 ripple_start_frame
= min(
86 sequences
, key
=attrgetter("frame_final_start")
89 bpy
.ops
.sequencer
.snap(frame
=frame_current
)
91 s
.select_right_handle
= False
92 s
.select_left_handle
= False
94 if self
.ripple
and sequences
:
95 if self
.side
== "RIGHT":
96 ripple_start_frame
= max(
97 sequences
, key
=attrgetter("frame_final_end")
99 bpy
.ops
.power_sequencer
.gap_remove(frame
=ripple_start_frame
)
101 bpy
.ops
.power_sequencer
.gap_remove(frame
=ripple_start_frame
)