forked from GDQuest/blender-power-sequencer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvideo_editing_mouse.py
649 lines (530 loc) · 24.9 KB
/
video_editing_mouse.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
"""Video editing tools for Blender using the mouse"""
from math import floor, sqrt
import bpy
from bpy.props import BoolProperty, IntProperty, EnumProperty, FloatProperty, StringProperty, CollectionProperty
from .functions.sequences import find_effect_strips, get_frame_range
from operator import attrgetter
# import blf
def find_strips_mouse(frame=None, channel=None, select_linked=True):
"""
Finds a list of sequences to select based on the mouse position
or using the time cursor.
Args:
- frame: the frame the mouse or cursor is on
- channel: the channel the mouse is hovering
- select_linked: include the sequences linked in time if True
Returns the sequence(s) under the mouse cursor as a list
Returns an empty list if nothing found
"""
sequences = bpy.context.sequences
selection = []
for s in sequences:
if s.lock or (not s.channel == channel):
continue
if s.frame_final_start <= frame <= s.frame_final_end:
selection.append(s)
break
if select_linked and len(selection) > 0:
for s in sequences:
if s.channel == selection[0].channel or s.lock:
continue
if s.frame_final_start == selection[0].frame_final_start and s.frame_final_end == selection[0].frame_final_end:
selection.append(s)
return selection
def find_snap_candidate(frame=0):
"""
Finds and returns the best frame snap candidate around the frame
"""
closest_cut_frame = 1000000
for s in bpy.context.sequences:
start_to_frame = frame - s.frame_final_start
end_to_frame = frame - s.frame_final_end
distance_to_start = abs( start_to_frame )
distance_to_end = abs(end_to_frame)
smallest_distance = min(distance_to_start, distance_to_end)
if smallest_distance == distance_to_start:
snap_candidate = frame - start_to_frame
else:
snap_candidate = frame - end_to_frame
if abs(frame - snap_candidate) < abs(frame - closest_cut_frame):
closest_cut_frame = snap_candidate
return closest_cut_frame
class MouseCut(bpy.types.Operator):
"""Cuts, trims and remove gaps with mouse clicks"""
bl_idname = "power_sequencer.mouse_cut"
bl_label = "PS.Mouse cut strips"
bl_options = {'REGISTER', 'UNDO'}
select_mode = EnumProperty(
items=[('mouse', 'Mouse', 'Only select the strip hovered by the mouse'
), ('cursor', 'Time cursor',
'Select all of the strips the time cursor overlaps'),
('smart', 'Smart',
'Uses the selection if possible, else uses the other modes')],
name="Selection mode",
description=
"Cut only the strip under the mouse or all strips under the time cursor",
default='smart')
select_linked = BoolProperty(
name="Use linked time",
description=
"In mouse or smart mode, always cut linked strips if this is checked",
default=False)
remove_gaps = BoolProperty(
name="Remove gaps",
description="When trimming the sequences, remove gaps automatically",
default=True)
cut_gaps = BoolProperty(
name="Cut gaps",
description="If you click on a gap, remove it",
default=True)
auto_move_cursor = BoolProperty(
name="Auto move cursor",
description=
"When trimming the sequence, auto move the cursor if playback is active",
default=True)
cursor_offset = IntProperty(
name="Cursor trim offset",
description=
"On trim, during playback, offset the cursor to better see if the cut works",
default=12,
min=0)
threshold_trim_distance = IntProperty(
name="Tablet trim distance",
description="If you use a pen tablet, the trim will only happen past this distance",
default=6,
min=0)
use_pen_tablet = False
mouse_start_x, mouse_start_y = 0.0, 0.0
start_frame, start_channel = 0, 0
end_frame, end_channel = 0, 0
select_mouse, action_mouse = '', ''
cut_mode = ''
@classmethod
def poll(cls, context):
return context.sequences is not None
def invoke(self, context, event):
# Detect pen tablets
if event.pressure not in [0.0, 1.0]:
self.use_pen_tablet = True
self.mouse_start_x, self.mouse_start_y = event.mouse_region_x, event.mouse_region_y
frame_float, channel_float = context.region.view2d.region_to_view(
x=event.mouse_region_x,
y=event.mouse_region_y)
self.start_frame, self.start_channel = round(frame_float), floor(channel_float)
self.end_frame = self.start_frame
# Reverse keymaps if the user selects with the left mouse button
self.select_mouse = 'RIGHTMOUSE'
self.action_mouse = 'LEFTMOUSE'
if bpy.context.user_preferences.inputs.select_mouse == 'LEFT':
self.select_mouse = 'LEFTMOUSE'
self.action_mouse = 'RIGHTMOUSE'
bpy.context.scene.frame_current = self.start_frame
context.window_manager.modal_handler_add(self)
return {'RUNNING_MODAL'}
def modal(self, context, event):
# if event.type in {'LEFTMOUSE', 'RIGHTMOUSE'}:
# print('type: {!s}, value: {!s}'.format(event.type, event.value))
if event.type in {'ESC'}:
return {'CANCELLED'}
elif event.type == self.action_mouse and event.value == 'RELEASE':
self.select_mode = 'cursor' if event.shift else 'smart'
cursor_distance = abs(event.mouse_region_x - self.mouse_start_x)
if (self.use_pen_tablet and cursor_distance <= self.threshold_trim_distance) \
or self.start_frame == self.end_frame:
to_select = self.find_strips_to_cut()
bpy.ops.sequencer.select_all(action='DESELECT')
for s in to_select:
s.select = True
print(bpy.context.selected_sequences)
self.cut_strips_or_gap()
else:
to_select, to_delete = self.find_strips_to_trim()
trim_strips(self.start_frame, self.end_frame, self.select_mode, to_select, to_delete, self.remove_gaps)
return {'FINISHED'}
elif event.type == 'MOUSEMOVE':
x, y = context.region.view2d.region_to_view(
x=event.mouse_region_x,
y=event.mouse_region_y)
self.end_frame, self.end_channel = round(x), floor(y)
bpy.context.scene.frame_current = self.end_frame
return {'PASS_THROUGH'}
return {'RUNNING_MODAL'}
def find_strips_to_cut(self):
"""
Finds and Returns a list of strips to cut
"""
to_select = []
overlapping_strips = []
if self.select_mode == 'smart':
overlapping_strips = find_strips_mouse(self.start_frame, self.start_channel, self.select_linked)
to_select.extend(overlapping_strips)
if self.select_mode == 'cursor' or (not overlapping_strips and self.select_mode == 'smart'):
for s in bpy.context.sequences:
if s.lock:
continue
if s.frame_final_start <= self.start_frame <= s.frame_final_end:
to_select.append(s)
return to_select
def cut_strips_or_gap(self):
if self.cut_gaps and len(bpy.context.selected_sequences) == 0:
bpy.ops.sequencer.gap_remove(all=False)
else:
bpy.ops.sequencer.cut(frame=bpy.context.scene.frame_current, type='SOFT', side='BOTH')
def find_strips_to_trim(self):
"""
Finds and Returns two lists of strips to trim and strips to delete
"""
to_select, to_delete = [], []
overlapping_strips = []
trim_start, trim_end = min(self.start_frame, self.end_frame), max(self.start_frame, self.end_frame)
if self.select_mode == 'smart':
overlapping_strips = find_strips_mouse(trim_start, self.start_channel, self.select_linked)
to_select.extend(overlapping_strips)
if self.select_mode == 'cursor' or (not overlapping_strips and self.select_mode == 'smart'):
for s in bpy.context.sequences:
if s.lock:
continue
if trim_start <= s.frame_final_start and trim_end >= s.frame_final_end:
to_delete.append(s)
continue
if s.frame_final_start <= trim_start <= s.frame_final_end or \
s.frame_final_start <= trim_end <= s.frame_final_end:
to_select.append(s)
return to_select, to_delete
def trim_strips(start_frame, end_frame, select_mode, strips_to_trim=[], strips_to_delete=[], remove_gaps=True):
"""
Trims strips in the timeline between the start and end frame. The caller must pass strips to select
"""
trim_start = min(start_frame, end_frame)
trim_end = max(start_frame, end_frame)
# print('num of strips to del: {}'.format(len(strips_to_delete)))
for s in strips_to_trim:
if s.frame_final_start < trim_start and s.frame_final_end > trim_end:
bpy.ops.sequencer.select_all(action='DESELECT')
s.select = True
bpy.ops.sequencer.cut(frame=trim_start, type='SOFT', side='RIGHT')
bpy.ops.sequencer.cut(frame=trim_end, type='SOFT', side='LEFT')
strips_to_delete.append(bpy.context.selected_sequences[0])
continue
elif s.frame_final_start < trim_end and s.frame_final_end > trim_end:
s.frame_final_start = trim_end
elif s.frame_final_end > trim_start and s.frame_final_start < trim_start:
s.frame_final_end = trim_start
if strips_to_delete != []:
bpy.ops.sequencer.select_all(action='DESELECT')
for s in strips_to_delete:
s.select = True
bpy.ops.sequencer.delete()
if remove_gaps:
bpy.context.scene.frame_current = trim_end - 1
bpy.ops.sequencer.gap_remove()
bpy.context.scene.frame_current = trim_start
return {'FINISHED'}
class MouseTrim(bpy.types.Operator):
"""
Trims a frame range or a selection from a start to an end frame.
If there's no precise time range, auto trims based on the closest cut
Args:
- start_frame and end_frame (int) define the frame range to trim
"""
bl_idname = "power_sequencer.mouse_trim"
bl_label = "PS.Mouse trim strips"
bl_options = {'REGISTER', 'UNDO'}
select_mode = EnumProperty(
items=[('mouse', 'Mouse', 'Only select the strip hovered by the mouse'),
('cursor', 'Time cursor', 'Select all of the strips the time cursor overlaps'),
('smart', 'Smart', 'Uses the selection if possible, else uses the other modes')],
name="Selection mode",
description= "Auto-select the strip you click on or that the time cursor overlaps",
default='smart')
select_linked = BoolProperty(
name="Use linked time",
description= "If auto-select, cut linked strips if checked",
default=False)
remove_gaps = BoolProperty(
name="Remove gaps",
description="When trimming the sequences, remove gaps automatically",
default=True)
start_frame, end_frame = IntProperty(), IntProperty()
selection_override = CollectionProperty()
to_select = []
@classmethod
def poll(cls, context):
return context.sequences is not None
def invoke(self, context, event):
# if self.snap_to_closest_cut:
# self.start_frame = find_snap_candidate(self.start_frame)
to_select = []
if not self.start_frame or self.end_frame:
x, y = context.region.view2d.region_to_view(
x=event.mouse_region_x,
y=event.mouse_region_y)
frame, channel = round(x), floor(y)
mouse_clicked_strip = find_strips_mouse(frame, channel, self.select_linked)
if self.select_mode == 'smart' and mouse_clicked_strip:
self.select_mode = 'mouse'
else:
self.select_mode = 'cursor'
if self.select_mode == 'mouse':
if mouse_clicked_strip == []:
return {'CANCELLED'}
to_select.extend(mouse_clicked_strip)
if self.select_mode == 'cursor':
for s in bpy.context.sequences:
if s.frame_final_start <= frame <= s.frame_final_end:
to_select.append(s)
selection_start, selection_end = get_frame_range(to_select)
self.start_frame = frame
self.end_frame = selection_end if abs(frame - selection_end) <= abs(frame - selection_start) else selection_start
self.to_select = to_select
trim_strips(self.start_frame, self.end_frame, self.select_mode, self.to_select, remove_gaps=self.remove_gaps)
return {'FINISHED'}
def find_strips_in_range(start_frame, end_frame, sequences = None, find_overlapping = True):
"""
Returns strips which start and end within a certain frame range, or that overlap a certain frame range
Args:
- start_frame, the start of the frame range
- end_frame, the end of the frame range
- sequences (optional): only work with these sequences. If it doesn't receive any, the function works with all the sequences in the current context
- find_overlapping (optional): find and return a list of strips that overlap the frame range
Returns a tuple of two lists:
[0], strips entirely in the frame range
[1], strips that only overlap the frame range
"""
strips_in_range = []
strips_overlapping_range = []
if not sequences:
sequences = bpy.context.sequences
for s in sequences:
if start_frame <= s.frame_final_start <= end_frame:
if start_frame <= s.frame_final_end <= end_frame:
strips_in_range.append(s)
elif find_overlapping:
strips_overlapping_range.append(s)
elif find_overlapping and start_frame <= s.frame_final_end <= end_frame:
strips_overlapping_range.append(s)
if s.frame_final_start < start_frame and s.frame_final_end > end_frame:
strips_overlapping_range.append(s)
return strips_in_range, strips_overlapping_range
def find_closest_surrounding_cuts(frame=0):
"""
Returns a tuple of (left_cut_frame, right_cut_frame) of the two closest cuts surrounding a frame
Args:
- frame, find the closest cuts that surround this frame
"""
start_cut_frame, end_cut_frame = 1000000, 1000000
for s in bpy.context.sequences:
distance_to_start = abs(frame - s.frame_final_start)
distance_to_end = abs(frame - s.frame_final_end)
distance_to_start_cut_frame = abs(start_cut_frame - frame)
distance_to_end_cut_frame = abs(end_cut_frame - frame)
if s.frame_final_start < frame and \
distance_to_start < distance_to_start_cut_frame:
start_cut_frame = s.frame_final_start
if s.frame_final_end < frame and \
distance_to_end < distance_to_start_cut_frame:
start_cut_frame = s.frame_final_end
if s.frame_final_end > frame and \
distance_to_end < distance_to_end_cut_frame:
end_cut_frame = s.frame_final_end
if s.frame_final_start > frame and \
distance_to_start < distance_to_end_cut_frame:
end_cut_frame = s.frame_final_start
return start_cut_frame, end_cut_frame
# TODO: rewrite self.find_cut_and_handles_closest_to_mouse
# use find_snap_candidate? at least a similar approach
class GrabClosestHandleOrCut(bpy.types.Operator):
"""
Selects and grabs the strip handle or cut closest to the mouse cursor.
Hover near a cut and fire this tool to slide it.
"""
bl_idname = "power_sequencer.grab_closest_handle_or_cut"
bl_label = "PS.Grab closest handle or cut"
bl_options = {'REGISTER', 'UNDO'}
@classmethod
def poll(cls, context):
return context is not None
def invoke(self, context, event):
if not bpy.context.sequences:
return {'CANCELLED'}
sequencer = bpy.ops.sequencer
view2d = bpy.context.region.view2d
mouse_x, mouse_y = event.mouse_region_x, event.mouse_region_y
frame, channel = self.find_cut_and_handles_closest_to_mouse(mouse_x, mouse_y)
matching_sequences = []
for s in bpy.context.sequences:
if not s.channel == channel:
continue
if abs(s.frame_final_start - frame) <= 1 or abs(s.frame_final_end - frame) <= 1:
matching_sequences.append(s)
matching_count = len(matching_sequences)
sequencer.select_all(action='DESELECT')
if matching_count == 1:
sequence = matching_sequences[0]
sequence.select = True
if abs(sequence.frame_final_start - frame) <= 1:
sequence.select_left_handle = True
elif abs(sequence.frame_final_end - frame) <= 1:
sequence.select_right_handle = True
elif matching_count == 2:
cut_select_range = 40
sorted_sequences = sorted(matching_sequences, key=attrgetter('frame_final_start'))
first_sequence, second_sequence = sorted_sequences[0], sorted_sequences[1]
cut_x, _ = view2d.view_to_region(frame, channel)
if abs(mouse_x - cut_x) > cut_select_range:
if mouse_x < cut_x:
first_sequence.select = True
first_sequence.select_right_handle = True
else:
second_sequence.select = True
second_sequence.select_left_handle = True
else:
first_sequence.select = True
first_sequence.select_right_handle = True
second_sequence.select = True
second_sequence.select_left_handle = True
return bpy.ops.transform.seq_slide('INVOKE_DEFAULT')
def find_cut_and_handles_closest_to_mouse(self, mouse_x, mouse_y):
"""
takes the mouse's coordinates in the sequencer area and returns the two strips
who share the cut closest to the mouse, or the strip with the closest handle.
Use it to find the handle(s) to select with the grab on the fly operator
"""
view2d = bpy.context.region.view2d
closest_cut = (None, None)
distance_to_closest_cut = 1000000.0
for s in bpy.context.sequences:
channel_offset = s.channel + 0.5
start_x, start_y = view2d.view_to_region(s.frame_final_start, channel_offset)
end_x, end_y = view2d.view_to_region(s.frame_final_start, channel_offset)
distance_to_start = self.calculate_distance(start_x, start_y, mouse_x, mouse_y)
distance_to_end = self.calculate_distance(end_x, end_y, mouse_x, mouse_y)
if distance_to_start < distance_to_closest_cut:
closest_cut = (start_x, start_y)
distance_to_closest_cut = distance_to_start
if distance_to_end < distance_to_closest_cut:
closest_cut = (end_x, end_y)
distance_to_closest_cut = distance_to_end
closest_cut_local_coords = view2d.region_to_view(closest_cut[0], closest_cut[1])
frame, channel = round(closest_cut_local_coords[0]), floor(closest_cut_local_coords[1])
return frame, channel
def calculate_distance(self, x1, y1, x2, y2):
return sqrt((x2 - x1)**2 + (y2 - y1)**2)
class TrimToSurroundingCuts(bpy.types.Operator):
"""
Find the two closest cuts, trims and deletes all strips above in the range but leaves some margin. Removes the newly formed gap.
"""
bl_idname = "power_sequencer.trim_to_surrounding_cuts"
bl_label = "PS.Trim to surrounding cuts"
bl_options = {'REGISTER', 'UNDO'}
margin = FloatProperty(
name="Trim margin",
description=
"Margin to leave on either sides of the trim in seconds",
default=0.2,
min=0)
remove_gaps = BoolProperty(
name="Remove gaps",
description="When trimming the sequences, remove gaps automatically",
default=True)
@classmethod
def poll(cls, context):
return context is not None
def invoke(self, context, event):
if not bpy.context.sequences:
return {'CANCELLED'}
sequencer = bpy.ops.sequencer
time_cursor_start_frame = bpy.context.scene.frame_current
# Convert mouse position to frame, channel
x, y = context.region.view2d.region_to_view(
x=event.mouse_region_x,
y=event.mouse_region_y)
frame, channel = round(x), floor(y)
left_cut_frame, right_cut_frame = find_closest_surrounding_cuts(frame)
surrounding_cut_frames_duration = abs(left_cut_frame - right_cut_frame)
margin_frame = round(self.margin * bpy.context.scene.render.fps)
if surrounding_cut_frames_duration <= margin_frame * 2:
self.report({'WARNING'}, "The trim margin is larger than the gap \n Use snap trim or reduce the margin")
return {'CANCELLED'}
strips_to_delete, strips_to_trim = find_strips_in_range(left_cut_frame, right_cut_frame)
trim_start, trim_end = left_cut_frame + margin_frame, right_cut_frame - margin_frame
# print("start: {!s}, end: {!s}".format(left_cut_frame, right_cut_frame))
# for s in strips_to_trim:
# print(s.name)
for s in strips_to_trim:
# If the strip is larger than the range to trim cut it in three
if s.frame_final_start < trim_start and s.frame_final_end > trim_end:
sequencer.select_all(action='DESELECT')
s.select = True
sequencer.cut(frame=trim_start, type='SOFT', side='RIGHT')
sequencer.cut(frame=trim_end, type='SOFT', side='LEFT')
strips_to_delete.append(bpy.context.selected_sequences[0])
continue
if s.frame_final_start < trim_end and s.frame_final_end > trim_end:
s.frame_final_start = trim_end
elif s.frame_final_end > trim_start and s.frame_final_start < trim_start:
s.frame_final_end = trim_start
# Delete all sequences that are between the cuts
sequencer.select_all(action='DESELECT')
for s in strips_to_delete:
s.select = True
sequencer.delete()
if self.remove_gaps:
frame_to_remove_gap = right_cut_frame - 1 if frame == right_cut_frame else frame
# bpy.ops.anim.change_frame(frame_to_remove_gap)
bpy.context.scene.frame_current = frame_to_remove_gap
sequencer.gap_remove()
bpy.context.scene.frame_current = trim_start
return {'FINISHED'}
class MouseToggleMute(bpy.types.Operator):
"""Toggle mute a sequence as you click on it"""
bl_idname = "power_sequencer.mouse_toggle_mute"
bl_label = "PS.Toggle Mute with Mouse"
bl_options = {'REGISTER', 'UNDO'}
@classmethod
def poll(cls, context):
return context is not None
def invoke(self, context, event):
sequencer = bpy.ops.sequencer
# get current frame and channel the mouse hovers
x, y = context.region.view2d.region_to_view(
x=event.mouse_region_x,
y=event.mouse_region_y)
frame, channel = round(x), floor(y)
# Strip selection
sequencer.select_all(action='DESELECT')
to_select = find_strips_mouse(frame, channel)
if not to_select:
return {"CANCELLED"}
for s in to_select:
s.mute = not s.mute
return {"FINISHED"}
class EditCrossfade(bpy.types.Operator):
"""
Selects handles of a crossfade strip's input and calls the grab operator
"""
bl_idname = "power_sequencer.edit_crossfade"
bl_label = "PS.Edit crossfade"
bl_options = {'REGISTER', 'UNDO'}
def execute(self, context):
if not context.area.type == 'SEQUENCE_EDITOR':
self.report({'WARNING'}, "You need to be in the Video Sequence Editor to use this tool. \
Operation cancelled.")
return {'CANCELLED'}
active = bpy.context.scene.sequence_editor.active_strip
if active.type != "GAMMA_CROSS":
effect = find_effect_strips(active)
if effect is None:
self.report({'WARNING'},
"The active strip has to be a gamma cross for this tool to work. \
Operation cancelled.")
return {"CANCELLED"}
active = bpy.context.scene.sequence_editor.active_strip = effect[0]
bpy.ops.sequencer.select_all(action='DESELECT')
active.select = True
active.input_1.select_right_handle = True
active.input_2.select_left_handle = True
active.input_1.select = True
active.input_2.select = True
bpy.ops.transform.seq_slide('INVOKE_DEFAULT')
return {'FINISHED'}