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