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 allqueue(REDRAWVIEW3D, 0);
219 static uiBlock *time_viewmenu(void *arg_unused)
221 SpaceTime *stime= curarea->spacedata.first;
223 short yco= 0, menuwidth=120;
225 block= uiNewBlock(&curarea->uiblocks, "time_viewmenu",
226 UI_EMBOSSP, UI_HELV, curarea->headwin);
227 uiBlockSetButmFunc(block, do_time_viewmenu, NULL);
229 uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Play Back Animation", 0, yco-=20,
230 menuwidth, 19, NULL, 0.0, 0.0, 1, 2, "");
232 uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
234 if(stime->flag & TIME_DRAWFRAMES)
235 uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Show Seconds|T", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 5, "");
237 uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Show Frames|T", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 5, "");
239 uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
241 uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Jump To Next Marker|PageUp", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 6, "");
242 uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Jump To Prev Marker|PageDown", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 7, "");
243 uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Jump To Next Key|Ctrl PageUp", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 8, "");
244 uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Jump To Prev Key|Ctrl PageDown", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 9, "");
246 uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
248 uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Center View|C", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 10, "");
249 uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "View All|Home", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 3, "");
252 uiDefIconTextBut(block, BUTM, B_FULL, ICON_BLANK1, "Maximize Window|Ctrl UpArrow", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 4, "");
254 uiDefIconTextBut(block, BUTM, B_FULL, ICON_BLANK1, "Tile Window|Ctrl DownArrow", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 4, "");
256 if(curarea->headertype==HEADERTOP) {
257 uiBlockSetDirection(block, UI_DOWN);
260 uiBlockSetDirection(block, UI_TOP);
261 uiBlockFlipOrder(block);
264 uiTextBoundsBlock(block, 50);
269 static void do_time_framemenu(void *arg, int event)
272 case 1: /*Set as Start */
273 G.scene->r.sfra = CFRA;
274 allqueue(REDRAWALL, 1);
276 case 2: /* Set as End */
277 G.scene->r.efra = CFRA;
278 allqueue(REDRAWALL, 1);
280 case 3: /* Add Marker */
281 add_timeline_marker(CFRA);
283 case 4: /* Remove Marker */
284 remove_timeline_marker();
286 case 5: /* Rename Marker */
287 rename_timeline_marker();
289 case 6: /* Grab Marker */
290 timeline_grab('g', 0);
293 allqueue(REDRAWTIME, 0);
296 static uiBlock *time_framemenu(void *arg_unused)
299 short yco= 0, menuwidth=120;
301 block= uiNewBlock(&curarea->uiblocks, "time_framemenu",
302 UI_EMBOSSP, UI_HELV, curarea->headwin);
303 uiBlockSetButmFunc(block, do_time_framemenu, NULL);
305 uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Add Marker|M", 0, yco-=20,
306 menuwidth, 19, NULL, 0.0, 0.0, 1, 3, "");
307 uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Remove Marker|X", 0, yco-=20,
308 menuwidth, 19, NULL, 0.0, 0.0, 1, 4, "");
309 uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Name Marker|Ctrl M", 0, yco-=20,
310 menuwidth, 19, NULL, 0.0, 0.0, 1, 5, "");
311 uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Grab/move Marker|G", 0, yco-=20,
312 menuwidth, 19, NULL, 0.0, 0.0, 1, 6, "");
314 uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
316 uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Set as Start|S", 0, yco-=20,
317 menuwidth, 19, NULL, 0.0, 0.0, 1, 1, "");
318 uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Set as End|E", 0, yco-=20,
319 menuwidth, 19, NULL, 0.0, 0.0, 1, 2, "");
321 if(curarea->headertype==HEADERTOP) {
322 uiBlockSetDirection(block, UI_DOWN);
325 uiBlockSetDirection(block, UI_TOP);
326 uiBlockFlipOrder(block);
329 uiTextBoundsBlock(block, 50);
334 void time_buttons(ScrArea *sa)
336 SpaceTime *stime= sa->spacedata.first;
341 sprintf(name, "header %d", sa->headwin);
342 block= uiNewBlock(&sa->uiblocks, name, UI_EMBOSS, UI_HELV, sa->headwin);
344 if(area_is_active_area(sa)) uiBlockSetCol(block, TH_HEADER);
345 else uiBlockSetCol(block, TH_HEADERDESEL);
347 sa->butspacetype= SPACE_TIME;
351 uiDefIconTextButC(block, ICONTEXTROW,B_NEWSPACE, ICON_VIEW3D,
352 windowtype_pup(), xco, 0, XIC+10, YIC,
353 &(sa->butspacetype), 1.0, SPACEICONMAX, 0, 0,
354 "Displays Current Window Type. "
355 "Click for menu of available types.");
359 uiBlockSetEmboss(block, UI_EMBOSSN);
360 if (sa->flag & HEADER_NO_PULLDOWN) {
361 uiDefIconButBitS(block, TOG, HEADER_NO_PULLDOWN, B_FLIPINFOMENU,
362 ICON_DISCLOSURE_TRI_RIGHT,
364 &(sa->flag), 0, 0, 0, 0,
365 "Show pulldown menus");
368 uiDefIconButBitS(block, TOG, HEADER_NO_PULLDOWN, B_FLIPINFOMENU,
369 ICON_DISCLOSURE_TRI_DOWN,
371 &(sa->flag), 0, 0, 0, 0,
372 "Hide pulldown menus");
374 uiBlockSetEmboss(block, UI_EMBOSS);
377 if((sa->flag & HEADER_NO_PULLDOWN)==0) {
378 /* pull down menus */
379 uiBlockSetEmboss(block, UI_EMBOSSP);
381 xmax= GetButStringLength("View");
382 uiDefPulldownBut(block, time_viewmenu, NULL,
383 "View", xco, -2, xmax-3, 24, "");
385 xmax= GetButStringLength("Frame");
386 uiDefPulldownBut(block, time_framemenu, NULL,
387 "Frame", xco, -2, xmax-3, 24, "");
390 xmax= GetButStringLength("Playback");
391 uiDefPulldownBut(block, time_redrawmenu, NULL,
392 "Playback", xco, -2, xmax-3, 24, "");
396 uiBlockSetEmboss(block, UI_EMBOSS);
398 uiBlockBeginAlign(block);
399 uiDefButS(block, NUM, REDRAWALL,"Start:",
401 &G.scene->r.sfra,MINFRAMEF, MAXFRAMEF, 0, 0,
402 "The start frame of the animation");
406 uiDefButS(block, NUM, REDRAWALL,"End:",
408 &G.scene->r.efra,MINFRAMEF,MAXFRAMEF, 0, 0,
409 "The end frame of the animation");
410 uiBlockEndAlign(block);
414 uiDefButS(block, NUM, B_NEWFRAME, "",
416 &(G.scene->r.cfra), MINFRAMEF, MAXFRAMEF, 0, 0,
417 "Displays Current Frame of animation. Click to change.");
421 uiDefIconBut(block, BUT, B_TL_REW, ICON_REW,
422 xco, 0, XIC, YIC, 0, 0, 0, 0, 0, "Skip to Start frame (Shift DownArrow)");
424 uiDefIconBut(block, BUT, B_TL_PREVKEY, ICON_PREV_KEYFRAME,
425 xco, 0, XIC, YIC, 0, 0, 0, 0, 0, "Skip to previous keyframe (Ctrl PageDown)");
428 if(has_screenhandler(G.curscreen, SCREEN_HANDLER_ANIM))
429 uiDefIconBut(block, BUT, B_TL_STOP, ICON_PAUSE,
430 xco, 0, XIC, YIC, 0, 0, 0, 0, 0, "Stop Playing Timeline");
432 uiDefIconBut(block, BUT, B_TL_PLAY, ICON_PLAY,
433 xco, 0, XIC, YIC, 0, 0, 0, 0, 0, "Play Timeline ");
436 uiDefIconBut(block, BUT, B_TL_NEXTKEY, ICON_NEXT_KEYFRAME,
437 xco, 0, XIC, YIC, 0, 0, 0, 0, 0, "Skip to next keyframe (Ctrl PageUp)");
439 uiDefIconBut(block, BUT, B_TL_FF, ICON_FF,
440 xco, 0, XIC, YIC, 0, 0, 0, 0, 0, "Skip to End frame (Shift UpArrow)");
443 uiDefIconButBitI(block, TOG, G_RECORDKEYS, REDRAWINFO, ICON_REC,
444 xco, 0, XIC, YIC, &(G.flags), 0, 0, 0, 0, "Automatically insert keyframes in Object and Action Ipo curves");
448 uiDefIconButBitI(block, TOG, TIME_WITH_SEQ_AUDIO, B_DIFF, ICON_SPEAKER,
449 xco, 0, XIC, YIC, &(stime->redraws), 0, 0, 0, 0, "Play back and sync with audio from Sequence Editor");
452 sa->headbutlen= xco+2*XIC;