2.5 - Bugfixes
[blender.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 static ARegion *time_top_left_3dwindow(bScreen *screen)
73 {
74         ARegion *aret= NULL;
75         ScrArea *sa;
76         int min= 10000;
77         
78         for(sa= screen->areabase.first; sa; sa= sa->next) {
79                 if(sa->spacetype==SPACE_VIEW3D) {
80                         ARegion *ar;
81                         for(ar= sa->regionbase.first; ar; ar= ar->next) {
82                                 if(ar->regiontype==RGN_TYPE_WINDOW) {
83                                         if(ar->winrct.xmin - ar->winrct.ymin < min) {
84                                                 aret= ar;
85                                                 min= ar->winrct.xmin - ar->winrct.ymin;
86                                         }
87                                 }
88                         }
89                 }
90         }
91         return aret;
92 }
93
94 static void do_time_redrawmenu(bContext *C, void *arg, int event)
95 {
96         
97         if(event < 1001) {
98                 bScreen *screen= CTX_wm_screen(C);
99                 SpaceTime *stime= CTX_wm_space_time(C);
100                 
101                 stime->redraws ^= event;
102                 
103                 if(screen->animtimer) {
104                         wmTimer *wt= screen->animtimer;
105                         ScreenAnimData *sad= wt->customdata;
106                         
107                         sad->redraws= stime->redraws;
108                         sad->ar= NULL;
109                         if(stime->redraws & TIME_REGION)
110                                 sad->ar= time_top_left_3dwindow(screen);
111                 }
112         }
113 }
114
115
116 static uiBlock *time_redrawmenu(bContext *C, ARegion *ar, void *arg_unused)
117 {
118         ScrArea *curarea= CTX_wm_area(C);
119         SpaceTime *stime= CTX_wm_space_time(C);
120         uiBlock *block;
121         short yco= 0, menuwidth=120, icon;
122         
123         block= uiBeginBlock(C, ar, "header time_redrawmenu", UI_EMBOSSP);
124         uiBlockSetButmFunc(block, do_time_redrawmenu, NULL);
125         
126         if(stime->redraws & TIME_REGION) icon= ICON_CHECKBOX_HLT;
127         else icon= ICON_CHECKBOX_DEHLT;
128         uiDefIconTextBut(block, BUTM, 1, icon, "Top-Left 3D Window",     0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, TIME_REGION, "");
129         
130         if(stime->redraws & TIME_ALL_3D_WIN) icon= ICON_CHECKBOX_HLT;
131         else icon= ICON_CHECKBOX_DEHLT;
132         uiDefIconTextBut(block, BUTM, 1, icon, "All 3D Windows",         0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, TIME_ALL_3D_WIN, "");
133         
134         if(stime->redraws & TIME_ALL_ANIM_WIN) icon= ICON_CHECKBOX_HLT;
135         else icon= ICON_CHECKBOX_DEHLT;
136         uiDefIconTextBut(block, BUTM, 1, icon, "Animation Windows",      0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, TIME_ALL_ANIM_WIN, "");
137         
138         if(stime->redraws & TIME_ALL_BUTS_WIN) icon= ICON_CHECKBOX_HLT;
139         else icon= ICON_CHECKBOX_DEHLT;
140         uiDefIconTextBut(block, BUTM, 1, icon, "Buttons Windows",        0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, TIME_ALL_BUTS_WIN, "");
141         
142         if(stime->redraws & TIME_ALL_IMAGE_WIN) icon= ICON_CHECKBOX_HLT;
143         else icon= ICON_CHECKBOX_DEHLT;
144         uiDefIconTextBut(block, BUTM, 1, icon, "Image Windows",      0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, TIME_ALL_IMAGE_WIN, "");
145         
146         /* Add sequencer only redraw*/
147         if(stime->redraws & TIME_SEQ) icon= ICON_CHECKBOX_HLT;
148         else icon= ICON_CHECKBOX_DEHLT;
149         uiDefIconTextBut(block, BUTM, 1, icon, "Sequencer Windows",      0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, TIME_SEQ, "");
150         
151         uiDefBut(block, SEPR, 0, "",        0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
152         
153         if(stime->redraws & TIME_CONTINUE_PHYSICS) icon= ICON_CHECKBOX_HLT;
154         else icon= ICON_CHECKBOX_DEHLT;
155         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");
156         
157         if(curarea->headertype==HEADERTOP) {
158                 uiBlockSetDirection(block, UI_DOWN);
159         }
160         else {
161                 uiBlockSetDirection(block, UI_TOP);
162                 uiBlockFlipOrder(block);
163         }
164         
165         uiTextBoundsBlock(block, 50);
166         uiEndBlock(C, block);
167         
168         return block;
169 }
170
171 static void do_time_viewmenu(bContext *C, void *arg, int event)
172 {
173         ScrArea *curarea= CTX_wm_area(C);
174         SpaceTime *stime= CTX_wm_space_time(C);
175         View2D *v2d= UI_view2d_fromcontext_rwin(C);
176         Scene *scene= CTX_data_scene(C);
177         int first;
178         
179         switch(event) {
180                 case 2: /* Play Back Animation */
181                         //if(!has_screenhandler(G.curscreen, SCREEN_HANDLER_ANIM))
182                         //      start_animated_screen(stime);
183                         break;
184                 case 3: /* View All */
185                         if(v2d) {
186                                 first= scene->r.sfra;
187                                 if(first >= scene->r.efra) first= scene->r.efra;
188                                         v2d->cur.xmin=v2d->tot.xmin= (float)first-2;
189                                 v2d->cur.xmax=v2d->tot.xmax= (float)scene->r.efra+2;
190                         
191                                 ED_area_tag_redraw(curarea);
192                         }
193                         break;
194                 case 4: /* Maximize Window */
195                         /* using event B_FULL */
196                         break;
197                 case 5: /* show time or frames */
198                         stime->flag ^= TIME_DRAWFRAMES;
199                         ED_area_tag_redraw(curarea);
200                         break;
201                 case 6:
202                         //nextprev_marker(1);
203                         break;
204                 case 7:
205                         //nextprev_marker(-1);
206                         break;
207                 case 8:
208                         //nextprev_timeline_key(1);
209                         break;
210                 case 9:
211                         //nextprev_timeline_key(-1);
212                         break;
213                 case 10:
214                         //timeline_frame_to_center();
215                         break;
216                 case 11:
217                         if(v2d) {
218                                 v2d->flag ^= V2D_VIEWSYNC_SCREEN_TIME;
219                                 UI_view2d_sync(CTX_wm_screen(C), CTX_wm_area(C), v2d, V2D_LOCK_SET);
220                         }
221                         break;
222                 case 12: /* only show keyframes from selected data */
223                         stime->flag ^= TIME_ONLYACTSEL;
224                         ED_area_tag_redraw(curarea);
225                         break;
226         }
227 }
228
229 static uiBlock *time_viewmenu(bContext *C, ARegion *ar, void *arg_unused)
230 {
231         ScrArea *curarea= CTX_wm_area(C);
232         SpaceTime *stime= CTX_wm_space_time(C);
233         View2D *v2d= UI_view2d_fromcontext_rwin(C);
234         uiBlock *block;
235         short yco= 0, menuwidth=120;
236         
237         block= uiBeginBlock(C, ar, "time_viewmenu", UI_EMBOSSP);
238         uiBlockSetButmFunc(block, do_time_viewmenu, NULL);
239         
240         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Play Back Animation", 0, yco-=20,
241                                          menuwidth, 19, NULL, 0.0, 0.0, 1, 2, "");
242         
243         uiDefBut(block, SEPR, 0, "",        0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
244         
245         if(stime->flag & TIME_DRAWFRAMES)
246                 uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Show Seconds|Ctrl T", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 5, "");
247         else 
248                 uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Show Frames|Ctrl T", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 5, "");
249         
250         uiDefIconTextBut(block, BUTM, 1, (stime->flag & TIME_ONLYACTSEL)?ICON_CHECKBOX_HLT:ICON_CHECKBOX_DEHLT, 
251                                          "Only Selected Data Keys|", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 12, "");
252         
253         uiDefBut(block, SEPR, 0, "",        0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
254         
255         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Jump To Next Marker|PageUp", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 6, "");
256         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Jump To Prev Marker|PageDown", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 7, "");
257         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Jump To Next Key|Ctrl PageUp", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 8, "");
258         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Jump To Prev Key|Ctrl PageDown", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 9, "");
259         
260         uiDefBut(block, SEPR, 0, "",        0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
261         
262         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Center View|C", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 10, "");
263         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "View All|Home", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 3, "");
264         uiDefIconTextBut(block, BUTM, 1, (v2d->flag & V2D_VIEWSYNC_SCREEN_TIME)?ICON_CHECKBOX_HLT:ICON_CHECKBOX_DEHLT, 
265                                          "Lock Time to Other Windows|", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 11, "");
266         
267 //      if (!curarea->full) 
268 //              uiDefIconTextBut(block, BUTM, B_FULL, ICON_BLANK1, "Maximize Window|Ctrl UpArrow", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 4, "");
269 //      else 
270 //              uiDefIconTextBut(block, BUTM, B_FULL, ICON_BLANK1, "Tile Window|Ctrl DownArrow", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 4, "");
271         
272         if(curarea->headertype==HEADERTOP) {
273                 uiBlockSetDirection(block, UI_DOWN);
274         }
275         else {
276                 uiBlockSetDirection(block, UI_TOP);
277                 uiBlockFlipOrder(block);
278         }
279         
280         uiTextBoundsBlock(block, 50);
281         uiEndBlock(C, block);
282         
283         return block;
284 }
285
286 static void do_time_framemenu(bContext *C, void *arg, int event)
287 {
288         Scene *scene= CTX_data_scene(C);
289
290         switch(event) {
291                 case 1: /*Set as Start */
292                         if (scene->r.psfra) {
293                                 if (scene->r.pefra < scene->r.cfra)
294                                         scene->r.pefra= scene->r.cfra;
295                                 scene->r.psfra= scene->r.cfra;
296                         }                               
297                         else
298                                 scene->r.sfra = scene->r.cfra;
299                         WM_event_add_notifier(C, NC_SCENE|ND_RENDER_OPTIONS, scene);
300                         break;
301                 case 2: /* Set as End */
302                         if (scene->r.psfra) {
303                                 if (scene->r.cfra < scene->r.psfra)
304                                         scene->r.psfra= scene->r.cfra;
305                                 scene->r.pefra= scene->r.cfra;
306                         }                               
307                         else
308                                 scene->r.efra = scene->r.cfra;
309                         WM_event_add_notifier(C, NC_SCENE|ND_RENDER_OPTIONS, scene);
310                         break;
311                 case 3: /* Rename Marker */
312                         //rename_marker();
313                         break;
314         }
315 }
316
317 static uiBlock *time_framemenu(bContext *C, ARegion *ar, void *arg_unused)
318 {
319         ScrArea *curarea= CTX_wm_area(C);
320         uiBlock *block;
321         short yco= 0, menuwidth=120;
322         
323         block= uiBeginBlock(C, ar, "time_framemenu", UI_EMBOSSP);
324         uiBlockSetButmFunc(block, do_time_framemenu, NULL);
325
326         uiDefIconTextButO(block, BUTM, "MARKER_OT_add", WM_OP_EXEC_REGION_WIN, ICON_BLANK1, "Add Marker",
327                                           0, yco-=2, menuwidth, 19, "");
328         uiDefIconTextButO(block, BUTM, "MARKER_OT_duplicate", WM_OP_EXEC_REGION_WIN, ICON_BLANK1, "Duplicate Marker",
329                                           0, yco-=20, menuwidth, 19, "");
330         uiDefIconTextButO(block, BUTM, "MARKER_OT_delete", WM_OP_EXEC_REGION_WIN, ICON_BLANK1, "Delete Marker",
331                                           0, yco-=20, menuwidth, 19, "");
332         
333         uiDefBut(block, SEPR, 0, "",        0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
334         
335         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Name Marker|Ctrl M",
336                                          0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 3, "");
337         uiDefIconTextButO(block, BUTM, "MARKER_OT_move", WM_OP_INVOKE_REGION_WIN, ICON_BLANK1, "Grab/Move Marker",
338                                           0, yco-=20, menuwidth, 19, "");
339         
340         uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
341         
342         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Set as Start|S",
343                                          0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 1, "");
344         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Set as End|E",
345                                          0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 2, "");
346         
347         if(curarea->headertype==HEADERTOP) {
348                 uiBlockSetDirection(block, UI_DOWN);
349         }
350         else {
351                 uiBlockSetDirection(block, UI_TOP);
352                 uiBlockFlipOrder(block);
353         }
354         
355         uiTextBoundsBlock(block, 50);
356         uiEndBlock(C, block);
357         
358         return block;
359 }
360
361
362 #define B_REDRAWALL             750
363 #define B_TL_PLAY               752
364 #define B_TL_RPLAY              760
365 #define B_TL_STOP               756
366 #define B_TL_PREVIEWON  757
367
368 #define B_FLIPINFOMENU 0
369 #define B_NEWFRAME 0
370 #define B_DIFF 0
371
372
373 void do_time_buttons(bContext *C, void *arg, int event)
374 {
375         bScreen *screen= CTX_wm_screen(C);
376         SpaceTime *stime= CTX_wm_space_time(C);
377         Scene *scene= CTX_data_scene(C);
378         
379         switch(event) {
380                 case B_REDRAWALL:
381                         WM_event_add_notifier(C, NC_SCENE|ND_RENDER_OPTIONS, scene);
382                         break;
383                 case B_NEWFRAME:
384                         WM_event_add_notifier(C, NC_SCENE|ND_FRAME, scene);
385                         break;
386                 case B_TL_PLAY:
387                         ED_screen_animation_timer(C, stime->redraws, 1);
388                         
389                         /* update region if TIME_REGION was set, to leftmost 3d window */
390                         if(screen->animtimer && (stime->redraws & TIME_REGION)) {
391                                 wmTimer *wt= screen->animtimer;
392                                 ScreenAnimData *sad= wt->customdata;
393                                 
394                                 sad->ar= time_top_left_3dwindow(screen);
395                         }
396                         
397                         break;
398                 case B_TL_RPLAY:
399                         ED_screen_animation_timer(C, stime->redraws, -1);
400                         
401                         /* update region if TIME_REGION was set, to leftmost 3d window */
402                         if(screen->animtimer && (stime->redraws & TIME_REGION)) {
403                                 wmTimer *wt= screen->animtimer;
404                                 ScreenAnimData *sad= wt->customdata;
405                                 
406                                 sad->ar= time_top_left_3dwindow(screen);
407                         }
408                         
409                         break;
410                 case B_TL_STOP:
411                         ED_screen_animation_timer(C, 0, 0);
412                         break;
413                         
414                 case B_TL_PREVIEWON:
415                         if (scene->r.psfra) {
416                                 /* turn on preview range */
417                                 scene->r.psfra= scene->r.sfra;
418                                 scene->r.pefra= scene->r.efra;
419                         }
420                         else {
421                                 /* turn off preview range */
422                                 scene->r.psfra= 0;
423                                 scene->r.pefra= 0;
424                         }
425                         //BIF_undo_push("Set anim-preview range");
426                         WM_event_add_notifier(C, NC_SCENE|ND_RENDER_OPTIONS, scene);
427                         break;
428         }
429 }
430
431
432 void time_header_buttons(const bContext *C, ARegion *ar)
433 {
434         ScrArea *sa= CTX_wm_area(C);
435         SpaceTime *stime= CTX_wm_space_time(C);
436         Scene *scene= CTX_data_scene(C);
437         wmTimer *animtimer= CTX_wm_screen(C)->animtimer;
438         uiBlock *block;
439         uiBut *but;
440         int xco, yco= 3;
441         char *menustr= NULL;
442         
443         block= uiBeginBlock(C, ar, "header buttons", UI_EMBOSS);
444         uiBlockSetHandleFunc(block, do_time_buttons, NULL);
445         
446         xco= ED_area_header_standardbuttons(C, block, yco);
447         
448         if((sa->flag & HEADER_NO_PULLDOWN)==0) {
449                 int xmax;
450                 
451                 xmax= GetButStringLength("View");
452                 uiDefPulldownBut(block, time_viewmenu, sa, 
453                                                  "View", xco, yco, xmax-3, 20, "");
454                 xco+= xmax;
455                 xmax= GetButStringLength("Frame");
456                 uiDefPulldownBut(block, time_framemenu, sa, 
457                                                  "Frame", xco, yco, xmax-3, 20, "");
458                 xco+= xmax;
459                 
460                 xmax= GetButStringLength("Playback");
461                 uiDefPulldownBut(block, time_redrawmenu, sa, 
462                                                  "Playback", xco, yco, xmax-3, 20, "");
463                 xco+= xmax;
464         }
465         
466         uiBlockSetEmboss(block, UI_EMBOSS);
467         
468         uiBlockBeginAlign(block);
469         
470         uiDefButI(block, TOG, B_TL_PREVIEWON,"PR",      
471                           xco,yco, XIC*2, YIC,
472                           &scene->r.psfra,0, 1, 0, 0,
473                           "Show settings for frame range of animation preview");
474         
475         xco += XIC*2;
476         
477         if (scene->r.psfra) {
478                 uiDefButI(block, NUM, B_REDRAWALL,"Start:",     
479                                   xco,yco, (int)4.5*XIC, YIC,
480                                   &scene->r.psfra,MINFRAMEF, MAXFRAMEF, 0, 0,
481                                   "The start frame of the animation preview (inclusive)");
482                 
483                 xco += (int)(4.5*XIC);
484                 
485                 uiDefButI(block, NUM, B_REDRAWALL,"End:",       
486                                   xco,yco, (int)4.5*XIC,YIC,
487                                   &scene->r.pefra,(float)PSFRA, MAXFRAMEF, 0, 0,
488                                   "The end frame of the animation preview (inclusive)");
489         }
490         else {
491                 uiDefButI(block, NUM, B_REDRAWALL,"Start:",     
492                                   xco,yco, (int)4.5*XIC, YIC,
493                                   &scene->r.sfra,MINFRAMEF, MAXFRAMEF, 0, 0,
494                                   "The start frame of the animation (inclusive)");
495                 
496                 xco += (short)(4.5*XIC);
497                 
498                 uiDefButI(block, NUM, B_REDRAWALL,"End:",       
499                                   xco,yco, (int)4.5*XIC,YIC,
500                                   &scene->r.efra,(float)SFRA, MAXFRAMEF, 0, 0,
501                                   "The end frame of the animation (inclusive)");
502         }
503         uiBlockEndAlign(block);
504         
505         xco += (short)(4.5 * XIC);
506         
507         /* MINAFRAMEF not MINFRAMEF, since MINAFRAMEF allows to set current frame negative 
508          * to facilitate easier keyframing in some situations
509          */
510         uiDefButI(block, NUM, B_NEWFRAME, "",
511                           xco,yco, (int)3.5*XIC,YIC,
512                           &(scene->r.cfra), MINAFRAMEF, MAXFRAMEF, 0, 0,
513                           "Displays Current Frame of animation");
514         
515         xco += (short)(3.5 * XIC);
516         
517         uiBlockBeginAlign(block);
518         
519         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)");
520                 RNA_boolean_set(uiButGetOperatorPtrRNA(but), "end", 0);
521         xco+= XIC;
522         
523         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)");
524                 RNA_boolean_set(uiButGetOperatorPtrRNA(but), "next", 0);
525         xco+= XIC;
526         
527         if (animtimer) {
528                 /* pause button 2*size to keep buttons in place */
529                 uiDefIconBut(block, BUT, B_TL_STOP, ICON_PAUSE,
530                                          xco, yco, XIC*2, YIC, 0, 0, 0, 0, 0, "Stop Playing Timeline");
531                                          
532                 xco+= XIC;
533         }
534         else {     
535                 uiDefIconBut(block, BUT, B_TL_RPLAY, ICON_PLAY_REVERSE,
536                                          xco, yco, XIC, YIC, 0, 0, 0, 0, 0, "Play Timeline in Reverse");
537                                          
538                 xco+= XIC;
539                                          
540                 uiDefIconBut(block, BUT, B_TL_PLAY, ICON_PLAY,
541                                          xco, yco, XIC, YIC, 0, 0, 0, 0, 0, "Play Timeline ");
542         }
543         xco+= XIC;
544         
545         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)");
546                 RNA_boolean_set(uiButGetOperatorPtrRNA(but), "next", 1);
547         xco+= XIC;
548         
549         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)");
550                 RNA_boolean_set(uiButGetOperatorPtrRNA(but), "end", 1);
551         xco+= XIC;
552         uiBlockEndAlign(block);
553
554         xco+= 2*XIC;
555         
556         uiBlockBeginAlign(block);
557         uiDefIconButBitS(block, TOG, AUTOKEY_ON, B_REDRAWALL, ICON_REC,
558                                          xco, yco, XIC, YIC, &(scene->toolsettings->autokey_mode), 0, 0, 0, 0, "Automatic keyframe insertion for Objects and Bones");
559         xco+= XIC;
560         
561         if (IS_AUTOKEY_ON(scene)) {
562                 uiDefButS(block, MENU, B_REDRAWALL, 
563                                   "Auto-Keying Mode %t|Add/Replace Keys%x3|Replace Keys %x5", 
564                                   xco, yco, (int)5.5*XIC, YIC, &(scene->toolsettings->autokey_mode), 0, 1, 0, 0, 
565                                   "Mode of automatic keyframe insertion for Objects and Bones");
566                 xco+= (5.5*XIC);
567                 
568                 if (animtimer) {
569                         uiDefButBitS(block, TOG, ANIMRECORD_FLAG_WITHNLA, B_REDRAWALL, "Layered",       
570                                   xco,yco, XIC*2.5, YIC,
571                                   &(scene->toolsettings->autokey_flag),0, 1, 0, 0,
572                                   "Add a new NLA Track + Strip for every loop/pass made over the animation to allow non-destructive tweaking.");
573                         xco+= (3*XIC);
574                 }
575         }
576         else
577                 xco+= 6;
578
579         uiBlockEndAlign(block);
580         
581         menustr= ANIM_build_keyingsets_menu(&scene->keyingsets, 0);
582         uiDefButI(block, MENU, B_DIFF, 
583                                   menustr, 
584                                   xco, yco, (int)5.5*XIC, YIC, &(scene->active_keyingset), 0, 1, 0, 0, 
585                                   "Active Keying Set (i.e. set of channels to Insert Keyframes for)");
586         MEM_freeN(menustr);
587         xco+= (5.5*XIC);
588         
589         uiBlockBeginAlign(block);
590         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)");
591         xco += XIC;
592         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)");
593         xco += XIC;
594         uiBlockEndAlign(block);
595         
596         xco+= XIC;
597         
598         uiDefIconButBitI(block, TOG, TIME_WITH_SEQ_AUDIO, B_DIFF, ICON_SPEAKER,
599                                          xco, yco, XIC, YIC, &(stime->redraws), 0, 0, 0, 0, "Play back and sync with audio from Sequence Editor");
600         
601         
602         /* always as last  */
603         UI_view2d_totRect_set(&ar->v2d, xco+XIC+80, (int)(ar->v2d.tot.ymax-ar->v2d.tot.ymin));
604         
605         uiEndBlock(C, block);
606         uiDrawBlock(C, block);
607 }
608
609