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