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