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