cleanup
[blender.git] / release / scripts / startup / bl_ui / space_sequencer.py
1 # ##### BEGIN GPL LICENSE BLOCK #####
2 #
3 #  This program is free software; you can redistribute it and/or
4 #  modify it under the terms of the GNU General Public License
5 #  as published by the Free Software Foundation; either version 2
6 #  of the License, or (at your option) any later version.
7 #
8 #  This program is distributed in the hope that it will be useful,
9 #  but WITHOUT ANY WARRANTY; without even the implied warranty of
10 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11 #  GNU General Public License for more details.
12 #
13 #  You should have received a copy of the GNU General Public License
14 #  along with this program; if not, write to the Free Software Foundation,
15 #  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 #
17 # ##### END GPL LICENSE BLOCK #####
18
19 # <pep8 compliant>
20 import bpy
21 from bpy.types import Header, Menu, Panel
22 from bl_ui.properties_grease_pencil_common import GreasePencilDataPanel, GreasePencilToolsPanel
23 from bpy.app.translations import pgettext_iface as iface_
24
25
26 def act_strip(context):
27     try:
28         return context.scene.sequence_editor.active_strip
29     except AttributeError:
30         return None
31
32
33 def draw_color_balance(layout, color_balance):
34     col = layout.column()
35     col.label(text="Lift:")
36     col.template_color_picker(color_balance, "lift", value_slider=True, cubic=True)
37     row = col.row()
38     row.prop(color_balance, "lift", text="")
39     row.prop(color_balance, "invert_lift", text="Inverse")
40
41     col = layout.column()
42     col.label(text="Gamma:")
43     col.template_color_picker(color_balance, "gamma", value_slider=True, lock_luminosity=True, cubic=True)
44     row = col.row()
45     row.prop(color_balance, "gamma", text="")
46     row.prop(color_balance, "invert_gamma", text="Inverse")
47
48     col = layout.column()
49     col.label(text="Gain:")
50     col.template_color_picker(color_balance, "gain", value_slider=True, lock_luminosity=True, cubic=True)
51     row = col.row()
52     row.prop(color_balance, "gain", text="")
53     row.prop(color_balance, "invert_gain", text="Inverse")
54
55
56 class SEQUENCER_HT_header(Header):
57     bl_space_type = 'SEQUENCE_EDITOR'
58
59     def draw(self, context):
60         layout = self.layout
61
62         st = context.space_data
63         scene = context.scene
64
65         row = layout.row(align=True)
66         row.template_header()
67
68         SEQUENCER_MT_editor_menus.draw_collapsible(context, layout)
69
70         row = layout.row(align=True)
71         row.prop(scene, "use_preview_range", text="", toggle=True)
72         row.prop(scene, "lock_frame_selection_to_range", text="", toggle=True)
73
74         layout.prop(st, "view_type", expand=True, text="")
75
76         if st.view_type in {'PREVIEW', 'SEQUENCER_PREVIEW'}:
77             layout.prop(st, "display_mode", expand=True, text="")
78
79         if st.view_type == 'SEQUENCER':
80             row = layout.row(align=True)
81             row.operator("sequencer.copy", text="", icon='COPYDOWN')
82             row.operator("sequencer.paste", text="", icon='PASTEDOWN')
83
84             layout.separator()
85             layout.operator("sequencer.refresh_all")
86             layout.prop(st, "show_backdrop")
87         else:
88             if st.view_type == 'SEQUENCER_PREVIEW':
89                 layout.separator()
90                 layout.operator("sequencer.refresh_all")
91
92             layout.prop(st, "preview_channels", expand=True, text="")
93             layout.prop(st, "display_channel", text="Channel")
94
95             ed = context.scene.sequence_editor
96             if ed:
97                 row = layout.row(align=True)
98                 row.prop(ed, "show_overlay", text="", icon='GHOST_ENABLED')
99                 if ed.show_overlay:
100                     row.prop(ed, "overlay_frame", text="")
101                     row.prop(ed, "use_overlay_lock", text="", icon='LOCKED')
102
103                     row = layout.row()
104                     row.prop(st, "overlay_type", text="")
105
106         if st.view_type in {'PREVIEW', 'SEQUENCER_PREVIEW'}:
107             gpd = context.gpencil_data
108             toolsettings = context.tool_settings
109
110             # Proportional editing
111             if gpd and gpd.use_stroke_edit_mode:
112                 row = layout.row(align=True)
113                 row.prop(toolsettings, "proportional_edit", icon_only=True)
114                 if toolsettings.proportional_edit != 'DISABLED':
115                     row.prop(toolsettings, "proportional_edit_falloff", icon_only=True)
116
117         row = layout.row(align=True)
118         row.operator("render.opengl", text="", icon='RENDER_STILL').sequencer = True
119         props = row.operator("render.opengl", text="", icon='RENDER_ANIMATION')
120         props.animation = True
121         props.sequencer = True
122
123         layout.template_running_jobs()
124
125
126 class SEQUENCER_MT_editor_menus(Menu):
127     bl_idname = "SEQUENCER_MT_editor_menus"
128     bl_label = ""
129
130     def draw(self, context):
131         self.draw_menus(self.layout, context)
132
133     @staticmethod
134     def draw_menus(layout, context):
135         st = context.space_data
136
137         layout.menu("SEQUENCER_MT_view")
138
139         if st.view_type in {'SEQUENCER', 'SEQUENCER_PREVIEW'}:
140             layout.menu("SEQUENCER_MT_select")
141             layout.menu("SEQUENCER_MT_marker")
142             layout.menu("SEQUENCER_MT_add")
143             layout.menu("SEQUENCER_MT_frame")
144             layout.menu("SEQUENCER_MT_strip")
145
146
147 class SEQUENCER_MT_view_toggle(Menu):
148     bl_label = "View Type"
149
150     def draw(self, context):
151         layout = self.layout
152
153         layout.operator("sequencer.view_toggle").type = 'SEQUENCER'
154         layout.operator("sequencer.view_toggle").type = 'PREVIEW'
155         layout.operator("sequencer.view_toggle").type = 'SEQUENCER_PREVIEW'
156
157
158 class SEQUENCER_MT_view(Menu):
159     bl_label = "View"
160
161     def draw(self, context):
162         layout = self.layout
163
164         st = context.space_data
165         is_preview = st.view_type in {'PREVIEW', 'SEQUENCER_PREVIEW'}
166         is_sequencer_view = st.view_type in {'SEQUENCER', 'SEQUENCER_PREVIEW'}
167
168         if st.view_type == 'PREVIEW':
169             # Specifying the REGION_PREVIEW context is needed in preview-only
170             # mode, else the lookup for the shortcut will fail in
171             # wm_keymap_item_find_props() (see #32595).
172             layout.operator_context = 'INVOKE_REGION_PREVIEW'
173         layout.operator("sequencer.properties", icon='MENU_PANEL')
174         layout.operator_context = 'INVOKE_DEFAULT'
175
176         layout.separator()
177
178         if is_sequencer_view:
179             layout.operator("sequencer.view_all", text="View all Sequences")
180             layout.operator("sequencer.view_selected")
181         if is_preview:
182             layout.operator_context = 'INVOKE_REGION_PREVIEW'
183             layout.operator("sequencer.view_all_preview", text="Fit preview in window")
184
185             layout.separator()
186
187             ratios = ((1, 8), (1, 4), (1, 2), (1, 1), (2, 1), (4, 1), (8, 1))
188
189             for a, b in ratios:
190                 layout.operator("sequencer.view_zoom_ratio", text=iface_("Zoom %d:%d") % (a, b), translate=False).ratio = a / b
191
192             layout.separator()
193
194             layout.operator_context = 'INVOKE_DEFAULT'
195
196             # # XXX, invokes in the header view
197             # layout.operator("sequencer.view_ghost_border", text="Overlay Border")
198
199         if is_sequencer_view:
200             layout.prop(st, "show_seconds")
201             layout.prop(st, "show_frame_indicator")
202             layout.prop(st, "show_strip_offset")
203
204             layout.prop_menu_enum(st, "waveform_draw_type")
205
206         if is_preview:
207             if st.display_mode == 'IMAGE':
208                 layout.prop(st, "show_safe_areas")
209             elif st.display_mode == 'WAVEFORM':
210                 layout.prop(st, "show_separate_color")
211
212         layout.separator()
213
214         if is_sequencer_view:
215             layout.prop(st, "use_marker_sync")
216             layout.separator()
217
218         layout.operator("screen.area_dupli")
219         layout.operator("screen.screen_full_area", text="Toggle Maximize Area")
220         layout.operator("screen.screen_full_area").use_hide_panels = True
221
222
223 class SEQUENCER_MT_select(Menu):
224     bl_label = "Select"
225
226     def draw(self, context):
227         layout = self.layout
228
229         layout.operator("sequencer.select_active_side", text="Strips to the Left").side = 'LEFT'
230         layout.operator("sequencer.select_active_side", text="Strips to the Right").side = 'RIGHT'
231         op = layout.operator("sequencer.select", text="All strips to the Left")
232         op.left_right = 'LEFT'
233         op.linked_time = True
234         op = layout.operator("sequencer.select", text="All strips to the Right")
235         op.left_right = 'RIGHT'
236         op.linked_time = True
237
238         layout.separator()
239         layout.operator("sequencer.select_handles", text="Surrounding Handles").side = 'BOTH'
240         layout.operator("sequencer.select_handles", text="Left Handle").side = 'LEFT'
241         layout.operator("sequencer.select_handles", text="Right Handle").side = 'RIGHT'
242         layout.separator()
243         layout.operator_menu_enum("sequencer.select_grouped", "type", text="Grouped")
244         layout.operator("sequencer.select_linked")
245         layout.operator("sequencer.select_all").action = 'TOGGLE'
246         layout.operator("sequencer.select_all", text="Inverse").action = 'INVERT'
247
248
249 class SEQUENCER_MT_marker(Menu):
250     bl_label = "Marker"
251
252     def draw(self, context):
253         layout = self.layout
254
255         from bl_ui.space_time import marker_menu_generic
256         marker_menu_generic(layout)
257
258
259 class SEQUENCER_MT_change(Menu):
260     bl_label = "Change"
261
262     def draw(self, context):
263         layout = self.layout
264
265         layout.operator_context = 'INVOKE_REGION_WIN'
266
267         layout.operator_menu_enum("sequencer.change_effect_input", "swap")
268         layout.operator_menu_enum("sequencer.change_effect_type", "type")
269         layout.operator("sequencer.change_path", text="Path/Files")
270
271
272 class SEQUENCER_MT_frame(Menu):
273     bl_label = "Frame"
274
275     def draw(self, context):
276         layout = self.layout
277
278         layout.operator("anim.previewrange_clear")
279         layout.operator("anim.previewrange_set")
280
281
282 class SEQUENCER_MT_add(Menu):
283     bl_label = "Add"
284
285     def draw(self, context):
286         layout = self.layout
287
288         layout.operator_context = 'INVOKE_REGION_WIN'
289
290         if len(bpy.data.scenes) > 10:
291             layout.operator_context = 'INVOKE_DEFAULT'
292             layout.operator("sequencer.scene_strip_add", text="Scene...")
293         else:
294             layout.operator_menu_enum("sequencer.scene_strip_add", "scene", text="Scene...")
295
296         if len(bpy.data.movieclips) > 10:
297             layout.operator_context = 'INVOKE_DEFAULT'
298             layout.operator("sequencer.movieclip_strip_add", text="Clips...")
299         else:
300             layout.operator_menu_enum("sequencer.movieclip_strip_add", "clip", text="Clip...")
301
302         if len(bpy.data.masks) > 10:
303             layout.operator_context = 'INVOKE_DEFAULT'
304             layout.operator("sequencer.mask_strip_add", text="Masks...")
305         else:
306             layout.operator_menu_enum("sequencer.mask_strip_add", "mask", text="Mask...")
307
308         layout.operator("sequencer.movie_strip_add", text="Movie")
309         layout.operator("sequencer.image_strip_add", text="Image")
310         layout.operator("sequencer.sound_strip_add", text="Sound")
311
312         layout.menu("SEQUENCER_MT_add_effect")
313
314
315 class SEQUENCER_MT_add_effect(Menu):
316     bl_label = "Effect Strip..."
317
318     def draw(self, context):
319         layout = self.layout
320
321         layout.operator_context = 'INVOKE_REGION_WIN'
322
323         layout.operator("sequencer.effect_strip_add", text="Add").type = 'ADD'
324         layout.operator("sequencer.effect_strip_add", text="Subtract").type = 'SUBTRACT'
325         layout.operator("sequencer.effect_strip_add", text="Alpha Over").type = 'ALPHA_OVER'
326         layout.operator("sequencer.effect_strip_add", text="Alpha Under").type = 'ALPHA_UNDER'
327         layout.operator("sequencer.effect_strip_add", text="Cross").type = 'CROSS'
328         layout.operator("sequencer.effect_strip_add", text="Gamma Cross").type = 'GAMMA_CROSS'
329         layout.operator("sequencer.effect_strip_add", text="Gaussian Blur").type = 'GAUSSIAN_BLUR'
330         layout.operator("sequencer.effect_strip_add", text="Multiply").type = 'MULTIPLY'
331         layout.operator("sequencer.effect_strip_add", text="Over Drop").type = 'OVER_DROP'
332         layout.operator("sequencer.effect_strip_add", text="Wipe").type = 'WIPE'
333         layout.operator("sequencer.effect_strip_add", text="Glow").type = 'GLOW'
334         layout.operator("sequencer.effect_strip_add", text="Transform").type = 'TRANSFORM'
335         layout.operator("sequencer.effect_strip_add", text="Color").type = 'COLOR'
336         layout.operator("sequencer.effect_strip_add", text="Speed Control").type = 'SPEED'
337         layout.operator("sequencer.effect_strip_add", text="Multicam Selector").type = 'MULTICAM'
338         layout.operator("sequencer.effect_strip_add", text="Adjustment Layer").type = 'ADJUSTMENT'
339
340
341 class SEQUENCER_MT_strip(Menu):
342     bl_label = "Strip"
343
344     def draw(self, context):
345         layout = self.layout
346
347         layout.operator_context = 'INVOKE_REGION_WIN'
348
349         layout.operator("transform.transform", text="Grab/Move").mode = 'TRANSLATION'
350         layout.operator("transform.transform", text="Grab/Extend from frame").mode = 'TIME_EXTEND'
351         layout.operator("sequencer.gap_remove").all = False
352         layout.operator("sequencer.gap_insert")
353
354         #  uiItemO(layout, NULL, 0, "sequencer.strip_snap"); // TODO - add this operator
355         layout.separator()
356
357         layout.operator("sequencer.cut", text="Cut (hard) at frame").type = 'HARD'
358         layout.operator("sequencer.cut", text="Cut (soft) at frame").type = 'SOFT'
359         layout.operator("sequencer.slip", text="Slip Strip Contents")
360         layout.operator("sequencer.images_separate")
361         layout.operator("sequencer.offset_clear")
362         layout.operator("sequencer.deinterlace_selected_movies")
363         layout.operator("sequencer.rebuild_proxy")
364         layout.separator()
365
366         layout.operator("sequencer.duplicate_move")
367         layout.operator("sequencer.delete")
368
369         strip = act_strip(context)
370
371         if strip:
372             stype = strip.type
373
374             # XXX note strip.type is never equal to 'EFFECT', look at seq_type_items within rna_sequencer.c
375             if stype == 'EFFECT':
376                 pass
377                 # layout.separator()
378                 # layout.operator("sequencer.effect_change")
379                 # layout.operator("sequencer.effect_reassign_inputs")
380             elif stype == 'IMAGE':
381                 layout.separator()
382                 # layout.operator("sequencer.image_change")
383                 layout.operator("sequencer.rendersize")
384             elif stype == 'SCENE':
385                 pass
386                 # layout.separator()
387                 # layout.operator("sequencer.scene_change", text="Change Scene")
388             elif stype == 'MOVIE':
389                 layout.separator()
390                 # layout.operator("sequencer.movie_change")
391                 layout.operator("sequencer.rendersize")
392             elif stype == 'SOUND':
393                 layout.separator()
394                 layout.operator("sequencer.crossfade_sounds")
395
396         layout.separator()
397
398         layout.operator("sequencer.meta_make")
399         layout.operator("sequencer.meta_separate")
400
401         #if (ed && (ed->metastack.first || (ed->act_seq && ed->act_seq->type == SEQ_META))) {
402         #       uiItemS(layout);
403         #       uiItemO(layout, NULL, 0, "sequencer.meta_toggle");
404         #}
405
406         layout.separator()
407         layout.operator("sequencer.reload", text="Reload Strips")
408         layout.operator("sequencer.reload", text="Reload Strips and Adjust Length").adjust_length = True
409         layout.operator("sequencer.reassign_inputs")
410         layout.operator("sequencer.swap_inputs")
411
412         layout.separator()
413         layout.operator("sequencer.lock")
414         layout.operator("sequencer.unlock")
415         layout.operator("sequencer.mute").unselected = False
416         layout.operator("sequencer.unmute").unselected = False
417
418         layout.operator("sequencer.mute", text="Mute Deselected Strips").unselected = True
419
420         layout.operator("sequencer.snap")
421
422         layout.operator_menu_enum("sequencer.swap", "side")
423
424         layout.separator()
425
426         layout.operator("sequencer.swap_data")
427         layout.menu("SEQUENCER_MT_change")
428
429
430 class SequencerButtonsPanel:
431     bl_space_type = 'SEQUENCE_EDITOR'
432     bl_region_type = 'UI'
433
434     @staticmethod
435     def has_sequencer(context):
436         return (context.space_data.view_type in {'SEQUENCER', 'SEQUENCER_PREVIEW'})
437
438     @classmethod
439     def poll(cls, context):
440         return cls.has_sequencer(context) and (act_strip(context) is not None)
441
442
443 class SequencerButtonsPanel_Output:
444     bl_space_type = 'SEQUENCE_EDITOR'
445     bl_region_type = 'UI'
446
447     @staticmethod
448     def has_preview(context):
449         st = context.space_data
450         return (st.view_type in {'PREVIEW', 'SEQUENCER_PREVIEW'}) or st.show_backdrop
451
452     @classmethod
453     def poll(cls, context):
454         return cls.has_preview(context)
455
456
457 class SEQUENCER_PT_edit(SequencerButtonsPanel, Panel):
458     bl_label = "Edit Strip"
459
460     def draw(self, context):
461         layout = self.layout
462
463         scene = context.scene
464         frame_current = scene.frame_current
465         strip = act_strip(context)
466
467         split = layout.split(percentage=0.3)
468         split.label(text="Name:")
469         split.prop(strip, "name", text="")
470
471         split = layout.split(percentage=0.3)
472         split.label(text="Type:")
473         split.prop(strip, "type", text="")
474
475         if strip.type not in {'SOUND'}:
476             split = layout.split(percentage=0.3)
477             split.label(text="Blend:")
478             split.prop(strip, "blend_type", text="")
479
480             row = layout.row(align=True)
481             sub = row.row(align=True)
482             sub.active = (not strip.mute)
483             sub.prop(strip, "blend_alpha", text="Opacity", slider=True)
484             row.prop(strip, "mute", toggle=True, icon_only=True)
485             row.prop(strip, "lock", toggle=True, icon_only=True)
486         else:
487             row = layout.row(align=True)
488             row.prop(strip, "mute", toggle=True, icon_only=True)
489             row.prop(strip, "lock", toggle=True, icon_only=True)
490
491         col = layout.column()
492         sub = col.column()
493         sub.enabled = not strip.lock
494         sub.prop(strip, "channel")
495         sub.prop(strip, "frame_start")
496         sub.prop(strip, "frame_final_duration")
497
498         col = layout.column(align=True)
499         row = col.row(align=True)
500         row.label(text=iface_("Final Length: %s") % bpy.utils.smpte_from_frame(strip.frame_final_duration),
501                   translate=False)
502         row = col.row(align=True)
503         row.active = (frame_current >= strip.frame_start and frame_current <= strip.frame_start + strip.frame_duration)
504         row.label(text=iface_("Playhead: %d") % (frame_current - strip.frame_start), translate=False)
505
506         col.label(text=iface_("Frame Offset %d:%d") % (strip.frame_offset_start, strip.frame_offset_end),
507                   translate=False)
508         col.label(text=iface_("Frame Still %d:%d") % (strip.frame_still_start, strip.frame_still_end), translate=False)
509
510         elem = False
511
512         if strip.type == 'IMAGE':
513             elem = strip.strip_elem_from_frame(frame_current)
514         elif strip.type == 'MOVIE':
515             elem = strip.elements[0]
516
517         if elem and elem.orig_width > 0 and elem.orig_height > 0:
518             col.label(text=iface_("Original Dimension: %dx%d") % (elem.orig_width, elem.orig_height), translate=False)
519         else:
520             col.label(text="Original Dimension: None")
521
522
523 class SEQUENCER_PT_effect(SequencerButtonsPanel, Panel):
524     bl_label = "Effect Strip"
525
526     @classmethod
527     def poll(cls, context):
528         if not cls.has_sequencer(context):
529             return False
530
531         strip = act_strip(context)
532         if not strip:
533             return False
534
535         return strip.type in {'ADD', 'SUBTRACT', 'ALPHA_OVER', 'ALPHA_UNDER',
536                               'CROSS', 'GAMMA_CROSS', 'MULTIPLY', 'OVER_DROP',
537                               'WIPE', 'GLOW', 'TRANSFORM', 'COLOR', 'SPEED',
538                               'MULTICAM', 'GAUSSIAN_BLUR'}
539
540     def draw(self, context):
541         layout = self.layout
542
543         strip = act_strip(context)
544
545         if strip.input_count > 0:
546             col = layout.column()
547             col.prop(strip, "input_1")
548             if strip.input_count > 1:
549                 col.prop(strip, "input_2")
550
551         if strip.type == 'COLOR':
552             layout.prop(strip, "color")
553
554         elif strip.type == 'WIPE':
555             col = layout.column()
556             col.prop(strip, "transition_type")
557             col.label(text="Direction:")
558             col.row().prop(strip, "direction", expand=True)
559
560             col = layout.column()
561             col.prop(strip, "blur_width", slider=True)
562             if strip.transition_type in {'SINGLE', 'DOUBLE'}:
563                 col.prop(strip, "angle")
564
565         elif strip.type == 'GLOW':
566             flow = layout.column_flow()
567             flow.prop(strip, "threshold", slider=True)
568             flow.prop(strip, "clamp", slider=True)
569             flow.prop(strip, "boost_factor")
570             flow.prop(strip, "blur_radius")
571
572             row = layout.row()
573             row.prop(strip, "quality", slider=True)
574             row.prop(strip, "use_only_boost")
575
576         elif strip.type == 'SPEED':
577             layout.prop(strip, "use_default_fade", "Stretch to input strip length")
578             if not strip.use_default_fade:
579                 layout.prop(strip, "use_as_speed")
580                 if strip.use_as_speed:
581                     layout.prop(strip, "speed_factor")
582                 else:
583                     layout.prop(strip, "speed_factor", text="Frame number")
584                     layout.prop(strip, "scale_to_length")
585
586         elif strip.type == 'TRANSFORM':
587             layout = self.layout
588             col = layout.column()
589
590             col.prop(strip, "interpolation")
591             col.prop(strip, "translation_unit")
592             col = layout.column(align=True)
593             col.label(text="Position:")
594             col.prop(strip, "translate_start_x", text="X")
595             col.prop(strip, "translate_start_y", text="Y")
596
597             layout.separator()
598
599             col = layout.column(align=True)
600             col.prop(strip, "use_uniform_scale")
601             if strip.use_uniform_scale:
602                 col = layout.column(align=True)
603                 col.prop(strip, "scale_start_x", text="Scale")
604             else:
605                 col = layout.column(align=True)
606                 col.label(text="Scale:")
607                 col.prop(strip, "scale_start_x", text="X")
608                 col.prop(strip, "scale_start_y", text="Y")
609
610             layout.separator()
611
612             col = layout.column(align=True)
613             col.label(text="Rotation:")
614             col.prop(strip, "rotation_start", text="Rotation")
615
616         elif strip.type == 'MULTICAM':
617             layout.prop(strip, "multicam_source")
618
619             row = layout.row(align=True)
620             sub = row.row(align=True)
621             sub.scale_x = 2.0
622
623             sub.operator("screen.animation_play", text="", icon='PAUSE' if context.screen.is_animation_playing else 'PLAY')
624
625             row.label("Cut To")
626             for i in range(1, strip.channel):
627                 row.operator("sequencer.cut_multicam", text="%d" % i).camera = i
628
629         col = layout.column(align=True)
630         if strip.type == 'SPEED':
631             col.prop(strip, "multiply_speed")
632         elif strip.type in {'CROSS', 'GAMMA_CROSS', 'WIPE', 'ALPHA_OVER', 'ALPHA_UNDER', 'OVER_DROP'}:
633             col.prop(strip, "use_default_fade", "Default fade")
634             if not strip.use_default_fade:
635                 col.prop(strip, "effect_fader", text="Effect fader")
636         elif strip.type == 'GAUSSIAN_BLUR':
637             col.prop(strip, "size_x")
638             col.prop(strip, "size_y")
639
640
641 class SEQUENCER_PT_input(SequencerButtonsPanel, Panel):
642     bl_label = "Strip Input"
643
644     @classmethod
645     def poll(cls, context):
646         if not cls.has_sequencer(context):
647             return False
648
649         strip = act_strip(context)
650         if not strip:
651             return False
652
653         return strip.type in {'MOVIE', 'IMAGE', 'SCENE', 'MOVIECLIP', 'META',
654                               'ADD', 'SUBTRACT', 'ALPHA_OVER', 'ALPHA_UNDER',
655                               'CROSS', 'GAMMA_CROSS', 'MULTIPLY', 'OVER_DROP',
656                               'WIPE', 'GLOW', 'TRANSFORM', 'COLOR',
657                               'MULTICAM', 'SPEED', 'ADJUSTMENT'}
658
659     def draw(self, context):
660         layout = self.layout
661
662         strip = act_strip(context)
663
664         seq_type = strip.type
665
666         # draw a filename if we have one
667         if seq_type == 'IMAGE':
668             split = layout.split(percentage=0.2)
669             split.label(text="Path:")
670             split.prop(strip, "directory", text="")
671
672             # Current element for the filename
673
674             elem = strip.strip_elem_from_frame(context.scene.frame_current)
675             if elem:
676                 split = layout.split(percentage=0.2)
677                 split.label(text="File:")
678                 split.prop(elem, "filename", text="")  # strip.elements[0] could be a fallback
679
680             layout.prop(strip.colorspace_settings, "name")
681             layout.prop(strip, "alpha_mode")
682
683             layout.operator("sequencer.change_path")
684
685         elif seq_type == 'MOVIE':
686             split = layout.split(percentage=0.2)
687             split.label(text="Path:")
688             split.prop(strip, "filepath", text="")
689
690             layout.prop(strip.colorspace_settings, "name")
691
692             layout.prop(strip, "mpeg_preseek")
693             layout.prop(strip, "stream_index")
694
695         layout.prop(strip, "use_translation", text="Image Offset")
696         if strip.use_translation:
697             col = layout.column(align=True)
698             col.prop(strip.transform, "offset_x", text="X")
699             col.prop(strip.transform, "offset_y", text="Y")
700
701         layout.prop(strip, "use_crop", text="Image Crop")
702         if strip.use_crop:
703             col = layout.column(align=True)
704             col.prop(strip.crop, "max_y")
705             col.prop(strip.crop, "min_x")
706             col.prop(strip.crop, "min_y")
707             col.prop(strip.crop, "max_x")
708
709         if not isinstance(strip, bpy.types.EffectSequence):
710             col = layout.column(align=True)
711             col.label(text="Trim Duration (hard):")
712             col.prop(strip, "animation_offset_start", text="Start")
713             col.prop(strip, "animation_offset_end", text="End")
714
715         col = layout.column(align=True)
716         col.label(text="Trim Duration (soft):")
717         col.prop(strip, "frame_offset_start", text="Start")
718         col.prop(strip, "frame_offset_end", text="End")
719
720
721 class SEQUENCER_PT_sound(SequencerButtonsPanel, Panel):
722     bl_label = "Sound"
723
724     @classmethod
725     def poll(cls, context):
726         if not cls.has_sequencer(context):
727             return False
728
729         strip = act_strip(context)
730         if not strip:
731             return False
732
733         return (strip.type == 'SOUND')
734
735     def draw(self, context):
736         layout = self.layout
737
738         st = context.space_data
739         strip = act_strip(context)
740         sound = strip.sound
741
742         # TODO: add support to handle SOUND datablock in sequencer soundstrips... For now, hide this useless thing!
743         # layout.template_ID(strip, "sound", open="sound.open")
744
745         # layout.separator()
746         layout.prop(strip, "filepath", text="")
747
748         if sound is not None:
749             row = layout.row()
750             if sound.packed_file:
751                 row.operator("sound.unpack", icon='PACKAGE', text="Unpack")
752             else:
753                 row.operator("sound.pack", icon='UGLYPACKAGE', text="Pack")
754
755             row.prop(sound, "use_memory_cache")
756
757         if st.waveform_draw_type == 'DEFAULT_WAVEFORMS':
758             layout.prop(strip, "show_waveform")
759
760         layout.prop(strip, "volume")
761         layout.prop(strip, "pitch")
762         layout.prop(strip, "pan")
763
764         col = layout.column(align=True)
765         col.label(text="Trim Duration (hard):")
766         col.prop(strip, "animation_offset_start", text="Start")
767         col.prop(strip, "animation_offset_end", text="End")
768
769         col = layout.column(align=True)
770         col.label(text="Trim Duration (soft):")
771         col.prop(strip, "frame_offset_start", text="Start")
772         col.prop(strip, "frame_offset_end", text="End")
773
774
775 class SEQUENCER_PT_scene(SequencerButtonsPanel, Panel):
776     bl_label = "Scene"
777
778     @classmethod
779     def poll(cls, context):
780         if not cls.has_sequencer(context):
781             return False
782
783         strip = act_strip(context)
784         if not strip:
785             return False
786
787         return (strip.type == 'SCENE')
788
789     def draw(self, context):
790         layout = self.layout
791
792         strip = act_strip(context)
793
794         layout.template_ID(strip, "scene")
795
796         scene = strip.scene
797
798         layout.label(text="Camera Override")
799         layout.template_ID(strip, "scene_camera")
800
801         layout.prop(strip, "use_grease_pencil", text="Show Grease Pencil")
802
803         if scene:
804             layout.prop(scene, "audio_volume", text="Audio Volume")
805
806             sta = scene.frame_start
807             end = scene.frame_end
808             layout.label(text=iface_("Original frame range: %d-%d (%d)") % (sta, end, end - sta + 1), translate=False)
809
810
811 class SEQUENCER_PT_mask(SequencerButtonsPanel, Panel):
812     bl_label = "Mask"
813
814     @classmethod
815     def poll(cls, context):
816         if not cls.has_sequencer(context):
817             return False
818
819         strip = act_strip(context)
820         if not strip:
821             return False
822
823         return (strip.type == 'MASK')
824
825     def draw(self, context):
826         layout = self.layout
827
828         strip = act_strip(context)
829
830         layout.template_ID(strip, "mask")
831
832         mask = strip.mask
833
834         if mask:
835             sta = mask.frame_start
836             end = mask.frame_end
837             layout.label(text=iface_("Original frame range: %d-%d (%d)") % (sta, end, end - sta + 1), translate=False)
838
839
840 class SEQUENCER_PT_filter(SequencerButtonsPanel, Panel):
841     bl_label = "Filter"
842
843     @classmethod
844     def poll(cls, context):
845         if not cls.has_sequencer(context):
846             return False
847
848         strip = act_strip(context)
849         if not strip:
850             return False
851
852         return strip.type in {'MOVIE', 'IMAGE', 'SCENE', 'MOVIECLIP', 'MASK',
853                               'META', 'ADD', 'SUBTRACT', 'ALPHA_OVER',
854                               'ALPHA_UNDER', 'CROSS', 'GAMMA_CROSS', 'MULTIPLY',
855                               'OVER_DROP', 'WIPE', 'GLOW', 'TRANSFORM', 'COLOR',
856                               'MULTICAM', 'SPEED', 'ADJUSTMENT'}
857
858     def draw(self, context):
859         layout = self.layout
860
861         strip = act_strip(context)
862
863         col = layout.column()
864         col.label(text="Video:")
865         col.prop(strip, "strobe")
866
867         if strip.type == 'MOVIECLIP':
868             col = layout.column()
869             col.label(text="Tracker:")
870             col.prop(strip, "stabilize2d")
871
872             col = layout.column()
873             col.label(text="Distortion:")
874             col.prop(strip, "undistort")
875
876         split = layout.split(percentage=0.65)
877
878         col = split.column()
879         col.prop(strip, "use_reverse_frames", text="Backwards")
880         col.prop(strip, "use_deinterlace")
881
882         col = split.column()
883         col.label(text="Flip:")
884         col.prop(strip, "use_flip_x", text="X")
885         col.prop(strip, "use_flip_y", text="Y")
886
887         col = layout.column()
888         col.label(text="Colors:")
889         col.prop(strip, "color_saturation", text="Saturation")
890         col.prop(strip, "color_multiply", text="Multiply")
891         col.prop(strip, "use_float")
892
893
894 class SEQUENCER_PT_proxy(SequencerButtonsPanel, Panel):
895     bl_label = "Proxy / Timecode"
896
897     @classmethod
898     def poll(cls, context):
899         if not cls.has_sequencer(context):
900             return False
901
902         strip = act_strip(context)
903         if not strip:
904             return False
905
906         return strip.type in {'MOVIE', 'IMAGE', 'SCENE', 'META', 'MULTICAM'}
907
908     def draw_header(self, context):
909         strip = act_strip(context)
910
911         self.layout.prop(strip, "use_proxy", text="")
912
913     def draw(self, context):
914         layout = self.layout
915
916         strip = act_strip(context)
917
918         flow = layout.column_flow()
919         flow.prop(strip, "use_proxy_custom_directory")
920         flow.prop(strip, "use_proxy_custom_file")
921         if strip.proxy:
922             if strip.use_proxy_custom_directory and not strip.use_proxy_custom_file:
923                 flow.prop(strip.proxy, "directory")
924             if strip.use_proxy_custom_file:
925                 flow.prop(strip.proxy, "filepath")
926
927             layout.label("Enabled Proxies:")
928             enabled = ""
929             row = layout.row()
930             if (strip.proxy.build_25):
931                 enabled += "25% "
932             if (strip.proxy.build_50):
933                 enabled += "50% "
934             if (strip.proxy.build_75):
935                 enabled += "75% "
936             if (strip.proxy.build_100):
937                 enabled += "100% "
938
939             row.label(enabled)
940             if (strip.proxy.use_overwrite):
941                 layout.label("Overwrite On")
942             else:
943                 layout.label("Overwrite Off")
944
945             col = layout.column()
946             col.label(text="Build JPEG quality")
947             col.prop(strip.proxy, "quality")
948
949             if strip.type == 'MOVIE':
950                 col = layout.column()
951                 col.label(text="Use timecode index:")
952
953                 col.prop(strip.proxy, "timecode")
954
955         col = layout.column()
956         col.operator("sequencer.enable_proxies")
957         col.operator("sequencer.rebuild_proxy")
958
959
960 class SEQUENCER_PT_preview(SequencerButtonsPanel_Output, Panel):
961     bl_label = "Scene Preview/Render"
962     bl_space_type = 'SEQUENCE_EDITOR'
963     bl_region_type = 'UI'
964
965     def draw(self, context):
966         layout = self.layout
967
968         render = context.scene.render
969
970         col = layout.column()
971         col.prop(render, "use_sequencer_gl_preview", text="Open GL Preview")
972         col = layout.column()
973         #col.active = render.use_sequencer_gl_preview
974         col.prop(render, "sequencer_gl_preview", text="")
975
976         row = col.row()
977         row.active = render.sequencer_gl_preview == 'SOLID'
978         row.prop(render, "use_sequencer_gl_textured_solid")
979
980
981 class SEQUENCER_PT_view(SequencerButtonsPanel_Output, Panel):
982     bl_label = "View Settings"
983
984     def draw(self, context):
985         layout = self.layout
986
987         st = context.space_data
988
989         col = layout.column()
990         if st.display_mode == 'IMAGE':
991             col.prop(st, "draw_overexposed")
992             col.separator()
993
994         elif st.display_mode == 'WAVEFORM':
995             col.prop(st, "show_separate_color")
996
997         col = layout.column()
998         col.separator()
999         col.prop(st, "proxy_render_size")
1000
1001
1002 class SEQUENCER_PT_view_safe_areas(SequencerButtonsPanel_Output, Panel):
1003     bl_label = "Safe Areas"
1004     bl_options = {'DEFAULT_CLOSED'}
1005
1006     @classmethod
1007     def poll(cls, context):
1008         st = context.space_data
1009         is_preview = st.view_type in {'PREVIEW', 'SEQUENCER_PREVIEW'}
1010         return is_preview and (st.display_mode == 'IMAGE')
1011
1012     def draw_header(self, context):
1013         st = context.space_data
1014
1015         self.layout.prop(st, "show_safe_areas", text="")
1016
1017     def draw(self, context):
1018         from bl_ui.properties_data_camera import draw_display_safe_settings
1019
1020         layout = self.layout
1021         st = context.space_data
1022         safe_data = context.scene.safe_areas
1023
1024         draw_display_safe_settings(layout, safe_data, st)
1025
1026
1027 class SEQUENCER_PT_modifiers(SequencerButtonsPanel, Panel):
1028     bl_label = "Modifiers"
1029
1030     def draw(self, context):
1031         layout = self.layout
1032
1033         strip = act_strip(context)
1034         sequencer = context.scene.sequence_editor
1035
1036         layout.prop(strip, "use_linear_modifiers")
1037
1038         layout.operator_menu_enum("sequencer.strip_modifier_add", "type")
1039
1040         for mod in strip.modifiers:
1041             box = layout.box()
1042
1043             row = box.row()
1044             row.prop(mod, "show_expanded", text="", emboss=False)
1045             row.prop(mod, "name", text="")
1046
1047             row.prop(mod, "mute", text="")
1048
1049             sub = row.row(align=True)
1050             props = sub.operator("sequencer.strip_modifier_move", text="", icon='TRIA_UP')
1051             props.name = mod.name
1052             props.direction = 'UP'
1053             props = sub.operator("sequencer.strip_modifier_move", text="", icon='TRIA_DOWN')
1054             props.name = mod.name
1055             props.direction = 'DOWN'
1056
1057             row.operator("sequencer.strip_modifier_remove", text="", icon='X', emboss=False).name = mod.name
1058
1059             if mod.show_expanded:
1060                 row = box.row()
1061                 row.prop(mod, "input_mask_type", expand=True)
1062
1063                 if mod.input_mask_type == 'STRIP':
1064                     sequences_object = sequencer
1065                     if sequencer.meta_stack:
1066                         sequences_object = sequencer.meta_stack[-1]
1067                     box.prop_search(mod, "input_mask_strip", sequences_object, "sequences", text="Mask")
1068                 else:
1069                     box.prop(mod, "input_mask_id")
1070
1071                 if mod.type == 'COLOR_BALANCE':
1072                     box.prop(mod, "color_multiply")
1073                     draw_color_balance(box, mod.color_balance)
1074                 elif mod.type == 'CURVES':
1075                     box.template_curve_mapping(mod, "curve_mapping", type='COLOR')
1076                 elif mod.type == 'HUE_CORRECT':
1077                     box.template_curve_mapping(mod, "curve_mapping", type='HUE')
1078                 elif mod.type == 'BRIGHT_CONTRAST':
1079                     col = box.column()
1080                     col.prop(mod, "bright")
1081                     col.prop(mod, "contrast")
1082
1083
1084 class SEQUENCER_PT_grease_pencil(GreasePencilDataPanel, SequencerButtonsPanel_Output, Panel):
1085     bl_space_type = 'SEQUENCE_EDITOR'
1086     bl_region_type = 'UI'
1087
1088     # NOTE: this is just a wrapper around the generic GP Panel
1089     # But, it should only show up when there are images in the preview region
1090
1091
1092 class SEQUENCER_PT_grease_pencil_tools(GreasePencilToolsPanel, SequencerButtonsPanel_Output, Panel):
1093     bl_space_type = 'SEQUENCE_EDITOR'
1094     bl_region_type = 'UI'
1095
1096     # NOTE: this is just a wrapper around the generic GP tools panel
1097     # It contains access to some essential tools usually found only in
1098     # toolbar, which doesn't exist here...
1099
1100
1101 if __name__ == "__main__":  # only for live edit.
1102     bpy.utils.register_module(__name__)