Reduced number of MSVC compiler warnings (mostly just casting issues).
[blender.git] / source / blender / src / header_time.c
1 /**
2  *
3  * $Id:
4  *
5  * ***** BEGIN GPL LICENSE BLOCK *****
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software Foundation,
19  * Inc., 59 Temple Place - Suite 330, Boston, MA        02111-1307, USA.
20  *
21  * The Original Code is Copyright (C) 2005 Blender Foundation.
22  * All rights reserved.
23  *
24  * The Original Code is: all of this file.
25  *
26  * Contributor(s): none yet.
27  *
28  * ***** END GPL LICENSE BLOCK *****
29  */
30
31 #include <stdlib.h>
32 #include <string.h>
33 #include <stdio.h>
34
35 #ifdef HAVE_CONFIG_H
36 #include <config.h>
37 #endif
38
39 #include "DNA_ID.h"
40 #include "DNA_screen_types.h"
41 #include "DNA_scene_types.h"
42 #include "DNA_space_types.h"
43 #include "DNA_view2d_types.h"
44 #include "DNA_userdef_types.h"
45
46 #include "BIF_gl.h"
47 #include "BIF_interface.h"
48 #include "BIF_keyframing.h"
49 #include "BIF_resources.h"
50 #include "BIF_screen.h"
51 #include "BIF_space.h"
52 #include "BIF_toolbox.h"
53 #include "BIF_butspace.h"
54
55 #include "BKE_global.h"
56 #include "BKE_main.h"
57 #include "BKE_pointcache.h"
58
59 #include "BSE_drawipo.h"
60 #include "BSE_drawview.h"
61 #include "BSE_editipo.h"
62 #include "BSE_filesel.h"
63 #include "BSE_headerbuttons.h"
64 #include "BSE_seqaudio.h"
65 #include "BSE_time.h"
66
67 #include "blendef.h"
68 #include "butspace.h"
69 #include "mydevice.h"
70
71 static void start_animated_screen(SpaceTime *stime)
72 {
73         add_screenhandler(G.curscreen, SCREEN_HANDLER_ANIM, stime->redraws);
74
75         if(stime->redraws & TIME_WITH_SEQ_AUDIO)
76                 audiostream_start( CFRA );
77
78         BKE_ptcache_set_continue_physics((stime->redraws & TIME_CONTINUE_PHYSICS));
79 }
80
81 static void end_animated_screen(SpaceTime *stime)
82 {
83         rem_screenhandler(G.curscreen, SCREEN_HANDLER_ANIM);
84
85         audiostream_stop();
86         BKE_ptcache_set_continue_physics(0);
87 }
88
89 void do_time_buttons(ScrArea *sa, unsigned short event)
90 {
91         SpaceTime *stime= sa->spacedata.first;
92         
93         switch(event) {
94
95         case B_TL_REW:
96                 CFRA= PSFRA;
97                 update_for_newframe();
98                 break;
99         case B_TL_PLAY:
100                 start_animated_screen(stime);
101                 break;
102         case B_TL_STOP:
103                 end_animated_screen(stime);
104                 allqueue(REDRAWALL, 0);
105                 break;
106         case B_TL_FF:
107                 /* end frame */
108                 CFRA= PEFRA;
109                 update_for_newframe();
110                 break;
111         case B_TL_PREVKEY:
112                 /* previous keyframe */
113                 nextprev_timeline_key(-1);
114                 break;
115         case B_TL_NEXTKEY:
116                 /* next keyframe */
117                 nextprev_timeline_key(1);
118                 break;
119                 
120         case B_TL_PREVIEWON:
121                 if (G.scene->r.psfra) {
122                         /* turn on preview range */
123                         G.scene->r.psfra= G.scene->r.sfra;
124                         G.scene->r.pefra= G.scene->r.efra;
125                 }
126                 else {
127                         /* turn off preview range */
128                         G.scene->r.psfra= 0;
129                         G.scene->r.pefra= 0;
130                 }
131                 BIF_undo_push("Set anim-preview range");
132                 allqueue(REDRAWALL, 0);
133                 break;
134                 
135         case B_TL_INSERTKEY:
136                 /* insert keyframe */
137                 common_insertkey();
138                 allqueue(REDRAWTIME, 1);
139                 break;
140         case B_TL_DELETEKEY:
141                 /* delete keyframe */
142                 common_deletekey();
143                 allqueue(REDRAWTIME, 1);
144                 break;
145         }
146 }
147
148 static void do_time_redrawmenu(void *arg, int event)
149 {
150         SpaceTime *stime= curarea->spacedata.first;
151         
152         if(event < 1001) {
153                 
154                 stime->redraws ^= event;
155                 /* update handler when it's running */
156                 if(has_screenhandler(G.curscreen, SCREEN_HANDLER_ANIM))
157                         start_animated_screen(stime);
158         }
159         else {
160                 if(event==1001) {
161                         button(&G.scene->r.frs_sec,1,120,"FPS:");
162                 }
163         }
164 }
165                         
166
167 static uiBlock *time_redrawmenu(void *arg_unused)
168 {
169         SpaceTime *stime= curarea->spacedata.first;
170         uiBlock *block;
171         short yco= 0, menuwidth=120, icon;
172         char str[32];
173         
174         block= uiNewBlock(&curarea->uiblocks, "time_redrawmenu", 
175                                           UI_EMBOSSP, UI_HELV, curarea->headwin);
176         uiBlockSetButmFunc(block, do_time_redrawmenu, NULL);
177         
178         if(stime->redraws & TIME_LEFTMOST_3D_WIN) icon= ICON_CHECKBOX_HLT;
179         else icon= ICON_CHECKBOX_DEHLT;
180         uiDefIconTextBut(block, BUTM, 1, icon, "Top-Left 3D Window",     0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, TIME_LEFTMOST_3D_WIN, "");
181
182         if(stime->redraws & TIME_ALL_3D_WIN) icon= ICON_CHECKBOX_HLT;
183         else icon= ICON_CHECKBOX_DEHLT;
184         uiDefIconTextBut(block, BUTM, 1, icon, "All 3D Windows",         0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, TIME_ALL_3D_WIN, "");
185         
186         if(stime->redraws & TIME_ALL_ANIM_WIN) icon= ICON_CHECKBOX_HLT;
187         else icon= ICON_CHECKBOX_DEHLT;
188         uiDefIconTextBut(block, BUTM, 1, icon, "Animation Windows",      0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, TIME_ALL_ANIM_WIN, "");
189         
190         if(stime->redraws & TIME_ALL_BUTS_WIN) icon= ICON_CHECKBOX_HLT;
191         else icon= ICON_CHECKBOX_DEHLT;
192         uiDefIconTextBut(block, BUTM, 1, icon, "Buttons Windows",        0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, TIME_ALL_BUTS_WIN, "");
193         
194         if(stime->redraws & TIME_ALL_IMAGE_WIN) icon= ICON_CHECKBOX_HLT;
195         else icon= ICON_CHECKBOX_DEHLT;
196         uiDefIconTextBut(block, BUTM, 1, icon, "Image Windows",      0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, TIME_ALL_IMAGE_WIN, "");
197         
198         /* Add sequencer only redraw*/
199         if(stime->redraws & TIME_SEQ) icon= ICON_CHECKBOX_HLT;
200         else icon= ICON_CHECKBOX_DEHLT;
201         uiDefIconTextBut(block, BUTM, 1, icon, "Sequencer Windows",      0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, TIME_SEQ, "");
202
203         uiDefBut(block, SEPR, 0, "",        0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
204         
205         sprintf(str, "Set Frames/Sec (%d/%f)", G.scene->r.frs_sec, G.scene->r.frs_sec_base);
206         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, str,       0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 1001, "");
207
208         uiDefBut(block, SEPR, 0, "",        0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
209
210         if(stime->redraws & TIME_CONTINUE_PHYSICS) icon= ICON_CHECKBOX_HLT;
211         else icon= ICON_CHECKBOX_DEHLT;
212         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");
213         
214         
215         if(curarea->headertype==HEADERTOP) {
216                 uiBlockSetDirection(block, UI_DOWN);
217         }
218         else {
219                 uiBlockSetDirection(block, UI_TOP);
220                 uiBlockFlipOrder(block);
221         }
222         
223         uiTextBoundsBlock(block, 50);
224         
225         return block;
226 }
227
228 static void do_time_viewmenu(void *arg, int event)
229 {
230         SpaceTime *stime= curarea->spacedata.first;
231         int first;
232         
233         switch(event) {
234                 case 2: /* Play Back Animation */
235                         if(!has_screenhandler(G.curscreen, SCREEN_HANDLER_ANIM))
236                                 start_animated_screen(stime);
237                         break;
238                 case 3: /* View All */
239                         first= G.scene->r.sfra;
240                         if(first >= G.scene->r.efra) first= G.scene->r.efra;
241                         G.v2d->cur.xmin=G.v2d->tot.xmin= (float)first-2;
242                         G.v2d->cur.xmax=G.v2d->tot.xmax= (float)G.scene->r.efra+2;
243                         
244                         test_view2d(G.v2d, curarea->winx, curarea->winy);
245                         scrarea_queue_winredraw(curarea);
246                         break;
247                 case 4: /* Maximize Window */
248                                 /* using event B_FULL */
249                         break;
250                 case 5: /* show time or frames */
251                         stime->flag ^= TIME_DRAWFRAMES;
252                         break;
253                 case 6:
254                         nextprev_marker(1);
255                         break;
256                 case 7:
257                         nextprev_marker(-1);
258                         break;
259                 case 8:
260                         nextprev_timeline_key(1);
261                         break;
262                 case 9:
263                         nextprev_timeline_key(-1);
264                         break;
265                 case 10:
266                         timeline_frame_to_center();
267                         break;
268                 case 11:
269                         G.v2d->flag ^= V2D_VIEWLOCK;
270                         if(G.v2d->flag & V2D_VIEWLOCK)
271                                 view2d_do_locks(curarea, 0);
272                         break;
273                 case 12: /* only show keyframes from selected data */
274                         stime->flag ^= TIME_ONLYACTSEL;
275                         break;
276         }
277         allqueue(REDRAWVIEW3D, 0);
278 }
279
280 static uiBlock *time_viewmenu(void *arg_unused)
281 {
282         SpaceTime *stime= curarea->spacedata.first;
283         uiBlock *block;
284         short yco= 0, menuwidth=120;
285         
286         block= uiNewBlock(&curarea->uiblocks, "time_viewmenu", 
287                                           UI_EMBOSSP, UI_HELV, curarea->headwin);
288         uiBlockSetButmFunc(block, do_time_viewmenu, NULL);
289         
290         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Play Back Animation", 0, yco-=20,
291                                          menuwidth, 19, NULL, 0.0, 0.0, 1, 2, "");
292
293         uiDefBut(block, SEPR, 0, "",        0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
294         
295         if(stime->flag & TIME_DRAWFRAMES)
296                 uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Show Seconds|T", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 5, "");
297         else 
298                 uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Show Frames|T", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 5, "");
299         
300         uiDefIconTextBut(block, BUTM, 1, (stime->flag & TIME_ONLYACTSEL)?ICON_CHECKBOX_HLT:ICON_CHECKBOX_DEHLT, 
301                                          "Only Selected Data Keys|", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 12, "");
302         
303         uiDefBut(block, SEPR, 0, "",        0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
304         
305         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Jump To Next Marker|PageUp", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 6, "");
306         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Jump To Prev Marker|PageDown", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 7, "");
307         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Jump To Next Key|Ctrl PageUp", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 8, "");
308         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Jump To Prev Key|Ctrl PageDown", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 9, "");
309         
310         uiDefBut(block, SEPR, 0, "",        0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
311         
312         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Center View|C", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 10, "");
313         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "View All|Home", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 3, "");
314         uiDefIconTextBut(block, BUTM, 1, (G.v2d->flag & V2D_VIEWLOCK)?ICON_CHECKBOX_HLT:ICON_CHECKBOX_DEHLT, 
315                                          "Lock Time to Other Windows|", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 11, "");
316         
317         if (!curarea->full) 
318                 uiDefIconTextBut(block, BUTM, B_FULL, ICON_BLANK1, "Maximize Window|Ctrl UpArrow", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 4, "");
319         else 
320                 uiDefIconTextBut(block, BUTM, B_FULL, ICON_BLANK1, "Tile Window|Ctrl DownArrow", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 4, "");
321         
322         if(curarea->headertype==HEADERTOP) {
323                 uiBlockSetDirection(block, UI_DOWN);
324         }
325         else {
326                 uiBlockSetDirection(block, UI_TOP);
327                 uiBlockFlipOrder(block);
328         }
329
330         uiTextBoundsBlock(block, 50);
331         
332         return block;
333 }
334
335 static void do_time_framemenu(void *arg, int event)
336 {
337         switch(event) {
338                 case 1: /*Set as Start */
339                         if (G.scene->r.psfra) {
340                                 if (G.scene->r.pefra < CFRA)
341                                         G.scene->r.pefra= CFRA;
342                                 G.scene->r.psfra= CFRA;
343                         }                               
344                         else
345                                 G.scene->r.sfra = CFRA;
346                         allqueue(REDRAWALL, 1);
347                         break;
348                 case 2: /* Set as End */
349                         if (G.scene->r.psfra) {
350                                 if (CFRA < G.scene->r.psfra)
351                                         G.scene->r.psfra= CFRA;
352                                 G.scene->r.pefra= CFRA;
353                         }                               
354                         else
355                                 G.scene->r.efra = CFRA;
356                         allqueue(REDRAWALL, 1);
357                         break;
358                 case 3: /* Add Marker */
359                         add_marker(CFRA);
360                         break;
361                 case 4: /* Remove Marker */
362                         remove_marker();
363                         break;
364                 case 5: /* Rename Marker */
365                         rename_marker();
366                         break;
367                 case 6: /* Grab Marker */
368                         transform_markers('g', 0);
369                         break;
370                 case 7: /* duplicate marker */
371                         duplicate_marker();
372                         break;
373         }
374         allqueue(REDRAWTIME, 0);
375         allqueue(REDRAWIPO, 0);
376         allqueue(REDRAWACTION, 0);
377         allqueue(REDRAWNLA, 0);
378         allqueue(REDRAWSOUND, 0);
379 }
380
381 static uiBlock *time_framemenu(void *arg_unused)
382 {
383         uiBlock *block;
384         short yco= 0, menuwidth=120;
385         
386         block= uiNewBlock(&curarea->uiblocks, "time_framemenu", 
387                                           UI_EMBOSSP, UI_HELV, curarea->headwin);
388         uiBlockSetButmFunc(block, do_time_framemenu, NULL);
389         
390         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Add Marker|M", 0, yco-=20, 
391                                          menuwidth, 19, NULL, 0.0, 0.0, 1, 3, "");
392         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Duplicate Marker|Shift D", 0, yco-=20, 
393                                          menuwidth, 19, NULL, 0.0, 0.0, 1, 7, "");
394         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Delete Marker|X", 0, yco-=20,
395                                          menuwidth, 19, NULL, 0.0, 0.0, 1, 4, "");
396                                          
397         uiDefBut(block, SEPR, 0, "",        0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
398
399         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Name Marker|Ctrl M", 0, yco-=20,
400                                          menuwidth, 19, NULL, 0.0, 0.0, 1, 5, "");
401         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Grab/Move Marker|G", 0, yco-=20,
402                                          menuwidth, 19, NULL, 0.0, 0.0, 1, 6, "");
403                                          
404         uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
405         
406         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Set as Start|S", 0, yco-=20, 
407                                          menuwidth, 19, NULL, 0.0, 0.0, 1, 1, "");
408         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Set as End|E", 0, yco-=20,
409                                          menuwidth, 19, NULL, 0.0, 0.0, 1, 2, "");
410
411         if(curarea->headertype==HEADERTOP) {
412                 uiBlockSetDirection(block, UI_DOWN);
413         }
414         else {
415                 uiBlockSetDirection(block, UI_TOP);
416                 uiBlockFlipOrder(block);
417         }
418
419         uiTextBoundsBlock(block, 50);
420         
421         return block;
422 }
423
424 void time_buttons(ScrArea *sa)
425 {
426         SpaceTime *stime= sa->spacedata.first;
427         uiBlock *block;
428         short xco, xmax;
429         char name[256];
430         
431         sprintf(name, "header %d", sa->headwin);
432         block= uiNewBlock(&sa->uiblocks, name, UI_EMBOSS, UI_HELV, sa->headwin);
433
434         if(area_is_active_area(sa)) uiBlockSetCol(block, TH_HEADER);
435         else uiBlockSetCol(block, TH_HEADERDESEL);
436         
437         sa->butspacetype= SPACE_TIME;
438
439         xco = 8;
440         
441         uiDefIconTextButC(block, ICONTEXTROW,B_NEWSPACE, ICON_VIEW3D, 
442                                           windowtype_pup(), xco, 0, XIC+10, YIC, 
443                                           &(sa->butspacetype), 1.0, SPACEICONMAX, 0, 0, 
444                                           "Displays Current Window Type. "
445                                           "Click for menu of available types.");
446
447         xco += XIC + 14;
448
449         uiBlockSetEmboss(block, UI_EMBOSSN);
450         if (sa->flag & HEADER_NO_PULLDOWN) {
451                 uiDefIconButBitS(block, TOG, HEADER_NO_PULLDOWN, B_FLIPINFOMENU, 
452                                           ICON_DISCLOSURE_TRI_RIGHT,
453                                           xco,2,XIC,YIC-2,
454                                           &(sa->flag), 0, 0, 0, 0, 
455                                           "Show pulldown menus");
456         }
457         else {
458                 uiDefIconButBitS(block, TOG, HEADER_NO_PULLDOWN, B_FLIPINFOMENU, 
459                                           ICON_DISCLOSURE_TRI_DOWN,
460                                           xco,2,XIC,YIC-2,
461                                           &(sa->flag), 0, 0, 0, 0, 
462                                           "Hide pulldown menus");
463         }
464         uiBlockSetEmboss(block, UI_EMBOSS);
465         xco+=XIC;
466
467         if((sa->flag & HEADER_NO_PULLDOWN)==0) {
468                 /* pull down menus */
469                 uiBlockSetEmboss(block, UI_EMBOSSP);
470         
471                 xmax= GetButStringLength("View");
472                 uiDefPulldownBut(block, time_viewmenu, NULL, 
473                                           "View", xco, -2, xmax-3, 24, "");
474                 xco+= xmax;
475                 xmax= GetButStringLength("Frame");
476                 uiDefPulldownBut(block, time_framemenu, NULL, 
477                                           "Frame", xco, -2, xmax-3, 24, "");
478                 xco+= xmax;
479
480                 xmax= GetButStringLength("Playback");
481                 uiDefPulldownBut(block, time_redrawmenu, NULL, 
482                                                  "Playback", xco, -2, xmax-3, 24, "");
483                 xco+= xmax;
484         }
485
486         uiBlockSetEmboss(block, UI_EMBOSS);
487         
488         uiBlockBeginAlign(block);
489         
490         uiDefButI(block, TOG, B_TL_PREVIEWON,"Preview", 
491                 xco,0, XIC, YIC,
492                 &G.scene->r.psfra,0, 1, 0, 0,
493                 "Show settings for frame range of animation preview");
494                 
495         xco += XIC;
496         
497         if (G.scene->r.psfra) {
498                 uiDefButI(block, NUM, REDRAWALL,"Start:",       
499                         xco,0, 4.5*XIC, YIC,
500                         &G.scene->r.psfra,MINFRAMEF, MAXFRAMEF, 0, 0,
501                         "The start frame of the animation preview (inclusive)");
502
503                 xco += (short)(4.5*XIC);
504
505                 uiDefButI(block, NUM, REDRAWALL,"End:", 
506                         xco,0,4.5*XIC,YIC,
507                         &G.scene->r.pefra,PSFRA,MAXFRAMEF, 0, 0,
508                         "The end frame of the animation preview (inclusive)");
509         }
510         else {
511                 uiDefButI(block, NUM, REDRAWALL,"Start:",       
512                 xco,0, 4.5*XIC, YIC,
513                 &G.scene->r.sfra,MINFRAMEF, MAXFRAMEF, 0, 0,
514                 "The start frame of the animation (inclusive)");
515
516                 xco += (short)(4.5*XIC);
517
518                 uiDefButI(block, NUM, REDRAWALL,"End:", 
519                         xco,0,4.5*XIC,YIC,
520                         &G.scene->r.efra,(float)SFRA,MAXFRAMEF, 0, 0,
521                         "The end frame of the animation (inclusive)");
522         }
523         uiBlockEndAlign(block);
524
525         xco += (short)(4.5 * XIC + 16);
526         
527         uiDefButI(block, NUM, B_NEWFRAME, "",
528                 xco,0,3.5*XIC,YIC,
529                 &(G.scene->r.cfra), MINFRAMEF, MAXFRAMEF, 0, 0,
530                 "Displays Current Frame of animation");
531         
532         xco += (short)(3.5 * XIC + 16);
533         
534         uiDefIconBut(block, BUT, B_TL_REW, ICON_REW,
535                         xco, 0, XIC, YIC, 0, 0, 0, 0, 0, "Skip to Start frame (Shift DownArrow)");
536         xco+= XIC+4;
537         uiDefIconBut(block, BUT, B_TL_PREVKEY, ICON_PREV_KEYFRAME,
538                         xco, 0, XIC, YIC, 0, 0, 0, 0, 0, "Skip to previous keyframe (Ctrl PageDown)");
539         xco+= XIC+4;
540         
541         if(has_screenhandler(G.curscreen, SCREEN_HANDLER_ANIM))
542            uiDefIconBut(block, BUT, B_TL_STOP, ICON_PAUSE,
543                         xco, 0, XIC, YIC, 0, 0, 0, 0, 0, "Stop Playing Timeline");
544         else       
545                 uiDefIconBut(block, BUT, B_TL_PLAY, ICON_PLAY,
546                         xco, 0, XIC, YIC, 0, 0, 0, 0, 0, "Play Timeline ");
547         
548         xco+= XIC+4;
549         uiDefIconBut(block, BUT, B_TL_NEXTKEY, ICON_NEXT_KEYFRAME,
550                         xco, 0, XIC, YIC, 0, 0, 0, 0, 0, "Skip to next keyframe (Ctrl PageUp)");
551         xco+= XIC+4;
552         uiDefIconBut(block, BUT, B_TL_FF, ICON_FF,
553                         xco, 0, XIC, YIC, 0, 0, 0, 0, 0, "Skip to End frame (Shift UpArrow)");
554         xco+= XIC+8;
555         
556         uiDefIconButBitS(block, TOG, AUTOKEY_ON, REDRAWINFO, ICON_REC,
557                         xco, 0, XIC, YIC, &(G.scene->autokey_mode), 0, 0, 0, 0, "Automatic keyframe insertion for Objects and Bones");
558         xco+= XIC;
559         if (IS_AUTOKEY_ON) {
560                 uiDefButS(block, MENU, REDRAWINFO, 
561                                         "Auto-Keying Mode %t|Add/Replace Keys%x3|Replace Keys %x5", 
562                                         xco, 0, 3.5*XIC, YIC, &(G.scene->autokey_mode), 0, 1, 0, 0, 
563                                         "Mode of automatic keyframe insertion for Objects and Bones");
564                 xco+= (4*XIC);
565         }
566         
567         xco+= 16;
568         
569         uiDefIconBut(block, BUT, B_TL_INSERTKEY, ICON_KEY_HLT,
570                         xco, 0, XIC, YIC, 0, 0, 0, 0, 0, "Insert Keyframe for the context of the largest area (IKEY)");
571         xco+= XIC+4;
572         uiDefIconBut(block, BUT, B_TL_DELETEKEY, ICON_KEY_DEHLT,
573                         xco, 0, XIC, YIC, 0, 0, 0, 0, 0, "Delete Keyframe for the context of the largest area (ALTKEY-IKEY)");
574         xco+= XIC+4;
575         
576         xco+= 16;
577         
578         uiDefIconButBitI(block, TOG, TIME_WITH_SEQ_AUDIO, B_DIFF, ICON_SPEAKER,
579                                          xco, 0, XIC, YIC, &(stime->redraws), 0, 0, 0, 0, "Play back and sync with audio from Sequence Editor");
580         
581         
582         /* always as last  */
583         sa->headbutlen= xco+XIC+80; // +80 because the last button is not an icon
584
585         uiDrawBlock(block);
586 }