47010a9771251dabe297a09df55273f7f10b7dfb
[blender-staging.git] / source / blender / editors / space_time / time_header.c
1 /**
2  * $Id$
3  *
4  * ***** BEGIN GPL LICENSE BLOCK *****
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version. 
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software Foundation,
18  * Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
19  *
20  * The Original Code is Copyright (C) 2008 Blender Foundation.
21  * All rights reserved.
22  *
23  * The Original Code is: all of this file.
24  *
25  * Contributor(s): none yet.
26  *
27  * ***** END GPL LICENSE BLOCK *****
28  */
29
30 #include <string.h>
31 #include <stdio.h>
32
33 #include "DNA_space_types.h"
34 #include "DNA_scene_types.h"
35 #include "DNA_screen_types.h"
36 #include "DNA_windowmanager_types.h"
37 #include "DNA_userdef_types.h"
38
39 #include "MEM_guardedalloc.h"
40
41 #include "BLI_blenlib.h"
42
43 #include "BKE_context.h"
44 #include "BKE_global.h"
45 #include "BKE_screen.h"
46
47 #include "ED_keyframing.h"
48 #include "ED_screen.h"
49 #include "ED_screen_types.h"
50 #include "ED_types.h"
51 #include "ED_util.h"
52
53 #include "WM_api.h"
54 #include "WM_types.h"
55
56 #include "RNA_access.h"
57
58 #include "BIF_gl.h"
59 #include "BIF_glutil.h"
60
61 #include "UI_interface.h"
62 #include "UI_resources.h"
63 #include "UI_view2d.h"
64
65 #include "ED_markers.h"
66
67 #include "time_intern.h"
68
69
70 /* ************************ header time area region *********************** */
71
72 /* exported for use in screen_ops.c */
73 ARegion *time_top_left_3dwindow(bScreen *screen)
74 {
75         ARegion *aret= NULL;
76         ScrArea *sa;
77         int min= 10000;
78         
79         for(sa= screen->areabase.first; sa; sa= sa->next) {
80                 if(sa->spacetype==SPACE_VIEW3D) {
81                         ARegion *ar;
82                         for(ar= sa->regionbase.first; ar; ar= ar->next) {
83                                 if(ar->regiontype==RGN_TYPE_WINDOW) {
84                                         if(ar->winrct.xmin - ar->winrct.ymin < min) {
85                                                 aret= ar;
86                                                 min= ar->winrct.xmin - ar->winrct.ymin;
87                                         }
88                                 }
89                         }
90                 }
91         }
92         return aret;
93 }
94
95 static void do_time_redrawmenu(bContext *C, void *arg, int event)
96 {
97         
98         if(event < 1001) {
99                 bScreen *screen= CTX_wm_screen(C);
100                 SpaceTime *stime= CTX_wm_space_time(C);
101                 
102                 stime->redraws ^= event;
103                 
104                 if(screen->animtimer) {
105                         wmTimer *wt= screen->animtimer;
106                         ScreenAnimData *sad= wt->customdata;
107                         
108                         sad->redraws= stime->redraws;
109                         sad->ar= NULL;
110                         if(stime->redraws & TIME_REGION)
111                                 sad->ar= time_top_left_3dwindow(screen);
112                 }
113         }
114 }
115
116
117 static uiBlock *time_redrawmenu(bContext *C, ARegion *ar, void *arg_unused)
118 {
119         ScrArea *curarea= CTX_wm_area(C);
120         SpaceTime *stime= CTX_wm_space_time(C);
121         uiBlock *block;
122         short yco= 0, menuwidth=120, icon;
123         
124         block= uiBeginBlock(C, ar, "header time_redrawmenu", UI_EMBOSSP);
125         uiBlockSetButmFunc(block, do_time_redrawmenu, NULL);
126         
127         if(stime->redraws & TIME_REGION) icon= ICON_CHECKBOX_HLT;
128         else icon= ICON_CHECKBOX_DEHLT;
129         uiDefIconTextBut(block, BUTM, 1, icon, "Top-Left 3D Window",     0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, TIME_REGION, "");
130         
131         if(stime->redraws & TIME_ALL_3D_WIN) icon= ICON_CHECKBOX_HLT;
132         else icon= ICON_CHECKBOX_DEHLT;
133         uiDefIconTextBut(block, BUTM, 1, icon, "All 3D Windows",         0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, TIME_ALL_3D_WIN, "");
134         
135         if(stime->redraws & TIME_ALL_ANIM_WIN) icon= ICON_CHECKBOX_HLT;
136         else icon= ICON_CHECKBOX_DEHLT;
137         uiDefIconTextBut(block, BUTM, 1, icon, "Animation Windows",      0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, TIME_ALL_ANIM_WIN, "");
138         
139         if(stime->redraws & TIME_ALL_BUTS_WIN) icon= ICON_CHECKBOX_HLT;
140         else icon= ICON_CHECKBOX_DEHLT;
141         uiDefIconTextBut(block, BUTM, 1, icon, "Buttons Windows",        0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, TIME_ALL_BUTS_WIN, "");
142         
143         if(stime->redraws & TIME_ALL_IMAGE_WIN) icon= ICON_CHECKBOX_HLT;
144         else icon= ICON_CHECKBOX_DEHLT;
145         uiDefIconTextBut(block, BUTM, 1, icon, "Image Windows",      0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, TIME_ALL_IMAGE_WIN, "");
146         
147         /* Add sequencer only redraw*/
148         if(stime->redraws & TIME_SEQ) icon= ICON_CHECKBOX_HLT;
149         else icon= ICON_CHECKBOX_DEHLT;
150         uiDefIconTextBut(block, BUTM, 1, icon, "Sequencer Windows",      0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, TIME_SEQ, "");
151         
152         uiDefBut(block, SEPR, 0, "",        0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
153         
154         if(stime->redraws & TIME_CONTINUE_PHYSICS) icon= ICON_CHECKBOX_HLT;
155         else icon= ICON_CHECKBOX_DEHLT;
156         uiDefIconTextBut(block, BUTM, 1, icon, "Continue Physics",      0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, TIME_CONTINUE_PHYSICS, "During playblack, continue physics simulations regardless of the frame number");
157         
158         if(curarea->headertype==HEADERTOP) {
159                 uiBlockSetDirection(block, UI_DOWN);
160         }
161         else {
162                 uiBlockSetDirection(block, UI_TOP);
163                 uiBlockFlipOrder(block);
164         }
165         
166         uiTextBoundsBlock(block, 50);
167         uiEndBlock(C, block);
168         
169         return block;
170 }
171
172 static void do_time_viewmenu(bContext *C, void *arg, int event)
173 {
174         ScrArea *curarea= CTX_wm_area(C);
175         SpaceTime *stime= CTX_wm_space_time(C);
176         View2D *v2d= UI_view2d_fromcontext_rwin(C);
177         Scene *scene= CTX_data_scene(C);
178         int first;
179         
180         switch(event) {
181                 case 2: /* Play Back Animation */
182                         //if(!has_screenhandler(G.curscreen, SCREEN_HANDLER_ANIM))
183                         //      start_animated_screen(stime);
184                         break;
185                 case 3: /* View All */
186                         if(v2d) {
187                                 first= scene->r.sfra;
188                                 if(first >= scene->r.efra) first= scene->r.efra;
189                                         v2d->cur.xmin=v2d->tot.xmin= (float)first-2;
190                                 v2d->cur.xmax=v2d->tot.xmax= (float)scene->r.efra+2;
191                         
192                                 ED_area_tag_redraw(curarea);
193                         }
194                         break;
195                 case 4: /* Maximize Window */
196                         /* using event B_FULL */
197                         break;
198                 case 5: /* show time or frames */
199                         stime->flag ^= TIME_DRAWFRAMES;
200                         ED_area_tag_redraw(curarea);
201                         break;
202                 case 6:
203                         //nextprev_marker(1);
204                         break;
205                 case 7:
206                         //nextprev_marker(-1);
207                         break;
208                 case 10:
209                         //timeline_frame_to_center();
210                         break;
211                 case 11:
212                         if(v2d) {
213                                 v2d->flag ^= V2D_VIEWSYNC_SCREEN_TIME;
214                                 UI_view2d_sync(CTX_wm_screen(C), CTX_wm_area(C), v2d, V2D_LOCK_SET);
215                         }
216                         break;
217                 case 12: /* only show keyframes from selected data */
218                         stime->flag ^= TIME_ONLYACTSEL;
219                         ED_area_tag_redraw(curarea);
220                         break;
221         }
222 }
223
224 static uiBlock *time_viewmenu(bContext *C, ARegion *ar, void *arg_unused)
225 {
226         ScrArea *curarea= CTX_wm_area(C);
227         SpaceTime *stime= CTX_wm_space_time(C);
228         View2D *v2d= UI_view2d_fromcontext_rwin(C);
229         uiBlock *block;
230         short yco= 0, menuwidth=120;
231         
232         block= uiBeginBlock(C, ar, "time_viewmenu", UI_EMBOSSP);
233         uiBlockSetButmFunc(block, do_time_viewmenu, NULL);
234         
235         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Play Back Animation", 0, yco-=20,
236                                          menuwidth, 19, NULL, 0.0, 0.0, 1, 2, "");
237         
238         uiDefBut(block, SEPR, 0, "",        0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
239         
240         if(stime->flag & TIME_DRAWFRAMES)
241                 uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Show Seconds|Ctrl T", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 5, "");
242         else 
243                 uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Show Frames|Ctrl T", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 5, "");
244         
245         uiDefIconTextBut(block, BUTM, 1, (stime->flag & TIME_ONLYACTSEL)?ICON_CHECKBOX_HLT:ICON_CHECKBOX_DEHLT, 
246                                          "Only Selected Data Keys|", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 12, "");
247         
248         uiDefBut(block, SEPR, 0, "",        0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
249         
250         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Jump To Next Marker|PageUp", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 6, "");
251         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Jump To Prev Marker|PageDown", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 7, "");
252         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Jump To Next Key|Ctrl PageUp", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 8, "");
253         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Jump To Prev Key|Ctrl PageDown", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 9, "");
254         
255         uiDefBut(block, SEPR, 0, "",        0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
256         
257         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Center View|C", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 10, "");
258         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "View All|Home", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 3, "");
259         uiDefIconTextBut(block, BUTM, 1, (v2d->flag & V2D_VIEWSYNC_SCREEN_TIME)?ICON_CHECKBOX_HLT:ICON_CHECKBOX_DEHLT, 
260                                          "Lock Time to Other Windows|", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 11, "");
261         
262 //      if (!curarea->full) 
263 //              uiDefIconTextBut(block, BUTM, B_FULL, ICON_BLANK1, "Maximize Window|Ctrl UpArrow", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 4, "");
264 //      else 
265 //              uiDefIconTextBut(block, BUTM, B_FULL, ICON_BLANK1, "Tile Window|Ctrl DownArrow", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 4, "");
266         
267         if(curarea->headertype==HEADERTOP) {
268                 uiBlockSetDirection(block, UI_DOWN);
269         }
270         else {
271                 uiBlockSetDirection(block, UI_TOP);
272                 uiBlockFlipOrder(block);
273         }
274         
275         uiTextBoundsBlock(block, 50);
276         uiEndBlock(C, block);
277         
278         return block;
279 }
280
281 static void do_time_framemenu(bContext *C, void *arg, int event)
282 {
283         Scene *scene= CTX_data_scene(C);
284
285         switch(event) {
286                 case 1: /*Set as Start */
287                         if (scene->r.psfra) {
288                                 if (scene->r.pefra < scene->r.cfra)
289                                         scene->r.pefra= scene->r.cfra;
290                                 scene->r.psfra= scene->r.cfra;
291                         }                               
292                         else
293                                 scene->r.sfra = scene->r.cfra;
294                         WM_event_add_notifier(C, NC_SCENE|ND_RENDER_OPTIONS, scene);
295                         break;
296                 case 2: /* Set as End */
297                         if (scene->r.psfra) {
298                                 if (scene->r.cfra < scene->r.psfra)
299                                         scene->r.psfra= scene->r.cfra;
300                                 scene->r.pefra= scene->r.cfra;
301                         }                               
302                         else
303                                 scene->r.efra = scene->r.cfra;
304                         WM_event_add_notifier(C, NC_SCENE|ND_RENDER_OPTIONS, scene);
305                         break;
306                 case 3: /* Rename Marker */
307                         //rename_marker();
308                         break;
309         }
310 }
311
312 static uiBlock *time_framemenu(bContext *C, ARegion *ar, void *arg_unused)
313 {
314         ScrArea *curarea= CTX_wm_area(C);
315         uiBlock *block;
316         short yco= 0, menuwidth=120;
317         
318         block= uiBeginBlock(C, ar, "time_framemenu", UI_EMBOSSP);
319         uiBlockSetButmFunc(block, do_time_framemenu, NULL);
320
321         uiDefIconTextButO(block, BUTM, "MARKER_OT_add", WM_OP_EXEC_REGION_WIN, ICON_BLANK1, "Add Marker",
322                                           0, yco-=2, menuwidth, 19, "");
323         uiDefIconTextButO(block, BUTM, "MARKER_OT_duplicate", WM_OP_EXEC_REGION_WIN, ICON_BLANK1, "Duplicate Marker",
324                                           0, yco-=20, menuwidth, 19, "");
325         uiDefIconTextButO(block, BUTM, "MARKER_OT_delete", WM_OP_EXEC_REGION_WIN, ICON_BLANK1, "Delete Marker",
326                                           0, yco-=20, menuwidth, 19, "");
327         
328         uiDefBut(block, SEPR, 0, "",        0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
329         
330         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Name Marker|Ctrl M",
331                                          0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 3, "");
332         uiDefIconTextButO(block, BUTM, "MARKER_OT_move", WM_OP_INVOKE_REGION_WIN, ICON_BLANK1, "Grab/Move Marker",
333                                           0, yco-=20, menuwidth, 19, "");
334         
335         uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
336         
337         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Set as Start|S",
338                                          0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 1, "");
339         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Set as End|E",
340                                          0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 2, "");
341         
342         if(curarea->headertype==HEADERTOP) {
343                 uiBlockSetDirection(block, UI_DOWN);
344         }
345         else {
346                 uiBlockSetDirection(block, UI_TOP);
347                 uiBlockFlipOrder(block);
348         }
349         
350         uiTextBoundsBlock(block, 50);
351         uiEndBlock(C, block);
352         
353         return block;
354 }
355
356
357 #define B_REDRAWALL             750
358 #define B_TL_PLAY               752
359 #define B_TL_RPLAY              760
360 #define B_TL_STOP               756
361 #define B_TL_PREVIEWON  757
362
363 #define B_FLIPINFOMENU 0
364 #define B_NEWFRAME 0
365 #define B_DIFF 0
366
367
368 void do_time_buttons(bContext *C, void *arg, int event)
369 {
370         Scene *scene= CTX_data_scene(C);
371         
372         switch(event) {
373                 case B_REDRAWALL:
374                         WM_event_add_notifier(C, NC_SCENE|ND_RENDER_OPTIONS, scene);
375                         break;
376                 case B_NEWFRAME:
377                         WM_event_add_notifier(C, NC_SCENE|ND_FRAME, scene);
378                         break;
379                 case B_TL_PREVIEWON:
380                         if (scene->r.psfra) {
381                                 /* turn on preview range */
382                                 scene->r.psfra= scene->r.sfra;
383                                 scene->r.pefra= scene->r.efra;
384                         }
385                         else {
386                                 /* turn off preview range */
387                                 scene->r.psfra= 0;
388                                 scene->r.pefra= 0;
389                         }
390                         //BIF_undo_push("Set anim-preview range");
391                         WM_event_add_notifier(C, NC_SCENE|ND_RENDER_OPTIONS, scene);
392                         break;
393         }
394 }
395
396
397 void time_header_buttons(const bContext *C, ARegion *ar)
398 {
399         ScrArea *sa= CTX_wm_area(C);
400         Scene *scene= CTX_data_scene(C);
401         wmTimer *animtimer= CTX_wm_screen(C)->animtimer;
402         uiBlock *block;
403         uiBut *but;
404         int xco, yco= 3;
405         char *menustr= NULL;
406         
407         block= uiBeginBlock(C, ar, "header buttons", UI_EMBOSS);
408         uiBlockSetHandleFunc(block, do_time_buttons, NULL);
409         
410         xco= ED_area_header_standardbuttons(C, block, yco);
411         
412         if((sa->flag & HEADER_NO_PULLDOWN)==0) {
413                 int xmax;
414                 
415                 xmax= GetButStringLength("View");
416                 uiDefPulldownBut(block, time_viewmenu, sa, 
417                                                  "View", xco, yco, xmax-3, 20, "");
418                 xco+= xmax;
419                 xmax= GetButStringLength("Frame");
420                 uiDefPulldownBut(block, time_framemenu, sa, 
421                                                  "Frame", xco, yco, xmax-3, 20, "");
422                 xco+= xmax;
423                 
424                 xmax= GetButStringLength("Playback");
425                 uiDefPulldownBut(block, time_redrawmenu, sa, 
426                                                  "Playback", xco, yco, xmax-3, 20, "");
427                 xco+= xmax;
428         }
429         
430         uiBlockSetEmboss(block, UI_EMBOSS);
431         
432         
433         
434         uiDefButI(block, TOG, B_TL_PREVIEWON,"PR",      
435                           xco,yco, XIC*2, YIC,
436                           &scene->r.psfra,0, 1, 0, 0,
437                           "Show settings for frame range of animation preview");
438         
439         xco += XIC*2;
440         
441         uiBlockBeginAlign(block);
442         
443         if (scene->r.psfra) {
444                 uiDefButI(block, NUM, B_REDRAWALL,"Start:",     
445                                   xco,yco, (int)4.5*XIC, YIC,
446                                   &scene->r.psfra,MINFRAMEF, MAXFRAMEF, 0, 0,
447                                   "The start frame of the animation preview (inclusive)");
448                 
449                 xco += (int)(4.5*XIC);
450                 
451                 uiDefButI(block, NUM, B_REDRAWALL,"End:",       
452                                   xco,yco, (int)4.5*XIC,YIC,
453                                   &scene->r.pefra,(float)PSFRA, MAXFRAMEF, 0, 0,
454                                   "The end frame of the animation preview (inclusive)");
455         }
456         else {
457                 uiDefButI(block, NUM, B_REDRAWALL,"Start:",     
458                                   xco,yco, (int)4.5*XIC, YIC,
459                                   &scene->r.sfra,MINFRAMEF, MAXFRAMEF, 0, 0,
460                                   "The start frame of the animation (inclusive)");
461                 
462                 xco += (short)(4.5*XIC);
463                 
464                 uiDefButI(block, NUM, B_REDRAWALL,"End:",       
465                                   xco,yco, (int)4.5*XIC,YIC,
466                                   &scene->r.efra,(float)SFRA, MAXFRAMEF, 0, 0,
467                                   "The end frame of the animation (inclusive)");
468         }
469         uiBlockEndAlign(block);
470         
471         xco += (short)(4.5 * XIC);
472         
473         /* MINAFRAMEF not MINFRAMEF, since MINAFRAMEF allows to set current frame negative 
474          * to facilitate easier keyframing in some situations
475          */
476         uiDefButI(block, NUM, B_NEWFRAME, "",
477                           xco,yco, (int)4.5*XIC,YIC,
478                           &(scene->r.cfra), MINAFRAMEF, MAXFRAMEF, 0, 0,
479                           "Displays Current Frame of animation");
480         
481         xco += (short)(4.5 * XIC);
482         
483         uiBlockBeginAlign(block);
484         
485         but= uiDefIconButO(block, BUT, "SCREEN_OT_frame_jump", WM_OP_INVOKE_REGION_WIN, ICON_REW, xco,yco,XIC,YIC, "Skip to Start frame (Shift DownArrow)");
486                 RNA_boolean_set(uiButGetOperatorPtrRNA(but), "end", 0);
487         xco+= XIC;
488         
489         but= uiDefIconButO(block, BUT, "SCREEN_OT_keyframe_jump", WM_OP_INVOKE_REGION_WIN, ICON_PREV_KEYFRAME, xco,yco,XIC,YIC, "Skip to previous keyframe (Ctrl PageDown)");
490                 RNA_boolean_set(uiButGetOperatorPtrRNA(but), "next", 0);
491         xco+= XIC;
492         
493         if (animtimer) {
494                 /* pause button 2*size to keep buttons in place */
495                 but=uiDefIconButO(block, BUT, "SCREEN_OT_animation_play", WM_OP_INVOKE_REGION_WIN, ICON_PAUSE, xco,yco,XIC*2,YIC, "Stop Playing Timeline");
496                 
497                 xco+= XIC;
498         }
499         else {     
500                 but=uiDefIconButO(block, BUT, "SCREEN_OT_animation_play", WM_OP_INVOKE_REGION_WIN, ICON_PLAY_REVERSE, xco,yco,XIC,YIC, "Play Timeline in Reverse");
501                         RNA_boolean_set(uiButGetOperatorPtrRNA(but), "reverse", 1);     
502                 xco+= XIC;
503                                          
504                 but=uiDefIconButO(block, BUT, "SCREEN_OT_animation_play", WM_OP_INVOKE_REGION_WIN, ICON_PLAY, xco,yco,XIC,YIC, "Play Timeline");
505                         RNA_boolean_set(uiButGetOperatorPtrRNA(but), "reverse", 0);     
506         }
507         xco+= XIC;
508         
509         but= uiDefIconButO(block, BUT, "SCREEN_OT_keyframe_jump", WM_OP_INVOKE_REGION_WIN, ICON_NEXT_KEYFRAME, xco,yco,XIC,YIC, "Skip to next keyframe (Ctrl PageUp)");
510                 RNA_boolean_set(uiButGetOperatorPtrRNA(but), "next", 1);
511         xco+= XIC;
512         
513         but= uiDefIconButO(block, BUT, "SCREEN_OT_frame_jump", WM_OP_INVOKE_REGION_WIN, ICON_FF, xco,yco,XIC,YIC, "Skip to End frame (Shift UpArrow)");
514                 RNA_boolean_set(uiButGetOperatorPtrRNA(but), "end", 1);
515         xco+= XIC;
516         uiBlockEndAlign(block);
517
518         xco+= (short)(0.5*XIC);
519         
520         uiBlockBeginAlign(block);
521         uiDefIconButBitS(block, TOG, AUTOKEY_ON, B_REDRAWALL, ICON_REC,
522                                          xco, yco, XIC, YIC, &(scene->toolsettings->autokey_mode), 0, 0, 0, 0, "Automatic keyframe insertion for Objects and Bones");
523         xco+= 1*XIC;
524         if (IS_AUTOKEY_ON(scene)) {
525                 uiDefButS(block, MENU, B_REDRAWALL, 
526                                   "Auto-Keying Mode %t|Add/Replace%x3|Replace%x5", 
527                                   xco, yco, (int)(4.25*XIC), YIC, &(scene->toolsettings->autokey_mode), 0, 1, 0, 0, 
528                                   "Mode of automatic keyframe insertion for Objects and Bones");
529                 xco+= (short)(4.25*XIC);
530                 
531                 if (animtimer) {
532                         uiDefButBitS(block, TOG, ANIMRECORD_FLAG_WITHNLA, B_REDRAWALL, "Layered",       
533                                   xco,yco, (int)(3.5*XIC), YIC,
534                                   &(scene->toolsettings->autokey_flag),0, 1, 0, 0,
535                                   "Add a new NLA Track + Strip for every loop/pass made over the animation to allow non-destructive tweaking.");
536                         uiBlockEndAlign(block);
537                         
538                         xco+= (short)(3.5*XIC);
539                 }
540                 
541                 xco += XIC;
542                 
543                 uiBlockEndAlign(block);
544         }
545         else {
546                 xco+= (short)(5.25*XIC);
547                 uiBlockEndAlign(block);
548         }
549         
550         menustr= ANIM_build_keyingsets_menu(&scene->keyingsets, 0);
551         uiDefButI(block, MENU, B_DIFF, 
552                                   menustr, 
553                                   xco, yco, (int)5.5*XIC, YIC, &(scene->active_keyingset), 0, 1, 0, 0, 
554                                   "Active Keying Set (i.e. set of channels to Insert Keyframes for)");
555         MEM_freeN(menustr);
556         xco+= (5.5*XIC);
557         
558         /* NOTE: order of these buttons needs to be kept in sync with other occurances 
559          * (see Outliner header for instance, also +/- stuff for filebrowser) 
560          */
561         uiBlockBeginAlign(block);
562         uiDefIconButO(block, BUT, "ANIM_OT_delete_keyframe", WM_OP_INVOKE_REGION_WIN, ICON_KEY_DEHLT, xco,yco,XIC,YIC, "Delete Keyframes for the Active Keying Set (Alt-I)");
563         xco += XIC;
564         uiDefIconButO(block, BUT, "ANIM_OT_insert_keyframe", WM_OP_INVOKE_REGION_WIN, ICON_KEY_HLT, xco,yco,XIC,YIC, "Insert Keyframes for the Active Keying Set (I)");
565         xco += XIC;
566         uiBlockEndAlign(block);
567         
568         xco+= XIC;
569         
570         uiDefIconButBitS(block, TOG, AUDIO_SYNC, B_DIFF, ICON_SPEAKER,
571                                          xco, yco, XIC, YIC, &(scene->r.audio.flag), 0, 0, 0, 0, "Play back and sync with audio from Sequence Editor");
572         
573         
574         /* always as last  */
575         UI_view2d_totRect_set(&ar->v2d, xco+XIC+80, (int)(ar->v2d.tot.ymax-ar->v2d.tot.ymin));
576         
577         uiEndBlock(C, block);
578         uiDrawBlock(C, block);
579 }
580
581