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