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