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