fb8cc12c43601bec4cc3b33d9fb91114a4c785cd
[blender.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(context)
19                 
20                 if context.area.show_menus:
21                         row = layout.row(align=True)
22                         row.itemM(context, "SEQUENCER_MT_view")
23                         
24                         row.itemR(st, "display_mode")
25                         
26                         layout.itemS()
27                         
28                         if st.display_mode == 'SEQUENCER':
29                                 row.itemM(context, "SEQUENCER_MT_select")
30                                 row.itemM(context, "SEQUENCER_MT_marker")
31                                 row.itemM(context, "SEQUENCER_MT_add")
32                                 row.itemM(context, "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                 
94                 """
95         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, "");
96         else uiDefIconTextBut(block, BUTM, B_FULL, ICON_BLANK1, "Tile Window|Ctrl DownArrow", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 0, "");
97
98                 """
99
100 class SEQUENCER_MT_select(bpy.types.Menu):
101         __space_type__ = "SEQUENCE_EDITOR"
102         __label__ = "Select"
103
104         def draw(self, context):
105                 layout = self.layout
106                 st = context.space_data
107                 
108                 layout.column()
109                 layout.item_enumO("SEQUENCER_OT_select_active_side", "side", 'LEFT', text="Strips to the Left")
110                 layout.item_enumO("SEQUENCER_OT_select_active_side", "side", 'RIGHT', text="Strips to the Right")
111                 layout.itemS()
112                 layout.item_enumO("SEQUENCER_OT_select_handles", "side", 'BOTH', text="Surrounding Handles")
113                 layout.item_enumO("SEQUENCER_OT_select_handles", "side", 'LEFT', text="Left Handle")
114                 layout.item_enumO("SEQUENCER_OT_select_handles", "side", 'RIGHT', text="Right Handle")
115                 layout.itemS()
116                 layout.itemO("SEQUENCER_OT_select_linked")
117                 layout.itemO("SEQUENCER_OT_select_all_toggle")
118                 layout.itemO("SEQUENCER_OT_select_invert")
119
120 class SEQUENCER_MT_marker(bpy.types.Menu):
121         __space_type__ = "SEQUENCE_EDITOR"
122         __label__ = "Marker (TODO)"
123
124         def draw(self, context):
125                 layout = self.layout
126                 st = context.space_data
127                 
128                 layout.column()
129                 layout.itemO("SEQUENCER_OT_sound_strip_add", text="Add Marker|Ctrl Alt M")
130                 layout.itemO("SEQUENCER_OT_sound_strip_add", text="Duplicate Marker|Ctrl Shift D")
131                 layout.itemO("SEQUENCER_OT_sound_strip_add", text="Delete Marker|Shift X")
132                 layout.itemS()
133                 layout.itemO("SEQUENCER_OT_sound_strip_add", text="(Re)Name Marker|Ctrl M")
134                 layout.itemO("SEQUENCER_OT_sound_strip_add", text="Grab/Move Marker|Ctrl G")
135                 layout.itemS()
136                 layout.itemO("SEQUENCER_OT_sound_strip_add", text="Transform Markers") # toggle, will be rna - (sseq->flag & SEQ_MARKER_TRANS)
137
138 class SEQUENCER_MT_add(bpy.types.Menu):
139         __space_type__ = "SEQUENCE_EDITOR"
140         __label__ = "Add"
141
142         def draw(self, context):
143                 layout = self.layout
144                 st = context.space_data
145                 
146                 layout.column()
147                 layout.itemO("SEQUENCER_OT_movie_strip_add", text="Movie")
148                 layout.item_booleanO("SEQUENCER_OT_movie_strip_add", "sound", True, text="Movie & Sound") # FFMPEG ONLY
149                 layout.itemO("SEQUENCER_OT_image_strip_add", text="Image")
150                 layout.itemO("SEQUENCER_OT_sound_strip_add", text="Sound (Ram)")
151                 layout.item_booleanO("SEQUENCER_OT_sound_strip_add", "hd", True, text="Sound (Streaming)") # FFMPEG ONLY
152                 
153                 layout.itemM(context, "SEQUENCER_MT_add_effect")
154
155
156 class SEQUENCER_MT_add_effect(bpy.types.Menu):
157         __space_type__ = "SEQUENCE_EDITOR"
158         __label__ = "Effect Strip..."
159
160         def draw(self, context):
161                 layout = self.layout
162                 st = context.space_data
163                 
164                 self.layout.column()
165                 self.layout.item_enumO("SEQUENCER_OT_effect_strip_add", 'type', 'ADD')
166                 self.layout.item_enumO("SEQUENCER_OT_effect_strip_add", 'type', 'SUBTRACT')
167                 self.layout.item_enumO("SEQUENCER_OT_effect_strip_add", 'type', 'ALPHA_OVER')
168                 self.layout.item_enumO("SEQUENCER_OT_effect_strip_add", 'type', 'ALPHA_UNDER')
169                 self.layout.item_enumO("SEQUENCER_OT_effect_strip_add", 'type', 'GAMMA_CROSS')
170                 self.layout.item_enumO("SEQUENCER_OT_effect_strip_add", 'type', 'MULTIPLY')
171                 self.layout.item_enumO("SEQUENCER_OT_effect_strip_add", 'type', 'OVER_DROP')
172                 self.layout.item_enumO("SEQUENCER_OT_effect_strip_add", 'type', 'PLUGIN')
173                 self.layout.item_enumO("SEQUENCER_OT_effect_strip_add", 'type', 'WIPE')
174                 self.layout.item_enumO("SEQUENCER_OT_effect_strip_add", 'type', 'GLOW')
175                 self.layout.item_enumO("SEQUENCER_OT_effect_strip_add", 'type', 'TRANSFORM')
176                 self.layout.item_enumO("SEQUENCER_OT_effect_strip_add", 'type', 'COLOR')
177                 self.layout.item_enumO("SEQUENCER_OT_effect_strip_add", 'type', 'SPEED')
178
179 class SEQUENCER_MT_strip(bpy.types.Menu):
180         __space_type__ = "SEQUENCE_EDITOR"
181         __label__ = "Strip"
182
183         def draw(self, context):
184                 layout = self.layout
185                 st = context.space_data
186                 
187                 layout.operator_context = 'INVOKE_REGION_WIN'
188                 
189                 layout.column()
190                 layout.item_enumO("TFM_OT_transform", "mode", 'TRANSLATION', text="Grab/Move")
191                 layout.item_enumO("TFM_OT_transform", "mode", 'TIME_EXTEND', text="Grab/Extend from frame")
192                 #  uiItemO(layout, NULL, 0, "SEQUENCER_OT_strip_snap"); // TODO - add this operator
193                 layout.itemS()
194                 
195                 layout.item_enumO("SEQUENCER_OT_cut", "type", 'HARD', text="Cut (hard) at frame")
196                 layout.item_enumO("SEQUENCER_OT_cut", "type", 'SOFT', text="Cut (soft) at frame")
197                 layout.itemO("SEQUENCER_OT_images_separate")
198                 layout.itemS()
199                 
200                 layout.itemO("SEQUENCER_OT_duplicate_add")
201                 layout.itemO("SEQUENCER_OT_delete")
202                 
203                 strip = act_strip(context)
204                 
205                 if strip:
206                         stype = strip.type
207                         
208                         if      stype=='EFFECT':
209                                 layout.itemS()
210                                 layout.itemO("SEQUENCER_OT_effect_change")
211                                 layout.itemO("SEQUENCER_OT_effect_reassign_inputs")
212                         elif stype=='IMAGE':
213                                 layout.itemS()
214                                 layout.itemO("SEQUENCER_OT_image_change")
215                         elif stype=='SCENE':
216                                 layout.itemS()
217                                 layout.itemO("SEQUENCER_OT_scene_change", text="Change Scene")
218                         elif stype=='MOVIE':
219                                 layout.itemS()
220                                 layout.itemO("SEQUENCER_OT_movie_change")
221                         
222                 layout.itemS()
223                 
224                 layout.itemO("SEQUENCER_OT_meta_make")
225                 layout.itemO("SEQUENCER_OT_meta_separate")
226                 
227                 #if (ed && (ed->metastack.first || (ed->act_seq && ed->act_seq->type == SEQ_META))) {
228                 #       uiItemS(layout);
229                 #       uiItemO(layout, NULL, 0, "SEQUENCER_OT_meta_toggle");
230                 #}
231                 
232                 layout.itemS()
233                 layout.itemO("SEQUENCER_OT_reload")
234                 layout.itemS()
235                 layout.itemO("SEQUENCER_OT_lock")
236                 layout.itemO("SEQUENCER_OT_unlock")
237                 layout.itemO("SEQUENCER_OT_mute")
238                 layout.itemO("SEQUENCER_OT_unmute")
239                 
240                 layout.item_enumO("SEQUENCER_OT_mute", property="type", value='UNSELECTED', text="Mute Deselected Strips")
241
242
243
244 # Panels
245 class SequencerButtonsPanel(bpy.types.Panel):
246         __space_type__ = "SEQUENCE_EDITOR"
247         __region_type__ = "UI"
248
249         def poll(self, context):
250                 return context.space_data.display_mode == 'SEQUENCER' and act_strip(context) != None
251                 
252 class SequencerButtonsPanel_Output(bpy.types.Panel):
253         __space_type__ = "SEQUENCE_EDITOR"
254         __region_type__ = "UI"
255
256         def poll(self, context):
257                 return context.space_data.display_mode != 'SEQUENCER'
258
259 class SEQUENCER_PT_edit(SequencerButtonsPanel):
260         __label__ = "Edit Strip"
261         __idname__ = "SEQUENCER_PT_edit"
262
263         def draw(self, context):
264                 layout = self.layout
265                 
266                 strip = act_strip(context)
267                 
268                 layout.itemR(strip, "name")
269                 
270                 layout.itemR(strip, "type")
271                 
272                 layout.itemR(strip, "blend_mode")
273                 
274                 layout.itemR(strip, "blend_opacity", text="Opacity", slider=True)
275                 
276                 split = layout.split()
277                 
278                 col = split.column()
279                 col.itemR(strip, "mute")
280                 col.itemR(strip, "lock")
281                 col.itemR(strip, "frame_locked")
282                 
283                 col = split.column()
284                 col.itemR(strip, "channel")
285                 col.itemR(strip, "start_frame")
286                 col.itemR(strip, "length")
287                 
288                 
289 class SEQUENCER_PT_effect(SequencerButtonsPanel):
290         __label__ = "Effect Strip"
291         __idname__ = "SEQUENCER_PT_effect"
292
293         def poll(self, context):
294                 if context.space_data.display_mode != 'SEQUENCER':
295                         return False
296                 
297                 strip = act_strip(context)
298                 if not strip:
299                         return False
300                 
301                 return strip.type in ('COLOR', 'WIPE', 'GLOW', 'SPEED', 'TRANSFORM')
302
303         def draw(self, context):
304                 layout = self.layout
305                 
306                 strip = act_strip(context)
307                 
308                 if strip.type == 'COLOR':
309                         layout.itemR(strip, "color")
310                         
311                 elif strip.type == 'WIPE':
312                         row = layout.row()
313                         row.itemL(text="Transition Type:")
314                         row.itemL(text="Direction:")
315                         
316                         row = layout.row()
317                         row.itemR(strip, "transition_type", text="")
318                         row.itemR(strip, "direction", text="")
319                         
320                         row = layout.row()
321                         row.itemR(strip, "blur_width")
322                         if strip.transition_type in ('SINGLE', 'DOUBLE'):
323                                 row.itemR(strip, "angle")
324                                 
325                 elif strip.type == 'GLOW':
326                         flow = layout.column_flow()
327                         flow.itemR(strip, "threshold")
328                         flow.itemR(strip, "clamp")
329                         flow.itemR(strip, "boost_factor")
330                         flow.itemR(strip, "blur_distance")
331                         
332                         row = layout.row()
333                         row.itemR(strip, "quality", slider=True)
334                         row.itemR(strip, "only_boost")
335                         
336                 elif strip.type == 'SPEED':
337                         layout.itemR(strip, "global_speed")
338                         
339                         flow = layout.column_flow()
340                         flow.itemR(strip, "curve_velocity")
341                         flow.itemR(strip, "curve_compress_y")
342                         flow.itemR(strip, "frame_blending")
343                         
344                 elif strip.type == 'TRANSFORM':
345                         row = layout.row()
346                         row.itemL(text="Interpolation:")
347                         row.itemL(text="Translation Unit:")
348                         
349                         row = layout.row()
350                         row.itemR(strip, "interpolation", text="")
351                         row.itemR(strip, "translation_unit", text="")
352                         
353                         split = layout.split()
354                         
355                         col = split.column()
356                         sub = col.column(align=True) 
357                         sub.itemL(text="Position X:")
358                         sub.itemR(strip, "translate_start_x", text="Start")
359                         sub.itemR(strip, "translate_end_x", text="End")
360                         
361                         sub = col.column(align=True) 
362                         sub.itemL(text="Scale X:")
363                         sub.itemR(strip, "scale_start_x", text="Start")
364                         sub.itemR(strip, "scale_end_x", text="End")
365                         
366                         sub = col.column(align=True) 
367                         sub.itemL(text="Rotation:")
368                         sub.itemR(strip, "rotation_start", text="Start")
369                         sub.itemR(strip, "rotation_end", text="End")
370                         
371                         col = split.column()
372                         sub = col.column(align=True) 
373                         sub.itemL(text="Position Y:")
374                         sub.itemR(strip, "translate_start_y", text="Start")
375                         sub.itemR(strip, "translate_end_y", text="End")
376                         
377                         sub = col.column(align=True) 
378                         sub.itemL(text="Scale Y:")
379                         sub.itemR(strip, "scale_start_y", text="Start")
380                         sub.itemR(strip, "scale_end_y", text="End")
381
382 class SEQUENCER_PT_input(SequencerButtonsPanel):
383         __label__ = "Strip Input"
384         __idname__ = "SEQUENCER_PT_input"
385         
386         def poll(self, context):
387                 if context.space_data.display_mode != 'SEQUENCER':
388                         return False
389                 
390                 strip = act_strip(context)
391                 if not strip:
392                         return False
393                 
394                 return strip.type in ('MOVIE', 'IMAGE', 'SCENE', 'META')
395         
396         def draw(self, context):
397                 layout = self.layout
398                 
399                 strip = act_strip(context)
400                 
401                 split = layout.split(percentage=0.3)
402                 sub = split.column()
403                 sub.itemL(text="Directory:")
404                 sub = split.column() 
405                 sub.itemR(strip, "directory", text="")
406                 
407                 # TODO - get current element!
408                 split = layout.split(percentage=0.3)
409                 sub = split.column()
410                 sub.itemL(text="File Name:")
411                 sub = split.column() 
412                 sub.itemR(strip.elements[0], "filename", text="")
413                 
414                 """
415                 layout.itemR(strip, "use_crop")
416                 
417                 flow = layout.column_flow()
418                 flow.active = strip.use_crop
419                 flow.itemR(strip, "top")
420                 flow.itemR(strip, "left")
421                 flow.itemR(strip, "bottom")
422                 flow.itemR(strip, "right")
423                 """
424
425 class SEQUENCER_PT_filter(SequencerButtonsPanel):
426         __label__ = "Filter"
427         __idname__ = "SEQUENCER_PT_filter"
428         
429         def poll(self, context):
430                 if context.space_data.display_mode != 'SEQUENCER':
431                         return False
432                 
433                 strip = act_strip(context)
434                 if not strip:
435                         return False
436                 
437                 return strip.type in ('MOVIE', 'IMAGE', 'SCENE', 'META')
438         
439         def draw(self, context):
440                 layout = self.layout
441                 
442                 strip = act_strip(context)
443                 
444                 split = layout.split()
445                 
446                 col = split.column()
447                 col.itemR(strip, "premultiply")
448                 col.itemR(strip, "convert_float")
449                 col.itemR(strip, "de_interlace")
450                 col.itemR(strip, "multiply_colors")
451                 col.itemR(strip, "strobe")
452                 
453                 col = split.column()
454                 col.itemL(text="Flip:")
455                 col.itemR(strip, "flip_x", text="X")
456                 col.itemR(strip, "flip_y", text="Y")
457                 col.itemR(strip, "reverse_frames", text="Backwards")
458                 
459                 layout.itemR(strip, "use_color_balance")
460
461 class SEQUENCER_PT_proxy(SequencerButtonsPanel):
462         __label__ = "Proxy"
463         __idname__ = "SEQUENCER_PT_proxy"
464         
465         def poll(self, context):
466                 if context.space_data.display_mode != 'SEQUENCER':
467                         return False
468                 
469                 strip = act_strip(context)
470                 if not strip:
471                         return False
472                 
473                 return strip.type in ('MOVIE', 'IMAGE', 'SCENE', 'META')
474         
475         def draw_header(self, context):
476                 strip = act_strip(context)
477
478                 layout = self.layout
479                 
480                 layout.itemR(strip, "use_proxy", text="")
481
482         def draw(self, context):
483                 strip = act_strip(context)
484                 
485                 layout = self.layout
486                 
487                 row = layout.row()
488                 row.itemR(strip, "proxy_custom_directory")
489                 if strip.proxy: # TODO - need to add this somehow
490                         row.itemR(strip.proxy, "dir")
491                         row.itemR(strip.proxy, "file")
492
493
494 class SEQUENCER_PT_view(SequencerButtonsPanel_Output):
495         __label__ = "View Settings"
496         __idname__ = "SEQUENCER_PT_view"
497
498         def draw(self, context):
499                 st = context.space_data
500
501                 layout = self.layout
502
503                 flow = layout.column_flow()
504                 flow.itemR(st, "draw_overexposed") # text="Zebra"
505                 flow.itemR(st, "draw_safe_margin")
506
507
508 bpy.types.register(SEQUENCER_HT_header) # header/menu classes
509 bpy.types.register(SEQUENCER_MT_view)
510 bpy.types.register(SEQUENCER_MT_select)
511 bpy.types.register(SEQUENCER_MT_marker)
512 bpy.types.register(SEQUENCER_MT_add)
513 bpy.types.register(SEQUENCER_MT_add_effect)
514 bpy.types.register(SEQUENCER_MT_strip)
515
516 bpy.types.register(SEQUENCER_PT_edit) # sequencer panels
517 bpy.types.register(SEQUENCER_PT_effect)
518 bpy.types.register(SEQUENCER_PT_input)
519 bpy.types.register(SEQUENCER_PT_filter)
520 bpy.types.register(SEQUENCER_PT_proxy)
521
522 bpy.types.register(SEQUENCER_PT_view) # view panels
523