Sequencer: expose GL preview alpha in scene UI
[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 from rna_prop_ui import PropertyPanel
23 from bl_ui.properties_grease_pencil_common import GreasePencilDataPanel, GreasePencilToolsPanel
24 from bpy.app.translations import pgettext_iface as iface_
25
26
27 def act_strip(context):
28     try:
29         return context.scene.sequence_editor.active_strip
30     except AttributeError:
31         return None
32
33
34 def draw_color_balance(layout, color_balance):
35     col = layout.column()
36     col.label(text="Lift:")
37     col.template_color_picker(color_balance, "lift", value_slider=True, cubic=True)
38     row = col.row()
39     row.prop(color_balance, "lift", text="")
40     row.prop(color_balance, "invert_lift", text="Inverse")
41
42     col = layout.column()
43     col.label(text="Gamma:")
44     col.template_color_picker(color_balance, "gamma", value_slider=True, lock_luminosity=True, cubic=True)
45     row = col.row()
46     row.prop(color_balance, "gamma", text="")
47     row.prop(color_balance, "invert_gamma", text="Inverse")
48
49     col = layout.column()
50     col.label(text="Gain:")
51     col.template_color_picker(color_balance, "gain", value_slider=True, lock_luminosity=True, cubic=True)
52     row = col.row()
53     row.prop(color_balance, "gain", text="")
54     row.prop(color_balance, "invert_gain", text="Inverse")
55
56
57 class SEQUENCER_HT_header(Header):
58     bl_space_type = 'SEQUENCE_EDITOR'
59
60     def draw(self, context):
61         layout = self.layout
62
63         st = context.space_data
64         scene = context.scene
65
66         row = layout.row(align=True)
67         row.template_header()
68
69         SEQUENCER_MT_editor_menus.draw_collapsible(context, layout)
70
71         row = layout.row(align=True)
72         row.prop(scene, "use_preview_range", text="", toggle=True)
73         row.prop(scene, "lock_frame_selection_to_range", text="", toggle=True)
74
75         layout.prop(st, "view_type", expand=True, text="")
76
77         if st.view_type in {'PREVIEW', 'SEQUENCER_PREVIEW'}:
78             layout.prop(st, "display_mode", expand=True, text="")
79
80         if st.view_type == 'SEQUENCER':
81             row = layout.row(align=True)
82             row.operator("sequencer.copy", text="", icon='COPYDOWN')
83             row.operator("sequencer.paste", text="", icon='PASTEDOWN')
84
85             layout.separator()
86             layout.operator("sequencer.refresh_all")
87             layout.prop(st, "show_backdrop")
88         else:
89             if st.view_type == 'SEQUENCER_PREVIEW':
90                 layout.separator()
91                 layout.operator("sequencer.refresh_all")
92
93             layout.prop(st, "preview_channels", expand=True, text="")
94             layout.prop(st, "display_channel", text="Channel")
95
96             ed = context.scene.sequence_editor
97             if ed:
98                 row = layout.row(align=True)
99                 row.prop(ed, "show_overlay", text="", icon='GHOST_ENABLED')
100                 if ed.show_overlay:
101                     row.prop(ed, "overlay_frame", text="")
102                     row.prop(ed, "use_overlay_lock", text="", icon='LOCKED')
103
104                     row = layout.row()
105                     row.prop(st, "overlay_type", text="")
106
107         if st.view_type in {'PREVIEW', 'SEQUENCER_PREVIEW'}:
108             gpd = context.gpencil_data
109             toolsettings = context.tool_settings
110
111             # Proportional editing
112             if gpd and gpd.use_stroke_edit_mode:
113                 row = layout.row(align=True)
114                 row.prop(toolsettings, "proportional_edit", icon_only=True)
115                 if toolsettings.proportional_edit != 'DISABLED':
116                     row.prop(toolsettings, "proportional_edit_falloff", icon_only=True)
117
118         row = layout.row(align=True)
119         row.operator("render.opengl", text="", icon='RENDER_STILL').sequencer = True
120         props = row.operator("render.opengl", text="", icon='RENDER_ANIMATION')
121         props.animation = True
122         props.sequencer = True
123
124         layout.template_running_jobs()
125
126
127 class SEQUENCER_MT_editor_menus(Menu):
128     bl_idname = "SEQUENCER_MT_editor_menus"
129     bl_label = ""
130
131     def draw(self, context):
132         self.draw_menus(self.layout, context)
133
134     @staticmethod
135     def draw_menus(layout, context):
136         st = context.space_data
137
138         layout.menu("SEQUENCER_MT_view")
139
140         if st.view_type in {'SEQUENCER', 'SEQUENCER_PREVIEW'}:
141             layout.menu("SEQUENCER_MT_select")
142             layout.menu("SEQUENCER_MT_marker")
143             layout.menu("SEQUENCER_MT_add")
144             layout.menu("SEQUENCER_MT_frame")
145             layout.menu("SEQUENCER_MT_strip")
146
147
148 class SEQUENCER_MT_view_toggle(Menu):
149     bl_label = "View Type"
150
151     def draw(self, context):
152         layout = self.layout
153
154         layout.operator("sequencer.view_toggle").type = 'SEQUENCER'
155         layout.operator("sequencer.view_toggle").type = 'PREVIEW'
156         layout.operator("sequencer.view_toggle").type = 'SEQUENCER_PREVIEW'
157
158
159 class SEQUENCER_MT_view(Menu):
160     bl_label = "View"
161
162     def draw(self, context):
163         layout = self.layout
164
165         st = context.space_data
166         is_preview = st.view_type in {'PREVIEW', 'SEQUENCER_PREVIEW'}
167         is_sequencer_view = st.view_type in {'SEQUENCER', 'SEQUENCER_PREVIEW'}
168
169         if st.view_type == 'PREVIEW':
170             # Specifying the REGION_PREVIEW context is needed in preview-only
171             # mode, else the lookup for the shortcut will fail in
172             # wm_keymap_item_find_props() (see #32595).
173             layout.operator_context = 'INVOKE_REGION_PREVIEW'
174         layout.operator("sequencer.properties", icon='MENU_PANEL')
175         layout.operator_context = 'INVOKE_DEFAULT'
176
177         layout.separator()
178
179         if is_sequencer_view:
180             layout.operator_context = 'INVOKE_REGION_WIN'
181             layout.operator("sequencer.view_all", text="View all Sequences")
182             layout.operator("sequencer.view_selected")
183             layout.operator_context = 'INVOKE_DEFAULT'
184         if is_preview:
185             layout.operator_context = 'INVOKE_REGION_PREVIEW'
186             layout.operator("sequencer.view_all_preview", text="Fit preview in window")
187
188             layout.separator()
189
190             ratios = ((1, 8), (1, 4), (1, 2), (1, 1), (2, 1), (4, 1), (8, 1))
191
192             for a, b in ratios:
193                 layout.operator("sequencer.view_zoom_ratio", text=iface_("Zoom %d:%d") % (a, b), translate=False).ratio = a / b
194
195             layout.separator()
196
197             layout.operator_context = 'INVOKE_DEFAULT'
198
199             # # XXX, invokes in the header view
200             # layout.operator("sequencer.view_ghost_border", text="Overlay Border")
201
202         if is_sequencer_view:
203             layout.prop(st, "show_seconds")
204             layout.prop(st, "show_frame_indicator")
205             layout.prop(st, "show_strip_offset")
206
207             layout.prop_menu_enum(st, "waveform_draw_type")
208
209         if is_preview:
210             if st.display_mode == 'IMAGE':
211                 layout.prop(st, "show_safe_areas")
212                 layout.prop(st, "show_metadata")
213             elif st.display_mode == 'WAVEFORM':
214                 layout.prop(st, "show_separate_color")
215
216         layout.separator()
217
218         if is_sequencer_view:
219             layout.prop(st, "use_marker_sync")
220             layout.separator()
221
222         layout.operator("screen.area_dupli")
223         layout.operator("screen.screen_full_area", text="Toggle Maximize Area")
224         layout.operator("screen.screen_full_area").use_hide_panels = True
225
226
227 class SEQUENCER_MT_select(Menu):
228     bl_label = "Select"
229
230     def draw(self, context):
231         layout = self.layout
232
233         layout.operator("sequencer.select_active_side", text="Strips to the Left").side = 'LEFT'
234         layout.operator("sequencer.select_active_side", text="Strips to the Right").side = 'RIGHT'
235         props = layout.operator("sequencer.select", text="All strips to the Left")
236         props.left_right = 'LEFT'
237         props.linked_time = True
238         props = layout.operator("sequencer.select", text="All strips to the Right")
239         props.left_right = 'RIGHT'
240         props.linked_time = True
241
242         layout.separator()
243         layout.operator("sequencer.select_handles", text="Surrounding Handles").side = 'BOTH'
244         layout.operator("sequencer.select_handles", text="Left Handle").side = 'LEFT'
245         layout.operator("sequencer.select_handles", text="Right Handle").side = 'RIGHT'
246         layout.separator()
247         layout.operator_menu_enum("sequencer.select_grouped", "type", text="Grouped")
248         layout.operator("sequencer.select_linked")
249         layout.operator("sequencer.select_less")
250         layout.operator("sequencer.select_more")
251         layout.operator("sequencer.select_all").action = 'TOGGLE'
252         layout.operator("sequencer.select_all", text="Inverse").action = 'INVERT'
253
254
255 class SEQUENCER_MT_marker(Menu):
256     bl_label = "Marker"
257
258     def draw(self, context):
259         layout = self.layout
260
261         from bl_ui.space_time import marker_menu_generic
262         marker_menu_generic(layout)
263
264
265 class SEQUENCER_MT_change(Menu):
266     bl_label = "Change"
267
268     def draw(self, context):
269         layout = self.layout
270         strip = act_strip(context)
271
272         layout.operator_context = 'INVOKE_REGION_WIN'
273
274         layout.operator_menu_enum("sequencer.change_effect_input", "swap")
275         layout.operator_menu_enum("sequencer.change_effect_type", "type")
276         prop = layout.operator("sequencer.change_path", text="Path/Files")
277
278         if strip:
279             stype = strip.type
280
281             if stype == 'IMAGE':
282                 prop.filter_image = True
283             elif stype == 'MOVIE':
284                 prop.filter_movie = True
285             elif stype == 'SOUND':
286                 prop.filter_sound = True
287
288
289 class SEQUENCER_MT_frame(Menu):
290     bl_label = "Frame"
291
292     def draw(self, context):
293         layout = self.layout
294
295         layout.operator("anim.previewrange_clear")
296         layout.operator("anim.previewrange_set")
297
298         layout.separator()
299
300         props = layout.operator("sequencer.strip_jump", text="Jump to Previous Strip")
301         props.next = False
302         props.center = False
303         props = layout.operator("sequencer.strip_jump", text="Jump to Next Strip")
304         props.next = True
305         props.center = False
306
307         layout.separator()
308
309         props = layout.operator("sequencer.strip_jump", text="Jump to Previous Strip (Center)")
310         props.next = False
311         props.center = True
312         props = layout.operator("sequencer.strip_jump", text="Jump to Next Strip (Center)")
313         props.next = True
314         props.center = True
315
316
317 class SEQUENCER_MT_add(Menu):
318     bl_label = "Add"
319
320     def draw(self, context):
321         layout = self.layout
322
323         layout.operator_context = 'INVOKE_REGION_WIN'
324
325         if len(bpy.data.scenes) > 10:
326             layout.operator_context = 'INVOKE_DEFAULT'
327             layout.operator("sequencer.scene_strip_add", text="Scene...")
328         else:
329             layout.operator_menu_enum("sequencer.scene_strip_add", "scene", text="Scene...")
330
331         if len(bpy.data.movieclips) > 10:
332             layout.operator_context = 'INVOKE_DEFAULT'
333             layout.operator("sequencer.movieclip_strip_add", text="Clips...")
334         else:
335             layout.operator_menu_enum("sequencer.movieclip_strip_add", "clip", text="Clip...")
336
337         if len(bpy.data.masks) > 10:
338             layout.operator_context = 'INVOKE_DEFAULT'
339             layout.operator("sequencer.mask_strip_add", text="Masks...")
340         else:
341             layout.operator_menu_enum("sequencer.mask_strip_add", "mask", text="Mask...")
342
343         layout.operator("sequencer.movie_strip_add", text="Movie")
344         layout.operator("sequencer.image_strip_add", text="Image")
345         layout.operator("sequencer.sound_strip_add", text="Sound")
346
347         layout.menu("SEQUENCER_MT_add_effect")
348
349
350 class SEQUENCER_MT_add_effect(Menu):
351     bl_label = "Effect Strip..."
352
353     def draw(self, context):
354         layout = self.layout
355
356         layout.operator_context = 'INVOKE_REGION_WIN'
357
358         layout.operator("sequencer.effect_strip_add", text="Add").type = 'ADD'
359         layout.operator("sequencer.effect_strip_add", text="Subtract").type = 'SUBTRACT'
360         layout.operator("sequencer.effect_strip_add", text="Alpha Over").type = 'ALPHA_OVER'
361         layout.operator("sequencer.effect_strip_add", text="Alpha Under").type = 'ALPHA_UNDER'
362         layout.operator("sequencer.effect_strip_add", text="Cross").type = 'CROSS'
363         layout.operator("sequencer.effect_strip_add", text="Gamma Cross").type = 'GAMMA_CROSS'
364         layout.operator("sequencer.effect_strip_add", text="Gaussian Blur").type = 'GAUSSIAN_BLUR'
365         layout.operator("sequencer.effect_strip_add", text="Multiply").type = 'MULTIPLY'
366         layout.operator("sequencer.effect_strip_add", text="Over Drop").type = 'OVER_DROP'
367         layout.operator("sequencer.effect_strip_add", text="Wipe").type = 'WIPE'
368         layout.operator("sequencer.effect_strip_add", text="Glow").type = 'GLOW'
369         layout.operator("sequencer.effect_strip_add", text="Text").type = 'TEXT'
370         layout.operator("sequencer.effect_strip_add", text="Transform").type = 'TRANSFORM'
371         layout.operator("sequencer.effect_strip_add", text="Color").type = 'COLOR'
372         layout.operator("sequencer.effect_strip_add", text="Speed Control").type = 'SPEED'
373         layout.operator("sequencer.effect_strip_add", text="Multicam Selector").type = 'MULTICAM'
374         layout.operator("sequencer.effect_strip_add", text="Adjustment Layer").type = 'ADJUSTMENT'
375
376
377 class SEQUENCER_MT_strip(Menu):
378     bl_label = "Strip"
379
380     def draw(self, context):
381         layout = self.layout
382
383         layout.operator_context = 'INVOKE_REGION_WIN'
384
385         layout.operator("transform.transform", text="Grab/Move").mode = 'TRANSLATION'
386         layout.operator("transform.transform", text="Grab/Extend from frame").mode = 'TIME_EXTEND'
387         layout.operator("sequencer.gap_remove").all = False
388         layout.operator("sequencer.gap_insert")
389
390         #  uiItemO(layout, NULL, 0, "sequencer.strip_snap"); // TODO - add this operator
391         layout.separator()
392
393         layout.operator("sequencer.cut", text="Cut (hard) at frame").type = 'HARD'
394         layout.operator("sequencer.cut", text="Cut (soft) at frame").type = 'SOFT'
395         layout.operator("sequencer.slip", text="Slip Strip Contents")
396         layout.operator("sequencer.images_separate")
397         layout.operator("sequencer.offset_clear")
398         layout.operator("sequencer.deinterlace_selected_movies")
399         layout.operator("sequencer.rebuild_proxy")
400         layout.separator()
401
402         layout.operator("sequencer.duplicate_move")
403         layout.operator("sequencer.delete")
404
405         strip = act_strip(context)
406
407         if strip:
408             stype = strip.type
409
410             # XXX note strip.type is never equal to 'EFFECT', look at seq_type_items within rna_sequencer.c
411             if stype == 'EFFECT':
412                 pass
413                 # layout.separator()
414                 # layout.operator("sequencer.effect_change")
415                 # layout.operator("sequencer.effect_reassign_inputs")
416             elif stype == 'IMAGE':
417                 layout.separator()
418                 # layout.operator("sequencer.image_change")
419                 layout.operator("sequencer.rendersize")
420             elif stype == 'SCENE':
421                 pass
422                 # layout.separator()
423                 # layout.operator("sequencer.scene_change", text="Change Scene")
424             elif stype == 'MOVIE':
425                 layout.separator()
426                 # layout.operator("sequencer.movie_change")
427                 layout.operator("sequencer.rendersize")
428             elif stype == 'SOUND':
429                 layout.separator()
430                 layout.operator("sequencer.crossfade_sounds")
431
432         layout.separator()
433
434         layout.operator("sequencer.meta_make")
435         layout.operator("sequencer.meta_separate")
436
437         #if (ed && (ed->metastack.first || (ed->act_seq && ed->act_seq->type == SEQ_META))) {
438         #       uiItemS(layout);
439         #       uiItemO(layout, NULL, 0, "sequencer.meta_toggle");
440         #}
441
442         layout.separator()
443         layout.operator("sequencer.reload", text="Reload Strips")
444         layout.operator("sequencer.reload", text="Reload Strips and Adjust Length").adjust_length = True
445         layout.operator("sequencer.reassign_inputs")
446         layout.operator("sequencer.swap_inputs")
447
448         layout.separator()
449         layout.operator("sequencer.lock")
450         layout.operator("sequencer.unlock")
451         layout.operator("sequencer.mute").unselected = False
452         layout.operator("sequencer.unmute").unselected = False
453
454         layout.operator("sequencer.mute", text="Mute Deselected Strips").unselected = True
455
456         layout.operator("sequencer.snap")
457
458         layout.operator_menu_enum("sequencer.swap", "side")
459
460         layout.separator()
461
462         layout.operator("sequencer.swap_data")
463         layout.menu("SEQUENCER_MT_change")
464
465
466 class SequencerButtonsPanel:
467     bl_space_type = 'SEQUENCE_EDITOR'
468     bl_region_type = 'UI'
469
470     @staticmethod
471     def has_sequencer(context):
472         return (context.space_data.view_type in {'SEQUENCER', 'SEQUENCER_PREVIEW'})
473
474     @classmethod
475     def poll(cls, context):
476         return cls.has_sequencer(context) and (act_strip(context) is not None)
477
478
479 class SequencerButtonsPanel_Output:
480     bl_space_type = 'SEQUENCE_EDITOR'
481     bl_region_type = 'UI'
482
483     @staticmethod
484     def has_preview(context):
485         st = context.space_data
486         return (st.view_type in {'PREVIEW', 'SEQUENCER_PREVIEW'}) or st.show_backdrop
487
488     @classmethod
489     def poll(cls, context):
490         return cls.has_preview(context)
491
492
493 class SEQUENCER_PT_edit(SequencerButtonsPanel, Panel):
494     bl_label = "Edit Strip"
495
496     def draw(self, context):
497         layout = self.layout
498
499         scene = context.scene
500         frame_current = scene.frame_current
501         strip = act_strip(context)
502
503         split = layout.split(percentage=0.3)
504         split.label(text="Name:")
505         split.prop(strip, "name", text="")
506
507         split = layout.split(percentage=0.3)
508         split.label(text="Type:")
509         split.prop(strip, "type", text="")
510
511         if strip.type != 'SOUND':
512             split = layout.split(percentage=0.3)
513             split.label(text="Blend:")
514             split.prop(strip, "blend_type", text="")
515
516             row = layout.row(align=True)
517             sub = row.row(align=True)
518             sub.active = (not strip.mute)
519             sub.prop(strip, "blend_alpha", text="Opacity", slider=True)
520             row.prop(strip, "mute", toggle=True, icon_only=True)
521             row.prop(strip, "lock", toggle=True, icon_only=True)
522         else:
523             row = layout.row(align=True)
524             row.prop(strip, "mute", toggle=True, icon_only=True)
525             row.prop(strip, "lock", toggle=True, icon_only=True)
526
527         col = layout.column()
528         sub = col.column()
529         sub.enabled = not strip.lock
530         sub.prop(strip, "channel")
531         sub.prop(strip, "frame_start")
532         sub.prop(strip, "frame_final_duration")
533
534         col = layout.column(align=True)
535         row = col.row(align=True)
536         row.label(text=iface_("Final Length: %s") % bpy.utils.smpte_from_frame(strip.frame_final_duration),
537                   translate=False)
538         row = col.row(align=True)
539         row.active = (frame_current >= strip.frame_start and frame_current <= strip.frame_start + strip.frame_duration)
540         row.label(text=iface_("Playhead: %d") % (frame_current - strip.frame_start), translate=False)
541
542         col.label(text=iface_("Frame Offset %d:%d") % (strip.frame_offset_start, strip.frame_offset_end),
543                   translate=False)
544         col.label(text=iface_("Frame Still %d:%d") % (strip.frame_still_start, strip.frame_still_end), translate=False)
545
546         elem = False
547
548         if strip.type == 'IMAGE':
549             elem = strip.strip_elem_from_frame(frame_current)
550         elif strip.type == 'MOVIE':
551             elem = strip.elements[0]
552
553         if elem and elem.orig_width > 0 and elem.orig_height > 0:
554             col.label(text=iface_("Original Dimension: %dx%d") % (elem.orig_width, elem.orig_height), translate=False)
555         else:
556             col.label(text="Original Dimension: None")
557
558
559 class SEQUENCER_PT_effect(SequencerButtonsPanel, Panel):
560     bl_label = "Effect Strip"
561
562     @classmethod
563     def poll(cls, context):
564         if not cls.has_sequencer(context):
565             return False
566
567         strip = act_strip(context)
568         if not strip:
569             return False
570
571         return strip.type in {'ADD', 'SUBTRACT', 'ALPHA_OVER', 'ALPHA_UNDER',
572                               'CROSS', 'GAMMA_CROSS', 'MULTIPLY', 'OVER_DROP',
573                               'WIPE', 'GLOW', 'TRANSFORM', 'COLOR', 'SPEED',
574                               'MULTICAM', 'GAUSSIAN_BLUR', 'TEXT'}
575
576     def draw(self, context):
577         layout = self.layout
578
579         strip = act_strip(context)
580
581         if strip.input_count > 0:
582             col = layout.column()
583             col.enabled = False
584             col.prop(strip, "input_1")
585             if strip.input_count > 1:
586                 col.prop(strip, "input_2")
587
588         if strip.type == 'COLOR':
589             layout.prop(strip, "color")
590
591         elif strip.type == 'WIPE':
592             col = layout.column()
593             col.prop(strip, "transition_type")
594             col.label(text="Direction:")
595             col.row().prop(strip, "direction", expand=True)
596
597             col = layout.column()
598             col.prop(strip, "blur_width", slider=True)
599             if strip.transition_type in {'SINGLE', 'DOUBLE'}:
600                 col.prop(strip, "angle")
601
602         elif strip.type == 'GLOW':
603             flow = layout.column_flow()
604             flow.prop(strip, "threshold", slider=True)
605             flow.prop(strip, "clamp", slider=True)
606             flow.prop(strip, "boost_factor")
607             flow.prop(strip, "blur_radius")
608
609             row = layout.row()
610             row.prop(strip, "quality", slider=True)
611             row.prop(strip, "use_only_boost")
612
613         elif strip.type == 'SPEED':
614             layout.prop(strip, "use_default_fade", "Stretch to input strip length")
615             if not strip.use_default_fade:
616                 layout.prop(strip, "use_as_speed")
617                 if strip.use_as_speed:
618                     layout.prop(strip, "speed_factor")
619                 else:
620                     layout.prop(strip, "speed_factor", text="Frame number")
621                     layout.prop(strip, "scale_to_length")
622
623         elif strip.type == 'TRANSFORM':
624             layout = self.layout
625             col = layout.column()
626
627             col.prop(strip, "interpolation")
628             col.prop(strip, "translation_unit")
629             col = layout.column(align=True)
630             col.label(text="Position:")
631             col.prop(strip, "translate_start_x", text="X")
632             col.prop(strip, "translate_start_y", text="Y")
633
634             layout.separator()
635
636             col = layout.column(align=True)
637             col.prop(strip, "use_uniform_scale")
638             if strip.use_uniform_scale:
639                 col = layout.column(align=True)
640                 col.prop(strip, "scale_start_x", text="Scale")
641             else:
642                 col = layout.column(align=True)
643                 col.label(text="Scale:")
644                 col.prop(strip, "scale_start_x", text="X")
645                 col.prop(strip, "scale_start_y", text="Y")
646
647             layout.separator()
648
649             col = layout.column(align=True)
650             col.label(text="Rotation:")
651             col.prop(strip, "rotation_start", text="Rotation")
652
653         elif strip.type == 'MULTICAM':
654             layout.prop(strip, "multicam_source")
655
656             row = layout.row(align=True)
657             sub = row.row(align=True)
658             sub.scale_x = 2.0
659
660             sub.operator("screen.animation_play", text="", icon='PAUSE' if context.screen.is_animation_playing else 'PLAY')
661
662             row.label("Cut To")
663             for i in range(1, strip.channel):
664                 row.operator("sequencer.cut_multicam", text="%d" % i).camera = i
665
666         elif strip.type == 'TEXT':
667             col = layout.column()
668             col.prop(strip, "text")
669             col.prop(strip, "font_size")
670             col.prop(strip, "use_shadow")
671             col.prop(strip, "align_x")
672             col.prop(strip, "align_y")
673             col.prop(strip, "location")
674             col.prop(strip, "wrap_width")
675             layout.operator("sequencer.export_subtitles")
676
677         col = layout.column(align=True)
678         if strip.type == 'SPEED':
679             col.prop(strip, "multiply_speed")
680         elif strip.type in {'CROSS', 'GAMMA_CROSS', 'WIPE', 'ALPHA_OVER', 'ALPHA_UNDER', 'OVER_DROP'}:
681             col.prop(strip, "use_default_fade", "Default fade")
682             if not strip.use_default_fade:
683                 col.prop(strip, "effect_fader", text="Effect fader")
684         elif strip.type == 'GAUSSIAN_BLUR':
685             col.prop(strip, "size_x")
686             col.prop(strip, "size_y")
687
688
689 class SEQUENCER_PT_input(SequencerButtonsPanel, Panel):
690     bl_label = "Strip Input"
691
692     @classmethod
693     def poll(cls, context):
694         if not cls.has_sequencer(context):
695             return False
696
697         strip = act_strip(context)
698         if not strip:
699             return False
700
701         return strip.type in {'MOVIE', 'IMAGE', 'SCENE', 'MOVIECLIP', 'META',
702                               'ADD', 'SUBTRACT', 'ALPHA_OVER', 'ALPHA_UNDER',
703                               'CROSS', 'GAMMA_CROSS', 'MULTIPLY', 'OVER_DROP',
704                               'WIPE', 'GLOW', 'TRANSFORM', 'COLOR',
705                               'MULTICAM', 'SPEED', 'ADJUSTMENT'}
706
707     def draw(self, context):
708         layout = self.layout
709         scene = context.scene
710
711         strip = act_strip(context)
712
713         seq_type = strip.type
714
715         # draw a filename if we have one
716         if seq_type == 'IMAGE':
717             split = layout.split(percentage=0.2)
718             split.label(text="Path:")
719             split.prop(strip, "directory", text="")
720
721             # Current element for the filename
722
723             elem = strip.strip_elem_from_frame(scene.frame_current)
724             if elem:
725                 split = layout.split(percentage=0.2)
726                 split.label(text="File:")
727                 split.prop(elem, "filename", text="")  # strip.elements[0] could be a fallback
728
729             layout.prop(strip.colorspace_settings, "name")
730             layout.prop(strip, "alpha_mode")
731
732             layout.operator("sequencer.change_path").filter_image = True
733
734         elif seq_type == 'MOVIE':
735             split = layout.split(percentage=0.2)
736             split.label(text="Path:")
737             split.prop(strip, "filepath", text="")
738
739             layout.prop(strip.colorspace_settings, "name")
740
741             layout.prop(strip, "mpeg_preseek")
742             layout.prop(strip, "stream_index")
743
744         layout.prop(strip, "use_translation", text="Image Offset")
745         if strip.use_translation:
746             col = layout.column(align=True)
747             col.prop(strip.transform, "offset_x", text="X")
748             col.prop(strip.transform, "offset_y", text="Y")
749
750         layout.prop(strip, "use_crop", text="Image Crop")
751         if strip.use_crop:
752             col = layout.column(align=True)
753             col.prop(strip.crop, "max_y")
754             col.prop(strip.crop, "min_x")
755             col.prop(strip.crop, "min_y")
756             col.prop(strip.crop, "max_x")
757
758         if not isinstance(strip, bpy.types.EffectSequence):
759             col = layout.column(align=True)
760             col.label(text="Trim Duration (hard):")
761             col.prop(strip, "animation_offset_start", text="Start")
762             col.prop(strip, "animation_offset_end", text="End")
763
764         col = layout.column(align=True)
765         col.label(text="Trim Duration (soft):")
766         col.prop(strip, "frame_offset_start", text="Start")
767         col.prop(strip, "frame_offset_end", text="End")
768
769         if scene.render.use_multiview and seq_type in {'IMAGE', 'MOVIE'}:
770             layout.prop(strip, "use_multiview")
771
772             col = layout.column()
773             col.active = strip.use_multiview
774
775             col.label(text="Views Format:")
776             col.row().prop(strip, "views_format", expand=True)
777
778             box = col.box()
779             box.active = strip.views_format == 'STEREO_3D'
780             box.template_image_stereo_3d(strip.stereo_3d_format)
781
782
783 class SEQUENCER_PT_sound(SequencerButtonsPanel, Panel):
784     bl_label = "Sound"
785
786     @classmethod
787     def poll(cls, context):
788         if not cls.has_sequencer(context):
789             return False
790
791         strip = act_strip(context)
792         if not strip:
793             return False
794
795         return (strip.type == 'SOUND')
796
797     def draw(self, context):
798         layout = self.layout
799
800         st = context.space_data
801         strip = act_strip(context)
802         sound = strip.sound
803
804         layout.template_ID(strip, "sound", open="sound.open")
805         if sound is not None:
806             layout.prop(sound, "filepath", text="")
807
808             row = layout.row()
809             if sound.packed_file:
810                 row.operator("sound.unpack", icon='PACKAGE', text="Unpack")
811             else:
812                 row.operator("sound.pack", icon='UGLYPACKAGE', text="Pack")
813
814             row.prop(sound, "use_memory_cache")
815
816             layout.prop(sound, "use_mono")
817
818         if st.waveform_draw_type == 'DEFAULT_WAVEFORMS':
819             layout.prop(strip, "show_waveform")
820
821         layout.prop(strip, "volume")
822         layout.prop(strip, "pitch")
823         layout.prop(strip, "pan")
824
825         col = layout.column(align=True)
826         col.label(text="Trim Duration (hard):")
827         col.prop(strip, "animation_offset_start", text="Start")
828         col.prop(strip, "animation_offset_end", text="End")
829
830         col = layout.column(align=True)
831         col.label(text="Trim Duration (soft):")
832         col.prop(strip, "frame_offset_start", text="Start")
833         col.prop(strip, "frame_offset_end", text="End")
834
835
836 class SEQUENCER_PT_scene(SequencerButtonsPanel, Panel):
837     bl_label = "Scene"
838
839     @classmethod
840     def poll(cls, context):
841         if not cls.has_sequencer(context):
842             return False
843
844         strip = act_strip(context)
845         if not strip:
846             return False
847
848         return (strip.type == 'SCENE')
849
850     def draw(self, context):
851         layout = self.layout
852
853         strip = act_strip(context)
854
855         layout.template_ID(strip, "scene")
856
857         scene = strip.scene
858         layout.prop(strip, "use_sequence")
859
860         if not strip.use_sequence:
861             layout.label(text="Camera Override")
862             layout.template_ID(strip, "scene_camera")
863
864             layout.prop(strip, "use_grease_pencil", text="Show Grease Pencil")
865
866         if scene:
867             layout.prop(scene, "audio_volume", text="Audio Volume")
868
869         if not strip.use_sequence:
870             if scene:
871                 # Warning, this is not a good convention to follow.
872                 # Expose here because setting the alpha from the 'Render' menu is very inconvenient.
873                 layout.label("Preview")
874                 layout.prop(scene.render, "alpha_mode")
875
876         if scene:
877             sta = scene.frame_start
878             end = scene.frame_end
879             layout.label(text=iface_("Original frame range: %d-%d (%d)") % (sta, end, end - sta + 1), translate=False)
880
881
882 class SEQUENCER_PT_mask(SequencerButtonsPanel, Panel):
883     bl_label = "Mask"
884
885     @classmethod
886     def poll(cls, context):
887         if not cls.has_sequencer(context):
888             return False
889
890         strip = act_strip(context)
891         if not strip:
892             return False
893
894         return (strip.type == 'MASK')
895
896     def draw(self, context):
897         layout = self.layout
898
899         strip = act_strip(context)
900
901         layout.template_ID(strip, "mask")
902
903         mask = strip.mask
904
905         if mask:
906             sta = mask.frame_start
907             end = mask.frame_end
908             layout.label(text=iface_("Original frame range: %d-%d (%d)") % (sta, end, end - sta + 1), translate=False)
909
910
911 class SEQUENCER_PT_filter(SequencerButtonsPanel, Panel):
912     bl_label = "Filter"
913
914     @classmethod
915     def poll(cls, context):
916         if not cls.has_sequencer(context):
917             return False
918
919         strip = act_strip(context)
920         if not strip:
921             return False
922
923         return strip.type in {'MOVIE', 'IMAGE', 'SCENE', 'MOVIECLIP', 'MASK',
924                               'META', 'ADD', 'SUBTRACT', 'ALPHA_OVER',
925                               'ALPHA_UNDER', 'CROSS', 'GAMMA_CROSS', 'MULTIPLY',
926                               'OVER_DROP', 'WIPE', 'GLOW', 'TRANSFORM', 'COLOR',
927                               'MULTICAM', 'SPEED', 'ADJUSTMENT'}
928
929     def draw(self, context):
930         layout = self.layout
931
932         strip = act_strip(context)
933
934         col = layout.column()
935         col.label(text="Video:")
936         col.prop(strip, "strobe")
937
938         if strip.type == 'MOVIECLIP':
939             col = layout.column()
940             col.label(text="Tracker:")
941             col.prop(strip, "stabilize2d")
942
943             col = layout.column()
944             col.label(text="Distortion:")
945             col.prop(strip, "undistort")
946
947         split = layout.split(percentage=0.65)
948
949         col = split.column()
950         col.prop(strip, "use_reverse_frames", text="Backwards")
951         col.prop(strip, "use_deinterlace")
952
953         col = split.column()
954         col.label(text="Flip:")
955         col.prop(strip, "use_flip_x", text="X")
956         col.prop(strip, "use_flip_y", text="Y")
957
958         col = layout.column()
959         col.label(text="Colors:")
960         col.prop(strip, "color_saturation", text="Saturation")
961         col.prop(strip, "color_multiply", text="Multiply")
962         col.prop(strip, "use_float")
963
964
965 class SEQUENCER_PT_proxy(SequencerButtonsPanel, Panel):
966     bl_label = "Proxy / Timecode"
967
968     @classmethod
969     def poll(cls, context):
970         if not cls.has_sequencer(context):
971             return False
972
973         strip = act_strip(context)
974         if not strip:
975             return False
976
977         return strip.type in {'MOVIE', 'IMAGE', 'SCENE', 'META', 'MULTICAM'}
978
979     def draw_header(self, context):
980         strip = act_strip(context)
981
982         self.layout.prop(strip, "use_proxy", text="")
983
984     def draw(self, context):
985         layout = self.layout
986
987         sequencer = context.scene.sequence_editor
988
989         strip = act_strip(context)
990
991         if strip.proxy:
992             proxy = strip.proxy
993
994             flow = layout.column_flow()
995             flow.prop(sequencer, "proxy_storage")
996             if sequencer.proxy_storage == 'PROJECT':
997                 flow.prop(sequencer, "proxy_dir")
998             else:
999                 flow.prop(proxy, "use_proxy_custom_directory")
1000                 flow.prop(proxy, "use_proxy_custom_file")
1001
1002                 if proxy.use_proxy_custom_directory and not proxy.use_proxy_custom_file:
1003                     flow.prop(proxy, "directory")
1004                 if proxy.use_proxy_custom_file:
1005                     flow.prop(proxy, "filepath")
1006
1007             row = layout.row(align=True)
1008             row.prop(strip.proxy, "build_25", toggle=True)
1009             row.prop(strip.proxy, "build_50", toggle=True)
1010             row.prop(strip.proxy, "build_75", toggle=True)
1011             row.prop(strip.proxy, "build_100", toggle=True)
1012
1013             layout.prop(proxy, "use_overwrite")
1014
1015             col = layout.column()
1016             col.label(text="Build JPEG quality")
1017             col.prop(proxy, "quality")
1018
1019             if strip.type == 'MOVIE':
1020                 col = layout.column()
1021                 col.label(text="Use timecode index:")
1022
1023                 col.prop(proxy, "timecode")
1024
1025         col = layout.column()
1026         col.operator("sequencer.enable_proxies")
1027         col.operator("sequencer.rebuild_proxy")
1028
1029
1030 class SEQUENCER_PT_preview(SequencerButtonsPanel_Output, Panel):
1031     bl_label = "Scene Preview/Render"
1032     bl_space_type = 'SEQUENCE_EDITOR'
1033     bl_region_type = 'UI'
1034
1035     def draw(self, context):
1036         layout = self.layout
1037
1038         render = context.scene.render
1039
1040         col = layout.column()
1041         col.prop(render, "use_sequencer_gl_preview", text="OpenGL Preview")
1042         col = layout.column()
1043         #col.active = render.use_sequencer_gl_preview
1044         col.prop(render, "sequencer_gl_preview", text="")
1045
1046         row = col.row()
1047         row.active = render.sequencer_gl_preview == 'SOLID'
1048         row.prop(render, "use_sequencer_gl_textured_solid")
1049
1050
1051 class SEQUENCER_PT_view(SequencerButtonsPanel_Output, Panel):
1052     bl_label = "View Settings"
1053
1054     def draw(self, context):
1055         layout = self.layout
1056
1057         st = context.space_data
1058
1059         col = layout.column()
1060         if st.display_mode == 'IMAGE':
1061             col.prop(st, "draw_overexposed")
1062             col.separator()
1063
1064         elif st.display_mode == 'WAVEFORM':
1065             col.prop(st, "show_separate_color")
1066
1067         col = layout.column()
1068         col.separator()
1069         col.prop(st, "proxy_render_size")
1070
1071
1072 class SEQUENCER_PT_view_safe_areas(SequencerButtonsPanel_Output, Panel):
1073     bl_label = "Safe Areas"
1074     bl_options = {'DEFAULT_CLOSED'}
1075
1076     @classmethod
1077     def poll(cls, context):
1078         st = context.space_data
1079         is_preview = st.view_type in {'PREVIEW', 'SEQUENCER_PREVIEW'}
1080         return is_preview and (st.display_mode == 'IMAGE')
1081
1082     def draw_header(self, context):
1083         st = context.space_data
1084
1085         self.layout.prop(st, "show_safe_areas", text="")
1086
1087     def draw(self, context):
1088         from bl_ui.properties_data_camera import draw_display_safe_settings
1089
1090         layout = self.layout
1091         st = context.space_data
1092         safe_data = context.scene.safe_areas
1093
1094         draw_display_safe_settings(layout, safe_data, st)
1095
1096
1097 class SEQUENCER_PT_modifiers(SequencerButtonsPanel, Panel):
1098     bl_label = "Modifiers"
1099
1100     def draw(self, context):
1101         layout = self.layout
1102
1103         strip = act_strip(context)
1104         sequencer = context.scene.sequence_editor
1105
1106         layout.prop(strip, "use_linear_modifiers")
1107
1108         layout.operator_menu_enum("sequencer.strip_modifier_add", "type")
1109         layout.operator("sequencer.strip_modifier_copy")
1110
1111         for mod in strip.modifiers:
1112             box = layout.box()
1113
1114             row = box.row()
1115             row.prop(mod, "show_expanded", text="", emboss=False)
1116             row.prop(mod, "name", text="")
1117
1118             row.prop(mod, "mute", text="")
1119
1120             sub = row.row(align=True)
1121             props = sub.operator("sequencer.strip_modifier_move", text="", icon='TRIA_UP')
1122             props.name = mod.name
1123             props.direction = 'UP'
1124             props = sub.operator("sequencer.strip_modifier_move", text="", icon='TRIA_DOWN')
1125             props.name = mod.name
1126             props.direction = 'DOWN'
1127
1128             row.operator("sequencer.strip_modifier_remove", text="", icon='X', emboss=False).name = mod.name
1129
1130             if mod.show_expanded:
1131                 row = box.row()
1132                 row.prop(mod, "input_mask_type", expand=True)
1133
1134                 if mod.input_mask_type == 'STRIP':
1135                     sequences_object = sequencer
1136                     if sequencer.meta_stack:
1137                         sequences_object = sequencer.meta_stack[-1]
1138                     box.prop_search(mod, "input_mask_strip", sequences_object, "sequences", text="Mask")
1139                 else:
1140                     box.prop(mod, "input_mask_id")
1141                     row = box.row()
1142                     row.prop(mod, "mask_time", expand=True)
1143
1144                 if mod.type == 'COLOR_BALANCE':
1145                     box.prop(mod, "color_multiply")
1146                     draw_color_balance(box, mod.color_balance)
1147                 elif mod.type == 'CURVES':
1148                     box.template_curve_mapping(mod, "curve_mapping", type='COLOR')
1149                 elif mod.type == 'HUE_CORRECT':
1150                     box.template_curve_mapping(mod, "curve_mapping", type='HUE')
1151                 elif mod.type == 'BRIGHT_CONTRAST':
1152                     col = box.column()
1153                     col.prop(mod, "bright")
1154                     col.prop(mod, "contrast")
1155                 elif mod.type == 'WHITE_BALANCE':
1156                     col = box.column()
1157                     col.prop(mod, "white_value")
1158                 elif mod.type == 'TONEMAP':
1159                     col = box.column()
1160                     col.prop(mod, "tonemap_type")
1161                     if mod.tonemap_type == 'RD_PHOTORECEPTOR':
1162                         col.prop(mod, "intensity")
1163                         col.prop(mod, "contrast")
1164                         col.prop(mod, "adaptation")
1165                         col.prop(mod, "correction")
1166                     elif mod.tonemap_type == 'RH_SIMPLE':
1167                         col.prop(mod, "key")
1168                         col.prop(mod, "offset")
1169                         col.prop(mod, "gamma")
1170
1171
1172 class SEQUENCER_PT_grease_pencil(GreasePencilDataPanel, SequencerButtonsPanel_Output, Panel):
1173     bl_space_type = 'SEQUENCE_EDITOR'
1174     bl_region_type = 'UI'
1175
1176     # NOTE: this is just a wrapper around the generic GP Panel
1177     # But, it should only show up when there are images in the preview region
1178
1179
1180 class SEQUENCER_PT_grease_pencil_tools(GreasePencilToolsPanel, SequencerButtonsPanel_Output, Panel):
1181     bl_space_type = 'SEQUENCE_EDITOR'
1182     bl_region_type = 'UI'
1183
1184     # NOTE: this is just a wrapper around the generic GP tools panel
1185     # It contains access to some essential tools usually found only in
1186     # toolbar, which doesn't exist here...
1187
1188
1189 class SEQUENCER_PT_custom_props(SequencerButtonsPanel, PropertyPanel, Panel):
1190     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
1191     _context_path = "scene.sequence_editor.active_strip"
1192     _property_type = (bpy.types.Sequence,)
1193
1194
1195 if __name__ == "__main__":  # only for live edit.
1196     bpy.utils.register_module(__name__)