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