FIX for #20256 New folder doesn't rename
[blender-staging.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="Gamma Cross").type = 'GAMMA_CROSS'
182         layout.operator("sequencer.effect_strip_add", text="Multiply").type = 'MULTIPLY'
183         layout.operator("sequencer.effect_strip_add", text="Over Drop").type = 'OVER_DROP'
184         layout.operator("sequencer.effect_strip_add", text="Plugin").type = 'PLUGIN'
185         layout.operator("sequencer.effect_strip_add", text="Wipe").type = 'WIPE'
186         layout.operator("sequencer.effect_strip_add", text="Glow").type = 'GLOW'
187         layout.operator("sequencer.effect_strip_add", text="Transform").type = 'TRANSFORM'
188         layout.operator("sequencer.effect_strip_add", text="Color").type = 'COLOR'
189         layout.operator("sequencer.effect_strip_add", text="Speed Control").type = 'SPEED'
190
191
192 class SEQUENCER_MT_strip(bpy.types.Menu):
193     bl_label = "Strip"
194
195     def draw(self, context):
196         layout = self.layout
197
198         layout.operator_context = 'INVOKE_REGION_WIN'
199
200         layout.column()
201         layout.operator("tfm.transform", text="Grab/Move").mode = 'TRANSLATION'
202         layout.operator("tfm.transform", text="Grab/Extend from frame").mode = 'TIME_EXTEND'
203         #  uiItemO(layout, NULL, 0, "sequencer.strip_snap"); // TODO - add this operator
204         layout.separator()
205
206         layout.operator("sequencer.cut", text="Cut (hard) at frame").type = 'HARD'
207         layout.operator("sequencer.cut", text="Cut (soft) at frame").type = 'SOFT'
208         layout.operator("sequencer.images_separate")
209         layout.separator()
210
211         layout.operator("sequencer.duplicate")
212         layout.operator("sequencer.delete")
213
214         strip = act_strip(context)
215
216         if strip:
217             stype = strip.type
218
219             if  stype == 'EFFECT':
220                 layout.separator()
221                 layout.operator("sequencer.effect_change")
222                 layout.operator("sequencer.effect_reassign_inputs")
223             elif stype == 'IMAGE':
224                 layout.separator()
225                 layout.operator("sequencer.image_change")
226                 layout.operator("sequencer.rendersize")
227             elif stype == 'SCENE':
228                 layout.separator()
229                 layout.operator("sequencer.scene_change", text="Change Scene")
230             elif stype == 'MOVIE':
231                 layout.separator()
232                 layout.operator("sequencer.movie_change")
233                 layout.operator("sequencer.rendersize")
234
235         layout.separator()
236
237         layout.operator("sequencer.meta_make")
238         layout.operator("sequencer.meta_separate")
239
240         #if (ed && (ed->metastack.first || (ed->act_seq && ed->act_seq->type == SEQ_META))) {
241         #       uiItemS(layout);
242         #       uiItemO(layout, NULL, 0, "sequencer.meta_toggle");
243         #}
244
245         layout.separator()
246         layout.operator("sequencer.reload")
247         layout.separator()
248         layout.operator("sequencer.lock")
249         layout.operator("sequencer.unlock")
250         layout.operator("sequencer.mute")
251         layout.operator("sequencer.unmute")
252
253         layout.operator("sequencer.mute", text="Mute Deselected Strips").unselected = True
254
255         layout.operator("sequencer.snap")
256
257         layout.operator("sequencer.swap_right")
258         layout.operator("sequencer.swap_left")
259
260
261 class SequencerButtonsPanel(bpy.types.Panel):
262     bl_space_type = 'SEQUENCE_EDITOR'
263     bl_region_type = 'UI'
264
265     def poll(self, context):
266         return (context.space_data.display_mode == 'SEQUENCER') and (act_strip(context) is not None)
267
268
269 class SequencerButtonsPanel_Output(bpy.types.Panel):
270     bl_space_type = 'SEQUENCE_EDITOR'
271     bl_region_type = 'UI'
272
273     def poll(self, context):
274         return context.space_data.display_mode != 'SEQUENCER'
275
276
277 class SEQUENCER_PT_edit(SequencerButtonsPanel):
278     bl_label = "Edit Strip"
279
280     def draw(self, context):
281         layout = self.layout
282
283         strip = act_strip(context)
284
285         split = layout.split(percentage=0.3)
286         split.label(text="Name:")
287         split.prop(strip, "name", text="")
288
289         split = layout.split(percentage=0.3)
290         split.label(text="Type:")
291         split.prop(strip, "type", text="")
292
293         split = layout.split(percentage=0.3)
294         split.label(text="Blend:")
295         split.prop(strip, "blend_mode", text="")
296
297         row = layout.row()
298         if strip.mute == True:
299             row.prop(strip, "mute", toggle=True, icon='ICON_RESTRICT_VIEW_ON', text="")
300         elif strip.mute is False:
301             row.prop(strip, "mute", toggle=True, icon='ICON_RESTRICT_VIEW_OFF', text="")
302
303         sub = row.row()
304         sub.active = (not strip.mute)
305
306         sub.prop(strip, "blend_opacity", text="Opacity", slider=True)
307
308         row = layout.row()
309         row.prop(strip, "lock")
310         row.prop(strip, "frame_locked", text="Frame Lock")
311
312         col = layout.column()
313         col.enabled = not strip.lock
314         col.prop(strip, "channel")
315         col.prop(strip, "start_frame")
316         col.prop(strip, "length")
317
318         col = layout.column(align=True)
319         col.label(text="Offset:")
320         col.prop(strip, "start_offset", text="Start")
321         col.prop(strip, "end_offset", text="End")
322
323         col = layout.column(align=True)
324         col.label(text="Still:")
325         col.prop(strip, "start_still", text="Start")
326         col.prop(strip, "end_still", text="End")
327
328
329 class SEQUENCER_PT_effect(SequencerButtonsPanel):
330     bl_label = "Effect Strip"
331
332     def poll(self, context):
333         if context.space_data.display_mode != 'SEQUENCER':
334             return False
335
336         strip = act_strip(context)
337         if not strip:
338             return False
339
340         return strip.type in ('ADD', 'SUBTRACT', 'ALPHA_OVER', 'ALPHA_UNDER',
341                               'GAMMA_CROSS', 'MULTIPLY', 'OVER_DROP',
342                               'PLUGIN',
343                               'WIPE', 'GLOW', 'TRANSFORM', 'COLOR', 'SPEED')
344
345     def draw(self, context):
346         layout = self.layout
347
348         strip = act_strip(context)
349
350         if strip.type == 'COLOR':
351             layout.prop(strip, "color")
352
353         elif strip.type == 'WIPE':
354
355             col = layout.column()
356             col.prop(strip, "transition_type")
357             col.label(text="Direction:")
358             col.row().prop(strip, "direction", expand=True)
359
360             col = layout.column()
361             col.prop(strip, "blur_width", slider=True)
362             if strip.transition_type in ('SINGLE', 'DOUBLE'):
363                 col.prop(strip, "angle")
364
365         elif strip.type == 'GLOW':
366             flow = layout.column_flow()
367             flow.prop(strip, "threshold", slider=True)
368             flow.prop(strip, "clamp", slider=True)
369             flow.prop(strip, "boost_factor")
370             flow.prop(strip, "blur_distance")
371
372             row = layout.row()
373             row.prop(strip, "quality", slider=True)
374             row.prop(strip, "only_boost")
375
376         elif strip.type == 'SPEED':
377             layout.prop(strip, "global_speed")
378
379             flow = layout.column_flow()
380             flow.prop(strip, "curve_velocity")
381             flow.prop(strip, "curve_compress_y")
382             flow.prop(strip, "frame_blending")
383
384         elif strip.type == 'TRANSFORM':
385
386             col = layout.column()
387             col.prop(strip, "interpolation")
388             col.prop(strip, "translation_unit")
389
390             col = layout.column(align=True)
391             col.label(text="Position X:")
392             col.prop(strip, "translate_start_x", text="Start")
393             col.prop(strip, "translate_end_x", text="End")
394
395             col = layout.column(align=True)
396             col.label(text="Position Y:")
397             col.prop(strip, "translate_start_y", text="Start")
398             col.prop(strip, "translate_end_y", text="End")
399
400             layout.separator()
401
402             col = layout.column(align=True)
403             col.label(text="Scale X:")
404             col.prop(strip, "scale_start_x", text="Start")
405             col.prop(strip, "scale_end_x", text="End")
406
407             col = layout.column(align=True)
408             col.label(text="Scale Y:")
409             col.prop(strip, "scale_start_y", text="Start")
410             col.prop(strip, "scale_end_y", text="End")
411
412             layout.separator()
413
414             col = layout.column(align=True)
415             col.label(text="Rotation:")
416             col.prop(strip, "rotation_start", text="Start")
417             col.prop(strip, "rotation_end", text="End")
418
419         col = layout.column(align=True)
420         if strip.type == 'SPEED':
421             col.prop(strip, "speed_fader", text="Speed fader")
422         else:
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
428 class SEQUENCER_PT_input(SequencerButtonsPanel):
429     bl_label = "Strip Input"
430
431     def poll(self, context):
432         if context.space_data.display_mode != 'SEQUENCER':
433             return False
434
435         strip = act_strip(context)
436         if not strip:
437             return False
438
439         return strip.type in ('MOVIE', 'IMAGE')
440
441     def draw(self, context):
442         layout = self.layout
443
444         strip = act_strip(context)
445
446         split = layout.split(percentage=0.2)
447         col = split.column()
448         col.label(text="Path:")
449         col = split.column()
450         col.prop(strip, "directory", text="")
451
452         # Current element for the filename
453
454         elem = strip.getStripElem(context.scene.current_frame)
455         if elem:
456             split = layout.split(percentage=0.2)
457             col = split.column()
458             col.label(text="File:")
459             col = split.column()
460             col.prop(elem, "filename", text="") # strip.elements[0] could be a fallback
461
462         layout.prop(strip, "use_translation", text="Image Offset:")
463         if strip.transform:
464             col = layout.column(align=True)
465             col.active = strip.use_translation
466             col.prop(strip.transform, "offset_x", text="X")
467             col.prop(strip.transform, "offset_y", text="Y")
468
469         layout.prop(strip, "use_crop", text="Image Crop:")
470         if strip.crop:
471             col = layout.column(align=True)
472             col.active = strip.use_crop
473             col.prop(strip.crop, "top")
474             col.prop(strip.crop, "left")
475             col.prop(strip.crop, "bottom")
476             col.prop(strip.crop, "right")
477
478         col = layout.column(align=True)
479         col.label(text="Trim Duration:")
480         col.prop(strip, "animation_start_offset", text="Start")
481         col.prop(strip, "animation_end_offset", text="End")
482
483
484 class SEQUENCER_PT_sound(SequencerButtonsPanel):
485     bl_label = "Sound"
486
487     def poll(self, context):
488         if context.space_data.display_mode != 'SEQUENCER':
489             return False
490
491         strip = act_strip(context)
492         if not strip:
493             return False
494
495         return (strip.type == 'SOUND')
496
497     def draw(self, context):
498         layout = self.layout
499
500         strip = act_strip(context)
501
502         layout.template_ID(strip, "sound", open="sound.open")
503
504         layout.separator()
505         layout.prop(strip.sound, "filename", text="")
506
507         row = layout.row()
508         if strip.sound.packed_file:
509             row.operator("sound.unpack", icon='ICON_PACKAGE', text="Unpack")
510         else:
511             row.operator("sound.pack", icon='ICON_UGLYPACKAGE', text="Pack")
512
513         row.prop(strip.sound, "caching")
514
515         layout.prop(strip, "volume")
516
517
518 class SEQUENCER_PT_scene(SequencerButtonsPanel):
519     bl_label = "Scene"
520
521     def poll(self, context):
522         if context.space_data.display_mode != 'SEQUENCER':
523             return False
524
525         strip = act_strip(context)
526         if not strip:
527             return False
528
529         return (strip.type == 'SCENE')
530
531     def draw(self, context):
532         layout = self.layout
533
534         strip = act_strip(context)
535
536         layout.template_ID(strip, "scene")
537
538
539 class SEQUENCER_PT_filter(SequencerButtonsPanel):
540     bl_label = "Filter"
541
542     def poll(self, context):
543         if context.space_data.display_mode != 'SEQUENCER':
544             return False
545
546         strip = act_strip(context)
547         if not strip:
548             return False
549
550         return strip.type in ('MOVIE', 'IMAGE', 'SCENE', 'META')
551
552     def draw(self, context):
553         layout = self.layout
554
555         strip = act_strip(context)
556
557         col = layout.column()
558         col.label(text="Video:")
559         col.prop(strip, "strobe")
560         col.prop(strip, "de_interlace")
561
562         col = layout.column()
563         col.label(text="Colors:")
564         col.prop(strip, "multiply_colors", text="Multiply")
565         col.prop(strip, "premultiply")
566         col.prop(strip, "convert_float")
567
568         col = layout.column()
569         col.label(text="Flip:")
570         col.prop(strip, "flip_x", text="X")
571         col.prop(strip, "flip_y", text="Y")
572         col.prop(strip, "reverse_frames", text="Backwards")
573
574         layout.prop(strip, "use_color_balance")
575         if strip.color_balance: # TODO - need to add this somehow
576             row = layout.row()
577             row.active = strip.use_color_balance
578             col = row.column()
579             col.prop(strip.color_balance, "lift")
580             col.prop(strip.color_balance, "inverse_lift", text="Inverse")
581             col = row.column()
582             col.prop(strip.color_balance, "gamma")
583             col.prop(strip.color_balance, "inverse_gamma", text="Inverse")
584             col = row.column()
585             col.prop(strip.color_balance, "gain")
586             col.prop(strip.color_balance, "inverse_gain", text="Inverse")
587
588
589 class SEQUENCER_PT_proxy(SequencerButtonsPanel):
590     bl_label = "Proxy"
591
592     def poll(self, context):
593         if context.space_data.display_mode != 'SEQUENCER':
594             return False
595
596         strip = act_strip(context)
597         if not strip:
598             return False
599
600         return strip.type in ('MOVIE', 'IMAGE', 'SCENE', 'META')
601
602     def draw_header(self, context):
603         strip = act_strip(context)
604
605         self.layout.prop(strip, "use_proxy", text="")
606
607     def draw(self, context):
608         layout = self.layout
609
610         strip = act_strip(context)
611
612         flow = layout.column_flow()
613         flow.prop(strip, "proxy_custom_directory")
614         if strip.proxy: # TODO - need to add this somehow
615             flow.prop(strip.proxy, "directory")
616             flow.prop(strip.proxy, "file")
617
618
619 class SEQUENCER_PT_view(SequencerButtonsPanel_Output):
620     bl_label = "View Settings"
621
622     def draw(self, context):
623         layout = self.layout
624
625         st = context.space_data
626
627         col = layout.column()
628         col.prop(st, "draw_overexposed") # text="Zebra"
629         col.prop(st, "draw_safe_margin")
630
631 bpy.types.register(SEQUENCER_HT_header) # header/menu classes
632 bpy.types.register(SEQUENCER_MT_view)
633 bpy.types.register(SEQUENCER_MT_select)
634 bpy.types.register(SEQUENCER_MT_marker)
635 bpy.types.register(SEQUENCER_MT_add)
636 bpy.types.register(SEQUENCER_MT_add_effect)
637 bpy.types.register(SEQUENCER_MT_strip)
638
639 bpy.types.register(SEQUENCER_PT_edit) # sequencer panels
640 bpy.types.register(SEQUENCER_PT_effect)
641 bpy.types.register(SEQUENCER_PT_input)
642 bpy.types.register(SEQUENCER_PT_sound)
643 bpy.types.register(SEQUENCER_PT_scene)
644 bpy.types.register(SEQUENCER_PT_filter)
645 bpy.types.register(SEQUENCER_PT_proxy)
646
647 bpy.types.register(SEQUENCER_PT_view) # view panels