svn merge -r 30566:30717 https://svn.blender.org/svnroot/bf-blender/trunk/blender
[blender.git] / release / scripts / 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
22
23 def act_strip(context):
24     try:
25         return context.scene.sequence_editor.active_strip
26     except AttributeError:
27         return None
28
29
30 class SEQUENCER_HT_header(bpy.types.Header):
31     bl_space_type = 'SEQUENCE_EDITOR'
32
33     def draw(self, context):
34         layout = self.layout
35
36         st = context.space_data
37
38         row = layout.row(align=True)
39         row.template_header()
40
41         if context.area.show_menus:
42             sub = row.row(align=True)
43             sub.menu("SEQUENCER_MT_view")
44
45             row.separator()
46
47             if (st.view_type == 'SEQUENCER') or (st.view_type == 'SEQUENCER_PREVIEW'):
48                 sub.menu("SEQUENCER_MT_select")
49                 sub.menu("SEQUENCER_MT_marker")
50                 sub.menu("SEQUENCER_MT_add")
51                 sub.menu("SEQUENCER_MT_strip")
52
53         layout.prop(st, "view_type", expand=True, text="")
54
55         if (st.view_type == 'PREVIEW') or (st.view_type == 'SEQUENCER_PREVIEW'):
56             layout.prop(st, "display_mode", expand=True, text="")
57
58         if (st.view_type == 'SEQUENCER'):
59             row = layout.row(align=True)
60             row.operator("sequencer.copy", text="", icon='COPYDOWN')
61             row.operator("sequencer.paste", text="", icon='PASTEDOWN')
62
63             layout.separator()
64             layout.operator("sequencer.refresh_all")
65         elif (st.view_type == 'SEQUENCER_PREVIEW'):
66             layout.separator()
67             layout.operator("sequencer.refresh_all")
68             layout.prop(st, "display_channel", text="Channel")
69         else:
70             layout.prop(st, "display_channel", text="Channel")
71
72             ed = context.scene.sequence_editor
73             if ed:
74                 row = layout.row(align=True)
75                 row.prop(ed, "show_overlay", text="", icon='GHOST_ENABLED')
76                 if ed.show_overlay:
77                     row.prop(ed, "overlay_frame", text="")
78                     row.prop(ed, "overlay_lock", text="", icon='LOCKED')
79
80
81 class SEQUENCER_MT_view_toggle(bpy.types.Menu):
82     bl_label = "View Type"
83
84     def draw(self, context):
85         layout = self.layout
86
87         layout.operator("sequencer.view_toggle").type = 'SEQUENCER'
88         layout.operator("sequencer.view_toggle").type = 'PREVIEW'
89         layout.operator("sequencer.view_toggle").type = 'SEQUENCER_PREVIEW'
90
91
92 class SEQUENCER_MT_view(bpy.types.Menu):
93     bl_label = "View"
94
95     def draw(self, context):
96         layout = self.layout
97
98         st = context.space_data
99
100         layout.column()
101
102         """
103     uiBlock *block= uiBeginBlock(C, ar, "seq_viewmenu", UI_EMBOSSP);
104     short yco= 0, menuwidth=120;
105
106     if (sseq->mainb == SEQ_DRAW_SEQUENCE) {
107         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1,
108                  "Play Back Animation "
109                  "in all Sequence Areas|Alt A", 0, yco-=20,
110                  menuwidth, 19, NULL, 0.0, 0.0, 1, 1, "");
111     }
112     else {
113         uiDefIconTextBut(block, BUTM, 1, ICON_MENU_PANEL,
114                  "Grease Pencil...", 0, yco-=20,
115                  menuwidth, 19, NULL, 0.0, 0.0, 1, 7, "");
116         uiDefMenuSep(block);
117
118         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1,
119                  "Play Back Animation "
120                  "in this window|Alt A", 0, yco-=20,
121                  menuwidth, 19, NULL, 0.0, 0.0, 1, 1, "");
122     }
123     uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1,
124              "Play Back Animation in all "
125              "3D Views and Sequence Areas|Alt Shift A",
126              0, yco-=20,
127              menuwidth, 19, NULL, 0.0, 0.0, 1, 2, "");
128
129         """
130         layout.separator()
131         if (st.view_type == 'SEQUENCER') or (st.view_type == 'SEQUENCER_PREVIEW'):
132             layout.operator("sequencer.view_all", text='View all Sequences')
133         if (st.view_type == 'PREVIEW') or (st.view_type == 'SEQUENCER_PREVIEW'):
134             layout.operator_context = 'INVOKE_REGION_PREVIEW'
135             layout.operator("sequencer.view_all_preview", text='Fit preview in window')
136             layout.operator_context = 'INVOKE_DEFAULT'
137
138             # # XXX, invokes in the header view
139             # layout.operator("sequencer.view_ghost_border", text='Overlay Border')
140
141         layout.operator("sequencer.view_selected")
142
143         layout.prop(st, "draw_frames")
144         layout.prop(st, "show_cframe_indicator")
145         if st.display_mode == 'IMAGE':
146             layout.prop(st, "draw_safe_margin")
147         if st.display_mode == 'WAVEFORM':
148             layout.prop(st, "separate_color_preview")
149
150         layout.separator()
151         layout.prop(st, "use_marker_sync")
152         layout.separator()
153
154         layout.operator("screen.area_dupli")
155         layout.operator("screen.screen_full_area")
156
157
158 class SEQUENCER_MT_select(bpy.types.Menu):
159     bl_label = "Select"
160
161     def draw(self, context):
162         layout = self.layout
163
164         layout.column()
165         layout.operator("sequencer.select_active_side", text="Strips to the Left").side = 'LEFT'
166         layout.operator("sequencer.select_active_side", text="Strips to the Right").side = 'RIGHT'
167         layout.separator()
168         layout.operator("sequencer.select_handles", text="Surrounding Handles").side = 'BOTH'
169         layout.operator("sequencer.select_handles", text="Left Handle").side = 'LEFT'
170         layout.operator("sequencer.select_handles", text="Right Handle").side = 'RIGHT'
171         layout.separator()
172         layout.operator("sequencer.select_linked")
173         layout.operator("sequencer.select_all_toggle")
174         layout.operator("sequencer.select_inverse")
175
176
177 class SEQUENCER_MT_marker(bpy.types.Menu):
178     bl_label = "Marker"
179
180     def draw(self, context):
181         layout = self.layout
182
183         layout.column()
184         layout.operator("marker.add", text="Add Marker")
185         layout.operator("marker.duplicate", text="Duplicate Marker")
186         layout.operator("marker.move", text="Grab/Move Marker")
187         layout.operator("marker.delete", text="Delete Marker")
188         layout.separator()
189         layout.label(text="ToDo: Name Marker")
190
191         #layout.operator("sequencer.sound_strip_add", text="Transform Markers") # toggle, will be rna - (sseq->flag & SEQ_MARKER_TRANS)
192
193
194 class SEQUENCER_MT_add(bpy.types.Menu):
195     bl_label = "Add"
196
197     def draw(self, context):
198         layout = self.layout
199         layout.operator_context = 'INVOKE_REGION_WIN'
200
201         layout.column()
202         layout.operator_menu_enum("sequencer.scene_strip_add", "scene", text="Scene...")
203         layout.operator("sequencer.movie_strip_add", text="Movie")
204         layout.operator("sequencer.image_strip_add", text="Image")
205         layout.operator("sequencer.sound_strip_add", text="Sound")
206
207         layout.menu("SEQUENCER_MT_add_effect")
208
209
210 class SEQUENCER_MT_add_effect(bpy.types.Menu):
211     bl_label = "Effect Strip..."
212
213     def draw(self, context):
214         layout = self.layout
215         layout.operator_context = 'INVOKE_REGION_WIN'
216
217         layout.column()
218         layout.operator("sequencer.effect_strip_add", text="Add").type = 'ADD'
219         layout.operator("sequencer.effect_strip_add", text="Subtract").type = 'SUBTRACT'
220         layout.operator("sequencer.effect_strip_add", text="Alpha Over").type = 'ALPHA_OVER'
221         layout.operator("sequencer.effect_strip_add", text="Alpha Under").type = 'ALPHA_UNDER'
222         layout.operator("sequencer.effect_strip_add", text="Cross").type = 'CROSS'
223         layout.operator("sequencer.effect_strip_add", text="Gamma Cross").type = 'GAMMA_CROSS'
224         layout.operator("sequencer.effect_strip_add", text="Multiply").type = 'MULTIPLY'
225         layout.operator("sequencer.effect_strip_add", text="Over Drop").type = 'OVER_DROP'
226         layout.operator("sequencer.effect_strip_add", text="Plugin").type = 'PLUGIN'
227         layout.operator("sequencer.effect_strip_add", text="Wipe").type = 'WIPE'
228         layout.operator("sequencer.effect_strip_add", text="Glow").type = 'GLOW'
229         layout.operator("sequencer.effect_strip_add", text="Transform").type = 'TRANSFORM'
230         layout.operator("sequencer.effect_strip_add", text="Color").type = 'COLOR'
231         layout.operator("sequencer.effect_strip_add", text="Speed Control").type = 'SPEED'
232         layout.operator("sequencer.effect_strip_add", text="Multicam Selector").type = 'MULTICAM'
233
234
235 class SEQUENCER_MT_strip(bpy.types.Menu):
236     bl_label = "Strip"
237
238     def draw(self, context):
239         layout = self.layout
240
241         layout.operator_context = 'INVOKE_REGION_WIN'
242
243         layout.column()
244         layout.operator("transform.transform", text="Grab/Move").mode = 'TRANSLATION'
245         layout.operator("transform.transform", text="Grab/Extend from frame").mode = 'TIME_EXTEND'
246         #  uiItemO(layout, NULL, 0, "sequencer.strip_snap"); // TODO - add this operator
247         layout.separator()
248
249         layout.operator("sequencer.cut", text="Cut (hard) at frame").type = 'HARD'
250         layout.operator("sequencer.cut", text="Cut (soft) at frame").type = 'SOFT'
251         layout.operator("sequencer.images_separate")
252         layout.operator("sequencer.deinterlace_selected_movies")
253         layout.separator()
254
255         layout.operator("sequencer.duplicate")
256         layout.operator("sequencer.delete")
257
258         strip = act_strip(context)
259
260         if strip:
261             stype = strip.type
262
263             # XXX note strip.type is never equal to 'EFFECT', look at seq_type_items within rna_sequencer.c
264             if stype == 'EFFECT':
265                 pass
266                 # layout.separator()
267                 # layout.operator("sequencer.effect_change")
268                 # layout.operator("sequencer.effect_reassign_inputs")
269             elif stype == 'IMAGE':
270                 layout.separator()
271                 # layout.operator("sequencer.image_change")
272                 layout.operator("sequencer.rendersize")
273             elif stype == 'SCENE':
274                 pass
275                 # layout.separator()
276                 # layout.operator("sequencer.scene_change", text="Change Scene")
277             elif stype == 'MOVIE':
278                 layout.separator()
279                 # layout.operator("sequencer.movie_change")
280                 layout.operator("sequencer.rendersize")
281
282         layout.separator()
283
284         layout.operator("sequencer.meta_make")
285         layout.operator("sequencer.meta_separate")
286
287         #if (ed && (ed->metastack.first || (ed->act_seq && ed->act_seq->type == SEQ_META))) {
288         #       uiItemS(layout);
289         #       uiItemO(layout, NULL, 0, "sequencer.meta_toggle");
290         #}
291
292         layout.separator()
293         layout.operator("sequencer.reload")
294         layout.operator("sequencer.reassign_inputs")
295         layout.separator()
296         layout.operator("sequencer.lock")
297         layout.operator("sequencer.unlock")
298         layout.operator("sequencer.mute")
299         layout.operator("sequencer.unmute")
300
301         layout.operator("sequencer.mute", text="Mute Deselected Strips").unselected = True
302
303         layout.operator("sequencer.snap")
304
305         layout.operator_menu_enum("sequencer.swap", "side")
306
307         layout.separator()
308
309         layout.operator("sequencer.swap_data")
310
311
312 class SequencerButtonsPanel(bpy.types.Panel):
313     bl_space_type = 'SEQUENCE_EDITOR'
314     bl_region_type = 'UI'
315
316     def has_sequencer(self, context):
317         return (context.space_data.view_type == 'SEQUENCER') or (context.space_data.view_type == 'SEQUENCER_PREVIEW')
318
319     def poll(self, context):
320         return self.has_sequencer(context) and (act_strip(context) is not None)
321
322
323 class SequencerButtonsPanel_Output(bpy.types.Panel):
324     bl_space_type = 'SEQUENCE_EDITOR'
325     bl_region_type = 'UI'
326
327     def has_preview(self, context):
328         return (context.space_data.view_type == 'PREVIEW') or (context.space_data.view_type == 'SEQUENCER_PREVIEW')
329
330     def poll(self, context):
331         return self.has_preview(context)
332
333
334 class SEQUENCER_PT_edit(SequencerButtonsPanel):
335     bl_label = "Edit Strip"
336
337     def draw(self, context):
338         layout = self.layout
339         scene = context.scene
340         render = context.scene.render
341         frame_current = scene.frame_current
342         strip = act_strip(context)
343
344         split = layout.split(percentage=0.3)
345         split.label(text="Name:")
346         split.prop(strip, "name", text="")
347
348         split = layout.split(percentage=0.3)
349         split.label(text="Type:")
350         split.prop(strip, "type", text="")
351
352         split = layout.split(percentage=0.3)
353         split.label(text="Blend:")
354         split.prop(strip, "blend_mode", text="")
355
356         row = layout.row(align=True)
357         sub = row.row()
358         sub.active = (not strip.mute)
359         sub.prop(strip, "blend_opacity", text="Opacity", slider=True)
360         sub = row.row()
361         row.prop(strip, "mute", toggle=True, icon='RESTRICT_VIEW_ON' if strip.mute else 'RESTRICT_VIEW_OFF', text="")
362         row.prop(strip, "lock", toggle=True, icon='LOCKED' if strip.lock else 'UNLOCKED', text="")
363
364         col = layout.column()
365         sub = col.column()
366         sub.enabled = not strip.lock
367         sub.prop(strip, "channel")
368         sub.prop(strip, "frame_start")
369         sub.prop(strip, "frame_final_length")
370
371         col = layout.column(align=True)
372         row = col.row()
373         row.label(text="Final Length: %s" % bpy.utils.smpte_from_frame(strip.frame_final_length))
374         row = col.row()
375         row.active = (frame_current >= strip.frame_start and frame_current <= strip.frame_start + strip.frame_length)
376         row.label(text="Playhead: %d" % (frame_current - strip.frame_start))
377
378         col.label(text="Frame Offset %d:%d" % (strip.frame_offset_start, strip.frame_offset_end))
379         col.label(text="Frame Still %d:%d" % (strip.frame_still_start, strip.frame_still_end))
380
381
382 class SEQUENCER_PT_preview(bpy.types.Panel):
383     bl_label = "Scene Preview/Render"
384     bl_space_type = 'SEQUENCE_EDITOR'
385     bl_region_type = 'UI'
386
387     def draw(self, context):
388         layout = self.layout
389         render = context.scene.render
390
391         col = layout.column()
392         col.prop(render, "use_sequencer_gl_preview", text="Open GL Preview")
393         col = layout.column()
394         col.active = render.use_sequencer_gl_preview
395         col.prop(render, "sequencer_gl_preview", text="")
396
397         '''
398         col = layout.column()
399         col.prop(render, "use_sequencer_gl_render", text="Open GL Render")
400         col = layout.column()
401         col.active = render.use_sequencer_gl_render
402         col.prop(render, "sequencer_gl_render", text="")
403         '''
404
405
406 class SEQUENCER_PT_effect(SequencerButtonsPanel):
407     bl_label = "Effect Strip"
408
409     def poll(self, context):
410         if not self.has_sequencer(context):
411             return False
412
413         strip = act_strip(context)
414         if not strip:
415             return False
416
417         return strip.type in ('ADD', 'SUBTRACT', 'ALPHA_OVER', 'ALPHA_UNDER',
418                               'CROSS', 'GAMMA_CROSS', 'MULTIPLY', 'OVER_DROP',
419                               'PLUGIN',
420                               'WIPE', 'GLOW', 'TRANSFORM', 'COLOR', 'SPEED',
421                               'MULTICAM')
422
423     def draw(self, context):
424         layout = self.layout
425
426         strip = act_strip(context)
427
428         if strip.type == 'COLOR':
429             layout.prop(strip, "color")
430
431         elif strip.type == 'WIPE':
432
433             col = layout.column()
434             col.prop(strip, "transition_type")
435             col.label(text="Direction:")
436             col.row().prop(strip, "direction", expand=True)
437
438             col = layout.column()
439             col.prop(strip, "blur_width", slider=True)
440             if strip.transition_type in ('SINGLE', 'DOUBLE'):
441                 col.prop(strip, "angle")
442
443         elif strip.type == 'GLOW':
444             flow = layout.column_flow()
445             flow.prop(strip, "threshold", slider=True)
446             flow.prop(strip, "clamp", slider=True)
447             flow.prop(strip, "boost_factor")
448             flow.prop(strip, "blur_distance")
449
450             row = layout.row()
451             row.prop(strip, "quality", slider=True)
452             row.prop(strip, "only_boost")
453
454         elif strip.type == 'SPEED':
455             layout.prop(strip, "global_speed")
456
457             flow = layout.column_flow()
458             flow.prop(strip, "curve_velocity")
459             flow.prop(strip, "curve_compress_y")
460             flow.prop(strip, "frame_blending")
461
462         elif strip.type == 'TRANSFORM':
463             self.draw_panel_transform(strip)
464
465         elif strip.type == "MULTICAM":
466             layout.prop(strip, "multicam_source")
467
468             row = layout.row(align=True)
469             sub = row.row()
470             sub.scale_x = 2.0
471
472             if not context.screen.animation_playing:
473                 sub.operator("screen.animation_play", text="", icon='PLAY')
474             else:
475                 sub.operator("screen.animation_play", text="", icon='PAUSE')
476
477             row.label("Cut To")
478             for i in range(1, strip.channel):
479                 row.operator("sequencer.cut_multicam", text=str(i)).camera = i
480
481
482         col = layout.column(align=True)
483         if strip.type == 'SPEED':
484             col.prop(strip, "speed_fader", text="Speed fader")
485         elif strip.type in ('CROSS', 'GAMMA_CROSS', 'PLUGIN', 'WIPE'):
486                 col.prop(strip, "use_effect_default_fade", "Default fade")
487                 if not strip.use_effect_default_fade:
488                     col.prop(strip, "effect_fader", text="Effect fader")
489         
490         layout.prop(strip, "use_translation", text="Image Offset:")
491         if strip.use_translation:
492             col = layout.column(align=True)
493             col.prop(strip.transform, "offset_x", text="X")
494             col.prop(strip.transform, "offset_y", text="Y")
495
496         layout.prop(strip, "use_crop", text="Image Crop:")
497         if strip.use_crop:
498             col = layout.column(align=True)
499             col.prop(strip.crop, "top")
500             col.prop(strip.crop, "left")
501             col.prop(strip.crop, "bottom")
502             col.prop(strip.crop, "right")
503
504     def draw_panel_transform(self, strip):
505         layout = self.layout
506         col = layout.column()
507
508         col.prop(strip, "interpolation")
509         col.prop(strip, "translation_unit")
510         col = layout.column(align=True)
511         col.label(text="Position:")
512         col.prop(strip, "translate_start_x", text="X")
513         col.prop(strip, "translate_start_y", text="Y")
514
515         layout.separator()
516
517         col = layout.column(align=True)
518         col.prop(strip, "uniform_scale")
519         if (strip.uniform_scale):
520             col = layout.column(align=True)
521             col.prop(strip, "scale_start_x", text="Scale")
522         else:
523             col = layout.column(align=True)
524             col.label(text="Scale:")
525             col.prop(strip, "scale_start_x", text="X")
526             col.prop(strip, "scale_start_y", text="Y")
527
528         layout.separator()
529
530         col = layout.column(align=True)
531         col.label(text="Rotation:")
532         col.prop(strip, "rotation_start", text="Rotation")
533
534
535 class SEQUENCER_PT_input(SequencerButtonsPanel):
536     bl_label = "Strip Input"
537
538     def poll(self, context):
539         if not self.has_sequencer(context):
540             return False
541
542         strip = act_strip(context)
543         if not strip:
544             return False
545
546         return strip.type in ('MOVIE', 'IMAGE', 'SCENE', 'META',
547                               'ADD', 'SUBTRACT', 'ALPHA_OVER', 'ALPHA_UNDER',
548                               'CROSS', 'GAMMA_CROSS', 'MULTIPLY', 'OVER_DROP',
549                               'PLUGIN',
550                               'WIPE', 'GLOW', 'TRANSFORM', 'COLOR',
551                               'MULTICAM', 'SPEED')
552
553     def draw_filename(self, context):
554         pass
555
556     def draw(self, context):
557         layout = self.layout
558
559         strip = act_strip(context)
560
561         self.draw_filename(context)
562
563         layout.prop(strip, "use_translation", text="Image Offset:")
564         if strip.use_translation:
565             col = layout.column(align=True)
566             col.prop(strip.transform, "offset_x", text="X")
567             col.prop(strip.transform, "offset_y", text="Y")
568
569         layout.prop(strip, "use_crop", text="Image Crop:")
570         if strip.use_crop:
571             col = layout.column(align=True)
572             col.prop(strip.crop, "top")
573             col.prop(strip.crop, "left")
574             col.prop(strip.crop, "bottom")
575             col.prop(strip.crop, "right")
576
577         col = layout.column(align=True)
578         col.label(text="Trim Duration:")
579         col.prop(strip, "animation_start_offset", text="Start")
580         col.prop(strip, "animation_end_offset", text="End")
581
582
583 class SEQUENCER_PT_input_movie(SEQUENCER_PT_input):
584     bl_label = "Strip Input"
585
586     def poll(self, context):
587         if not self.has_sequencer(context):
588             return False
589
590         strip = act_strip(context)
591         if not strip:
592             return False
593
594         return strip.type == 'MOVIE'
595
596     def draw_filename(self, context):
597         layout = self.layout
598
599         strip = act_strip(context)
600
601         split = layout.split(percentage=0.2)
602         col = split.column()
603         col.label(text="Path:")
604         col = split.column()
605         col.prop(strip, "filepath", text="")
606         col.prop(strip, "mpeg_preseek", text="MPEG Preseek")
607
608
609 class SEQUENCER_PT_input_image(SEQUENCER_PT_input):
610     bl_label = "Strip Input"
611
612     def poll(self, context):
613         if not self.has_sequencer(context):
614             return False
615
616         strip = act_strip(context)
617         if not strip:
618             return False
619
620         return strip.type == 'IMAGE'
621
622     def draw_filename(self, context):
623         layout = self.layout
624
625         strip = act_strip(context)
626
627         split = layout.split(percentage=0.2)
628         col = split.column()
629         col.label(text="Path:")
630         col = split.column()
631         col.prop(strip, "directory", text="")
632
633         # Current element for the filename
634
635         elem = strip.getStripElem(context.scene.frame_current)
636         if elem:
637             split = layout.split(percentage=0.2)
638             col = split.column()
639             col.label(text="File:")
640             col = split.column()
641             col.prop(elem, "filename", text="") # strip.elements[0] could be a fallback
642
643
644 class SEQUENCER_PT_input_secondary(SEQUENCER_PT_input):
645     bl_label = "Strip Input"
646
647     def poll(self, context):
648         if not self.has_sequencer(context):
649             return False
650
651         strip = act_strip(context)
652         if not strip:
653             return False
654
655         return strip.type in ('SCENE', 'META')
656
657     def draw_filename(self, context):
658         pass
659
660
661 class SEQUENCER_PT_sound(SequencerButtonsPanel):
662     bl_label = "Sound"
663
664     def poll(self, context):
665         if not self.has_sequencer(context):
666             return False
667
668         strip = act_strip(context)
669         if not strip:
670             return False
671
672         return (strip.type == 'SOUND')
673
674     def draw(self, context):
675         layout = self.layout
676
677         strip = act_strip(context)
678
679         layout.template_ID(strip, "sound", open="sound.open")
680
681         layout.separator()
682         layout.prop(strip, "filepath", text="")
683
684         row = layout.row()
685         if strip.sound.packed_file:
686             row.operator("sound.unpack", icon='PACKAGE', text="Unpack")
687         else:
688             row.operator("sound.pack", icon='UGLYPACKAGE', text="Pack")
689
690         row.prop(strip.sound, "caching")
691
692         layout.prop(strip, "volume")
693         layout.prop(strip, "attenuation")
694
695         col = layout.column(align=True)
696         col.label(text="Trim Duration:")
697         col.prop(strip, "animation_start_offset", text="Start")
698         col.prop(strip, "animation_end_offset", text="End")
699
700
701 class SEQUENCER_PT_scene(SequencerButtonsPanel):
702     bl_label = "Scene"
703
704     def poll(self, context):
705         if not self.has_sequencer(context):
706             return False
707
708         strip = act_strip(context)
709         if not strip:
710             return False
711
712         return (strip.type == 'SCENE')
713
714     def draw(self, context):
715         layout = self.layout
716
717         strip = act_strip(context)
718
719         layout.template_ID(strip, "scene")
720
721         layout.label(text="Camera Override")
722         layout.template_ID(strip, "scene_camera")
723
724
725 class SEQUENCER_PT_filter(SequencerButtonsPanel):
726     bl_label = "Filter"
727
728     def poll(self, context):
729         if not self.has_sequencer(context):
730             return False
731
732         strip = act_strip(context)
733         if not strip:
734             return False
735
736         return strip.type in ('MOVIE', 'IMAGE', 'SCENE', 'META',
737                               'ADD', 'SUBTRACT', 'ALPHA_OVER', 'ALPHA_UNDER',
738                               'CROSS', 'GAMMA_CROSS', 'MULTIPLY', 'OVER_DROP',
739                               'PLUGIN',
740                               'WIPE', 'GLOW', 'TRANSFORM', 'COLOR',
741                               'MULTICAM', 'SPEED')
742
743     def draw(self, context):
744         layout = self.layout
745
746         strip = act_strip(context)
747
748         col = layout.column()
749         col.label(text="Video:")
750         col.prop(strip, "strobe")
751
752         row = layout.row()
753         row.label(text="Flip:")
754         row.prop(strip, "flip_x", text="X")
755         row.prop(strip, "flip_y", text="Y")
756
757         col = layout.column()
758         col.prop(strip, "reverse_frames", text="Backwards")
759         col.prop(strip, "de_interlace")
760
761         col = layout.column()
762         col.label(text="Colors:")
763         col.prop(strip, "color_saturation", text="Saturation")
764         col.prop(strip, "multiply_colors", text="Multiply")
765         col.prop(strip, "premultiply")
766         col.prop(strip, "convert_float")
767
768         layout.prop(strip, "use_color_balance")
769         if strip.use_color_balance and strip.color_balance: # TODO - need to add this somehow
770             row = layout.row()
771             row.active = strip.use_color_balance
772             col = row.column()
773             col.template_color_wheel(strip.color_balance, "lift", value_slider=False, cubic=True)
774             col.row().prop(strip.color_balance, "lift")
775             col.prop(strip.color_balance, "inverse_lift", text="Inverse")
776             col = row.column()
777             col.template_color_wheel(strip.color_balance, "gamma", value_slider=False, lock_luminosity=True, cubic=True)
778             col.row().prop(strip.color_balance, "gamma")
779             col.prop(strip.color_balance, "inverse_gamma", text="Inverse")
780             col = row.column()
781             col.template_color_wheel(strip.color_balance, "gain", value_slider=False, lock_luminosity=True, cubic=True)
782             col.row().prop(strip.color_balance, "gain")
783             col.prop(strip.color_balance, "inverse_gain", text="Inverse")
784
785
786 class SEQUENCER_PT_proxy(SequencerButtonsPanel):
787     bl_label = "Proxy"
788
789     def poll(self, context):
790         if not self.has_sequencer(context):
791             return False
792
793         strip = act_strip(context)
794         if not strip:
795             return False
796
797         return strip.type in ('MOVIE', 'IMAGE', 'SCENE', 'META', 'MULTICAM')
798
799     def draw_header(self, context):
800         strip = act_strip(context)
801
802         self.layout.prop(strip, "use_proxy", text="")
803
804     def draw(self, context):
805         layout = self.layout
806
807         strip = act_strip(context)
808
809         flow = layout.column_flow()
810         flow.prop(strip, "proxy_custom_directory")
811         flow.prop(strip, "proxy_custom_file")
812         if strip.proxy: # TODO - need to add this somehow
813             if strip.proxy_custom_directory and not strip.proxy_custom_file:
814                 flow.prop(strip.proxy, "directory")
815             if strip.proxy_custom_file:
816                 flow.prop(strip.proxy, "filepath")
817
818
819 class SEQUENCER_PT_view(SequencerButtonsPanel_Output):
820     bl_label = "View Settings"
821
822     def draw(self, context):
823         layout = self.layout
824
825         st = context.space_data
826
827         col = layout.column()
828         if st.display_mode == 'IMAGE':
829             col.prop(st, "draw_overexposed") # text="Zebra"
830             col.prop(st, "draw_safe_margin")
831         if st.display_mode == 'WAVEFORM':
832             col.prop(st, "separate_color_preview")
833         col.prop(st, "proxy_render_size")
834
835 classes = [
836     SEQUENCER_HT_header, # header/menu classes
837     SEQUENCER_MT_view,
838     SEQUENCER_MT_view_toggle,
839     SEQUENCER_MT_select,
840     SEQUENCER_MT_marker,
841     SEQUENCER_MT_add,
842     SEQUENCER_MT_add_effect,
843     SEQUENCER_MT_strip,
844
845     SEQUENCER_PT_edit, # sequencer panels
846     SEQUENCER_PT_preview,
847     SEQUENCER_PT_effect,
848     SEQUENCER_PT_input_movie,
849     SEQUENCER_PT_input_image,
850     SEQUENCER_PT_input_secondary,
851     SEQUENCER_PT_sound,
852     SEQUENCER_PT_scene,
853     SEQUENCER_PT_filter,
854     SEQUENCER_PT_proxy,
855
856     SEQUENCER_PT_view] # view panels
857
858
859 def register():
860     register = bpy.types.register
861     for cls in classes:
862         register(cls)
863
864
865 def unregister():
866     unregister = bpy.types.unregister
867     for cls in classes:
868         unregister(cls)
869
870 if __name__ == "__main__":
871     register()