-
Notifications
You must be signed in to change notification settings - Fork 11
/
__init__.py
1510 lines (1330 loc) · 64.6 KB
/
__init__.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
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# ##### BEGIN GPL LICENSE BLOCK #####
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# ##### END GPL LICENSE BLOCK #####
import os
import bpy
import gpu
import math
from bpy_extras.io_utils import ImportHelper
from bpy.app.handlers import persistent
from gpu_extras.batch import batch_for_shader
from bpy.types import Menu
from . import cuts
from . import fades
from . import grabs
from . import markers
from . import parenting
from . import shortcuts
from . import snaps
from . import tags
from . import threepoint
from . import timeline
from . import zoom
from . import vseqf
from . import vu_meter
bl_info = {
"name": "VSE Quick Functions",
"description": "Improves functionality of the sequencer by adding new menus and functions for snapping, adding fades, zooming, sequence parenting, ripple editing, playback speed, and more.",
"author": "Hudson Barkley (Snu/snuq/Aritodo)",
"version": (4, 0, 2),
"blender": (4, 0, 0),
"location": "Sequencer Panels; Sequencer Menus; Sequencer S, F, Shift-F, Z, Ctrl-P, Shift-P, Alt-M, Alt-K Shortcuts",
"wiki_url": "https://github.com/snuq/VSEQF",
"tracker_url": "https://github.com/snuq/VSEQF/issues",
"category": "Sequencer"
}
from .addon_updater import Updater as updater
updater.addon = "vseqf"
from . import addon_updater_ops
vseqf_draw_handler = None
vu_meter_draw_handler = None
frame_step_handler = None
continuous_handler = None
classes = []
classes = classes + [cuts.VSEQFCut, cuts.VSEQFQuickCutsMenu, cuts.VSEQF_PT_QuickCutsPanel, cuts.VSEQFDelete,
cuts.VSEQFDeleteConfirm, cuts.VSEQFDeleteConfirmMenu, cuts.VSEQFDeleteRippleConfirm,
cuts.VSEQFDeleteRippleConfirmMenu]
classes = classes + [fades.VSEQFModalFades, fades.VSEQF_PT_QuickFadesPanel, fades.VSEQFQuickFadesMenu,
fades.VSEQFQuickFadesSet, fades.VSEQFQuickFadesClear, fades.VSEQFQuickFadesCross,
fades.VSEQFModalVolumeDraw, fades.VSEQF_PT_QuickFadesStripPanel]
classes = classes + [grabs.VSEQFContextMenu, grabs.VSEQFContextCursor, grabs.VSEQFContextMarker, grabs.VSEQFContextNone,
grabs.VSEQFContextSequence, grabs.VSEQFDoubleUndo, grabs.VSEQFContextSequenceLeft,
grabs.VSEQFContextSequenceRight, grabs.VSEQFGrab, grabs.VSEQFGrabAdd, grabs.VSEQFSelectGrab]
classes = classes + [markers.VSEQF_PT_QuickMarkersPanel, markers.VSEQF_UL_QuickMarkerPresetList,
markers.VSEQF_UL_QuickMarkerList, markers.VSEQFQuickMarkerDelete, markers.VSEQFQuickMarkerMove,
markers.VSEQFQuickMarkerRename, markers.VSEQFQuickMarkerJump, markers.VSEQFQuickMarkersMenu,
markers.VSEQFQuickMarkersPlace, markers.VSEQFQuickMarkersRemovePreset,
markers.VSEQFQuickMarkersAddPreset, markers.VSEQFMarkerPreset]
classes = classes + [parenting.VSEQF_PT_Parenting, parenting.VSEQFQuickParentsMenu, parenting.VSEQFQuickParents,
parenting.VSEQFQuickParentsClear]
classes = classes + [snaps.VSEQFQuickSnapsMenu, snaps.VSEQFQuickSnaps]
classes = classes + [shortcuts.VSEQFQuickShortcutsNudge, shortcuts.VSEQFQuickShortcutsSpeed,
shortcuts.VSEQFQuickShortcutsSkip, shortcuts.VSEQFQuickShortcutsResetPlay]
classes = classes + [tags.VSEQFQuickTagsMenu, tags.VSEQF_PT_QuickTagsPanel, tags.VSEQF_UL_QuickTagListAll,
tags.VSEQF_UL_QuickTagList, tags.VSEQFQuickTagsClear, tags.VSEQFQuickTagsSelect,
tags.VSEQFQuickTagsRemoveFrom, tags.VSEQFQuickTagsRemove, tags.VSEQFQuickTagsStripMarkerMenu,
tags.VSEQFQuickTagsAdd, tags.VSEQFQuickTagsAddActive, tags.VSEQFTags, tags.VSEQFQuickTagsAddMarker,
tags.VSEQFQuickTagsRemoveMarker]
classes = classes + [threepoint.VSEQF_PT_ThreePointBrowserPanel, threepoint.VSEQFThreePointImportToClip,
threepoint.VSEQF_PT_ThreePointPanel, threepoint.VSEQFThreePointImport,
threepoint.VSEQFThreePointOperator, threepoint.VSEQFQuick3PointValues]
classes = classes + [timeline.VSEQFMeta, timeline.VSEQFMetaExit, timeline.VSEQFQuickTimeline,
timeline.VSEQFQuickTimelineMenu]
classes = classes + [zoom.VSEQFQuickZoomsMenu, zoom.VSEQFQuickZoomPresetMenu, zoom.VSEQFQuickZoomPreset,
zoom.VSEQFClearZooms, zoom.VSEQFRemoveZoom, zoom.VSEQFAddZoom, zoom.VSEQFQuickZooms,
zoom.VSEQFZoomPreset]
classes = classes + [vu_meter.VUMeterCheckClipping]
#Menu draw functions
def draw_quickzoom_menu(self, context):
"""Draws the submenu for the QuickZoom shortcuts, placed in the sequencer view menu"""
del context
layout = self.layout
layout.menu('VSEQF_MT_quickzooms_menu', text="Quick Zoom")
def draw_quickmarker_menu(self, context):
"""Draws the submenu for the QuickMarker presets, placed in the sequencer markers menu"""
layout = self.layout
if len(context.scene.vseqf.marker_presets) > 0:
layout.menu('VSEQF_MT_quickmarkers_menu', text="Quick Markers")
def draw_quicksettings_menu(self, context):
"""Draws the general settings menu for QuickContinuous related functions"""
del context
layout = self.layout
layout.menu('VSEQF_MT_settings_menu', text="Quick Functions Settings")
def draw_follow_header(self, context):
layout = self.layout
scene = context.scene
if context.space_data.view_type != 'PREVIEW':
layout.prop(scene.vseqf, 'follow', text='Follow Cursor', toggle=True)
def draw_timeline_menu(self, context):
layout = self.layout
if context.sequences and context.scene.sequence_editor and len(context.sequences) > 0:
layout.menu('VSEQF_MT_quicktimeline_menu', text='Timeline')
def start_follow(_, context):
if context.scene.vseqf.follow:
bpy.ops.vseqf.follow('INVOKE_DEFAULT')
class VSEQFFollow(bpy.types.Operator):
"""Modal operator that will center on the play cursor while running."""
bl_idname = "vseqf.follow"
bl_label = "Center the playcursor"
region = None
view = None
cursor_target = 0
animation_playing_last = False
skip_first_click = True
_timer = None
def modal(self, context, event):
view = self.view
if not context.scene.vseqf.follow:
return {'CANCELLED'}
if context.screen.is_animation_playing and not self.animation_playing_last:
self.recalculate_target(context)
if event.type == 'LEFTMOUSE' and context.screen.is_animation_playing:
if self.skip_first_click:
self.skip_first_click = False
else:
old_x = self.view.view_to_region(context.scene.frame_current, 0, clip=False)[0]
new_x = event.mouse_region_x
delta_x = new_x - old_x
self.cursor_target = self.cursor_target + delta_x
if event.type == 'TIMER' and context.screen.is_animation_playing and not context.screen.is_scrubbing:
cursor_location = view.view_to_region(context.scene.frame_current, 0, clip=False)[0]
if cursor_location != 12000:
offset = (self.cursor_target - cursor_location)
with bpy.context.temp_override(region=self.region, view2d=self.view):
bpy.ops.view2d.pan(deltax=-offset)
self.animation_playing_last = context.screen.is_animation_playing
return {'PASS_THROUGH'}
def invoke(self, context, event):
del event
self.animation_playing_last = context.screen.is_animation_playing
if context.screen.is_animation_playing:
#Need to put this in to prevent blender from changing cursor position when the click that STARTED this is caught
self.skip_first_click = True
else:
self.skip_first_click = False
area = context.area
for region in area.regions:
if region.type == 'WINDOW':
self.region = region
self.view = region.view2d
if self.region is None or self.view is None:
return {'CANCELLED'}
if context.screen.is_animation_playing:
self.recalculate_target(context)
self._timer = context.window_manager.event_timer_add(time_step=0.25, window=context.window)
context.window_manager.modal_handler_add(self)
return {'RUNNING_MODAL'}
def recalculate_target(self, context):
cursor_location = self.view.view_to_region(context.scene.frame_current, 0, clip=True)[0]
if cursor_location == 12000:
self.cursor_target = int(round(self.region.width / 4))
else:
self.cursor_target = cursor_location
class VSEQF_PT_CompactEdit(bpy.types.Panel):
"""Panel for displaying QuickList"""
bl_label = "Edit Strip Compact"
bl_space_type = 'SEQUENCE_EDITOR'
bl_region_type = 'UI'
bl_category = "Strip"
@classmethod
def poll(cls, context):
prefs = vseqf.get_prefs()
if not timeline.current_active(context):
return False
else:
return prefs.edit
def draw(self, context):
prefs = vseqf.get_prefs()
scene = context.scene
strip = timeline.current_active(context)
layout = self.layout
fps = vseqf.get_fps(scene)
row = layout.row()
split = row.split(factor=.8)
split.prop(strip, 'name', text="")
split.label(text="("+strip.type+")")
if strip.type == 'SOUND':
row = layout.row(align=True)
sub = row.row(align=True)
sub.active = not strip.mute
sub.prop(strip, 'volume', text='Volume')
row.prop(strip, "mute", toggle=True, icon_only=True)
row.prop(strip, "lock", toggle=True, icon_only=True)
row = layout.row()
row.prop(strip, "pan")
else:
row = layout.row(align=True)
sub = row.row(align=True)
sub.active = not strip.mute
split = sub.split(factor=.3, align=True)
split.prop(strip, "blend_type", text="")
split.prop(strip, "blend_alpha", text="Opacity", slider=True)
row.prop(strip, "mute", toggle=True, icon_only=True)
row.prop(strip, "lock", toggle=True, icon_only=True)
row = layout.row(align=True)
row.prop(strip, "color_saturation", text="Saturation")
row.prop(strip, "color_multiply", text="Multiply")
col = layout.column()
sub = col.column()
sub.enabled = not strip.lock
row = sub.row(align=True)
row.prop(strip, "channel")
row.prop(strip, "frame_start", text="Position: ("+vseqf.timecode_from_frames(strip.frame_final_start, fps)+")")
row = sub.row()
row.prop(strip, "frame_final_duration", text="Length: ("+vseqf.timecode_from_frames(strip.frame_final_duration, fps)+")")
row = sub.row(align=True)
row.prop(strip, "frame_offset_start", text="In Offset: ("+vseqf.timecode_from_frames(strip.frame_offset_start, fps)+")")
row.prop(strip, "frame_offset_end", text="Out Offset: ("+vseqf.timecode_from_frames(strip.frame_offset_end, fps)+")")
if prefs.fades:
#display info about the fade in and out of the current sequence
fade_curve = fades.get_fade_curve(context, strip, create=False)
if fade_curve:
fadein = fades.fades(fade_curve, strip, 'detect', 'in')
fadeout = fades.fades(fade_curve, strip, 'detect', 'out')
else:
fadein = 0
fadeout = 0
row = layout.row()
if fadein > 0:
row.label(text="Fadein: "+str(round(fadein))+" Frames")
else:
row.label(text="No Fadein Detected")
if fadeout > 0:
row.label(text="Fadeout: "+str(round(fadeout))+" Frames")
else:
row.label(text="No Fadeout Detected")
if prefs.parenting:
#display info about parenting relationships
sequence = timeline.current_active(context)
selected = context.selected_sequences
if len(scene.sequence_editor.meta_stack) > 0:
#inside a meta strip
sequencer = scene.sequence_editor.meta_stack[-1]
else:
#not inside a meta strip
sequencer = scene.sequence_editor
if hasattr(sequencer, 'sequences'):
sequences = sequencer.sequences
else:
sequences = []
children = parenting.find_children(sequence, sequences=sequences)
parent = parenting.find_parent(sequence)
box = layout.box()
#List relationships for active sequence
if parent:
row = box.row()
split = row.split(factor=.8, align=True)
split.label(text="Parent: "+parent.name)
split.operator('vseqf.quickparents', text='', icon="ARROW_LEFTRIGHT").action = 'select_parent'
split.operator('vseqf.quickparents', text='', icon="X").action = 'clear_parent'
if len(children) > 0:
row = box.row()
split = row.split(factor=.8, align=True)
subsplit = split.split(factor=.1)
subsplit.prop(scene.vseqf, 'expanded_children', icon="TRIA_DOWN" if scene.vseqf.expanded_children else "TRIA_RIGHT", icon_only=True, emboss=False)
subsplit.label(text="Children: "+children[0].name)
split.operator('vseqf.quickparents', text='', icon="ARROW_LEFTRIGHT").action = 'select_children'
split.operator('vseqf.quickparents', text='', icon="X").action = 'clear_children'
if scene.vseqf.expanded_children:
index = 1
while index < len(children):
row = box.row()
split = row.split(factor=.1)
split.label(text='')
split.label(text=children[index].name)
index = index + 1
row = box.row()
split = row.split()
split.operator('vseqf.quickparents', text='Set Active As Parent').action = 'add'
if len(selected) <= 1:
split.enabled = False
row.prop(scene.vseqf, 'children', toggle=True)
row = box.row()
row.prop(scene.vseqf, 'select_children', toggle=True)
row.prop(scene.vseqf, 'delete_children', toggle=True)
class VSEQFImport(bpy.types.Operator, ImportHelper):
"""Loads different types of files into the sequencer"""
bl_idname = 'vseqf.import_strip'
bl_label = 'Import Strip'
type: bpy.props.EnumProperty(
name="Import Type",
items=(('MOVIE', 'Movie', ""), ("IMAGE", "Image", "")),
default='MOVIE')
files: bpy.props.CollectionProperty(type=bpy.types.PropertyGroup)
relative_path: bpy.props.BoolProperty(
name="Relative Path",
description="Select the file relative to the blend file",
default=True)
start_frame: bpy.props.IntProperty(
name="Start Frame",
description="Start frame of the sequence strip",
default=0)
channel: bpy.props.IntProperty(
name="Channel",
description="Channel to place this strip into",
default=1)
replace_selection: bpy.props.BoolProperty(
name="Replace Selection",
description="Replace the current selection",
default=True)
sound: bpy.props.BoolProperty(
name="Sound",
description="Load sound with the movie",
default=True)
use_movie_framerate: bpy.props.BoolProperty(
name="Use Movie Framerate",
description="Use framerate from the movie to keep sound and video in sync",
default=False)
import_location: bpy.props.EnumProperty(
name="Import At",
description="Location to import strips at",
items=(("IMPORT_FRAME", "Import At Frame", ""), ("INSERT_FRAME", "Insert At Frame", ""), ("CUT_INSERT", "Cut And Insert At Frame", ""), ("END", "Import At End", "")),
default="IMPORT_FRAME")
autoparent: bpy.props.BoolProperty(
name="Auto-Parent A/V",
description="Automatically parent audio strips to their movie strips",
default=True)
use_placeholders: bpy.props.BoolProperty(
name="Use Placeholders",
description="Use placeholders for missing frames of the strip",
default=False)
length: bpy.props.IntProperty(
name="Image Length",
description="Length in frames to use for a single imported image",
default=30)
filename: bpy.props.StringProperty(
name="Filename",
description="File with path, used when files is not set."
)
frame = 0
to_parent = []
all_imported = []
def draw(self, context):
prefs = vseqf.get_prefs()
context.space_data.params.use_filter = True
context.space_data.params.use_filter_folder = True
if self.type == 'MOVIE':
context.space_data.params.use_filter_movie = True
layout = self.layout
layout.prop(self, 'relative_path')
layout.prop(self, 'start_frame')
layout.prop(self, 'channel')
layout.prop(self, 'import_location')
layout.prop(self, 'replace_selection')
layout.prop(self, 'sound')
layout.prop(self, 'use_movie_framerate')
if vseqf.parenting():
layout.prop(self, 'autoparent')
elif self.type == 'IMAGE':
context.space_data.params.use_filter_image = True
layout = self.layout
number_of_files = len(self.files)
row = layout.row()
row.prop(self, 'relative_path')
row = layout.row()
row.prop(self, 'start_frame')
row = layout.row()
if number_of_files > 1:
row.label(text="Length: "+str(number_of_files))
else:
row.prop(self, 'length')
row = layout.row()
row.prop(self, 'channel')
row = layout.row()
row.prop(self, 'import_location')
row = layout.row()
row.prop(self, 'replace_selection')
def invoke(self, context, event):
del event
sequencer = context.scene.sequence_editor
if not sequencer:
context.scene.sequence_editor_create()
if self.type == 'MOVIE':
self.bl_label = 'Add Movie Strip'
elif self.type == 'IMAGE':
self.bl_label = 'Add Image'
scene = context.scene
prefs = vseqf.get_prefs()
fps = vseqf.get_fps(context.scene)
self.length = int(fps * 4)
self.start_frame = context.scene.frame_current
if len(context.scene.sequence_editor.sequences_all) == 0:
self.use_movie_framerate = True
if prefs.parenting and scene.vseqf.children:
self.autoparent = scene.vseqf.autoparent
else:
self.autoparent = False
context.window_manager.fileselect_add(self)
return {'RUNNING_MODAL'}
def find_end_frame(self, sequences):
frame = 1
for sequence in sequences:
if sequence.frame_final_end > frame:
frame = sequence.frame_final_end
return frame
def execute(self, context):
sequencer = context.scene.sequence_editor
if not sequencer:
context.scene.sequence_editor_create()
bpy.ops.ed.undo_push()
old_snap_new_end = context.scene.vseqf.snap_new_end
context.scene.vseqf.snap_new_end = False #disable this so the continuous function doesnt do weird stuff while importing this
selected = timeline.current_selected(context)
active = timeline.current_active(context)
end_frame = self.find_end_frame(timeline.current_sequences(context))
dirname = os.path.dirname(bpy.path.abspath(self.filepath))
bpy.ops.sequencer.select_all(action='DESELECT')
if self.import_location in ['END', 'INSERT_FRAME', 'CUT_INSERT']:
self.frame = end_frame
else:
self.frame = self.start_frame
self.all_imported = []
self.to_parent = []
last_frame = context.scene.frame_current
if self.type == 'MOVIE':
if self.files:
#iterate through files and import them
for file in self.files:
filename = os.path.join(dirname, file.name)
self.import_movie(context, filename)
else:
self.import_movie(context, self.filename)
elif self.type == 'IMAGE':
files = [{"name": i.name} for i in self.files]
if len(self.files) > 1:
length = len(self.files)
else:
length = self.length
dirname = dirname + os.path.sep
bpy.ops.sequencer.image_strip_add(directory=dirname, files=files, relative_path=self.relative_path, frame_start=self.frame, frame_end=self.frame+length-1, channel=self.channel, replace_sel=True, use_placeholders=self.use_placeholders)
imported = timeline.current_selected(context)
self.all_imported.extend(imported)
if self.import_location == 'INSERT_FRAME' or self.import_location == 'CUT_INSERT':
new_end_frame = self.find_end_frame(timeline.current_sequences(context))
move_forward = new_end_frame - end_frame
move_back = end_frame - self.start_frame + move_forward
if self.import_location == 'INSERT_FRAME':
cut_type = 'INSERT_ONLY'
else:
cut_type = 'INSERT'
bpy.ops.vseqf.cut(type=cut_type, use_insert=True, insert=move_forward, use_all=True, all=True)
for sequence in self.all_imported:
sequence.frame_start = sequence.frame_start - move_back
if self.sound and self.autoparent:
#autoparent audio strips to video
for pair in self.to_parent:
movie, sound = pair
parenting.add_children(movie, [sound])
if not self.replace_selection:
bpy.ops.sequencer.select_all(action='DESELECT')
for sequence in selected:
sequence.select = True
if active:
context.scene.sequence_editor.active_strip = active
else:
bpy.ops.sequencer.select_all(action='DESELECT')
for sequence in self.all_imported:
sequence.select = True
for file in self.all_imported:
if file.frame_final_end > last_frame:
last_frame = file.frame_final_end
if old_snap_new_end:
context.scene.frame_current = last_frame
context.scene.vseqf.snap_new_end = old_snap_new_end
return {'FINISHED'}
def import_movie(self, context, filename):
bpy.ops.sequencer.movie_strip_add(filepath=filename, frame_start=self.frame, relative_path=self.relative_path, channel=self.channel, replace_sel=True, sound=self.sound, use_framerate=self.use_movie_framerate)
imported = timeline.current_selected(context)
if len(imported) > 1:
#this included a sound strip, maybe other types?
moviestrip = False
soundstrip = False
otherstrips = []
for seq in imported:
if seq.type == 'MOVIE':
moviestrip = seq
elif seq.type == 'SOUND':
soundstrip = seq
else:
otherstrips.append(seq)
if seq.frame_final_end > self.frame:
self.frame = seq.frame_final_end
if moviestrip and soundstrip:
#Attempt to fix a blender bug where it puts the audio strip too low - https://developer.blender.org/T64964
frame_start = moviestrip.frame_start
sound_channel = moviestrip.channel
moviestrip.channel = moviestrip.channel + 1
moviestrip.frame_start = frame_start
soundstrip.channel = sound_channel
self.to_parent.append([moviestrip, soundstrip])
else:
self.frame = imported[0].frame_final_end
self.all_imported.extend(imported)
#Functions related to continuous update
@persistent
def vseqf_continuous(scene):
if not bpy.context.scene or bpy.context.scene != scene:
return
if scene.vseqf.last_frame != scene.frame_current:
#scene frame was changed, assume nothing else happened
pass
#scene.vseqf.last_frame = scene.frame_current
else:
#something in the scene was changed by the user, figure out what
try:
sequencer = scene.sequence_editor
sequences = sequencer.sequences
except:
return
new_sequences = []
new_end = scene.frame_current
for sequence in sequences:
if sequence.new:
if not (sequence.type == 'META' or hasattr(sequence, 'input_1')):
new_sequences.append(sequence)
sequence.last_name = sequence.name
sequence.new = False
if sequence.last_name != sequence.name:
#sequence was renamed or duplicated, update parenting if the original doesnt still exist
if sequence.name and sequence.last_name:
original = False
for seq in sequences:
if seq.name == sequence.last_name:
#this sequence was just duplicated or copied, dont do anything
original = seq
break
if not original:
#sequence was renamed, update parenting
children = parenting.find_children(sequence.last_name, name=True, sequences=sequences)
for child in children:
child.parent = sequence.name
sequence.last_name = sequence.name
if new_sequences:
for sequence in new_sequences:
if sequence.type not in ['ADJUSTMENT', 'TEXT', 'COLOR', 'MULTICAM'] and sequence.frame_final_end > new_end:
new_end = sequence.frame_final_end
if vseqf.parenting() and scene.vseqf.autoparent:
#autoparent
if sequence.type == 'SOUND':
for seq in new_sequences:
if seq.type == 'MOVIE':
if seq.filepath == sequence.sound.filepath:
sequence.parent = seq.name
break
if scene.vseqf.snap_new_end:
scene.frame_current = new_end
def vseqf_draw():
context = bpy.context
prefs = vseqf.get_prefs()
colors = bpy.context.preferences.themes[0].user_interface
text_color = list(colors.wcol_text.text_sel)+[1]
active_strip = timeline.current_active(context)
if not active_strip:
return
region = bpy.context.region
view = region.view2d
#determine pixels per frame and channel
width = region.width
height = region.height
left, bottom = view.region_to_view(0, 0)
right, top = view.region_to_view(width, height)
if math.isnan(left):
return
shown_width = right - left
shown_height = top - bottom
channel_px = height / shown_height
frame_px = width / shown_width
min_x = 25
max_x = width - 10
fps = vseqf.get_fps()
draw_strip_info(context, active_strip, fps, frame_px, channel_px, min_x, max_x, view, width, text_color, prefs.fades, prefs.parenting, context.scene.vseqf.display_length, True)
selected = timeline.current_selected(context)
for strip in selected:
if strip != active_strip:
draw_strip_info(context, strip, fps, frame_px, channel_px, min_x, max_x, view, width, text_color, prefs.fades, prefs.parenting, False, True)
def draw_strip_info(context, active_strip, fps, frame_px, channel_px, min_x, max_x, view, width, text_color, show_fades, show_parenting, show_length, show_markers):
length = active_strip.frame_final_duration
active_x = active_strip.frame_final_start + (length / 2)
active_y = active_strip.channel + 0.5
active_left, active_top = view.view_to_region(active_strip.frame_final_start, active_strip.channel+1, clip=False)
active_right, active_bottom = view.view_to_region(active_strip.frame_final_end, active_strip.channel, clip=False)
active_pos_x, active_pos_y = view.view_to_region(active_x, active_strip.channel + 0.5, clip=False)
active_width = length * frame_px
fade_height = channel_px / 20
text_size = 10
strip_x = active_pos_x
if strip_x <= min_x and active_right > min_x:
strip_x = min_x
if strip_x >= max_x and active_left < max_x:
strip_x = max_x
#display length
if show_length:
length_timecode = vseqf.timecode_from_frames(length, fps)
vseqf.draw_text(strip_x - (strip_x / width) * 40, active_bottom + (channel_px * .5), text_size, '('+length_timecode+')', text_color)
#display fades
if show_fades and active_width > text_size * 6:
fade_curve = fades.get_fade_curve(context, active_strip, create=False)
if fade_curve:
fadein = int(fades.fades(fade_curve, active_strip, 'detect', 'in'))
if fadein and length:
fadein_percent = fadein / length
vseqf.draw_rect(active_left, active_top - (fade_height * 2), fadein_percent * active_width, fade_height, color=(.5, .5, 1, .75))
vseqf.draw_text(active_left, active_top, text_size, 'In: '+str(fadein), text_color)
fadeout = int(fades.fades(fade_curve, active_strip, 'detect', 'out'))
if fadeout and length:
fadeout_percent = fadeout / length
fadeout_width = active_width * fadeout_percent
vseqf.draw_rect(active_right - fadeout_width, active_top - (fade_height * 2), fadeout_width, fade_height, color=(.5, .5, 1, .75))
vseqf.draw_text(active_right - (text_size * 4), active_top, text_size, 'Out: '+str(fadeout), text_color)
if show_parenting:
children = parenting.find_children(active_strip)
parent = parenting.find_parent(active_strip)
if parent:
parent_x = parent.frame_final_start + (parent.frame_final_duration / 2)
parent_y = parent.channel + 0.5
distance_x = parent_x - active_x
distance_y = parent_y - active_y
pixel_x_distance = int(distance_x * frame_px)
pixel_y_distance = int(distance_y * channel_px)
pixel_x = active_pos_x + pixel_x_distance
pixel_y = active_pos_y + pixel_y_distance
vseqf.draw_line(strip_x, active_pos_y, pixel_x, pixel_y, color=(0.0, 0.0, 0.0, 0.5))
coords = []
for child in children:
child_x = child.frame_final_start + (child.frame_final_duration / 2)
child_y = child.channel + 0.5
distance_x = child_x - active_x
distance_y = child_y - active_y
pixel_x_distance = int(distance_x * frame_px)
pixel_y_distance = int(distance_y * channel_px)
pixel_x = active_pos_x + pixel_x_distance
pixel_y = active_pos_y + pixel_y_distance
coords.append((strip_x, active_pos_y))
coords.append((pixel_x, pixel_y))
shader = gpu.shader.from_builtin('UNIFORM_COLOR')
batch = batch_for_shader(shader, 'LINES', {'pos': coords})
shader.bind()
shader.uniform_float('color', (1.0, 1.0, 1.0, 0.2))
batch.draw(shader)
if show_markers:
for tag in active_strip.tags:
if tag.use_offset:
if active_strip.frame_offset_start < tag.offset <= active_strip.frame_final_duration + active_strip.frame_offset_start:
adjusted_offset = tag.offset - 1 - active_strip.frame_offset_start
left = active_left + (adjusted_offset * frame_px)
width = tag.length * frame_px
if left + width > active_right:
width = active_right - left
vseqf.draw_rect(left, active_bottom, width, channel_px, color=(tag.color[0], tag.color[1], tag.color[2], 0.33))
vseqf.draw_text(left, active_top, text_size, tag.text)
#Functions related to QuickSpeed
@persistent
def frame_step(scene):
"""Handler that skips frames when the speed step value is used, and updates the vu meter
Argument:
scene: the current Scene"""
vu_meter.vu_meter_calculate(scene)
if bpy.context.scene != scene:
return
if scene.vseqf.step in [-1, 0, 1]:
return
difference = scene.frame_current - scene.vseqf.last_frame
if difference == -1 or difference == 1:
frame_skip = int(difference * (abs(scene.vseqf.step) - 1))
bpy.ops.screen.frame_offset(delta=frame_skip)
scene.vseqf.last_frame = scene.frame_current
def draw_quickspeed_header(self, context):
"""Draws the speed selector in the sequencer header"""
layout = self.layout
scene = context.scene
self.layout_width = 30
layout.prop(scene.vseqf, 'step', text="Speed Step")
#Classes for settings and variables
class VSEQFSettingsMenu(Menu):
"""Pop-up menu for settings related to QuickContinuous"""
bl_idname = "VSEQF_MT_settings_menu"
bl_label = "Quick Settings"
def draw(self, context):
prefs = vseqf.get_prefs()
layout = self.layout
scene = context.scene
layout.prop(scene.vseqf, 'vu_show', text='Show VU Meter')
layout.prop(scene.vseqf, 'snap_cursor_to_edge')
layout.prop(scene.vseqf, 'snap_new_end')
layout.prop(scene.vseqf, 'shortcut_skip')
layout.prop(scene.vseqf, 'ripple_markers')
layout.prop(scene.vseqf, 'delete_confirm')
layout.prop(scene.vseqf, 'display_length')
if prefs.parenting:
layout.separator()
layout.label(text='QuickParenting Settings')
layout.separator()
layout.prop(scene.vseqf, 'children')
layout.prop(scene.vseqf, 'move_edges')
layout.prop(scene.vseqf, 'delete_children')
layout.prop(scene.vseqf, 'autoparent')
layout.prop(scene.vseqf, 'select_children')
class VSEQFSetting(bpy.types.PropertyGroup):
"""Property group to store most VSEQF settings. This will be assigned to scene.vseqf"""
vu: bpy.props.FloatProperty(
name="VU Meter Level",
default=-60)
vu_show: bpy.props.BoolProperty(
name="Enable VU Meter",
default=True)
vu_max: bpy.props.FloatProperty(
name="VU Meter Max Level",
default=-60)
zoom_presets: bpy.props.CollectionProperty(type=zoom.VSEQFZoomPreset)
last_frame: bpy.props.IntProperty(
name="Last Scene Frame",
default=1)
shortcut_skip: bpy.props.IntProperty(
name="Shortcut Skip Frames",
default=0,
min=0,
description="Number of frames that QuickShortcuts will skip with the numpad 7 and 8 keys. Setting to 0 will default to one second.")
follow: bpy.props.BoolProperty(
name="Cursor Following",
default=False,
update=start_follow)
children: bpy.props.BoolProperty(
name="Cut/Move Children",
default=True,
description="Automatically cut and move child strips along with a parent.")
autoparent: bpy.props.BoolProperty(
name="Auto-Parent New Audio To Video",
default=True,
description="Automatically parent audio strips to video when importing a movie with both types of strips.")
select_children: bpy.props.BoolProperty(
name="Auto-Select Children",
default=False,
description="Automatically select child strips when a parent is selected.")
expanded_children: bpy.props.BoolProperty(default=True)
delete_children: bpy.props.BoolProperty(
name="Auto-Delete Children",
default=False,
description="Automatically delete child strips when a parent is deleted.")
move_edges: bpy.props.BoolProperty(
name="Move Matching Child Edges",
default=True,
description="When a child edge matches a parent's, it will be moved when the parent's edge is moved.")
transition: bpy.props.EnumProperty(
name="Transition Type",
default="CROSS",
items=[("CROSS", "Crossfade", "", 1), ("WIPE", "Wipe", "", 2), ("GAMMA_CROSS", "Gamma Cross", "", 3)])
fade: bpy.props.IntProperty(
name="Fade Length",
default=10,
min=0,
description="Default Fade Length In Frames")
fadein: bpy.props.IntProperty(
name="Fade In Length",
default=0,
min=0,
description="Current Fade In Length In Frames")
fadeout: bpy.props.IntProperty(
name="Fade Out Length",
default=0,
min=0,
description="Current Fade Out Length In Frames")
current_marker_frame: bpy.props.IntProperty(
default=0)
marker_index: bpy.props.IntProperty(
name="Marker Display Index",
default=0)
marker_presets: bpy.props.CollectionProperty(
type=markers.VSEQFMarkerPreset)
expanded_markers: bpy.props.BoolProperty(default=True)
current_marker: bpy.props.StringProperty(
name="New Preset",
default='')
marker_deselect: bpy.props.BoolProperty(
name="Deselect New Markers",
default=True,
description="Markers added with this interface will not be selected when added")
ripple_markers: bpy.props.BoolProperty(
name="Ripple Edit Markers",
default=False,
description="When performing ripple edits, markers will be moved along with strips")
zoom_size: bpy.props.IntProperty(
name='Zoom Amount',
default=200,
min=1,
description="Zoom size in frames",
update=zoom.zoom_cursor)
step: bpy.props.IntProperty(
name="Frame Step",
default=0,
min=-4,
max=4)
skip_index: bpy.props.IntProperty(
default=0)
current_tag: bpy.props.StringProperty(
name="New Tag",
default='')
tags: bpy.props.CollectionProperty(type=tags.VSEQFTags)
selected_tags: bpy.props.CollectionProperty(type=tags.VSEQFTags)
show_selected_tags: bpy.props.BoolProperty(
name="Show Tags For All Selected Sequences",
default=False)
tag_index: bpy.props.IntProperty(
name="Tag Display Index",
default=0)
strip_tag_index: bpy.props.IntProperty(
name="Strip Tag Display Index",
default=0)
quickcuts_insert: bpy.props.IntProperty(
name="Frames To Insert",
default=0,
min=0,
description='Number of frames to insert when performing an insert cut')
quickcuts_all: bpy.props.BoolProperty(
name='Cut All Sequences',
default=False,
description='Cut all sequences, regardless of selection (not including locked sequences)')
snap_new_end: bpy.props.BoolProperty(
name='Snap Cursor To End Of New Sequences',
default=False)
snap_cursor_to_edge: bpy.props.BoolProperty(
name='Snap Cursor When Dragging Edges',
default=False)
delete_confirm: bpy.props.BoolProperty(
name='Popup Confirm Strip Delete',
default=False)
display_length: bpy.props.BoolProperty(
name='Display Length Of Active Strip',
default=True)
class VSEQuickFunctionSettings(bpy.types.AddonPreferences):
"""Addon preferences for QuickFunctions, used to enable and disable features"""
bl_idname = __name__
parenting: bpy.props.BoolProperty(
name="Enable Quick Parenting",
default=True)
fades: bpy.props.BoolProperty(
name="Enable Quick Fades",
default=True)
markers: bpy.props.BoolProperty(
name="Enable Quick Markers",
default=True)
tags: bpy.props.BoolProperty(
name="Enable Quick Tags",
default=True)
cuts: bpy.props.BoolProperty(
name="Enable Quick Cuts",
default=True)
edit: bpy.props.BoolProperty(
name="Enable Compact Edit Panel",
default=False)
threepoint: bpy.props.BoolProperty(
name="Enable Quick Three Point",
default=True)
context_menu: bpy.props.BoolProperty(
name="Enable Right-Click Menus (In Left-Click Mode)",
default=True)
auto_check_update: bpy.props.BoolProperty(
name="Auto-check for Update",
description="If enabled, auto-check for updates using an interval",
default=False)
updater_interval_months: bpy.props.IntProperty(
name='Months',
description="Number of months between checking for updates",
default=0,
min=0)
updater_interval_days: bpy.props.IntProperty(
name='Days',
description="Number of days between checking for updates",
default=7,
min=0,
max=31)
updater_interval_hours: bpy.props.IntProperty(
name='Hours',
description="Number of hours between checking for updates",
default=0,
min=0,
max=23)
updater_interval_minutes: bpy.props.IntProperty(
name='Minutes',
description="Number of minutes between checking for updates",
default=0,
min=0,
max=59)
def draw(self, context):
layout = self.layout
layout.prop(self, "parenting")
layout.prop(self, "fades")
layout.prop(self, "markers")