Repository navigation
Expand file tree
/
Copy path__init__.py
More file actions
763 lines (664 loc) · 33.3 KB
/
Copy path__init__.py
File metadata and controls
763 lines (664 loc) · 33.3 KB
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
# ##### 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 shortcuts
from . import snaps
from . import tags
from . import threepoint
from . import timeline
from . import zoom
from . import vseqf
from . import vu_meter
from . import replace_menus
bl_info = {
"name": "VSE Quick Functions",
"description": "Improves functionality of the sequencer by adding new menus and functions for snapping, adding fades, zooming, ripple editing, playback speed, and more.",
"author": "Hudson Barkley (Snu/snuq/Aritodo)",
"version": (5, 1, 0),
"blender": (5, 1, 0),
"location": "Sequencer Panels; Sequencer Menus; Sequencer S, F, Shift-F, Z, Alt-M, Alt-K Shortcuts",
"wiki_url": "https://github.com/snuq/VSEQF",
"tracker_url": "https://github.com/snuq/VSEQF/issues",
"category": "Sequencer"
}
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.VSEQFContextStrip, grabs.VSEQFDoubleUndo, grabs.VSEQFContextStripLeft,
grabs.VSEQFContextStripRight, 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 + [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.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.strips and context.scene.sequence_editor and len(context.strips) > 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
#Functions related to continuous update
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, 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, 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_length, show_markers):
length = active_strip.duration
active_x = active_strip.left_handle + (length / 2)
active_y = active_strip.channel + 0.5
active_left, active_top = view.view_to_region(active_strip.left_handle, active_strip.channel+1, clip=False)
active_right, active_bottom = view.view_to_region(active_strip.right_handle, 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_markers:
for tag in active_strip.tags:
if tag.use_offset:
if active_strip.left_handle_offset < tag.offset <= active_strip.duration + active_strip.left_handle_offset:
adjusted_offset = tag.offset - 1 - active_strip.left_handle_offset
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, 'vu_left')
layout.prop(scene.vseqf, 'snap_cursor_to_edge')
layout.prop(scene.vseqf, 'shortcut_skip')
layout.prop(scene.vseqf, 'ripple_markers')
layout.prop(scene.vseqf, 'delete_confirm')
layout.prop(scene.vseqf, 'display_length')
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)
vu_left: bpy.props.BoolProperty(
name="Draw VU Meter On Left",
default=True)
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.")
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 Strips",
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 Strips',
default=False,
description='Cut all strips, regardless of selection (not including locked strips)')
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__
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)
def draw(self, context):
layout = self.layout
layout.prop(self, "fades")
layout.prop(self, "markers")
layout.prop(self, "tags")
layout.prop(self, "cuts")
layout.prop(self, "edit")
layout.prop(self, "threepoint")
layout.prop(self, "context_menu")
def remove_vu_draw_handler(add=False):
global vu_meter_draw_handler
if vu_meter_draw_handler:
try:
bpy.types.SpaceSequenceEditor.draw_handler_remove(vu_meter_draw_handler, 'WINDOW')
vu_meter_draw_handler = None
except:
pass
if add:
vu_meter_draw_handler = bpy.types.SpaceSequenceEditor.draw_handler_add(vu_meter.vu_meter_draw, (), 'WINDOW', 'POST_PIXEL')
def remove_frame_step_handler(add=False):
global frame_step_handler
handlers = bpy.app.handlers.frame_change_post
if frame_step_handler:
try:
handlers.remove(frame_step_handler)
frame_step_handler = None
except:
pass
if add:
frame_step_handler = handlers.append(frame_step)
#Register properties, operators, menus and shortcuts
classes = classes + [VSEQFSettingsMenu, VSEQFSetting, VSEQFFollow]
classes = classes + [replace_menus.SEQUENCER_MT_strip, replace_menus.SEQUENCER_MT_strip_transform, replace_menus.SEQUENCER_MT_add]
def register_keymaps():
#register standard keymaps
if bpy.context.window_manager.keyconfigs.addon:
keymap = bpy.context.window_manager.keyconfigs.addon.keymaps.new(name='Sequencer', space_type='SEQUENCE_EDITOR', region_type='WINDOW')
keymapitems = keymap.keymap_items
for keymapitem in keymapitems:
#Iterate through keymaps and delete old shortcuts
if (keymapitem.type == 'Z') | (keymapitem.type == 'F') | (keymapitem.type == 'S') | (keymapitem.type == 'G') | (keymapitem.type == 'W') | (keymapitem.type == 'LEFTMOUSE') | (keymapitem.type == 'RIGHTMOUSE') | (keymapitem.type == 'K') | (keymapitem.type == 'E') | (keymapitem.type == 'X') | (keymapitem.type == 'DEL') | (keymapitem.type == 'M'):
keymapitems.remove(keymapitem)
keymapmarker = keymapitems.new('wm.call_menu', 'M', 'PRESS', alt=True)
keymapmarker.properties.name = 'VSEQF_MT_quickmarkers_menu'
keymapstripmarker = keymapitems.new('wm.call_menu', 'M', 'PRESS', shift=True)
keymapstripmarker.properties.name = 'VSEQF_MT_quickmarkers_strip_menu'
keymapzoom = keymapitems.new('wm.call_menu', 'Z', 'PRESS')
keymapzoom.properties.name = 'VSEQF_MT_quickzooms_menu'
keymapitems.new('vseqf.modal_fades', 'F', 'PRESS')
keymapfademenu = keymapitems.new('wm.call_menu', 'F', 'PRESS', shift=True)
keymapfademenu.properties.name = 'VSEQF_MT_quickfades_menu'
keymapitems.new('vseqf.volume_draw', 'V', 'PRESS')
keymapsnap = keymapitems.new('wm.call_menu', 'S', 'PRESS')
keymapsnapto = keymapitems.new('vseqf.quicksnaps', 'S', 'PRESS', shift=True)
keymapsnapto.properties.type = 'selection_to_cursor'
keymapsnap.properties.name = 'VSEQF_MT_quicksnaps_menu'
keymapcuts = keymapitems.new('wm.call_menu', 'K', 'PRESS', ctrl=True)
keymapcuts.properties.name = 'VSEQF_MT_quickcuts_menu'
keymapitems.new('vseqf.cut', 'K', 'PRESS')
keymapcuthard = keymapitems.new('vseqf.cut', 'K', 'PRESS', shift=True)
keymapcuthard.properties.type = 'HARD'
keymapcutripple = keymapitems.new('vseqf.cut', 'K', 'PRESS', alt=True)
keymapcutripple.properties.type = 'RIPPLE'
keymapcuttrim = keymapitems.new('vseqf.cut', 'K', 'PRESS', alt=True, shift=True)
keymapcuttrim.properties.type = 'TRIM'
keymapitems.new('vseqf.grab', 'G', 'PRESS')
keymapitems.new('vseqf.context_menu', 'ACCENT_GRAVE', 'PRESS')
keymapitems.new('vseqf.select_grab', 'LEFTMOUSE', 'PRESS')
keymapitems.new('vseqf.select_grab', 'RIGHTMOUSE', 'PRESS')
keymapitems.new('vseqf.select_grab', 'LEFTMOUSE', 'CLICK_DRAG')
keymapgrabextend = keymapitems.new('vseqf.grab', 'E', 'PRESS')
keymapgrabextend.properties.mode = 'TIME_EXTEND'
keymapslip = keymapitems.new('vseqf.grab', 'S', 'PRESS', alt=True)
keymapslip.properties.mode = 'SLIP'
keymapitems.new('vseqf.delete_confirm', 'X', 'PRESS')
keymapitems.new('vseqf.delete_confirm', 'DEL', 'PRESS')
keymapitems.new('vseqf.delete_ripple_confirm', 'X', 'PRESS', alt=True)
keymapitems.new('vseqf.delete_ripple_confirm', 'DEL', 'PRESS', alt=True)
#QuickShortcuts Shortcuts
keymapitems.new('vseqf.cut', 'NUMPAD_SLASH', 'PRESS')
keymapitem = keymapitems.new('wm.call_menu', 'NUMPAD_SLASH', 'PRESS', ctrl=True)
keymapitem.properties.name = 'VSEQF_MT_quickcuts_menu'
keymapitem = keymapitems.new('vseqf.cut', 'NUMPAD_SLASH', 'PRESS', alt=True)
keymapitem.properties.type = 'RIPPLE'
keymapitem = keymapitems.new('vseqf.cut', 'NUMPAD_SLASH', 'PRESS', shift=True)
keymapitem.properties.type = 'TRIM'
#Numpad: basic movement and playback
keymapitem = keymapitems.new('screen.frame_offset', 'NUMPAD_1', 'PRESS')
keymapitem.properties.delta = -1
keymapitem = keymapitems.new('screen.frame_offset', 'NUMPAD_3', 'PRESS')
keymapitem.properties.delta = 1
keymapitem = keymapitems.new('vseqf.change_speed', 'NUMPAD_4', 'PRESS')
keymapitem.properties.speed_change = 'DOWN'
keymapitem = keymapitems.new('vseqf.change_speed', 'NUMPAD_6', 'PRESS')
keymapitem.properties.speed_change = 'UP'
keymapitem = keymapitems.new('vseqf.skip_timeline', 'NUMPAD_7', 'PRESS')
keymapitem.properties.type = 'LASTSECOND'
keymapitem = keymapitems.new('vseqf.skip_timeline', 'NUMPAD_9', 'PRESS')
keymapitem.properties.type = 'NEXTSECOND'
keymapitems.new('vseqf.reset_playback', 'NUMPAD_5', 'PRESS')
#Numpad + Ctrl: Advanced movement/jumps
keymapitem = keymapitems.new('screen.keyframe_jump', 'NUMPAD_1', 'PRESS', ctrl=True)
keymapitem.properties.next = False
keymapitem = keymapitems.new('screen.keyframe_jump', 'NUMPAD_3', 'PRESS', ctrl=True)
keymapitem.properties.next = True
keymapitem = keymapitems.new('vseqf.skip_timeline', 'NUMPAD_4', 'PRESS', ctrl=True)
keymapitem.properties.type = 'LASTEDGE'
keymapitem = keymapitems.new('vseqf.skip_timeline', 'NUMPAD_6', 'PRESS', ctrl=True)
keymapitem.properties.type = 'NEXTEDGE'
keymapitem = keymapitems.new('vseqf.skip_timeline', 'NUMPAD_7', 'PRESS', ctrl=True)
keymapitem.properties.type = 'LASTMARKER'
keymapitem = keymapitems.new('vseqf.skip_timeline', 'NUMPAD_9', 'PRESS', ctrl=True)
keymapitem.properties.type = 'NEXTMARKER'
#Numpad + Alt: Move selected strips
keymapitem = keymapitems.new('vseqf.nudge_selected', 'NUMPAD_1', 'PRESS', alt=True)
keymapitem.properties.direction = 'LEFT'
keymapitem = keymapitems.new('vseqf.nudge_selected', 'NUMPAD_3', 'PRESS', alt=True)
keymapitem.properties.direction = 'RIGHT'
keymapitem = keymapitems.new('vseqf.nudge_selected', 'NUMPAD_4', 'PRESS', alt=True)
keymapitem.properties.direction = 'LEFT-M'
keymapitem = keymapitems.new('vseqf.nudge_selected', 'NUMPAD_6', 'PRESS', alt=True)
keymapitem.properties.direction = 'RIGHT-M'
keymapitem = keymapitems.new('vseqf.nudge_selected', 'NUMPAD_7', 'PRESS', alt=True)
keymapitem.properties.direction = 'LEFT-L'
keymapitem = keymapitems.new('vseqf.nudge_selected', 'NUMPAD_9', 'PRESS', alt=True)
keymapitem.properties.direction = 'RIGHT-L'
keymapitem = keymapitems.new('vseqf.nudge_selected', 'NUMPAD_2', 'PRESS', alt=True)
keymapitem.properties.direction = 'DOWN'
keymapitem = keymapitems.new('vseqf.nudge_selected', 'NUMPAD_8', 'PRESS', alt=True)
keymapitem.properties.direction = 'UP'
keymapitems.new('vseqf.grab', 'NUMPAD_5', 'PRESS', alt=True)
#Numpad + Shift: Zoom viewport
keymapitem = keymapitems.new('vseqf.quickzooms', 'NUMPAD_1', 'PRESS', shift=True)
keymapitem.properties.area = '2'
keymapitem = keymapitems.new('vseqf.quickzooms', 'NUMPAD_2', 'PRESS', shift=True)
keymapitem.properties.area = '10'
keymapitem = keymapitems.new('vseqf.quickzooms', 'NUMPAD_3', 'PRESS', shift=True)
keymapitem.properties.area = '30'
keymapitem = keymapitems.new('vseqf.quickzooms', 'NUMPAD_4', 'PRESS', shift=True)
keymapitem.properties.area = '60'
keymapitem = keymapitems.new('vseqf.quickzooms', 'NUMPAD_5', 'PRESS', shift=True)
keymapitem.properties.area = '120'
keymapitem = keymapitems.new('vseqf.quickzooms', 'NUMPAD_6', 'PRESS', shift=True)
keymapitem.properties.area = '300'
keymapitem = keymapitems.new('vseqf.quickzooms', 'NUMPAD_7', 'PRESS', shift=True)
keymapitem.properties.area = '600'
keymapitems.new('sequencer.view_selected', 'NUMPAD_8', 'PRESS', shift=True)
keymapitems.new('sequencer.view_all', 'NUMPAD_9', 'PRESS', shift=True)
def disable_tweak_default_keymaps(enable=False):
#disable sequencer tweak tool keymaps
keymaps = bpy.context.window_manager.keyconfigs['Blender'].keymaps
operators = ['transform.seq_slide', 'sequencer.select']
found = False
for keymap in keymaps:
if keymap.name not in ['Sequencer', 'Preview']:
for item in keymap.keymap_items:
if item.map_type == 'MOUSE' and item.idname in operators and not (item.ctrl_ui or item.alt_ui or item.shift_ui):
message = "VSEQF: enabling default shortcut: " if enable else "VSEQF: disabling default shortcut: "
print(message+keymap.name+": "+item.name)
item.active = enable
found = True
if not found:
print('Unable to find default shortcut, VSEQF mouse shortcuts may not work properly.')
def register():
bpy.utils.register_class(VSEQuickFunctionSettings)
#Register classes
for cls in classes:
try:
bpy.utils.register_class(cls)
except Exception as e:
print('Unable to register class: '+str(cls)+' : '+str(e))
#Register toolbar buttons
#bpy.utils.register_tool(grabs.VSEQFSelectGrabTool, separator=True)
global vseqf_draw_handler
if vseqf_draw_handler:
try:
bpy.types.SpaceSequenceEditor.draw_handler_remove(vseqf_draw_handler, 'WINDOW')
except:
pass
vseqf_draw_handler = bpy.types.SpaceSequenceEditor.draw_handler_add(vseqf_draw, (), 'WINDOW', 'POST_PIXEL')
#Add menus
bpy.types.SEQUENCER_HT_header.append(draw_timeline_menu)
try:
bpy.types.TIME_HT_editor_buttons.append(draw_quickspeed_header)
except:
#Fix for blender 2.91, move the quickspeed header...
bpy.types.DOPESHEET_HT_header.append(draw_quickspeed_header)
bpy.types.SEQUENCER_HT_header.append(draw_follow_header)
bpy.types.SEQUENCER_MT_view.append(draw_quickzoom_menu)
bpy.types.SEQUENCER_MT_view.prepend(draw_quicksettings_menu)
bpy.types.SEQUENCER_MT_marker.prepend(draw_quickmarker_menu)
#New variables
bpy.types.Scene.vseqf_skip_interval = bpy.props.IntProperty(default=0, min=0)
bpy.types.Scene.vseqf = bpy.props.PointerProperty(type=VSEQFSetting)
bpy.types.Strip.parent = bpy.props.StringProperty()
bpy.types.Strip.tags = bpy.props.CollectionProperty(type=tags.VSEQFTags)
bpy.types.MovieClip.import_settings = bpy.props.PointerProperty(type=threepoint.VSEQFQuick3PointValues)
#Register shortcuts
register_keymaps()
disable_tweak_default_keymaps()
#Register handlers
remove_frame_step_handler(add=True)
remove_vu_draw_handler(add=True)
def unregister():
global vseqf_draw_handler
bpy.types.SpaceSequenceEditor.draw_handler_remove(vseqf_draw_handler, 'WINDOW')
#Unregister menus
bpy.types.SEQUENCER_HT_header.remove(draw_timeline_menu)
try:
bpy.types.TIME_HT_editor_buttons.remove(draw_quickspeed_header)
except:
bpy.types.DOPESHEET_HT_header.remove(draw_quickspeed_header)
bpy.types.SEQUENCER_MT_view.remove(draw_quickzoom_menu)
bpy.types.SEQUENCER_MT_view.remove(draw_quicksettings_menu)
bpy.types.SEQUENCER_HT_header.remove(draw_follow_header)
#Remove shortcuts
disable_tweak_default_keymaps(enable=True)
keymapitems = bpy.context.window_manager.keyconfigs.addon.keymaps['Sequencer'].keymap_items
for keymapitem in keymapitems:
if (keymapitem.type == 'Z') | (keymapitem.type == 'F') | (keymapitem.type == 'S') | (keymapitem.type == 'G') | (keymapitem.type == 'RIGHTMOUSE') | (keymapitem.type == 'K') | (keymapitem.type == 'E') | (keymapitem.type == 'X') | (keymapitem.type == 'DEL') | (keymapitem.type == 'M') | (keymapitem.type == 'NUMPAD_0') | (keymapitem.type == 'NUMPAD_1') | (keymapitem.type == 'NUMPAD_2') | (keymapitem.type == 'NUMPAD_3') | (keymapitem.type == 'NUMPAD_4') | (keymapitem.type == 'NUMPAD_5') | (keymapitem.type == 'NUMPAD_6') | (keymapitem.type == 'NUMPAD_7') | (keymapitem.type == 'NUMPAD_8') | (keymapitem.type == 'NUMPAD_9'):
keymapitems.remove(keymapitem)
#Remove handlers
remove_vu_draw_handler()
remove_frame_step_handler()
try:
bpy.utils.unregister_class(VSEQuickFunctionSettings)
except RuntimeError:
pass
#Unregister classes
for cls in reversed(classes):
bpy.utils.unregister_class(cls)
if __name__ == "__main__":
register()