"View Frame" now works in the sequencer too
[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", text="Toggle Maximize Area")
225         layout.operator("screen.screen_full_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             col.prop(strip, "use_shadow")
672             col.prop(strip, "align_x")
673             col.prop(strip, "align_y")
674             col.prop(strip, "location")
675             col.prop(strip, "wrap_width")
676             layout.operator("sequencer.export_subtitles")
677
678         col = layout.column(align=True)
679         if strip.type == 'SPEED':
680             col.prop(strip, "multiply_speed")
681         elif strip.type in {'CROSS', 'GAMMA_CROSS', 'WIPE', 'ALPHA_OVER', 'ALPHA_UNDER', 'OVER_DROP'}:
682             col.prop(strip, "use_default_fade", "Default fade")
683             if not strip.use_default_fade:
684                 col.prop(strip, "effect_fader", text="Effect fader")
685         elif strip.type == 'GAUSSIAN_BLUR':
686             col.prop(strip, "size_x")
687             col.prop(strip, "size_y")
688
689
690 class SEQUENCER_PT_input(SequencerButtonsPanel, Panel):
691     bl_label = "Strip Input"
692
693     @classmethod
694     def poll(cls, context):
695         if not cls.has_sequencer(context):
696             return False
697
698         strip = act_strip(context)
699         if not strip:
700             return False
701
702         return strip.type in {'MOVIE', 'IMAGE', 'SCENE', 'MOVIECLIP', 'META',
703                               'ADD', 'SUBTRACT', 'ALPHA_OVER', 'ALPHA_UNDER',
704                               'CROSS', 'GAMMA_CROSS', 'MULTIPLY', 'OVER_DROP',
705                               'WIPE', 'GLOW', 'TRANSFORM', 'COLOR',
706                               'MULTICAM', 'SPEED', 'ADJUSTMENT'}
707
708     def draw(self, context):
709         layout = self.layout
710         scene = context.scene
711
712         strip = act_strip(context)
713
714         seq_type = strip.type
715
716         # draw a filename if we have one
717         if seq_type == 'IMAGE':
718             split = layout.split(percentage=0.2)
719             split.label(text="Path:")
720             split.prop(strip, "directory", text="")
721
722             # Current element for the filename
723
724             elem = strip.strip_elem_from_frame(scene.frame_current)
725             if elem:
726                 split = layout.split(percentage=0.2)
727                 split.label(text="File:")
728                 split.prop(elem, "filename", text="")  # strip.elements[0] could be a fallback
729
730             layout.prop(strip.colorspace_settings, "name")
731             layout.prop(strip, "alpha_mode")
732
733             layout.operator("sequencer.change_path").filter_image = True
734
735         elif seq_type == 'MOVIE':
736             split = layout.split(percentage=0.2)
737             split.label(text="Path:")
738             split.prop(strip, "filepath", text="")
739
740             layout.prop(strip.colorspace_settings, "name")
741
742             layout.prop(strip, "mpeg_preseek")
743             layout.prop(strip, "stream_index")
744
745         layout.prop(strip, "use_translation", text="Image Offset")
746         if strip.use_translation:
747             col = layout.column(align=True)
748             col.prop(strip.transform, "offset_x", text="X")
749             col.prop(strip.transform, "offset_y", text="Y")
750
751         layout.prop(strip, "use_crop", text="Image Crop")
752         if strip.use_crop:
753             col = layout.column(align=True)
754             col.prop(strip.crop, "max_y")
755             col.prop(strip.crop, "min_x")
756             col.prop(strip.crop, "min_y")
757             col.prop(strip.crop, "max_x")
758
759         if not isinstance(strip, bpy.types.EffectSequence):
760             col = layout.column(align=True)
761             col.label(text="Trim Duration (hard):")
762             col.prop(strip, "animation_offset_start", text="Start")
763             col.prop(strip, "animation_offset_end", text="End")
764
765         col = layout.column(align=True)
766         col.label(text="Trim Duration (soft):")
767         col.prop(strip, "frame_offset_start", text="Start")
768         col.prop(strip, "frame_offset_end", text="End")
769
770         if scene.render.use_multiview and seq_type in {'IMAGE', 'MOVIE'}:
771             layout.prop(strip, "use_multiview")
772
773             col = layout.column()
774             col.active = strip.use_multiview
775
776             col.label(text="Views Format:")
777             col.row().prop(strip, "views_format", expand=True)
778
779             box = col.box()
780             box.active = strip.views_format == 'STEREO_3D'
781             box.template_image_stereo_3d(strip.stereo_3d_format)
782
783
784 class SEQUENCER_PT_sound(SequencerButtonsPanel, Panel):
785     bl_label = "Sound"
786
787     @classmethod
788     def poll(cls, context):
789         if not cls.has_sequencer(context):
790             return False
791
792         strip = act_strip(context)
793         if not strip:
794             return False
795
796         return (strip.type == 'SOUND')
797
798     def draw(self, context):
799         layout = self.layout
800
801         st = context.space_data
802         strip = act_strip(context)
803         sound = strip.sound
804
805         layout.template_ID(strip, "sound", open="sound.open")
806         if sound is not None:
807             layout.prop(sound, "filepath", text="")
808
809             row = layout.row()
810             if sound.packed_file:
811                 row.operator("sound.unpack", icon='PACKAGE', text="Unpack")
812             else:
813                 row.operator("sound.pack", icon='UGLYPACKAGE', text="Pack")
814
815             row.prop(sound, "use_memory_cache")
816
817             layout.prop(sound, "use_mono")
818
819         if st.waveform_draw_type == 'DEFAULT_WAVEFORMS':
820             layout.prop(strip, "show_waveform")
821
822         layout.prop(strip, "volume")
823         layout.prop(strip, "pitch")
824         layout.prop(strip, "pan")
825
826         col = layout.column(align=True)
827         col.label(text="Trim Duration (hard):")
828         col.prop(strip, "animation_offset_start", text="Start")
829         col.prop(strip, "animation_offset_end", text="End")
830
831         col = layout.column(align=True)
832         col.label(text="Trim Duration (soft):")
833         col.prop(strip, "frame_offset_start", text="Start")
834         col.prop(strip, "frame_offset_end", text="End")
835
836
837 class SEQUENCER_PT_scene(SequencerButtonsPanel, Panel):
838     bl_label = "Scene"
839
840     @classmethod
841     def poll(cls, context):
842         if not cls.has_sequencer(context):
843             return False
844
845         strip = act_strip(context)
846         if not strip:
847             return False
848
849         return (strip.type == 'SCENE')
850
851     def draw(self, context):
852         layout = self.layout
853
854         strip = act_strip(context)
855
856         layout.template_ID(strip, "scene")
857
858         scene = strip.scene
859         layout.prop(strip, "use_sequence")
860
861         if not strip.use_sequence:
862             layout.label(text="Camera Override")
863             layout.template_ID(strip, "scene_camera")
864
865             layout.prop(strip, "use_grease_pencil", text="Show Grease Pencil")
866
867         if scene:
868             layout.prop(scene, "audio_volume", text="Audio Volume")
869
870         if not strip.use_sequence:
871             if scene:
872                 # Warning, this is not a good convention to follow.
873                 # Expose here because setting the alpha from the 'Render' menu is very inconvenient.
874                 layout.label("Preview")
875                 layout.prop(scene.render, "alpha_mode")
876
877         if scene:
878             sta = scene.frame_start
879             end = scene.frame_end
880             layout.label(text=iface_("Original frame range: %d-%d (%d)") % (sta, end, end - sta + 1), translate=False)
881
882
883 class SEQUENCER_PT_mask(SequencerButtonsPanel, Panel):
884     bl_label = "Mask"
885
886     @classmethod
887     def poll(cls, context):
888         if not cls.has_sequencer(context):
889             return False
890
891         strip = act_strip(context)
892         if not strip:
893             return False
894
895         return (strip.type == 'MASK')
896
897     def draw(self, context):
898         layout = self.layout
899
900         strip = act_strip(context)
901
902         layout.template_ID(strip, "mask")
903
904         mask = strip.mask
905
906         if mask:
907             sta = mask.frame_start
908             end = mask.frame_end
909             layout.label(text=iface_("Original frame range: %d-%d (%d)") % (sta, end, end - sta + 1), translate=False)
910
911
912 class SEQUENCER_PT_filter(SequencerButtonsPanel, Panel):
913     bl_label = "Filter"
914
915     @classmethod
916     def poll(cls, context):
917         if not cls.has_sequencer(context):
918             return False
919
920         strip = act_strip(context)
921         if not strip:
922             return False
923
924         return strip.type in {'MOVIE', 'IMAGE', 'SCENE', 'MOVIECLIP', 'MASK',
925                               'META', 'ADD', 'SUBTRACT', 'ALPHA_OVER',
926                               'ALPHA_UNDER', 'CROSS', 'GAMMA_CROSS', 'MULTIPLY',
927                               'OVER_DROP', 'WIPE', 'GLOW', 'TRANSFORM', 'COLOR',
928                               'MULTICAM', 'SPEED', 'ADJUSTMENT'}
929
930     def draw(self, context):
931         layout = self.layout
932
933         strip = act_strip(context)
934
935         col = layout.column()
936         col.label(text="Video:")
937         col.prop(strip, "strobe")
938
939         if strip.type == 'MOVIECLIP':
940             col = layout.column()
941             col.label(text="Tracker:")
942             col.prop(strip, "stabilize2d")
943
944             col = layout.column()
945             col.label(text="Distortion:")
946             col.prop(strip, "undistort")
947
948         split = layout.split(percentage=0.65)
949
950         col = split.column()
951         col.prop(strip, "use_reverse_frames", text="Backwards")
952         col.prop(strip, "use_deinterlace")
953
954         col = split.column()
955         col.label(text="Flip:")
956         col.prop(strip, "use_flip_x", text="X")
957         col.prop(strip, "use_flip_y", text="Y")
958
959         col = layout.column()
960         col.label(text="Colors:")
961         col.prop(strip, "color_saturation", text="Saturation")
962         col.prop(strip, "color_multiply", text="Multiply")
963         col.prop(strip, "use_float")
964
965
966 class SEQUENCER_PT_proxy(SequencerButtonsPanel, Panel):
967     bl_label = "Proxy / Timecode"
968
969     @classmethod
970     def poll(cls, context):
971         if not cls.has_sequencer(context):
972             return False
973
974         strip = act_strip(context)
975         if not strip:
976             return False
977
978         return strip.type in {'MOVIE', 'IMAGE', 'SCENE', 'META', 'MULTICAM'}
979
980     def draw_header(self, context):
981         strip = act_strip(context)
982
983         self.layout.prop(strip, "use_proxy", text="")
984
985     def draw(self, context):
986         layout = self.layout
987
988         sequencer = context.scene.sequence_editor
989
990         strip = act_strip(context)
991
992         if strip.proxy:
993             proxy = strip.proxy
994
995             flow = layout.column_flow()
996             flow.prop(sequencer, "proxy_storage")
997             if sequencer.proxy_storage == 'PROJECT':
998                 flow.prop(sequencer, "proxy_dir")
999             else:
1000                 flow.prop(proxy, "use_proxy_custom_directory")
1001                 flow.prop(proxy, "use_proxy_custom_file")
1002
1003                 if proxy.use_proxy_custom_directory and not proxy.use_proxy_custom_file:
1004                     flow.prop(proxy, "directory")
1005                 if proxy.use_proxy_custom_file:
1006                     flow.prop(proxy, "filepath")
1007
1008             row = layout.row(align=True)
1009             row.prop(strip.proxy, "build_25", toggle=True)
1010             row.prop(strip.proxy, "build_50", toggle=True)
1011             row.prop(strip.proxy, "build_75", toggle=True)
1012             row.prop(strip.proxy, "build_100", toggle=True)
1013
1014             layout.prop(proxy, "use_overwrite")
1015
1016             col = layout.column()
1017             col.label(text="Build JPEG quality")
1018             col.prop(proxy, "quality")
1019
1020             if strip.type == 'MOVIE':
1021                 col = layout.column()
1022                 col.label(text="Use timecode index:")
1023
1024                 col.prop(proxy, "timecode")
1025
1026         col = layout.column()
1027         col.operator("sequencer.enable_proxies")
1028         col.operator("sequencer.rebuild_proxy")
1029
1030
1031 class SEQUENCER_PT_preview(SequencerButtonsPanel_Output, Panel):
1032     bl_label = "Scene Preview/Render"
1033     bl_space_type = 'SEQUENCE_EDITOR'
1034     bl_region_type = 'UI'
1035
1036     def draw(self, context):
1037         layout = self.layout
1038
1039         render = context.scene.render
1040
1041         col = layout.column()
1042         col.prop(render, "use_sequencer_gl_preview", text="OpenGL Preview")
1043         col = layout.column()
1044         #col.active = render.use_sequencer_gl_preview
1045         col.prop(render, "sequencer_gl_preview", text="")
1046
1047         row = col.row()
1048         row.active = render.sequencer_gl_preview == 'SOLID'
1049         row.prop(render, "use_sequencer_gl_textured_solid")
1050
1051
1052 class SEQUENCER_PT_view(SequencerButtonsPanel_Output, Panel):
1053     bl_label = "View Settings"
1054
1055     def draw(self, context):
1056         layout = self.layout
1057
1058         st = context.space_data
1059
1060         col = layout.column()
1061         if st.display_mode == 'IMAGE':
1062             col.prop(st, "draw_overexposed")
1063             col.separator()
1064
1065         elif st.display_mode == 'WAVEFORM':
1066             col.prop(st, "show_separate_color")
1067
1068         col = layout.column()
1069         col.separator()
1070         col.prop(st, "proxy_render_size")
1071
1072
1073 class SEQUENCER_PT_view_safe_areas(SequencerButtonsPanel_Output, Panel):
1074     bl_label = "Safe Areas"
1075     bl_options = {'DEFAULT_CLOSED'}
1076
1077     @classmethod
1078     def poll(cls, context):
1079         st = context.space_data
1080         is_preview = st.view_type in {'PREVIEW', 'SEQUENCER_PREVIEW'}
1081         return is_preview and (st.display_mode == 'IMAGE')
1082
1083     def draw_header(self, context):
1084         st = context.space_data
1085
1086         self.layout.prop(st, "show_safe_areas", text="")
1087
1088     def draw(self, context):
1089         from bl_ui.properties_data_camera import draw_display_safe_settings
1090
1091         layout = self.layout
1092         st = context.space_data
1093         safe_data = context.scene.safe_areas
1094
1095         draw_display_safe_settings(layout, safe_data, st)
1096
1097
1098 class SEQUENCER_PT_modifiers(SequencerButtonsPanel, Panel):
1099     bl_label = "Modifiers"
1100
1101     def draw(self, context):
1102         layout = self.layout
1103
1104         strip = act_strip(context)
1105         sequencer = context.scene.sequence_editor
1106
1107         layout.prop(strip, "use_linear_modifiers")
1108
1109         layout.operator_menu_enum("sequencer.strip_modifier_add", "type")
1110         layout.operator("sequencer.strip_modifier_copy")
1111
1112         for mod in strip.modifiers:
1113             box = layout.box()
1114
1115             row = box.row()
1116             row.prop(mod, "show_expanded", text="", emboss=False)
1117             row.prop(mod, "name", text="")
1118
1119             row.prop(mod, "mute", text="")
1120
1121             sub = row.row(align=True)
1122             props = sub.operator("sequencer.strip_modifier_move", text="", icon='TRIA_UP')
1123             props.name = mod.name
1124             props.direction = 'UP'
1125             props = sub.operator("sequencer.strip_modifier_move", text="", icon='TRIA_DOWN')
1126             props.name = mod.name
1127             props.direction = 'DOWN'
1128
1129             row.operator("sequencer.strip_modifier_remove", text="", icon='X', emboss=False).name = mod.name
1130
1131             if mod.show_expanded:
1132                 row = box.row()
1133                 row.prop(mod, "input_mask_type", expand=True)
1134
1135                 if mod.input_mask_type == 'STRIP':
1136                     sequences_object = sequencer
1137                     if sequencer.meta_stack:
1138                         sequences_object = sequencer.meta_stack[-1]
1139                     box.prop_search(mod, "input_mask_strip", sequences_object, "sequences", text="Mask")
1140                 else:
1141                     box.prop(mod, "input_mask_id")
1142                     row = box.row()
1143                     row.prop(mod, "mask_time", expand=True)
1144
1145                 if mod.type == 'COLOR_BALANCE':
1146                     box.prop(mod, "color_multiply")
1147                     draw_color_balance(box, mod.color_balance)
1148                 elif mod.type == 'CURVES':
1149                     box.template_curve_mapping(mod, "curve_mapping", type='COLOR')
1150                 elif mod.type == 'HUE_CORRECT':
1151                     box.template_curve_mapping(mod, "curve_mapping", type='HUE')
1152                 elif mod.type == 'BRIGHT_CONTRAST':
1153                     col = box.column()
1154                     col.prop(mod, "bright")
1155                     col.prop(mod, "contrast")
1156                 elif mod.type == 'WHITE_BALANCE':
1157                     col = box.column()
1158                     col.prop(mod, "white_value")
1159                 elif mod.type == 'TONEMAP':
1160                     col = box.column()
1161                     col.prop(mod, "tonemap_type")
1162                     if mod.tonemap_type == 'RD_PHOTORECEPTOR':
1163                         col.prop(mod, "intensity")
1164                         col.prop(mod, "contrast")
1165                         col.prop(mod, "adaptation")
1166                         col.prop(mod, "correction")
1167                     elif mod.tonemap_type == 'RH_SIMPLE':
1168                         col.prop(mod, "key")
1169                         col.prop(mod, "offset")
1170                         col.prop(mod, "gamma")
1171
1172
1173 class SEQUENCER_PT_grease_pencil(GreasePencilDataPanel, SequencerButtonsPanel_Output, Panel):
1174     bl_space_type = 'SEQUENCE_EDITOR'
1175     bl_region_type = 'UI'
1176
1177     # NOTE: this is just a wrapper around the generic GP Panel
1178     # But, it should only show up when there are images in the preview region
1179
1180
1181 class SEQUENCER_PT_grease_pencil_tools(GreasePencilToolsPanel, 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 tools panel
1186     # It contains access to some essential tools usually found only in
1187     # toolbar, which doesn't exist here...
1188
1189
1190 class SEQUENCER_PT_custom_props(SequencerButtonsPanel, PropertyPanel, Panel):
1191     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
1192     _context_path = "scene.sequence_editor.active_strip"
1193     _property_type = (bpy.types.Sequence,)
1194
1195
1196 if __name__ == "__main__":  # only for live edit.
1197     bpy.utils.register_module(__name__)