UI scripts:
[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(context)
19                 
20                 if context.area.show_menus:
21                         row = layout.row()
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_scene_strip_add", text="Scene")
148                 layout.itemO("SEQUENCER_OT_movie_strip_add", text="Movie")
149                 layout.item_booleanO("SEQUENCER_OT_movie_strip_add", "sound", True, text="Movie & Sound") # FFMPEG ONLY
150                 layout.itemO("SEQUENCER_OT_image_strip_add", text="Image")
151                 layout.itemO("SEQUENCER_OT_sound_strip_add", text="Sound (Ram)")
152                 layout.item_booleanO("SEQUENCER_OT_sound_strip_add", "hd", True, text="Sound (Streaming)") # FFMPEG ONLY
153                 
154                 layout.itemM(context, "SEQUENCER_MT_add_effect")
155
156
157 class SEQUENCER_MT_add_effect(bpy.types.Menu):
158         __space_type__ = "SEQUENCE_EDITOR"
159         __label__ = "Effect Strip..."
160
161         def draw(self, context):
162                 layout = self.layout
163                 st = context.space_data
164                 
165                 self.layout.column()
166                 self.layout.item_enumO("SEQUENCER_OT_effect_strip_add", 'type', 'ADD')
167                 self.layout.item_enumO("SEQUENCER_OT_effect_strip_add", 'type', 'SUBTRACT')
168                 self.layout.item_enumO("SEQUENCER_OT_effect_strip_add", 'type', 'ALPHA_OVER')
169                 self.layout.item_enumO("SEQUENCER_OT_effect_strip_add", 'type', 'ALPHA_UNDER')
170                 self.layout.item_enumO("SEQUENCER_OT_effect_strip_add", 'type', 'GAMMA_CROSS')
171                 self.layout.item_enumO("SEQUENCER_OT_effect_strip_add", 'type', 'MULTIPLY')
172                 self.layout.item_enumO("SEQUENCER_OT_effect_strip_add", 'type', 'OVER_DROP')
173                 self.layout.item_enumO("SEQUENCER_OT_effect_strip_add", 'type', 'PLUGIN')
174                 self.layout.item_enumO("SEQUENCER_OT_effect_strip_add", 'type', 'WIPE')
175                 self.layout.item_enumO("SEQUENCER_OT_effect_strip_add", 'type', 'GLOW')
176                 self.layout.item_enumO("SEQUENCER_OT_effect_strip_add", 'type', 'TRANSFORM')
177                 self.layout.item_enumO("SEQUENCER_OT_effect_strip_add", 'type', 'COLOR')
178                 self.layout.item_enumO("SEQUENCER_OT_effect_strip_add", 'type', 'SPEED')
179
180 class SEQUENCER_MT_strip(bpy.types.Menu):
181         __space_type__ = "SEQUENCE_EDITOR"
182         __label__ = "Strip"
183
184         def draw(self, context):
185                 layout = self.layout
186                 st = context.space_data
187                 
188                 layout.operator_context = 'INVOKE_REGION_WIN'
189                 
190                 layout.column()
191                 layout.item_enumO("TFM_OT_transform", "mode", 'TRANSLATION', text="Grab/Move")
192                 layout.item_enumO("TFM_OT_transform", "mode", 'TIME_EXTEND', text="Grab/Extend from frame")
193                 #  uiItemO(layout, NULL, 0, "SEQUENCER_OT_strip_snap"); // TODO - add this operator
194                 layout.itemS()
195                 
196                 layout.item_enumO("SEQUENCER_OT_cut", "type", 'HARD', text="Cut (hard) at frame")
197                 layout.item_enumO("SEQUENCER_OT_cut", "type", 'SOFT', text="Cut (soft) at frame")
198                 layout.itemO("SEQUENCER_OT_images_separate")
199                 layout.itemS()
200                 
201                 layout.itemO("SEQUENCER_OT_duplicate_add")
202                 layout.itemO("SEQUENCER_OT_delete")
203                 
204                 strip = act_strip(context)
205                 
206                 if strip:
207                         stype = strip.type
208                         
209                         if      stype=='EFFECT':
210                                 layout.itemS()
211                                 layout.itemO("SEQUENCER_OT_effect_change")
212                                 layout.itemO("SEQUENCER_OT_effect_reassign_inputs")
213                         elif stype=='IMAGE':
214                                 layout.itemS()
215                                 layout.itemO("SEQUENCER_OT_image_change")
216                         elif stype=='SCENE':
217                                 layout.itemS()
218                                 layout.itemO("SEQUENCER_OT_scene_change", text="Change Scene")
219                         elif stype=='MOVIE':
220                                 layout.itemS()
221                                 layout.itemO("SEQUENCER_OT_movie_change")
222                         
223                 layout.itemS()
224                 
225                 layout.itemO("SEQUENCER_OT_meta_make")
226                 layout.itemO("SEQUENCER_OT_meta_separate")
227                 
228                 #if (ed && (ed->metastack.first || (ed->act_seq && ed->act_seq->type == SEQ_META))) {
229                 #       uiItemS(layout);
230                 #       uiItemO(layout, NULL, 0, "SEQUENCER_OT_meta_toggle");
231                 #}
232                 
233                 layout.itemS()
234                 layout.itemO("SEQUENCER_OT_reload")
235                 layout.itemS()
236                 layout.itemO("SEQUENCER_OT_lock")
237                 layout.itemO("SEQUENCER_OT_unlock")
238                 layout.itemO("SEQUENCER_OT_mute")
239                 layout.itemO("SEQUENCER_OT_unmute")
240                 
241                 layout.item_enumO("SEQUENCER_OT_mute", property="type", value='UNSELECTED', text="Mute Deselected Strips")
242
243                 layout.itemO("SEQUENCER_OT_snap")
244
245 # Panels
246 class SequencerButtonsPanel(bpy.types.Panel):
247         __space_type__ = "SEQUENCE_EDITOR"
248         __region_type__ = "UI"
249
250         def poll(self, context):
251                 return context.space_data.display_mode == 'SEQUENCER' and act_strip(context) != None
252                 
253 class SequencerButtonsPanel_Output(bpy.types.Panel):
254         __space_type__ = "SEQUENCE_EDITOR"
255         __region_type__ = "UI"
256
257         def poll(self, context):
258                 return context.space_data.display_mode != 'SEQUENCER'
259
260 class SEQUENCER_PT_edit(SequencerButtonsPanel):
261         __label__ = "Edit Strip"
262         __idname__ = "SEQUENCER_PT_edit"
263
264         def draw(self, context):
265                 layout = self.layout
266                 
267                 strip = act_strip(context)
268                 
269                 layout.itemR(strip, "name")
270                 
271                 layout.itemR(strip, "type")
272                 
273                 layout.itemR(strip, "blend_mode")
274                 
275                 layout.itemR(strip, "blend_opacity", text="Opacity", slider=True)
276                 
277                 split = layout.split()
278                 
279                 col = split.column()
280                 col.itemR(strip, "mute")
281                 col.itemR(strip, "lock")
282                 col.itemR(strip, "frame_locked")
283                 
284                 col = split.column()
285                 col.itemR(strip, "channel")
286                 col.itemR(strip, "start_frame")
287                 col.itemR(strip, "length")
288                 
289                 split = layout.split()
290                 
291                 col = split.column()
292                 col.itemR(strip, "start_offset")
293                 col.itemR(strip, "start_still")
294                 
295                 col = split.column()
296                 col.itemR(strip, "end_offset")
297                 col.itemR(strip, "end_still")
298                 
299 class SEQUENCER_PT_effect(SequencerButtonsPanel):
300         __label__ = "Effect Strip"
301         __idname__ = "SEQUENCER_PT_effect"
302
303         def poll(self, context):
304                 if context.space_data.display_mode != 'SEQUENCER':
305                         return False
306                 
307                 strip = act_strip(context)
308                 if not strip:
309                         return False
310                 
311                 return strip.type in ('COLOR', 'WIPE', 'GLOW', 'SPEED', 'TRANSFORM')
312
313         def draw(self, context):
314                 layout = self.layout
315                 
316                 strip = act_strip(context)
317                 
318                 if strip.type == 'COLOR':
319                         layout.itemR(strip, "color")
320                         
321                 elif strip.type == 'WIPE':
322                         row = layout.row()
323                         row.itemL(text="Transition Type:")
324                         row.itemL(text="Direction:")
325                         
326                         row = layout.row()
327                         row.itemR(strip, "transition_type", text="")
328                         row.itemR(strip, "direction", text="")
329                         
330                         row = layout.row()
331                         row.itemR(strip, "blur_width")
332                         if strip.transition_type in ('SINGLE', 'DOUBLE'):
333                                 row.itemR(strip, "angle")
334                                 
335                 elif strip.type == 'GLOW':
336                         flow = layout.column_flow()
337                         flow.itemR(strip, "threshold")
338                         flow.itemR(strip, "clamp")
339                         flow.itemR(strip, "boost_factor")
340                         flow.itemR(strip, "blur_distance")
341                         
342                         row = layout.row()
343                         row.itemR(strip, "quality", slider=True)
344                         row.itemR(strip, "only_boost")
345                         
346                 elif strip.type == 'SPEED':
347                         layout.itemR(strip, "global_speed")
348                         
349                         flow = layout.column_flow()
350                         flow.itemR(strip, "curve_velocity")
351                         flow.itemR(strip, "curve_compress_y")
352                         flow.itemR(strip, "frame_blending")
353                         
354                 elif strip.type == 'TRANSFORM':
355                         row = layout.row()
356                         row.itemL(text="Interpolation:")
357                         row.itemL(text="Translation Unit:")
358                         
359                         row = layout.row()
360                         row.itemR(strip, "interpolation", text="")
361                         row.itemR(strip, "translation_unit", text="")
362                         
363                         split = layout.split()
364                         
365                         col = split.column()
366                         sub = col.column(align=True) 
367                         sub.itemL(text="Position X:")
368                         sub.itemR(strip, "translate_start_x", text="Start")
369                         sub.itemR(strip, "translate_end_x", text="End")
370                         
371                         sub = col.column(align=True) 
372                         sub.itemL(text="Scale X:")
373                         sub.itemR(strip, "scale_start_x", text="Start")
374                         sub.itemR(strip, "scale_end_x", text="End")
375                         
376                         sub = col.column(align=True) 
377                         sub.itemL(text="Rotation:")
378                         sub.itemR(strip, "rotation_start", text="Start")
379                         sub.itemR(strip, "rotation_end", text="End")
380                         
381                         col = split.column()
382                         sub = col.column(align=True) 
383                         sub.itemL(text="Position Y:")
384                         sub.itemR(strip, "translate_start_y", text="Start")
385                         sub.itemR(strip, "translate_end_y", text="End")
386                         
387                         sub = col.column(align=True) 
388                         sub.itemL(text="Scale Y:")
389                         sub.itemR(strip, "scale_start_y", text="Start")
390                         sub.itemR(strip, "scale_end_y", text="End")
391
392 class SEQUENCER_PT_input(SequencerButtonsPanel):
393         __label__ = "Strip Input"
394         __idname__ = "SEQUENCER_PT_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         __idname__ = "SEQUENCER_PT_filter"
451         
452         def poll(self, context):
453                 if context.space_data.display_mode != 'SEQUENCER':
454                         return False
455                 
456                 strip = act_strip(context)
457                 if not strip:
458                         return False
459                 
460                 return strip.type in ('MOVIE', 'IMAGE', 'SCENE', 'META')
461         
462         def draw(self, context):
463                 layout = self.layout
464                 
465                 strip = act_strip(context)
466                 
467                 split = layout.split()
468                 
469                 col = split.column()
470                 col.itemR(strip, "premultiply")
471                 col.itemR(strip, "convert_float")
472                 col.itemR(strip, "de_interlace")
473                 col.itemR(strip, "multiply_colors")
474                 col.itemR(strip, "strobe")
475                 
476                 col = split.column()
477                 col.itemL(text="Flip:")
478                 col.itemR(strip, "flip_x", text="X")
479                 col.itemR(strip, "flip_y", text="Y")
480                 col.itemR(strip, "reverse_frames", text="Backwards")
481                 
482                 layout.itemR(strip, "use_color_balance")
483                 if strip.color_balance: # TODO - need to add this somehow
484                         row = layout.row()
485                         row.active = strip.use_color_balance
486                         col = row.column()
487                         col.itemR(strip.color_balance, "lift")
488                         col.itemR(strip.color_balance, "inverse_lift")
489                         col = row.column()
490                         col.itemR(strip.color_balance, "gamma")
491                         col.itemR(strip.color_balance, "inverse_gamma")
492                         col = row.column()
493                         col.itemR(strip.color_balance, "gain")
494                         col.itemR(strip.color_balance, "inverse_gain")
495                         
496
497 class SEQUENCER_PT_proxy(SequencerButtonsPanel):
498         __label__ = "Proxy"
499         __idname__ = "SEQUENCER_PT_proxy"
500         
501         def poll(self, context):
502                 if context.space_data.display_mode != 'SEQUENCER':
503                         return False
504                 
505                 strip = act_strip(context)
506                 if not strip:
507                         return False
508                 
509                 return strip.type in ('MOVIE', 'IMAGE', 'SCENE', 'META')
510         
511         def draw_header(self, context):
512                 strip = act_strip(context)
513
514                 layout = self.layout
515                 
516                 layout.itemR(strip, "use_proxy", text="")
517
518         def draw(self, context):
519                 strip = act_strip(context)
520                 
521                 layout = self.layout
522                 
523                 flow = layout.column_flow()
524                 flow.itemR(strip, "proxy_custom_directory")
525                 if strip.proxy: # TODO - need to add this somehow
526                         flow.itemR(strip.proxy, "directory")
527                         flow.itemR(strip.proxy, "file")
528
529
530 class SEQUENCER_PT_view(SequencerButtonsPanel_Output):
531         __label__ = "View Settings"
532         __idname__ = "SEQUENCER_PT_view"
533
534         def draw(self, context):
535                 st = context.space_data
536
537                 layout = self.layout
538
539                 flow = layout.column_flow()
540                 flow.itemR(st, "draw_overexposed") # text="Zebra"
541                 flow.itemR(st, "draw_safe_margin")
542
543
544 bpy.types.register(SEQUENCER_HT_header) # header/menu classes
545 bpy.types.register(SEQUENCER_MT_view)
546 bpy.types.register(SEQUENCER_MT_select)
547 bpy.types.register(SEQUENCER_MT_marker)
548 bpy.types.register(SEQUENCER_MT_add)
549 bpy.types.register(SEQUENCER_MT_add_effect)
550 bpy.types.register(SEQUENCER_MT_strip)
551
552 bpy.types.register(SEQUENCER_PT_edit) # sequencer panels
553 bpy.types.register(SEQUENCER_PT_effect)
554 bpy.types.register(SEQUENCER_PT_input)
555 bpy.types.register(SEQUENCER_PT_filter)
556 bpy.types.register(SEQUENCER_PT_proxy)
557
558 bpy.types.register(SEQUENCER_PT_view) # view panels
559