added layout attribute for setting the operator execution context.
[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                                 layout.itemS()
38                                 row.itemR(st, "draw_overexposed") # text="Zebra"
39                                 layout.itemS()
40                                 row.itemR(st, "draw_safe_margin")
41
42 class SEQUENCER_MT_view(bpy.types.Menu):
43         __space_type__ = "SEQUENCE_EDITOR"
44         __label__ = "View (TODO)"
45         
46         def draw(self, context):
47                 layout = self.layout
48                 st = context.space_data
49                 
50                 layout.column()
51                 
52                 """
53         uiBlock *block= uiBeginBlock(C, ar, "seq_viewmenu", UI_EMBOSSP);
54         short yco= 0, menuwidth=120;
55
56         if (sseq->mainb == SEQ_DRAW_SEQUENCE) {
57                 uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1,
58                                  "Play Back Animation "
59                                  "in all Sequence Areas|Alt A", 0, yco-=20,
60                                  menuwidth, 19, NULL, 0.0, 0.0, 1, 1, "");
61         }
62         else {
63                 uiDefIconTextBut(block, BUTM, 1, ICON_MENU_PANEL,
64                                  "Grease Pencil...", 0, yco-=20,
65                                  menuwidth, 19, NULL, 0.0, 0.0, 1, 7, "");
66                 uiDefMenuSep(block);
67
68                 uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1,
69                                  "Play Back Animation "
70                                  "in this window|Alt A", 0, yco-=20,
71                                  menuwidth, 19, NULL, 0.0, 0.0, 1, 1, "");
72         }
73         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1,
74                          "Play Back Animation in all "
75                          "3D Views and Sequence Areas|Alt Shift A",
76                          0, yco-=20,
77                          menuwidth, 19, NULL, 0.0, 0.0, 1, 2, "");
78
79                 """
80                 layout.itemS()
81                 layout.itemO("SEQUENCER_OT_view_all")
82                 layout.itemO("SEQUENCER_OT_view_selected")
83                 layout.itemS()
84                 """
85         
86
87         /* Lock Time */
88         uiDefIconTextBut(block, BUTM, 1, (v2d->flag & V2D_VIEWSYNC_SCREEN_TIME)?ICON_CHECKBOX_HLT:ICON_CHECKBOX_DEHLT,
89                         "Lock Time to Other Windows|", 0, yco-=20,
90                         menuwidth, 19, NULL, 0.0, 0.0, 1, 5, "");
91
92         /* Draw time or frames.*/
93         uiDefMenuSep(block);
94                 """
95                 
96                 layout.itemR(st, "draw_frames")
97                 
98                 """
99         if(!sa->full) uiDefIconTextBut(block, BUTM, B_FULL, ICON_BLANK1, "Maximize Window|Ctrl UpArrow", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0,0, "");
100         else uiDefIconTextBut(block, BUTM, B_FULL, ICON_BLANK1, "Tile Window|Ctrl DownArrow", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 0, "");
101
102                 """
103
104 class SEQUENCER_MT_select(bpy.types.Menu):
105         __space_type__ = "SEQUENCE_EDITOR"
106         __label__ = "Select"
107
108         def draw(self, context):
109                 layout = self.layout
110                 st = context.space_data
111                 
112                 layout.column()
113                 layout.item_enumO("SEQUENCER_OT_select_active_side", "side", 'LEFT', text="Strips to the Left")
114                 layout.item_enumO("SEQUENCER_OT_select_active_side", "side", 'RIGHT', text="Strips to the Right")
115                 layout.itemS()
116                 layout.item_enumO("SEQUENCER_OT_select_handles", "side", 'BOTH', text="Surrounding Handles")
117                 layout.item_enumO("SEQUENCER_OT_select_handles", "side", 'LEFT', text="Left Handle")
118                 layout.item_enumO("SEQUENCER_OT_select_handles", "side", 'RIGHT', text="Right Handle")
119                 layout.itemS()
120                 layout.itemO("SEQUENCER_OT_select_linked")
121                 layout.itemO("SEQUENCER_OT_select_all_toggle")
122                 layout.itemO("SEQUENCER_OT_select_invert")
123
124 class SEQUENCER_MT_marker(bpy.types.Menu):
125         __space_type__ = "SEQUENCE_EDITOR"
126         __label__ = "Marker (TODO)"
127
128         def draw(self, context):
129                 layout = self.layout
130                 st = context.space_data
131                 
132                 layout.column()
133                 layout.itemO("SEQUENCER_OT_sound_strip_add", text="Add Marker|Ctrl Alt M")
134                 layout.itemO("SEQUENCER_OT_sound_strip_add", text="Duplicate Marker|Ctrl Shift D")
135                 layout.itemO("SEQUENCER_OT_sound_strip_add", text="Delete Marker|Shift X")
136                 layout.itemS()
137                 layout.itemO("SEQUENCER_OT_sound_strip_add", text="(Re)Name Marker|Ctrl M")
138                 layout.itemO("SEQUENCER_OT_sound_strip_add", text="Grab/Move Marker|Ctrl G")
139                 layout.itemS()
140                 layout.itemO("SEQUENCER_OT_sound_strip_add", text="Transform Markers") # toggle, will be rna - (sseq->flag & SEQ_MARKER_TRANS)
141
142 class SEQUENCER_MT_add(bpy.types.Menu):
143         __space_type__ = "SEQUENCE_EDITOR"
144         __label__ = "Add"
145
146         def draw(self, context):
147                 layout = self.layout
148                 st = context.space_data
149                 
150                 layout.column()
151                 layout.itemO("SEQUENCER_OT_movie_strip_add", text="Movie")
152                 layout.item_booleanO("SEQUENCER_OT_movie_strip_add", "sound", True, text="Movie & Sound") # FFMPEG ONLY
153                 layout.itemO("SEQUENCER_OT_image_strip_add", text="Image")
154                 layout.itemO("SEQUENCER_OT_sound_strip_add", text="Sound (Ram)")
155                 layout.item_booleanO("SEQUENCER_OT_sound_strip_add", "hd", True, text="Sound (Streaming)") # FFMPEG ONLY
156                 
157                 layout.itemM(context, "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_OT_effect_strip_add", 'type', 'ADD')
170                 self.layout.item_enumO("SEQUENCER_OT_effect_strip_add", 'type', 'SUBTRACT')
171                 self.layout.item_enumO("SEQUENCER_OT_effect_strip_add", 'type', 'ALPHA_OVER')
172                 self.layout.item_enumO("SEQUENCER_OT_effect_strip_add", 'type', 'ALPHA_UNDER')
173                 self.layout.item_enumO("SEQUENCER_OT_effect_strip_add", 'type', 'GAMMA_CROSS')
174                 self.layout.item_enumO("SEQUENCER_OT_effect_strip_add", 'type', 'MULTIPLY')
175                 self.layout.item_enumO("SEQUENCER_OT_effect_strip_add", 'type', 'OVER_DROP')
176                 self.layout.item_enumO("SEQUENCER_OT_effect_strip_add", 'type', 'PLUGIN')
177                 self.layout.item_enumO("SEQUENCER_OT_effect_strip_add", 'type', 'WIPE')
178                 self.layout.item_enumO("SEQUENCER_OT_effect_strip_add", 'type', 'GLOW')
179                 self.layout.item_enumO("SEQUENCER_OT_effect_strip_add", 'type', 'TRANSFORM')
180                 self.layout.item_enumO("SEQUENCER_OT_effect_strip_add", 'type', 'COLOR')
181                 self.layout.item_enumO("SEQUENCER_OT_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_OT_transform", "mode", 'TRANSLATION', text="Grab/Move")
195                 layout.item_enumO("TFM_OT_transform", "mode", 'TIME_EXTEND', text="Grab/Extend from frame")
196                 #  uiItemO(layout, NULL, 0, "SEQUENCER_OT_strip_snap"); // TODO - add this operator
197                 layout.itemS()
198                 
199                 layout.item_enumO("SEQUENCER_OT_cut", "type", 'HARD', text="Cut (hard) at frame")
200                 layout.item_enumO("SEQUENCER_OT_cut", "type", 'SOFT', text="Cut (soft) at frame")
201                 layout.itemO("SEQUENCER_OT_images_separate")
202                 layout.itemS()
203                 
204                 layout.itemO("SEQUENCER_OT_duplicate_add")
205                 layout.itemO("SEQUENCER_OT_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_OT_effect_change")
215                                 layout.itemO("SEQUENCER_OT_effect_reassign_inputs")
216                         elif stype=='IMAGE':
217                                 layout.itemS()
218                                 layout.itemO("SEQUENCER_OT_image_change")
219                         elif stype=='SCENE':
220                                 layout.itemS()
221                                 layout.itemO("SEQUENCER_OT_scene_change", text="Change Scene")
222                         elif stype=='MOVIE':
223                                 layout.itemS()
224                                 layout.itemO("SEQUENCER_OT_movie_change")
225                         
226                 layout.itemS()
227                 
228                 layout.itemO("SEQUENCER_OT_meta_make")
229                 layout.itemO("SEQUENCER_OT_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_OT_meta_toggle");
234                 #}
235                 
236                 layout.itemS()
237                 layout.itemO("SEQUENCER_OT_reload")
238                 layout.itemS()
239                 layout.itemO("SEQUENCER_OT_lock")
240                 layout.itemO("SEQUENCER_OT_unlock")
241                 layout.itemO("SEQUENCER_OT_mute")
242                 layout.itemO("SEQUENCER_OT_unmute")
243                 
244                 layout.item_enumO("SEQUENCER_OT_mute", property="type", value='UNSELECTED', text="Mute Deselected Strips")
245
246
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 act_strip(context) != None
255
256 class SEQUENCER_PT_edit(SequencerButtonsPanel):
257         __label__ = "Edit Strip"
258         __idname__ = "SEQUENCER_PT_edit"
259
260         def draw(self, context):
261                 layout = self.layout
262                 
263                 strip = act_strip(context)
264                 
265                 layout.itemR(strip, "name")
266                 
267                 layout.itemR(strip, "blend_mode")
268                 
269                 layout.itemR(strip, "blend_opacity")
270                 
271                 row = layout.row()
272                 row.itemR(strip, "mute")
273                 row.itemR(strip, "lock")
274                 row.itemR(strip, "frame_locked")
275                 
276                 row = layout.row()
277                 row.itemR(strip, "channel")
278                 row.itemR(strip, "start_frame")
279                 
280                 row = layout.row()
281                 row.itemR(strip, "length")
282                 row.itemR(strip, "type")
283                 
284 class SEQUENCER_PT_effect(SequencerButtonsPanel):
285         __label__ = "Effect Strip"
286         __idname__ = "SEQUENCER_PT_effect"
287
288         def poll(self, context):
289                 strip = act_strip(context)
290                 if not strip:
291                         return False
292                 
293                 return strip.type in ('COLOR', 'WIPE', 'GLOW', 'SPEED', 'TRANSFORM')
294
295         def draw(self, context):
296                 layout = self.layout
297                 
298                 strip = act_strip(context)
299                 
300                 if strip.type == 'COLOR':
301                         layout.itemR(strip, "color")
302                         
303                 elif strip.type == 'WIPE':
304                         row = layout.row()
305                         row.itemL(text="Transition Type:")
306                         row.itemL(text="Direction:")
307                         
308                         row = layout.row()
309                         row.itemR(strip, "transition_type", text="")
310                         row.itemR(strip, "direction", text="")
311                         
312                         row = layout.row()
313                         row.itemR(strip, "blur_width")
314                         if strip.transition_type in ('SINGLE', 'DOUBLE'):
315                                 row.itemR(strip, "angle")
316                                 
317                 elif strip.type == 'GLOW':
318                         flow = layout.column_flow()
319                         flow.itemR(strip, "threshold")
320                         flow.itemR(strip, "clamp")
321                         flow.itemR(strip, "boost_factor")
322                         flow.itemR(strip, "blur_distance")
323                         
324                         row = layout.row()
325                         row.itemR(strip, "quality", slider=True)
326                         row.itemR(strip, "only_boost")
327                         
328                 elif strip.type == 'SPEED':
329                         layout.itemR(strip, "global_speed")
330                         
331                         flow = layout.column_flow()
332                         flow.itemR(strip, "curve_velocity")
333                         flow.itemR(strip, "curve_compress_y")
334                         flow.itemR(strip, "frame_blending")
335                         
336                 elif strip.type == 'TRANSFORM':
337                         row = layout.row()
338                         row.itemL(text="Interpolation:")
339                         row.itemL(text="Translation Unit:")
340                         
341                         row = layout.row()
342                         row.itemR(strip, "interpolation", text="")
343                         row.itemR(strip, "translation_unit", text="")
344                         
345                         split = layout.split()
346                         
347                         col = split.column()
348                         sub = col.column(align=True) 
349                         sub.itemL(text="Position X:")
350                         sub.itemR(strip, "translate_start_x", text="Start")
351                         sub.itemR(strip, "translate_end_x", text="End")
352                         
353                         sub = col.column(align=True) 
354                         sub.itemL(text="Scale X:")
355                         sub.itemR(strip, "scale_start_x", text="Start")
356                         sub.itemR(strip, "scale_end_x", text="End")
357                         
358                         sub = col.column(align=True) 
359                         sub.itemL(text="Rotation:")
360                         sub.itemR(strip, "rotation_start", text="Start")
361                         sub.itemR(strip, "rotation_end", text="End")
362                         
363                         col = split.column()
364                         sub = col.column(align=True) 
365                         sub.itemL(text="Position Y:")
366                         sub.itemR(strip, "translate_start_y", text="Start")
367                         sub.itemR(strip, "translate_end_y", text="End")
368                         
369                         sub = col.column(align=True) 
370                         sub.itemL(text="Scale Y:")
371                         sub.itemR(strip, "scale_start_y", text="Start")
372                         sub.itemR(strip, "scale_end_y", text="End")
373
374 class SEQUENCER_PT_input(SequencerButtonsPanel):
375         __label__ = "Strip Input"
376         __idname__ = "SEQUENCER_PT_input"
377         
378         def poll(self, context):
379                 strip = act_strip(context)
380                 if not strip:
381                         return False
382                 
383                 return strip.type in ('MOVIE', 'IMAGE', 'SCENE', 'META')
384         
385         def draw(self, context):
386                 layout = self.layout
387                 
388                 strip = act_strip(context)
389                 
390                 layout.itemR(strip, "directory")
391                 
392                 # TODO - get current element!
393                 layout.itemR(strip.elements[0], "filename")
394                 
395                 """
396                 layout.itemR(strip, "use_crop")
397                 
398                 flow = layout.column_flow()
399                 flow.active = strip.use_crop
400                 flow.itemR(strip, "top")
401                 flow.itemR(strip, "left")
402                 flow.itemR(strip, "bottom")
403                 flow.itemR(strip, "right")
404                 """
405
406 class SEQUENCER_PT_filter(SequencerButtonsPanel):
407         __label__ = "Filter"
408         __idname__ = "SEQUENCER_PT_filter"
409         
410         def poll(self, context):
411                 strip = act_strip(context)
412                 if not strip:
413                         return False
414                 
415                 return strip.type in ('MOVIE', 'IMAGE', 'SCENE', 'META')
416         
417         def draw(self, context):
418                 layout = self.layout
419                 
420                 strip = act_strip(context)
421                 
422                 row = layout.row()
423                 row.itemR(strip, "premultiply")
424                 row.itemR(strip, "convert_float")
425                 row.itemR(strip, "de_interlace")
426                 
427                 row = layout.row()
428                 row.itemR(strip, "flip_x")
429                 row.itemR(strip, "flip_y")
430                 row.itemR(strip, "reverse_frames")
431                 
432                 row = layout.row()
433                 row.itemR(strip, "multiply_colors")
434                 row.itemR(strip, "strobe")
435                 
436                 layout.itemR(strip, "use_color_balance")
437
438 class SEQUENCER_PT_proxy(SequencerButtonsPanel):
439         __label__ = "Proxy"
440         __idname__ = "SEQUENCER_PT_proxy"
441         
442         def poll(self, context):
443                 strip = act_strip(context)
444                 if not strip:
445                         return False
446                 
447                 return strip.type in ('MOVIE', 'IMAGE', 'SCENE', 'META')
448         
449         def draw_header(self, context):
450                 strip = act_strip(context)
451
452                 layout = self.layout
453                 
454                 layout.itemR(strip, "use_proxy", text="")
455
456         def draw(self, context):
457                 strip = act_strip(context)
458                 
459                 layout = self.layout
460                 
461                 row = layout.row()
462                 row.itemR(strip, "proxy_custom_directory")
463                 if strip.proxy: # TODO - need to add this somehow
464                         row.itemR(strip.proxy, "dir")
465                         row.itemR(strip.proxy, "file")
466
467
468 bpy.types.register(SEQUENCER_HT_header)
469 bpy.types.register(SEQUENCER_MT_view)
470 bpy.types.register(SEQUENCER_MT_select)
471 bpy.types.register(SEQUENCER_MT_marker)
472 bpy.types.register(SEQUENCER_MT_add)
473 bpy.types.register(SEQUENCER_MT_add_effect)
474 bpy.types.register(SEQUENCER_MT_strip)
475
476 bpy.types.register(SEQUENCER_PT_edit)
477 bpy.types.register(SEQUENCER_PT_effect)
478 bpy.types.register(SEQUENCER_PT_input)
479 bpy.types.register(SEQUENCER_PT_filter)
480 bpy.types.register(SEQUENCER_PT_proxy)
481