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