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