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