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