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