rename operators TFM_OT_* --> TRANSFORM_OT_*
[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
104         layout.prop(st, "draw_frames")
105         layout.prop(st, "show_cframe_indicator")
106         if st.display_mode == 'IMAGE':
107             layout.prop(st, "draw_safe_margin")
108         if st.display_mode == 'WAVEFORM':
109             layout.prop(st, "separate_color_preview")
110
111         layout.separator()
112
113         layout.operator("screen.area_dupli")
114         layout.operator("screen.screen_full_area")
115
116
117 class SEQUENCER_MT_select(bpy.types.Menu):
118     bl_label = "Select"
119
120     def draw(self, context):
121         layout = self.layout
122
123         layout.column()
124         layout.operator("sequencer.select_active_side", text="Strips to the Left").side = 'LEFT'
125         layout.operator("sequencer.select_active_side", text="Strips to the Right").side = 'RIGHT'
126         layout.separator()
127         layout.operator("sequencer.select_handles", text="Surrounding Handles").side = 'BOTH'
128         layout.operator("sequencer.select_handles", text="Left Handle").side = 'LEFT'
129         layout.operator("sequencer.select_handles", text="Right Handle").side = 'RIGHT'
130         layout.separator()
131         layout.operator("sequencer.select_linked")
132         layout.operator("sequencer.select_all_toggle")
133         layout.operator("sequencer.select_inverse")
134
135
136 class SEQUENCER_MT_marker(bpy.types.Menu):
137     bl_label = "Marker (TODO)"
138
139     def draw(self, context):
140         layout = self.layout
141
142         layout.column()
143         layout.operator("marker.add", text="Add Marker")
144         layout.operator("marker.duplicate", text="Duplicate Marker")
145         layout.operator("marker.move", text="Grab/Move Marker")
146         layout.operator("marker.delete", text="Delete Marker")
147         layout.separator()
148         layout.label(text="ToDo: Name Marker")
149
150         #layout.operator("sequencer.sound_strip_add", text="Transform Markers") # toggle, will be rna - (sseq->flag & SEQ_MARKER_TRANS)
151
152
153 class SEQUENCER_MT_add(bpy.types.Menu):
154     bl_label = "Add"
155
156     def draw(self, context):
157         layout = self.layout
158         layout.operator_context = 'INVOKE_REGION_WIN'
159
160         layout.column()
161         layout.operator("sequencer.scene_strip_add", text="Scene")
162         layout.operator("sequencer.movie_strip_add", text="Movie")
163         layout.operator("sequencer.image_strip_add", text="Image")
164         layout.operator("sequencer.sound_strip_add", text="Sound")
165
166         layout.menu("SEQUENCER_MT_add_effect")
167
168
169 class SEQUENCER_MT_add_effect(bpy.types.Menu):
170     bl_label = "Effect Strip..."
171
172     def draw(self, context):
173         layout = self.layout
174         layout.operator_context = 'INVOKE_REGION_WIN'
175
176         layout.column()
177         layout.operator("sequencer.effect_strip_add", text="Add").type = 'ADD'
178         layout.operator("sequencer.effect_strip_add", text="Subtract").type = 'SUBTRACT'
179         layout.operator("sequencer.effect_strip_add", text="Alpha Over").type = 'ALPHA_OVER'
180         layout.operator("sequencer.effect_strip_add", text="Alpha Under").type = 'ALPHA_UNDER'
181         layout.operator("sequencer.effect_strip_add", text="Cross").type = 'CROSS'
182         layout.operator("sequencer.effect_strip_add", text="Gamma Cross").type = 'GAMMA_CROSS'
183         layout.operator("sequencer.effect_strip_add", text="Multiply").type = 'MULTIPLY'
184         layout.operator("sequencer.effect_strip_add", text="Over Drop").type = 'OVER_DROP'
185         layout.operator("sequencer.effect_strip_add", text="Plugin").type = 'PLUGIN'
186         layout.operator("sequencer.effect_strip_add", text="Wipe").type = 'WIPE'
187         layout.operator("sequencer.effect_strip_add", text="Glow").type = 'GLOW'
188         layout.operator("sequencer.effect_strip_add", text="Transform").type = 'TRANSFORM'
189         layout.operator("sequencer.effect_strip_add", text="Color").type = 'COLOR'
190         layout.operator("sequencer.effect_strip_add", text="Speed Control").type = 'SPEED'
191
192
193 class SEQUENCER_MT_strip(bpy.types.Menu):
194     bl_label = "Strip"
195
196     def draw(self, context):
197         layout = self.layout
198
199         layout.operator_context = 'INVOKE_REGION_WIN'
200
201         layout.column()
202         layout.operator("transform.transform", text="Grab/Move").mode = 'TRANSLATION'
203         layout.operator("transform.transform", text="Grab/Extend from frame").mode = 'TIME_EXTEND'
204         #  uiItemO(layout, NULL, 0, "sequencer.strip_snap"); // TODO - add this operator
205         layout.separator()
206
207         layout.operator("sequencer.cut", text="Cut (hard) at frame").type = 'HARD'
208         layout.operator("sequencer.cut", text="Cut (soft) at frame").type = 'SOFT'
209         layout.operator("sequencer.images_separate")
210         layout.separator()
211
212         layout.operator("sequencer.duplicate")
213         layout.operator("sequencer.delete")
214
215         strip = act_strip(context)
216
217         if strip:
218             stype = strip.type
219
220             if  stype == 'EFFECT':
221                 layout.separator()
222                 layout.operator("sequencer.effect_change")
223                 layout.operator("sequencer.effect_reassign_inputs")
224             elif stype == 'IMAGE':
225                 layout.separator()
226                 # layout.operator("sequencer.image_change")
227                 layout.operator("sequencer.rendersize")
228             elif stype == 'SCENE':
229                 layout.separator()
230                 layout.operator("sequencer.scene_change", text="Change Scene")
231             elif stype == 'MOVIE':
232                 layout.separator()
233                 layout.operator("sequencer.movie_change")
234                 layout.operator("sequencer.rendersize")
235
236         layout.separator()
237
238         layout.operator("sequencer.meta_make")
239         layout.operator("sequencer.meta_separate")
240
241         #if (ed && (ed->metastack.first || (ed->act_seq && ed->act_seq->type == SEQ_META))) {
242         #       uiItemS(layout);
243         #       uiItemO(layout, NULL, 0, "sequencer.meta_toggle");
244         #}
245
246         layout.separator()
247         layout.operator("sequencer.reload")
248         layout.separator()
249         layout.operator("sequencer.lock")
250         layout.operator("sequencer.unlock")
251         layout.operator("sequencer.mute")
252         layout.operator("sequencer.unmute")
253
254         layout.operator("sequencer.mute", text="Mute Deselected Strips").unselected = True
255
256         layout.operator("sequencer.snap")
257
258         layout.operator("sequencer.swap_right")
259         layout.operator("sequencer.swap_left")
260
261
262 class SequencerButtonsPanel(bpy.types.Panel):
263     bl_space_type = 'SEQUENCE_EDITOR'
264     bl_region_type = 'UI'
265
266     def poll(self, context):
267         return (context.space_data.display_mode == 'SEQUENCER') and (act_strip(context) is not None)
268
269
270 class SequencerButtonsPanel_Output(bpy.types.Panel):
271     bl_space_type = 'SEQUENCE_EDITOR'
272     bl_region_type = 'UI'
273
274     def poll(self, context):
275         return context.space_data.display_mode != 'SEQUENCER'
276
277
278 class SEQUENCER_PT_edit(SequencerButtonsPanel):
279     bl_label = "Edit Strip"
280
281     def draw(self, context):
282         layout = self.layout
283
284         strip = act_strip(context)
285
286         split = layout.split(percentage=0.3)
287         split.label(text="Name:")
288         split.prop(strip, "name", text="")
289
290         split = layout.split(percentage=0.3)
291         split.label(text="Type:")
292         split.prop(strip, "type", text="")
293
294         split = layout.split(percentage=0.3)
295         split.label(text="Blend:")
296         split.prop(strip, "blend_mode", text="")
297
298         row = layout.row()
299         if strip.mute == True:
300             row.prop(strip, "mute", toggle=True, icon='RESTRICT_VIEW_ON', text="")
301         elif strip.mute is False:
302             row.prop(strip, "mute", toggle=True, icon='RESTRICT_VIEW_OFF', text="")
303
304         sub = row.row()
305         sub.active = (not strip.mute)
306
307         sub.prop(strip, "blend_opacity", text="Opacity", slider=True)
308
309         row = layout.row()
310         row.prop(strip, "lock")
311         row.prop(strip, "frame_locked", text="Frame Lock")
312
313         col = layout.column()
314         col.enabled = not strip.lock
315         col.prop(strip, "channel")
316         col.prop(strip, "start_frame")
317         col.prop(strip, "length")
318
319         col = layout.column(align=True)
320         col.label(text="Offset:")
321         col.prop(strip, "start_offset", text="Start")
322         col.prop(strip, "end_offset", text="End")
323
324         col = layout.column(align=True)
325         col.label(text="Still:")
326         col.prop(strip, "start_still", text="Start")
327         col.prop(strip, "end_still", text="End")
328
329
330 class SEQUENCER_PT_effect(SequencerButtonsPanel):
331     bl_label = "Effect Strip"
332
333     def poll(self, context):
334         if context.space_data.display_mode != 'SEQUENCER':
335             return False
336
337         strip = act_strip(context)
338         if not strip:
339             return False
340
341         return strip.type in ('ADD', 'SUBTRACT', 'ALPHA_OVER', 'ALPHA_UNDER',
342                               'CROSS', 'GAMMA_CROSS', 'MULTIPLY', 'OVER_DROP',
343                               'PLUGIN',
344                               'WIPE', 'GLOW', 'TRANSFORM', 'COLOR', 'SPEED')
345
346     def draw(self, context):
347         layout = self.layout
348
349         strip = act_strip(context)
350
351         if strip.type == 'COLOR':
352             layout.prop(strip, "color")
353
354         elif strip.type == 'WIPE':
355
356             col = layout.column()
357             col.prop(strip, "transition_type")
358             col.label(text="Direction:")
359             col.row().prop(strip, "direction", expand=True)
360
361             col = layout.column()
362             col.prop(strip, "blur_width", slider=True)
363             if strip.transition_type in ('SINGLE', 'DOUBLE'):
364                 col.prop(strip, "angle")
365
366         elif strip.type == 'GLOW':
367             flow = layout.column_flow()
368             flow.prop(strip, "threshold", slider=True)
369             flow.prop(strip, "clamp", slider=True)
370             flow.prop(strip, "boost_factor")
371             flow.prop(strip, "blur_distance")
372
373             row = layout.row()
374             row.prop(strip, "quality", slider=True)
375             row.prop(strip, "only_boost")
376
377         elif strip.type == 'SPEED':
378             layout.prop(strip, "global_speed")
379
380             flow = layout.column_flow()
381             flow.prop(strip, "curve_velocity")
382             flow.prop(strip, "curve_compress_y")
383             flow.prop(strip, "frame_blending")
384
385         elif strip.type == 'TRANSFORM':
386
387             col = layout.column()
388             col.prop(strip, "interpolation")
389             col.prop(strip, "translation_unit")
390
391             col = layout.column(align=True)
392             col.label(text="Position X:")
393             col.prop(strip, "translate_start_x", text="Start")
394             col.prop(strip, "translate_end_x", text="End")
395
396             col = layout.column(align=True)
397             col.label(text="Position Y:")
398             col.prop(strip, "translate_start_y", text="Start")
399             col.prop(strip, "translate_end_y", text="End")
400
401             layout.separator()
402
403             col = layout.column(align=True)
404             col.prop(strip, "uniform_scale")
405             
406             if (strip.uniform_scale):
407                 col = layout.column(align=True)
408                 col.label(text="Scale:")
409                 col.prop(strip, "scale_start_x", text="Start")
410                 col.prop(strip, "scale_end_x", text="End")
411             else:
412                 col = layout.column(align=True)
413                 col.label(text="Scale X:")
414                 col.prop(strip, "scale_start_x", text="Start")
415                 col.prop(strip, "scale_end_x", text="End")
416
417                 col = layout.column(align=True)
418                 col.label(text="Scale Y:")
419                 col.prop(strip, "scale_start_y", text="Start")
420                 col.prop(strip, "scale_end_y", text="End")
421
422             layout.separator()
423
424             col = layout.column(align=True)
425             col.label(text="Rotation:")
426             col.prop(strip, "rotation_start", text="Start")
427             col.prop(strip, "rotation_end", text="End")
428
429         col = layout.column(align=True)
430         if strip.type == 'SPEED':
431             col.prop(strip, "speed_fader", text="Speed fader")
432         elif strip.type in ('CROSS', 'GAMMA_CROSS', 'PLUGIN', 'WIPE',
433                             'TRANSFORM'):
434                 col.prop(strip, "use_effect_default_fade", "Default fade")
435                 if not strip.use_effect_default_fade:
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='PACKAGE', text="Unpack")
521         else:
522             row.operator("sound.pack", 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