2 * header_nla.c oct-2003
4 * Functions to draw the "NLA Editor" window header
5 * and handle user events sent to it.
9 * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation; either version 2
14 * of the License, or (at your option) any later version. The Blender
15 * Foundation also sells licenses for use in proprietary software under
16 * the Blender License. See http://www.blender.org/BL/ for information
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, write to the Free Software Foundation,
26 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
28 * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
29 * All rights reserved.
31 * The Original Code is: all of this file.
33 * Contributor(s): none yet.
35 * ***** END GPL/BL DUAL LICENSE BLOCK *****
47 #include "DNA_nla_types.h"
48 #include "DNA_scene_types.h"
49 #include "DNA_screen_types.h"
50 #include "DNA_space_types.h"
52 #include "BKE_global.h"
54 #include "BKE_utildefines.h"
56 #include "BIF_interface.h"
57 #include "BIF_resources.h"
58 #include "BIF_screen.h"
59 #include "BIF_space.h"
60 #include "BIF_editnla.h"
62 #include "BSE_drawipo.h"
63 #include "BSE_headerbuttons.h"
70 void do_nla_buttons(unsigned short event)
79 /* i tried to understand nla/action drawing to reveil a 'tot' rect, impossible code! (ton) */
80 v2d->cur.xmin = G.scene->r.sfra-5;
81 v2d->cur.xmax = G.scene->r.efra+5;
82 v2d->cur.ymin= -SCROLLB;
83 v2d->cur.ymax= 5; // at least stuff is visiable then?
85 test_view2d(G.v2d, curarea->winx, curarea->winy);
86 addqueue (curarea->win, REDRAW, 1);
92 static void do_nla_viewmenu(void *arg, int event)
94 extern int play_anim(int mode);
97 case 0: /* Update Automatically */
98 if(BTST(G.snla->lock, 0)) G.snla->lock = BCLR(G.snla->lock, 0);
99 else G.snla->lock = BSET(G.snla->lock, 0);
101 case 1: /* Play Back Animation */
104 case 2: /* Play Back Animation in 3D View */
107 case 3: /* View All */
108 do_nla_buttons(B_NLAHOME);
110 case 4: /* Maximize Window */
111 /* using event B_FULL */
116 static uiBlock *nla_viewmenu(void *arg_unused)
118 /* static short tog=0; */
120 short yco= 0, menuwidth=120;
122 block= uiNewBlock(&curarea->uiblocks, "nla_viewmenu", UI_EMBOSSP, UI_HELV, curarea->headwin);
123 uiBlockSetButmFunc(block, do_nla_viewmenu, NULL);
125 if(BTST(G.snla->lock, 0)) {
126 uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_HLT, "Update Automatically|", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 0, "");
128 uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_DEHLT, "Update Automatically|", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 0, "");
131 uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
133 uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Play Back Animation|Alt A", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 1, "");
134 uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Play Back Animation in 3D View|Alt Shift A", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 2, "");
136 uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
138 uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "View All|Home", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 3, "");
140 if(!curarea->full) uiDefIconTextBut(block, BUTM, B_FULL, ICON_BLANK1, "Maximize Window|Ctrl UpArrow", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 4, "");
141 else uiDefIconTextBut(block, BUTM, B_FULL, ICON_BLANK1, "Tile Window|Ctrl DownArrow", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 4, "");
143 if(curarea->headertype==HEADERTOP) {
144 uiBlockSetDirection(block, UI_DOWN);
147 uiBlockSetDirection(block, UI_TOP);
148 uiBlockFlipOrder(block);
151 uiTextBoundsBlock(block, 50);
156 static void do_nla_selectmenu(void *arg, int event)
161 case 0: /* Border Select */
164 case 1: /* Select/Deselect All Keys */
165 deselect_nlachannel_keys(1);
166 allqueue (REDRAWNLA, 0);
167 allqueue (REDRAWIPO, 0);
169 case 2: /* Select/Deselect All Channel */
170 deselect_nlachannels(1);
171 allqueue (REDRAWVIEW3D, 0);
172 allqueue (REDRAWNLA, 0);
173 allqueue (REDRAWIPO, 0);
178 static uiBlock *nla_selectmenu(void *arg_unused)
181 short yco= 0, menuwidth=120;
183 block= uiNewBlock(&curarea->uiblocks, "nla_selectmenu", UI_EMBOSSP, UI_HELV, curarea->headwin);
184 uiBlockSetButmFunc(block, do_nla_selectmenu, NULL);
186 uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Border Select|B", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 0, "");
188 uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
190 uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Select/Deselect All Keys|A", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 1, "");
191 uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Select/Deselect All Channels", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 2, "");
193 if(curarea->headertype==HEADERTOP) {
194 uiBlockSetDirection(block, UI_DOWN);
197 uiBlockSetDirection(block, UI_TOP);
198 uiBlockFlipOrder(block);
201 uiTextBoundsBlock(block, 50);
206 static void do_nla_strip_transformmenu(void *arg, int event)
209 case 0: /* grab/move */
210 transform_nlachannel_keys ('g', 0);
211 update_for_newframe_muted();
214 transform_nlachannel_keys ('s', 0);
215 update_for_newframe_muted();
218 allqueue(REDRAWVIEW3D, 0);
221 static uiBlock *nla_strip_transformmenu(void *arg_unused)
224 short yco = 20, menuwidth = 120;
226 block= uiNewBlock(&curarea->uiblocks, "nla_strip_transformmenu", UI_EMBOSSP, UI_HELV, G.curscreen->mainwin);
227 uiBlockSetButmFunc(block, do_nla_strip_transformmenu, NULL);
229 uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Grab/Move|G", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 0, "");
230 uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Scale|S", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 1, "");
232 uiBlockSetDirection(block, UI_RIGHT);
233 uiTextBoundsBlock(block, 60);
237 static void do_nla_stripmenu(void *arg, int event)
241 case 0: /* Strip Properties */
242 add_blockhandler(curarea, NLA_HANDLER_PROPERTIES, UI_PNL_UNSTOW);
244 case 1: /* Add Action Strip */
246 case 2: /* Duplicate */
247 duplicate_nlachannel_keys();
248 update_for_newframe_muted();
250 case 3: /* Delete Strips */
251 delete_nlachannel_keys ();
252 update_for_newframe_muted();
254 case 5: /* Convert Action to NLA Strip */
256 case 6: /* Move Up */
257 shift_nlastrips_up();
259 case 7: /* Move Down */
260 shift_nlastrips_down();
265 static uiBlock *nla_stripmenu(void *arg_unused)
268 short yco= 0, menuwidth=120;
270 block= uiNewBlock(&curarea->uiblocks, "nla_stripmenu", UI_EMBOSSP, UI_HELV, curarea->headwin);
271 uiBlockSetButmFunc(block, do_nla_stripmenu, NULL);
273 uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Strip Properties...|N", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 0, "");
274 uiDefIconTextBlockBut(block, nla_strip_transformmenu, NULL, ICON_RIGHTARROW_THIN, "Transform", 0, yco-=20, 120, 20, "");
276 uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
278 // uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Add Action Strip|Shift A", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 1, "");
279 uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Duplicate|Shift D", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 2, "");
280 uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Delete|X", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 3, "");
281 // uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
283 uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
285 uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Move Up|Page Down", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 6, "");
286 uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Move Down|Page Up", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 7, "");
288 // uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Convert Action to NLA Strip|C", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 5, "");
290 if(curarea->headertype==HEADERTOP) {
291 uiBlockSetDirection(block, UI_DOWN);
294 uiBlockSetDirection(block, UI_TOP);
295 uiBlockFlipOrder(block);
298 uiTextBoundsBlock(block, 50);
303 void nla_buttons(void)
310 snla= curarea->spacedata.first;
312 sprintf(naam, "header %d", curarea->headwin);
313 block= uiNewBlock(&curarea->uiblocks, naam, UI_EMBOSS, UI_HELV, curarea->headwin);
315 if(area_is_active_area(curarea)) uiBlockSetCol(block, TH_HEADER);
316 else uiBlockSetCol(block, TH_HEADERDESEL);
318 curarea->butspacetype= SPACE_NLA;
322 uiDefIconTextButC(block, ICONTEXTROW,B_NEWSPACE, ICON_VIEW3D, windowtype_pup(), xco,0,XIC+10,YIC, &(curarea->butspacetype), 1.0, SPACEICONMAX, 0, 0, "Displays Current Window Type. Click for menu of available types.");
326 uiBlockSetEmboss(block, UI_EMBOSSN);
327 if(curarea->flag & HEADER_NO_PULLDOWN) {
328 uiDefIconButBitS(block, TOG, HEADER_NO_PULLDOWN, B_FLIPINFOMENU, ICON_DISCLOSURE_TRI_RIGHT,
330 &(curarea->flag), 0, 0, 0, 0, "Show pulldown menus");
332 uiDefIconButBitS(block, TOG, HEADER_NO_PULLDOWN, B_FLIPINFOMENU, ICON_DISCLOSURE_TRI_DOWN,
334 &(curarea->flag), 0, 0, 0, 0, "Hide pulldown menus");
336 uiBlockSetEmboss(block, UI_EMBOSS);
339 if((curarea->flag & HEADER_NO_PULLDOWN)==0) {
340 /* pull down menus */
341 uiBlockSetEmboss(block, UI_EMBOSSP);
343 xmax= GetButStringLength("View");
344 uiDefPulldownBut(block, nla_viewmenu, NULL, "View", xco, -2, xmax-3, 24, "");
347 xmax= GetButStringLength("Select");
348 uiDefPulldownBut(block, nla_selectmenu, NULL, "Select", xco, -2, xmax-3, 24, "");
351 xmax= GetButStringLength("Strip");
352 uiDefPulldownBut(block, nla_stripmenu, NULL, "Strip", xco, -2, xmax-3, 24, "");
357 uiBlockSetEmboss(block, UI_EMBOSS);
365 // uiDefIconTextButC(block, ICONTEXTROW,B_NEWSPACE, ICON_VIEW3D, windowtype_pup(), xco,0,XIC+10,YIC, &(curarea->butspacetype), 1.0, SPACEICONMAX, 0, 0, "Displays Current Window Type. Click for menu of available types.");
370 // if(curarea->full) uiDefIconBut(block, BUT,B_FULL, ICON_SPLITSCREEN, xco,0,XIC,YIC, 0, 0, 0, 0, 0, "Returns to multiple views window (CTRL+Up arrow)");
371 // else uiDefIconBut(block, BUT,B_FULL, ICON_FULLSCREEN, xco,0,XIC,YIC, 0, 0, 0, 0, 0, "Makes current window full screen (CTRL+Down arrow)");
374 // uiDefIconBut(block, BUT, B_NLAHOME, ICON_HOME, xco+=XIC,0,XIC,YIC, 0, 0, 0, 0, 0, "Zooms window to home view showing all items (HOMEKEY)");
378 // uiDefIconButS(block, TOG, B_REDR, ICON_IMAGE_COL, xco+=XIC,0,XIC,YIC, &sseq->mainb, 0, 0, 0, 0, "Toggles image display");
382 // uiDefIconButI(block, TOG, B_VIEW2DZOOM, ICON_VIEWZOOM, xco+=XIC,0,XIC,YIC, &viewmovetemp, 0, 0, 0, 0, "Zoom view (CTRL+MiddleMouse)");
383 // uiDefIconBut(block, BUT, B_NLABORDER, ICON_BORDERMOVE, xco+=XIC,0,XIC,YIC, 0, 0, 0, 0, 0, "Zoom view to area");
390 uiDefIconButS(block, ICONTOG, 1, ICON_UNLOCKED, xco,0,XIC,YIC, &(snla->lock), 0, 0, 0, 0, "Toggles forced redraw of other windows to reflect changes in real time");