sequencer clipboard
[blender.git] / release / scripts / 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., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
16 #
17 # ##### END GPL LICENSE BLOCK #####
18
19 # <pep8 compliant>
20 import bpy
21
22
23 def act_strip(context):
24     try:
25         return context.scene.sequence_editor.active_strip
26     except AttributeError:
27         return None
28
29
30 class SEQUENCER_HT_header(bpy.types.Header):
31     bl_space_type = 'SEQUENCE_EDITOR'
32
33     def draw(self, context):
34         layout = self.layout
35
36         st = context.space_data
37
38         row = layout.row(align=True)
39         row.template_header()
40
41         if context.area.show_menus:
42             sub = row.row(align=True)
43             sub.menu("SEQUENCER_MT_view")
44
45             row.separator()
46
47             if (st.view_type == 'SEQUENCER') or (st.view_type == 'SEQUENCER_PREVIEW'):
48                 sub.menu("SEQUENCER_MT_select")
49                 sub.menu("SEQUENCER_MT_marker")
50                 sub.menu("SEQUENCER_MT_add")
51                 sub.menu("SEQUENCER_MT_strip")
52
53         layout.prop(st, "view_type", text="")
54
55         if (st.view_type == 'PREVIEW') or (st.view_type == 'SEQUENCER_PREVIEW'):
56             layout.prop(st, "display_mode", text="")
57
58         if (st.view_type == 'SEQUENCER'):
59             row = layout.row(align=True)
60             row.operator("sequencer.copy", text="", icon='COPYDOWN')
61             row.operator("sequencer.paste", text="", icon='PASTEDOWN')
62
63             layout.separator()
64             layout.operator("sequencer.refresh_all")
65         elif (st.view_type == 'SEQUENCER_PREVIEW'):
66             layout.separator()
67             layout.operator("sequencer.refresh_all")
68             layout.prop(st, "display_channel", text="Channel")
69         else:
70             layout.prop(st, "display_channel", text="Channel")
71
72
73 class SEQUENCER_MT_view_toggle(bpy.types.Menu):
74     bl_label = "View Type"
75
76     def draw(self, context):
77         layout = self.layout
78
79         layout.operator("sequencer.view_toggle").type = 'SEQUENCER'
80         layout.operator("sequencer.view_toggle").type = 'PREVIEW'
81         layout.operator("sequencer.view_toggle").type = 'SEQUENCER_PREVIEW'
82
83
84 class SEQUENCER_MT_view(bpy.types.Menu):
85     bl_label = "View"
86
87     def draw(self, context):
88         layout = self.layout
89
90         st = context.space_data
91
92         layout.column()
93
94         """
95     uiBlock *block= uiBeginBlock(C, ar, "seq_viewmenu", UI_EMBOSSP);
96     short yco= 0, menuwidth=120;
97
98     if (sseq->mainb == SEQ_DRAW_SEQUENCE) {
99         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1,
100                  "Play Back Animation "
101                  "in all Sequence Areas|Alt A", 0, yco-=20,
102                  menuwidth, 19, NULL, 0.0, 0.0, 1, 1, "");
103     }
104     else {
105         uiDefIconTextBut(block, BUTM, 1, ICON_MENU_PANEL,
106                  "Grease Pencil...", 0, yco-=20,
107                  menuwidth, 19, NULL, 0.0, 0.0, 1, 7, "");
108         uiDefMenuSep(block);
109
110         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1,
111                  "Play Back Animation "
112                  "in this window|Alt A", 0, yco-=20,
113                  menuwidth, 19, NULL, 0.0, 0.0, 1, 1, "");
114     }
115     uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1,
116              "Play Back Animation in all "
117              "3D Views and Sequence Areas|Alt Shift A",
118              0, yco-=20,
119              menuwidth, 19, NULL, 0.0, 0.0, 1, 2, "");
120
121         """
122         layout.separator()
123         if (st.view_type == 'SEQUENCER') or (st.view_type == 'SEQUENCER_PREVIEW'):
124             layout.operator("sequencer.view_all", text='View all Sequences')
125         if (st.view_type == 'PREVIEW') or (st.view_type == 'SEQUENCER_PREVIEW'):
126             layout.operator("sequencer.view_all_preview", text='Fit preview in window')
127         layout.operator("sequencer.view_selected")
128
129         layout.prop(st, "draw_frames")
130         layout.prop(st, "show_cframe_indicator")
131         if st.display_mode == 'IMAGE':
132             layout.prop(st, "draw_safe_margin")
133         if st.display_mode == 'WAVEFORM':
134             layout.prop(st, "separate_color_preview")
135
136         layout.separator()
137
138         layout.operator("screen.area_dupli")
139         layout.operator("screen.screen_full_area")
140
141
142 class SEQUENCER_MT_select(bpy.types.Menu):
143     bl_label = "Select"
144
145     def draw(self, context):
146         layout = self.layout
147
148         layout.column()
149         layout.operator("sequencer.select_active_side", text="Strips to the Left").side = 'LEFT'
150         layout.operator("sequencer.select_active_side", text="Strips to the Right").side = 'RIGHT'
151         layout.separator()
152         layout.operator("sequencer.select_handles", text="Surrounding Handles").side = 'BOTH'
153         layout.operator("sequencer.select_handles", text="Left Handle").side = 'LEFT'
154         layout.operator("sequencer.select_handles", text="Right Handle").side = 'RIGHT'
155         layout.separator()
156         layout.operator("sequencer.select_linked")
157         layout.operator("sequencer.select_all_toggle")
158         layout.operator("sequencer.select_inverse")
159
160
161 class SEQUENCER_MT_marker(bpy.types.Menu):
162     bl_label = "Marker"
163
164     def draw(self, context):
165         layout = self.layout
166
167         layout.column()
168         layout.operator("marker.add", text="Add Marker")
169         layout.operator("marker.duplicate", text="Duplicate Marker")
170         layout.operator("marker.move", text="Grab/Move Marker")
171         layout.operator("marker.delete", text="Delete Marker")
172         layout.separator()
173         layout.label(text="ToDo: Name Marker")
174
175         #layout.operator("sequencer.sound_strip_add", text="Transform Markers") # toggle, will be rna - (sseq->flag & SEQ_MARKER_TRANS)
176
177
178 class SEQUENCER_MT_add(bpy.types.Menu):
179     bl_label = "Add"
180
181     def draw(self, context):
182         layout = self.layout
183         layout.operator_context = 'INVOKE_REGION_WIN'
184
185         layout.column()
186         layout.operator("sequencer.scene_strip_add", text="Scene")
187         layout.operator("sequencer.movie_strip_add", text="Movie")
188         layout.operator("sequencer.image_strip_add", text="Image")
189         layout.operator("sequencer.sound_strip_add", text="Sound")
190
191         layout.menu("SEQUENCER_MT_add_effect")
192
193
194 class SEQUENCER_MT_add_effect(bpy.types.Menu):
195     bl_label = "Effect Strip..."
196
197     def draw(self, context):
198         layout = self.layout
199         layout.operator_context = 'INVOKE_REGION_WIN'
200
201         layout.column()
202         layout.operator("sequencer.effect_strip_add", text="Add").type = 'ADD'
203         layout.operator("sequencer.effect_strip_add", text="Subtract").type = 'SUBTRACT'
204         layout.operator("sequencer.effect_strip_add", text="Alpha Over").type = 'ALPHA_OVER'
205         layout.operator("sequencer.effect_strip_add", text="Alpha Under").type = 'ALPHA_UNDER'
206         layout.operator("sequencer.effect_strip_add", text="Cross").type = 'CROSS'
207         layout.operator("sequencer.effect_strip_add", text="Gamma Cross").type = 'GAMMA_CROSS'
208         layout.operator("sequencer.effect_strip_add", text="Multiply").type = 'MULTIPLY'
209         layout.operator("sequencer.effect_strip_add", text="Over Drop").type = 'OVER_DROP'
210         layout.operator("sequencer.effect_strip_add", text="Plugin").type = 'PLUGIN'
211         layout.operator("sequencer.effect_strip_add", text="Wipe").type = 'WIPE'
212         layout.operator("sequencer.effect_strip_add", text="Glow").type = 'GLOW'
213         layout.operator("sequencer.effect_strip_add", text="Transform").type = 'TRANSFORM'
214         layout.operator("sequencer.effect_strip_add", text="Color").type = 'COLOR'
215         layout.operator("sequencer.effect_strip_add", text="Speed Control").type = 'SPEED'
216
217
218 class SEQUENCER_MT_strip(bpy.types.Menu):
219     bl_label = "Strip"
220
221     def draw(self, context):
222         layout = self.layout
223
224         layout.operator_context = 'INVOKE_REGION_WIN'
225
226         layout.column()
227         layout.operator("transform.transform", text="Grab/Move").mode = 'TRANSLATION'
228         layout.operator("transform.transform", text="Grab/Extend from frame").mode = 'TIME_EXTEND'
229         #  uiItemO(layout, NULL, 0, "sequencer.strip_snap"); // TODO - add this operator
230         layout.separator()
231
232         layout.operator("sequencer.cut", text="Cut (hard) at frame").type = 'HARD'
233         layout.operator("sequencer.cut", text="Cut (soft) at frame").type = 'SOFT'
234         layout.operator("sequencer.images_separate")
235         layout.separator()
236
237         layout.operator("sequencer.duplicate")
238         layout.operator("sequencer.delete")
239
240         strip = act_strip(context)
241
242         if strip:
243             stype = strip.type
244
245             if  stype == 'EFFECT':
246                 layout.separator()
247                 layout.operator("sequencer.effect_change")
248                 layout.operator("sequencer.effect_reassign_inputs")
249             elif stype == 'IMAGE':
250                 layout.separator()
251                 # layout.operator("sequencer.image_change")
252                 layout.operator("sequencer.rendersize")
253             elif stype == 'SCENE':
254                 layout.separator()
255                 layout.operator("sequencer.scene_change", text="Change Scene")
256             elif stype == 'MOVIE':
257                 layout.separator()
258                 layout.operator("sequencer.movie_change")
259                 layout.operator("sequencer.rendersize")
260
261         layout.separator()
262
263         layout.operator("sequencer.meta_make")
264         layout.operator("sequencer.meta_separate")
265
266         #if (ed && (ed->metastack.first || (ed->act_seq && ed->act_seq->type == SEQ_META))) {
267         #       uiItemS(layout);
268         #       uiItemO(layout, NULL, 0, "sequencer.meta_toggle");
269         #}
270
271         layout.separator()
272         layout.operator("sequencer.reload")
273         layout.separator()
274         layout.operator("sequencer.lock")
275         layout.operator("sequencer.unlock")
276         layout.operator("sequencer.mute")
277         layout.operator("sequencer.unmute")
278
279         layout.operator("sequencer.mute", text="Mute Deselected Strips").unselected = True
280
281         layout.operator("sequencer.snap")
282
283         layout.operator_menu_enum("sequencer.swap", "side")
284
285
286 class SequencerButtonsPanel(bpy.types.Panel):
287     bl_space_type = 'SEQUENCE_EDITOR'
288     bl_region_type = 'UI'
289
290     def has_sequencer(self, context):
291         return (context.space_data.view_type == 'SEQUENCER') or (context.space_data.view_type == 'SEQUENCER_PREVIEW')
292
293     def poll(self, context):
294         return self.has_sequencer(context) and (act_strip(context) is not None)
295
296
297 class SequencerButtonsPanel_Output(bpy.types.Panel):
298     bl_space_type = 'SEQUENCE_EDITOR'
299     bl_region_type = 'UI'
300
301     def has_preview(self, context):
302         return (context.space_data.view_type == 'PREVIEW') or (context.space_data.view_type == 'SEQUENCER_PREVIEW')
303
304     def poll(self, context):
305         return self.has_preview(context)
306
307
308 class SEQUENCER_PT_edit(SequencerButtonsPanel):
309     bl_label = "Edit Strip"
310
311     def draw(self, context):
312         layout = self.layout
313
314         strip = act_strip(context)
315
316         split = layout.split(percentage=0.3)
317         split.label(text="Name:")
318         split.prop(strip, "name", text="")
319
320         split = layout.split(percentage=0.3)
321         split.label(text="Type:")
322         split.prop(strip, "type", text="")
323
324         split = layout.split(percentage=0.3)
325         split.label(text="Blend:")
326         split.prop(strip, "blend_mode", text="")
327
328         row = layout.row()
329         if strip.mute == True:
330             row.prop(strip, "mute", toggle=True, icon='RESTRICT_VIEW_ON', text="")
331         elif strip.mute is False:
332             row.prop(strip, "mute", toggle=True, icon='RESTRICT_VIEW_OFF', text="")
333
334         sub = row.row()
335         sub.active = (not strip.mute)
336
337         sub.prop(strip, "blend_opacity", text="Opacity", slider=True)
338
339         row = layout.row()
340         row.prop(strip, "lock")
341         row.prop(strip, "frame_locked", text="Frame Lock")
342
343         col = layout.column()
344         col.enabled = not strip.lock
345         col.prop(strip, "channel")
346         col.prop(strip, "start_frame")
347         col.prop(strip, "length")
348
349         col = layout.column(align=True)
350         col.label(text="Offset:")
351         col.prop(strip, "start_offset", text="Start")
352         col.prop(strip, "end_offset", text="End")
353
354         col = layout.column(align=True)
355         col.label(text="Still:")
356         col.prop(strip, "start_still", text="Start")
357         col.prop(strip, "end_still", text="End")
358
359
360 class SEQUENCER_PT_effect(SequencerButtonsPanel):
361     bl_label = "Effect Strip"
362
363     def poll(self, context):
364         if not self.has_sequencer(context):
365             return False
366
367         strip = act_strip(context)
368         if not strip:
369             return False
370
371         return strip.type in ('ADD', 'SUBTRACT', 'ALPHA_OVER', 'ALPHA_UNDER',
372                               'CROSS', 'GAMMA_CROSS', 'MULTIPLY', 'OVER_DROP',
373                               'PLUGIN',
374                               'WIPE', 'GLOW', 'TRANSFORM', 'COLOR', 'SPEED')
375
376     def draw(self, context):
377         layout = self.layout
378
379         strip = act_strip(context)
380
381         if strip.type == 'COLOR':
382             layout.prop(strip, "color")
383
384         elif strip.type == 'WIPE':
385
386             col = layout.column()
387             col.prop(strip, "transition_type")
388             col.label(text="Direction:")
389             col.row().prop(strip, "direction", expand=True)
390
391             col = layout.column()
392             col.prop(strip, "blur_width", slider=True)
393             if strip.transition_type in ('SINGLE', 'DOUBLE'):
394                 col.prop(strip, "angle")
395
396         elif strip.type == 'GLOW':
397             flow = layout.column_flow()
398             flow.prop(strip, "threshold", slider=True)
399             flow.prop(strip, "clamp", slider=True)
400             flow.prop(strip, "boost_factor")
401             flow.prop(strip, "blur_distance")
402
403             row = layout.row()
404             row.prop(strip, "quality", slider=True)
405             row.prop(strip, "only_boost")
406
407         elif strip.type == 'SPEED':
408             layout.prop(strip, "global_speed")
409
410             flow = layout.column_flow()
411             flow.prop(strip, "curve_velocity")
412             flow.prop(strip, "curve_compress_y")
413             flow.prop(strip, "frame_blending")
414
415         elif strip.type == 'TRANSFORM':
416             self.draw_panel_transform(strip)
417
418
419         col = layout.column(align=True)
420         if strip.type == 'SPEED':
421             col.prop(strip, "speed_fader", text="Speed fader")
422         elif strip.type in ('CROSS', 'GAMMA_CROSS', 'PLUGIN', 'WIPE'):
423                 col.prop(strip, "use_effect_default_fade", "Default fade")
424                 if not strip.use_effect_default_fade:
425                     col.prop(strip, "effect_fader", text="Effect fader")
426
427     def draw_panel_transform(self, strip):
428         layout = self.layout
429         col = layout.column()
430
431         col.prop(strip, "interpolation")
432         col.prop(strip, "translation_unit")
433         col = layout.column(align=True)
434         col.label(text="Position:")
435         col.prop(strip, "translate_start_x", text="X")
436         col.prop(strip, "translate_start_y", text="Y")
437
438         layout.separator()
439
440         col = layout.column(align=True)
441         col.prop(strip, "uniform_scale")
442         if (strip.uniform_scale):
443             col = layout.column(align=True)
444             col.prop(strip, "scale_start_x", text="Scale")
445         else:
446             col = layout.column(align=True)
447             col.label(text="Scale:")
448             col.prop(strip, "scale_start_x", text="X")
449             col.prop(strip, "scale_start_y", text="Y")
450
451         layout.separator()
452
453         col = layout.column(align=True)
454         col.label(text="Rotation:")
455         col.prop(strip, "rotation_start", text="Rotation")
456
457
458 class SEQUENCER_PT_input(SequencerButtonsPanel):
459     bl_label = "Strip Input"
460
461     def poll(self, context):
462         if not self.has_sequencer(context):
463             return False
464
465         strip = act_strip(context)
466         if not strip:
467             return False
468
469         return strip.type in ('MOVIE', 'IMAGE')
470
471     def draw(self, context):
472         layout = self.layout
473
474         strip = act_strip(context)
475
476         split = layout.split(percentage=0.2)
477         col = split.column()
478         col.label(text="Path:")
479         col = split.column()
480         col.prop(strip, "directory", text="")
481
482         # Current element for the filename
483
484         elem = strip.getStripElem(context.scene.current_frame)
485         if elem:
486             split = layout.split(percentage=0.2)
487             col = split.column()
488             col.label(text="File:")
489             col = split.column()
490             col.prop(elem, "filename", text="") # strip.elements[0] could be a fallback
491
492         layout.prop(strip, "use_translation", text="Image Offset:")
493         if strip.transform:
494             col = layout.column(align=True)
495             col.active = strip.use_translation
496             col.prop(strip.transform, "offset_x", text="X")
497             col.prop(strip.transform, "offset_y", text="Y")
498
499         layout.prop(strip, "use_crop", text="Image Crop:")
500         if strip.crop:
501             col = layout.column(align=True)
502             col.active = strip.use_crop
503             col.prop(strip.crop, "top")
504             col.prop(strip.crop, "left")
505             col.prop(strip.crop, "bottom")
506             col.prop(strip.crop, "right")
507
508         col = layout.column(align=True)
509         col.label(text="Trim Duration:")
510         col.prop(strip, "animation_start_offset", text="Start")
511         col.prop(strip, "animation_end_offset", text="End")
512
513
514 class SEQUENCER_PT_sound(SequencerButtonsPanel):
515     bl_label = "Sound"
516
517     def poll(self, context):
518         if not self.has_sequencer(context):
519             return False
520
521         strip = act_strip(context)
522         if not strip:
523             return False
524
525         return (strip.type == 'SOUND')
526
527     def draw(self, context):
528         layout = self.layout
529
530         strip = act_strip(context)
531
532         layout.template_ID(strip, "sound", open="sound.open")
533
534         layout.separator()
535         layout.prop(strip.sound, "filename", text="")
536
537         row = layout.row()
538         if strip.sound.packed_file:
539             row.operator("sound.unpack", icon='PACKAGE', text="Unpack")
540         else:
541             row.operator("sound.pack", icon='UGLYPACKAGE', text="Pack")
542
543         row.prop(strip.sound, "caching")
544
545         layout.prop(strip, "volume")
546
547
548 class SEQUENCER_PT_scene(SequencerButtonsPanel):
549     bl_label = "Scene"
550
551     def poll(self, context):
552         if not self.has_sequencer(context):
553             return False
554
555         strip = act_strip(context)
556         if not strip:
557             return False
558
559         return (strip.type == 'SCENE')
560
561     def draw(self, context):
562         layout = self.layout
563
564         strip = act_strip(context)
565
566         layout.template_ID(strip, "scene")
567
568
569 class SEQUENCER_PT_filter(SequencerButtonsPanel):
570     bl_label = "Filter"
571
572     def poll(self, context):
573         if not self.has_sequencer(context):
574             return False
575
576         strip = act_strip(context)
577         if not strip:
578             return False
579
580         return strip.type in ('MOVIE', 'IMAGE', 'SCENE', 'META')
581
582     def draw(self, context):
583         layout = self.layout
584
585         strip = act_strip(context)
586
587         col = layout.column()
588         col.label(text="Video:")
589         col.prop(strip, "strobe")
590         col.prop(strip, "de_interlace")
591
592         col = layout.column()
593         col.label(text="Colors:")
594         col.prop(strip, "multiply_colors", text="Multiply")
595         col.prop(strip, "premultiply")
596         col.prop(strip, "convert_float")
597
598         col = layout.column()
599         col.label(text="Flip:")
600         col.prop(strip, "flip_x", text="X")
601         col.prop(strip, "flip_y", text="Y")
602         col.prop(strip, "reverse_frames", text="Backwards")
603
604         layout.prop(strip, "use_color_balance")
605         if strip.color_balance: # TODO - need to add this somehow
606             row = layout.row()
607             row.active = strip.use_color_balance
608             col = row.column()
609             col.prop(strip.color_balance, "lift")
610             col.prop(strip.color_balance, "inverse_lift", text="Inverse")
611             col = row.column()
612             col.prop(strip.color_balance, "gamma")
613             col.prop(strip.color_balance, "inverse_gamma", text="Inverse")
614             col = row.column()
615             col.prop(strip.color_balance, "gain")
616             col.prop(strip.color_balance, "inverse_gain", text="Inverse")
617
618
619 class SEQUENCER_PT_proxy(SequencerButtonsPanel):
620     bl_label = "Proxy"
621
622     def poll(self, context):
623         if not self.has_sequencer(context):
624             return False
625
626         strip = act_strip(context)
627         if not strip:
628             return False
629
630         return strip.type in ('MOVIE', 'IMAGE', 'SCENE', 'META')
631
632     def draw_header(self, context):
633         strip = act_strip(context)
634
635         self.layout.prop(strip, "use_proxy", text="")
636
637     def draw(self, context):
638         layout = self.layout
639
640         strip = act_strip(context)
641
642         flow = layout.column_flow()
643         flow.prop(strip, "proxy_custom_directory")
644         if strip.proxy: # TODO - need to add this somehow
645             flow.prop(strip.proxy, "directory")
646             flow.prop(strip.proxy, "file")
647
648
649 class SEQUENCER_PT_view(SequencerButtonsPanel_Output):
650     bl_label = "View Settings"
651
652     def draw(self, context):
653         layout = self.layout
654
655         st = context.space_data
656
657         col = layout.column()
658         col.prop(st, "draw_overexposed") # text="Zebra"
659         col.prop(st, "draw_safe_margin")
660
661 bpy.types.register(SEQUENCER_HT_header) # header/menu classes
662 bpy.types.register(SEQUENCER_MT_view)
663 bpy.types.register(SEQUENCER_MT_view_toggle)
664 bpy.types.register(SEQUENCER_MT_select)
665 bpy.types.register(SEQUENCER_MT_marker)
666 bpy.types.register(SEQUENCER_MT_add)
667 bpy.types.register(SEQUENCER_MT_add_effect)
668 bpy.types.register(SEQUENCER_MT_strip)
669
670 bpy.types.register(SEQUENCER_PT_edit) # sequencer panels
671 bpy.types.register(SEQUENCER_PT_effect)
672 bpy.types.register(SEQUENCER_PT_input)
673 bpy.types.register(SEQUENCER_PT_sound)
674 bpy.types.register(SEQUENCER_PT_scene)
675 bpy.types.register(SEQUENCER_PT_filter)
676 bpy.types.register(SEQUENCER_PT_proxy)
677
678 bpy.types.register(SEQUENCER_PT_view) # view panels