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