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