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