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