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