changes to defaults for sequencer strip adding
[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.itemO("sequencer.image_strip_add", text="Image")
153                 layout.itemO("sequencer.sound_strip_add", text="Sound")
154                 
155                 layout.itemM("SEQUENCER_MT_add_effect")
156
157
158 class SEQUENCER_MT_add_effect(bpy.types.Menu):
159         __space_type__ = "SEQUENCE_EDITOR"
160         __label__ = "Effect Strip..."
161
162         def draw(self, context):
163                 layout = self.layout
164                 st = context.space_data
165                 
166                 self.layout.column()
167                 self.layout.item_enumO("sequencer.effect_strip_add", 'type', 'ADD')
168                 self.layout.item_enumO("sequencer.effect_strip_add", 'type', 'SUBTRACT')
169                 self.layout.item_enumO("sequencer.effect_strip_add", 'type', 'ALPHA_OVER')
170                 self.layout.item_enumO("sequencer.effect_strip_add", 'type', 'ALPHA_UNDER')
171                 self.layout.item_enumO("sequencer.effect_strip_add", 'type', 'GAMMA_CROSS')
172                 self.layout.item_enumO("sequencer.effect_strip_add", 'type', 'MULTIPLY')
173                 self.layout.item_enumO("sequencer.effect_strip_add", 'type', 'OVER_DROP')
174                 self.layout.item_enumO("sequencer.effect_strip_add", 'type', 'PLUGIN')
175                 self.layout.item_enumO("sequencer.effect_strip_add", 'type', 'WIPE')
176                 self.layout.item_enumO("sequencer.effect_strip_add", 'type', 'GLOW')
177                 self.layout.item_enumO("sequencer.effect_strip_add", 'type', 'TRANSFORM')
178                 self.layout.item_enumO("sequencer.effect_strip_add", 'type', 'COLOR')
179                 self.layout.item_enumO("sequencer.effect_strip_add", 'type', 'SPEED')
180
181 class SEQUENCER_MT_strip(bpy.types.Menu):
182         __space_type__ = "SEQUENCE_EDITOR"
183         __label__ = "Strip"
184
185         def draw(self, context):
186                 layout = self.layout
187                 st = context.space_data
188                 
189                 layout.operator_context = 'INVOKE_REGION_WIN'
190                 
191                 layout.column()
192                 layout.item_enumO("tfm.transform", "mode", 'TRANSLATION', text="Grab/Move")
193                 layout.item_enumO("tfm.transform", "mode", 'TIME_EXTEND', text="Grab/Extend from frame")
194                 #  uiItemO(layout, NULL, 0, "sequencer.strip_snap"); // TODO - add this operator
195                 layout.itemS()
196                 
197                 layout.item_enumO("sequencer.cut", "type", 'HARD', text="Cut (hard) at frame")
198                 layout.item_enumO("sequencer.cut", "type", 'SOFT', text="Cut (soft) at frame")
199                 layout.itemO("sequencer.images_separate")
200                 layout.itemS()
201                 
202                 layout.itemO("sequencer.duplicate")
203                 layout.itemO("sequencer.delete")
204                 
205                 strip = act_strip(context)
206                 
207                 if strip:
208                         stype = strip.type
209                         
210                         if      stype=='EFFECT':
211                                 layout.itemS()
212                                 layout.itemO("sequencer.effect_change")
213                                 layout.itemO("sequencer.effect_reassign_inputs")
214                         elif stype=='IMAGE':
215                                 layout.itemS()
216                                 layout.itemO("sequencer.image_change")
217                         elif stype=='SCENE':
218                                 layout.itemS()
219                                 layout.itemO("sequencer.scene_change", text="Change Scene")
220                         elif stype=='MOVIE':
221                                 layout.itemS()
222                                 layout.itemO("sequencer.movie_change")
223                         
224                 layout.itemS()
225                 
226                 layout.itemO("sequencer.meta_make")
227                 layout.itemO("sequencer.meta_separate")
228                 
229                 #if (ed && (ed->metastack.first || (ed->act_seq && ed->act_seq->type == SEQ_META))) {
230                 #       uiItemS(layout);
231                 #       uiItemO(layout, NULL, 0, "sequencer.meta_toggle");
232                 #}
233                 
234                 layout.itemS()
235                 layout.itemO("sequencer.reload")
236                 layout.itemS()
237                 layout.itemO("sequencer.lock")
238                 layout.itemO("sequencer.unlock")
239                 layout.itemO("sequencer.mute")
240                 layout.itemO("sequencer.unmute")
241                 
242                 layout.item_booleanO("sequencer.mute", "unselected", 1, text="Mute Deselected Strips")
243
244                 layout.itemO("sequencer.snap")
245
246 # Panels
247 class SequencerButtonsPanel(bpy.types.Panel):
248         __space_type__ = "SEQUENCE_EDITOR"
249         __region_type__ = "UI"
250
251         def poll(self, context):
252                 return context.space_data.display_mode == 'SEQUENCER' and act_strip(context) != None
253                 
254 class SequencerButtonsPanel_Output(bpy.types.Panel):
255         __space_type__ = "SEQUENCE_EDITOR"
256         __region_type__ = "UI"
257
258         def poll(self, context):
259                 return context.space_data.display_mode != 'SEQUENCER'
260
261 class SEQUENCER_PT_edit(SequencerButtonsPanel):
262         __label__ = "Edit Strip"
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
302         def poll(self, context):
303                 if context.space_data.display_mode != 'SEQUENCER':
304                         return False
305                 
306                 strip = act_strip(context)
307                 if not strip:
308                         return False
309                 
310                 return strip.type in ('COLOR', 'WIPE', 'GLOW', 'SPEED', 'TRANSFORM')
311
312         def draw(self, context):
313                 layout = self.layout
314                 
315                 strip = act_strip(context)
316                 
317                 if strip.type == 'COLOR':
318                         layout.itemR(strip, "color")
319                         
320                 elif strip.type == 'WIPE':
321                         row = layout.row()
322                         row.itemL(text="Transition Type:")
323                         row.itemL(text="Direction:")
324                         
325                         row = layout.row()
326                         row.itemR(strip, "transition_type", text="")
327                         row.itemR(strip, "direction", text="")
328                         
329                         row = layout.row()
330                         row.itemR(strip, "blur_width")
331                         if strip.transition_type in ('SINGLE', 'DOUBLE'):
332                                 row.itemR(strip, "angle")
333                                 
334                 elif strip.type == 'GLOW':
335                         flow = layout.column_flow()
336                         flow.itemR(strip, "threshold")
337                         flow.itemR(strip, "clamp")
338                         flow.itemR(strip, "boost_factor")
339                         flow.itemR(strip, "blur_distance")
340                         
341                         row = layout.row()
342                         row.itemR(strip, "quality", slider=True)
343                         row.itemR(strip, "only_boost")
344                         
345                 elif strip.type == 'SPEED':
346                         layout.itemR(strip, "global_speed")
347                         
348                         flow = layout.column_flow()
349                         flow.itemR(strip, "curve_velocity")
350                         flow.itemR(strip, "curve_compress_y")
351                         flow.itemR(strip, "frame_blending")
352                         
353                 elif strip.type == 'TRANSFORM':
354                         row = layout.row()
355                         row.itemL(text="Interpolation:")
356                         row.itemL(text="Translation Unit:")
357                         
358                         row = layout.row()
359                         row.itemR(strip, "interpolation", text="")
360                         row.itemR(strip, "translation_unit", text="")
361                         
362                         split = layout.split()
363                         
364                         col = split.column()
365                         sub = col.column(align=True) 
366                         sub.itemL(text="Position X:")
367                         sub.itemR(strip, "translate_start_x", text="Start")
368                         sub.itemR(strip, "translate_end_x", text="End")
369                         
370                         sub = col.column(align=True) 
371                         sub.itemL(text="Scale X:")
372                         sub.itemR(strip, "scale_start_x", text="Start")
373                         sub.itemR(strip, "scale_end_x", text="End")
374                         
375                         sub = col.column(align=True) 
376                         sub.itemL(text="Rotation:")
377                         sub.itemR(strip, "rotation_start", text="Start")
378                         sub.itemR(strip, "rotation_end", text="End")
379                         
380                         col = split.column()
381                         sub = col.column(align=True) 
382                         sub.itemL(text="Position Y:")
383                         sub.itemR(strip, "translate_start_y", text="Start")
384                         sub.itemR(strip, "translate_end_y", text="End")
385                         
386                         sub = col.column(align=True) 
387                         sub.itemL(text="Scale Y:")
388                         sub.itemR(strip, "scale_start_y", text="Start")
389                         sub.itemR(strip, "scale_end_y", text="End")
390
391 class SEQUENCER_PT_input(SequencerButtonsPanel):
392         __label__ = "Strip Input"
393         
394         def poll(self, context):
395                 if context.space_data.display_mode != 'SEQUENCER':
396                         return False
397                 
398                 strip = act_strip(context)
399                 if not strip:
400                         return False
401                 
402                 return strip.type in ('MOVIE', 'IMAGE', 'SOUND')
403         
404         def draw(self, context):
405                 layout = self.layout
406                 
407                 strip = act_strip(context)
408                 
409                 split = layout.split(percentage=0.3)
410                 sub = split.column()
411                 sub.itemL(text="Directory:")
412                 sub = split.column() 
413                 sub.itemR(strip, "directory", text="")
414                 
415                 # Current element for the filename
416                 split = layout.split(percentage=0.3)
417                 sub = split.column()
418                 sub.itemL(text="File Name:")
419                 sub = split.column()
420                 
421                 elem = strip.getStripElem(context.scene.current_frame)
422                 if elem:
423                         sub.itemR(elem, "filename", text="") # strip.elements[0] could be a fallback
424                 
425                 layout.itemR(strip, "use_translation")
426                 if strip.transform:
427                         flow = layout.column_flow()
428                         flow.active = strip.use_translation
429                         flow.itemR(strip.transform, "offset_x")
430                         flow.itemR(strip.transform, "offset_y")
431                         
432                         
433                 layout.itemR(strip, "use_crop")
434                 if strip.crop:
435                         flow = layout.column_flow()
436                         flow.active = strip.use_crop
437                         flow.itemR(strip.crop, "top")
438                         flow.itemR(strip.crop, "left")
439                         flow.itemR(strip.crop, "bottom")
440                         flow.itemR(strip.crop, "right")
441                         
442                 layout.itemR(strip, "animation_start_offset")
443                 layout.itemR(strip, "animation_end_offset")
444                 
445
446 class SEQUENCER_PT_filter(SequencerButtonsPanel):
447         __label__ = "Filter"
448         
449         def poll(self, context):
450                 if context.space_data.display_mode != 'SEQUENCER':
451                         return False
452                 
453                 strip = act_strip(context)
454                 if not strip:
455                         return False
456                 
457                 return strip.type in ('MOVIE', 'IMAGE', 'SCENE', 'META')
458         
459         def draw(self, context):
460                 layout = self.layout
461                 
462                 strip = act_strip(context)
463                 
464                 split = layout.split()
465                 
466                 col = split.column()
467                 col.itemR(strip, "premultiply")
468                 col.itemR(strip, "convert_float")
469                 col.itemR(strip, "de_interlace")
470                 col.itemR(strip, "multiply_colors")
471                 col.itemR(strip, "strobe")
472                 
473                 col = split.column()
474                 col.itemL(text="Flip:")
475                 col.itemR(strip, "flip_x", text="X")
476                 col.itemR(strip, "flip_y", text="Y")
477                 col.itemR(strip, "reverse_frames", text="Backwards")
478                 
479                 layout.itemR(strip, "use_color_balance")
480                 if strip.color_balance: # TODO - need to add this somehow
481                         row = layout.row()
482                         row.active = strip.use_color_balance
483                         col = row.column()
484                         col.itemR(strip.color_balance, "lift")
485                         col.itemR(strip.color_balance, "inverse_lift")
486                         col = row.column()
487                         col.itemR(strip.color_balance, "gamma")
488                         col.itemR(strip.color_balance, "inverse_gamma")
489                         col = row.column()
490                         col.itemR(strip.color_balance, "gain")
491                         col.itemR(strip.color_balance, "inverse_gain")
492                         
493
494 class SEQUENCER_PT_proxy(SequencerButtonsPanel):
495         __label__ = "Proxy"
496         
497         def poll(self, context):
498                 if context.space_data.display_mode != 'SEQUENCER':
499                         return False
500                 
501                 strip = act_strip(context)
502                 if not strip:
503                         return False
504                 
505                 return strip.type in ('MOVIE', 'IMAGE', 'SCENE', 'META')
506         
507         def draw_header(self, context):
508                 strip = act_strip(context)
509
510                 layout = self.layout
511                 
512                 layout.itemR(strip, "use_proxy", text="")
513
514         def draw(self, context):
515                 strip = act_strip(context)
516                 
517                 layout = self.layout
518                 
519                 flow = layout.column_flow()
520                 flow.itemR(strip, "proxy_custom_directory")
521                 if strip.proxy: # TODO - need to add this somehow
522                         flow.itemR(strip.proxy, "directory")
523                         flow.itemR(strip.proxy, "file")
524
525
526 class SEQUENCER_PT_view(SequencerButtonsPanel_Output):
527         __label__ = "View Settings"
528
529         def draw(self, context):
530                 st = context.space_data
531
532                 layout = self.layout
533
534                 flow = layout.column_flow()
535                 flow.itemR(st, "draw_overexposed") # text="Zebra"
536                 flow.itemR(st, "draw_safe_margin")
537
538
539 bpy.types.register(SEQUENCER_HT_header) # header/menu classes
540 bpy.types.register(SEQUENCER_MT_view)
541 bpy.types.register(SEQUENCER_MT_select)
542 bpy.types.register(SEQUENCER_MT_marker)
543 bpy.types.register(SEQUENCER_MT_add)
544 bpy.types.register(SEQUENCER_MT_add_effect)
545 bpy.types.register(SEQUENCER_MT_strip)
546
547 bpy.types.register(SEQUENCER_PT_edit) # sequencer panels
548 bpy.types.register(SEQUENCER_PT_effect)
549 bpy.types.register(SEQUENCER_PT_input)
550 bpy.types.register(SEQUENCER_PT_filter)
551 bpy.types.register(SEQUENCER_PT_proxy)
552
553 bpy.types.register(SEQUENCER_PT_view) # view panels