5 * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
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. The Blender
11 * Foundation also sells licenses for use in proprietary software under
12 * the Blender License. See http://www.blender.org/BL/ for information
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software Foundation,
22 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 * The Original Code is Copyright (C) 2005 Blender Foundation.
25 * All rights reserved.
27 * The Original Code is: all of this file.
29 * Contributor(s): none yet.
31 * ***** END GPL/BL DUAL LICENSE BLOCK *****
43 #include "DNA_screen_types.h"
44 #include "DNA_scene_types.h"
45 #include "DNA_space_types.h"
46 #include "DNA_view2d_types.h"
47 #include "DNA_userdef_types.h"
50 #include "BIF_interface.h"
51 #include "BIF_resources.h"
52 #include "BIF_screen.h"
53 #include "BIF_space.h"
54 #include "BIF_toolbox.h"
55 #include "BIF_butspace.h"
57 #include "BKE_global.h"
60 #include "BSE_drawipo.h"
61 #include "BSE_drawview.h"
62 #include "BSE_editipo.h"
63 #include "BSE_filesel.h"
64 #include "BSE_headerbuttons.h"
65 #include "BSE_seqaudio.h"
72 void do_time_buttons(ScrArea *sa, unsigned short event)
74 SpaceTime *stime= sa->spacedata.first;
80 update_for_newframe();
83 add_screenhandler(G.curscreen, SCREEN_HANDLER_ANIM, stime->redraws);
84 if(stime->redraws & TIME_WITH_SEQ_AUDIO)
85 audiostream_start( CFRA );
89 rem_screenhandler(G.curscreen, SCREEN_HANDLER_ANIM);
90 if(stime->redraws & TIME_WITH_SEQ_AUDIO)
92 allqueue(REDRAWALL, 0);
98 update_for_newframe();
101 /* previous keyframe */
102 nextprev_timeline_key(-1);
106 nextprev_timeline_key(1);
111 static void do_time_redrawmenu(void *arg, int event)
113 SpaceTime *stime= curarea->spacedata.first;
117 stime->redraws ^= event;
118 /* update handler when it's running */
119 if(has_screenhandler(G.curscreen, SCREEN_HANDLER_ANIM))
120 add_screenhandler(G.curscreen, SCREEN_HANDLER_ANIM, stime->redraws);
124 button(&G.scene->r.frs_sec,1,120,"Frames/Second:");
130 static uiBlock *time_redrawmenu(void *arg_unused)
132 SpaceTime *stime= curarea->spacedata.first;
134 short yco= 0, menuwidth=120, icon;
137 block= uiNewBlock(&curarea->uiblocks, "time_redrawmenu",
138 UI_EMBOSSP, UI_HELV, curarea->headwin);
139 uiBlockSetButmFunc(block, do_time_redrawmenu, NULL);
141 if(stime->redraws & TIME_LEFTMOST_3D_WIN) icon= ICON_CHECKBOX_HLT;
142 else icon= ICON_CHECKBOX_DEHLT;
143 uiDefIconTextBut(block, BUTM, 1, icon, "Top-Left 3D Window", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, TIME_LEFTMOST_3D_WIN, "");
145 if(stime->redraws & TIME_ALL_3D_WIN) icon= ICON_CHECKBOX_HLT;
146 else icon= ICON_CHECKBOX_DEHLT;
147 uiDefIconTextBut(block, BUTM, 1, icon, "All 3D Windows", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, TIME_ALL_3D_WIN, "");
149 if(stime->redraws & TIME_ALL_ANIM_WIN) icon= ICON_CHECKBOX_HLT;
150 else icon= ICON_CHECKBOX_DEHLT;
151 uiDefIconTextBut(block, BUTM, 1, icon, "Animation Windows", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, TIME_ALL_ANIM_WIN, "");
153 if(stime->redraws & TIME_ALL_BUTS_WIN) icon= ICON_CHECKBOX_HLT;
154 else icon= ICON_CHECKBOX_DEHLT;
155 uiDefIconTextBut(block, BUTM, 1, icon, "Buttons Windows", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, TIME_ALL_BUTS_WIN, "");
157 uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
159 sprintf(str, "Set Frames/Sec (%d)", G.scene->r.frs_sec);
160 uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, str, 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 1001, "");
163 if(curarea->headertype==HEADERTOP) {
164 uiBlockSetDirection(block, UI_DOWN);
167 uiBlockSetDirection(block, UI_TOP);
168 uiBlockFlipOrder(block);
171 uiTextBoundsBlock(block, 50);
176 static void do_time_viewmenu(void *arg, int event)
178 SpaceTime *stime= curarea->spacedata.first;
182 case 2: /* Play Back Animation */
183 add_screenhandler(G.curscreen, SCREEN_HANDLER_ANIM, stime->redraws);
185 case 3: /* View All */
186 first= G.scene->r.sfra;
187 if(first >= G.scene->r.efra) first= G.scene->r.efra;
188 G.v2d->cur.xmin=G.v2d->tot.xmin= (float)first-2;
189 G.v2d->cur.xmax=G.v2d->tot.xmax= (float)G.scene->r.efra+2;
191 test_view2d(G.v2d, curarea->winx, curarea->winy);
192 scrarea_queue_winredraw(curarea);
194 case 4: /* Maximize Window */
195 /* using event B_FULL */
197 case 5: /* show time or frames */
198 stime->flag ^= TIME_DRAWFRAMES;
201 nextprev_timeline_marker(1);
204 nextprev_timeline_marker(-1);
207 nextprev_timeline_key(1);
210 nextprev_timeline_key(-1);
213 timeline_frame_to_center();
216 G.v2d->flag ^= V2D_VIEWLOCK;
217 if(G.v2d->flag & V2D_VIEWLOCK)
218 view2d_do_locks(curarea, 0);
221 allqueue(REDRAWVIEW3D, 0);
224 static uiBlock *time_viewmenu(void *arg_unused)
226 SpaceTime *stime= curarea->spacedata.first;
228 short yco= 0, menuwidth=120;
230 block= uiNewBlock(&curarea->uiblocks, "time_viewmenu",
231 UI_EMBOSSP, UI_HELV, curarea->headwin);
232 uiBlockSetButmFunc(block, do_time_viewmenu, NULL);
234 uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Play Back Animation", 0, yco-=20,
235 menuwidth, 19, NULL, 0.0, 0.0, 1, 2, "");
237 uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
239 if(stime->flag & TIME_DRAWFRAMES)
240 uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Show Seconds|T", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 5, "");
242 uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Show Frames|T", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 5, "");
244 uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
246 uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Jump To Next Marker|PageUp", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 6, "");
247 uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Jump To Prev Marker|PageDown", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 7, "");
248 uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Jump To Next Key|Ctrl PageUp", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 8, "");
249 uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Jump To Prev Key|Ctrl PageDown", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 9, "");
251 uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
253 uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Center View|C", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 10, "");
254 uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "View All|Home", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 3, "");
255 uiDefIconTextBut(block, BUTM, 1, (G.v2d->flag & V2D_VIEWLOCK)?ICON_CHECKBOX_HLT:ICON_CHECKBOX_DEHLT,
256 "Lock Time to Other Windows|", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 11, "");
259 uiDefIconTextBut(block, BUTM, B_FULL, ICON_BLANK1, "Maximize Window|Ctrl UpArrow", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 4, "");
261 uiDefIconTextBut(block, BUTM, B_FULL, ICON_BLANK1, "Tile Window|Ctrl DownArrow", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 4, "");
263 if(curarea->headertype==HEADERTOP) {
264 uiBlockSetDirection(block, UI_DOWN);
267 uiBlockSetDirection(block, UI_TOP);
268 uiBlockFlipOrder(block);
271 uiTextBoundsBlock(block, 50);
276 static void do_time_framemenu(void *arg, int event)
279 case 1: /*Set as Start */
280 G.scene->r.sfra = CFRA;
281 allqueue(REDRAWALL, 1);
283 case 2: /* Set as End */
284 G.scene->r.efra = CFRA;
285 allqueue(REDRAWALL, 1);
287 case 3: /* Add Marker */
288 add_timeline_marker(CFRA);
290 case 4: /* Remove Marker */
291 remove_timeline_marker();
293 case 5: /* Rename Marker */
294 rename_timeline_marker();
296 case 6: /* Grab Marker */
297 timeline_grab('g', 0);
300 allqueue(REDRAWTIME, 0);
303 static uiBlock *time_framemenu(void *arg_unused)
306 short yco= 0, menuwidth=120;
308 block= uiNewBlock(&curarea->uiblocks, "time_framemenu",
309 UI_EMBOSSP, UI_HELV, curarea->headwin);
310 uiBlockSetButmFunc(block, do_time_framemenu, NULL);
312 uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Add Marker|M", 0, yco-=20,
313 menuwidth, 19, NULL, 0.0, 0.0, 1, 3, "");
314 uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Remove Marker|X", 0, yco-=20,
315 menuwidth, 19, NULL, 0.0, 0.0, 1, 4, "");
316 uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Name Marker|Ctrl M", 0, yco-=20,
317 menuwidth, 19, NULL, 0.0, 0.0, 1, 5, "");
318 uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Grab/move Marker|G", 0, yco-=20,
319 menuwidth, 19, NULL, 0.0, 0.0, 1, 6, "");
321 uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
323 uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Set as Start|S", 0, yco-=20,
324 menuwidth, 19, NULL, 0.0, 0.0, 1, 1, "");
325 uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Set as End|E", 0, yco-=20,
326 menuwidth, 19, NULL, 0.0, 0.0, 1, 2, "");
328 if(curarea->headertype==HEADERTOP) {
329 uiBlockSetDirection(block, UI_DOWN);
332 uiBlockSetDirection(block, UI_TOP);
333 uiBlockFlipOrder(block);
336 uiTextBoundsBlock(block, 50);
341 void time_buttons(ScrArea *sa)
343 SpaceTime *stime= sa->spacedata.first;
348 sprintf(name, "header %d", sa->headwin);
349 block= uiNewBlock(&sa->uiblocks, name, UI_EMBOSS, UI_HELV, sa->headwin);
351 if(area_is_active_area(sa)) uiBlockSetCol(block, TH_HEADER);
352 else uiBlockSetCol(block, TH_HEADERDESEL);
354 sa->butspacetype= SPACE_TIME;
358 uiDefIconTextButC(block, ICONTEXTROW,B_NEWSPACE, ICON_VIEW3D,
359 windowtype_pup(), xco, 0, XIC+10, YIC,
360 &(sa->butspacetype), 1.0, SPACEICONMAX, 0, 0,
361 "Displays Current Window Type. "
362 "Click for menu of available types.");
366 uiBlockSetEmboss(block, UI_EMBOSSN);
367 if (sa->flag & HEADER_NO_PULLDOWN) {
368 uiDefIconButBitS(block, TOG, HEADER_NO_PULLDOWN, B_FLIPINFOMENU,
369 ICON_DISCLOSURE_TRI_RIGHT,
371 &(sa->flag), 0, 0, 0, 0,
372 "Show pulldown menus");
375 uiDefIconButBitS(block, TOG, HEADER_NO_PULLDOWN, B_FLIPINFOMENU,
376 ICON_DISCLOSURE_TRI_DOWN,
378 &(sa->flag), 0, 0, 0, 0,
379 "Hide pulldown menus");
381 uiBlockSetEmboss(block, UI_EMBOSS);
384 if((sa->flag & HEADER_NO_PULLDOWN)==0) {
385 /* pull down menus */
386 uiBlockSetEmboss(block, UI_EMBOSSP);
388 xmax= GetButStringLength("View");
389 uiDefPulldownBut(block, time_viewmenu, NULL,
390 "View", xco, -2, xmax-3, 24, "");
392 xmax= GetButStringLength("Frame");
393 uiDefPulldownBut(block, time_framemenu, NULL,
394 "Frame", xco, -2, xmax-3, 24, "");
397 xmax= GetButStringLength("Playback");
398 uiDefPulldownBut(block, time_redrawmenu, NULL,
399 "Playback", xco, -2, xmax-3, 24, "");
403 uiBlockSetEmboss(block, UI_EMBOSS);
405 uiBlockBeginAlign(block);
406 uiDefButS(block, NUM, REDRAWALL,"Start:",
408 &G.scene->r.sfra,MINFRAMEF, MAXFRAMEF, 0, 0,
409 "The start frame of the animation");
413 uiDefButS(block, NUM, REDRAWALL,"End:",
415 &G.scene->r.efra,MINFRAMEF,MAXFRAMEF, 0, 0,
416 "The end frame of the animation");
417 uiBlockEndAlign(block);
421 uiDefButS(block, NUM, B_NEWFRAME, "",
423 &(G.scene->r.cfra), MINFRAMEF, MAXFRAMEF, 0, 0,
424 "Displays Current Frame of animation. Click to change.");
428 uiDefIconBut(block, BUT, B_TL_REW, ICON_REW,
429 xco, 0, XIC, YIC, 0, 0, 0, 0, 0, "Skip to Start frame (Shift DownArrow)");
431 uiDefIconBut(block, BUT, B_TL_PREVKEY, ICON_PREV_KEYFRAME,
432 xco, 0, XIC, YIC, 0, 0, 0, 0, 0, "Skip to previous keyframe (Ctrl PageDown)");
435 if(has_screenhandler(G.curscreen, SCREEN_HANDLER_ANIM))
436 uiDefIconBut(block, BUT, B_TL_STOP, ICON_PAUSE,
437 xco, 0, XIC, YIC, 0, 0, 0, 0, 0, "Stop Playing Timeline");
439 uiDefIconBut(block, BUT, B_TL_PLAY, ICON_PLAY,
440 xco, 0, XIC, YIC, 0, 0, 0, 0, 0, "Play Timeline ");
443 uiDefIconBut(block, BUT, B_TL_NEXTKEY, ICON_NEXT_KEYFRAME,
444 xco, 0, XIC, YIC, 0, 0, 0, 0, 0, "Skip to next keyframe (Ctrl PageUp)");
446 uiDefIconBut(block, BUT, B_TL_FF, ICON_FF,
447 xco, 0, XIC, YIC, 0, 0, 0, 0, 0, "Skip to End frame (Shift UpArrow)");
450 uiDefIconButBitI(block, TOG, G_RECORDKEYS, REDRAWINFO, ICON_REC,
451 xco, 0, XIC, YIC, &(G.flags), 0, 0, 0, 0, "Automatically insert keyframes in Object and Action Ipo curves");
455 uiDefIconButBitI(block, TOG, TIME_WITH_SEQ_AUDIO, B_DIFF, ICON_SPEAKER,
456 xco, 0, XIC, YIC, &(stime->redraws), 0, 0, 0, 0, "Play back and sync with audio from Sequence Editor");
459 sa->headbutlen= xco+2*XIC;