4 * ***** BEGIN GPL LICENSE BLOCK *****
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.
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.
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.
20 * The Original Code is Copyright (C) 2008 Blender Foundation.
21 * All rights reserved.
24 * Contributor(s): Blender Foundation
26 * ***** END GPL LICENSE BLOCK *****
32 #include "DNA_action_types.h"
33 #include "DNA_space_types.h"
34 #include "DNA_scene_types.h"
35 #include "DNA_screen_types.h"
36 #include "DNA_windowmanager_types.h"
38 #include "MEM_guardedalloc.h"
40 #include "BLI_blenlib.h"
42 #include "BKE_context.h"
43 #include "BKE_screen.h"
45 #include "ED_anim_api.h"
46 #include "ED_screen.h"
54 #include "BIF_glutil.h"
56 #include "UI_interface.h"
57 #include "UI_resources.h"
58 #include "UI_view2d.h"
60 #include "action_intern.h"
62 /* ********************************************************* */
70 } eActHeader_ButEvents;
72 // ---------------- menus
74 /* Key menu --------------------------- */
76 static void do_keymenu(bContext *C, void *arg, int event)
81 static uiBlock *action_keymenu(bContext *C, uiMenuBlockHandle *handle, void *arg_unused)
83 ScrArea *curarea= CTX_wm_area(C);
85 short yco= 0, menuwidth=120;
87 block= uiBeginBlock(C, handle->region, "dummy_keymenu", UI_EMBOSSP, UI_HELV);
88 uiBlockSetButmFunc(block, do_keymenu, NULL);
90 uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Nothing yet", 0, yco-=20,
91 menuwidth, 19, NULL, 0.0, 0.0, 1, 3, "");
93 if(curarea->headertype==HEADERTOP) {
94 uiBlockSetDirection(block, UI_DOWN);
97 uiBlockSetDirection(block, UI_TOP);
98 uiBlockFlipOrder(block);
101 uiTextBoundsBlock(block, 50);
102 uiEndBlock(C, block);
107 /* Frame menu --------------------------- */
109 static void do_framemenu(bContext *C, void *arg, int event)
114 static uiBlock *action_framemenu(bContext *C, uiMenuBlockHandle *handle, void *arg_unused)
116 ScrArea *curarea= CTX_wm_area(C);
118 short yco= 0, menuwidth=120;
120 block= uiBeginBlock(C, handle->region, "dummy_framemenu", UI_EMBOSSP, UI_HELV);
121 uiBlockSetButmFunc(block, do_framemenu, NULL);
123 uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Nothing yet", 0, yco-=20,
124 menuwidth, 19, NULL, 0.0, 0.0, 1, 3, "");
126 if(curarea->headertype==HEADERTOP) {
127 uiBlockSetDirection(block, UI_DOWN);
130 uiBlockSetDirection(block, UI_TOP);
131 uiBlockFlipOrder(block);
134 uiTextBoundsBlock(block, 50);
135 uiEndBlock(C, block);
140 /* Marker menu --------------------------- */
142 static void do_markermenu(bContext *C, void *arg, int event)
147 static uiBlock *action_markermenu(bContext *C, uiMenuBlockHandle *handle, void *arg_unused)
149 ScrArea *curarea= CTX_wm_area(C);
151 short yco= 0, menuwidth=120;
153 block= uiBeginBlock(C, handle->region, "dummy_markermenu", UI_EMBOSSP, UI_HELV);
154 uiBlockSetButmFunc(block, do_markermenu, NULL);
156 uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Nothing yet", 0, yco-=20,
157 menuwidth, 19, NULL, 0.0, 0.0, 1, 3, "");
159 if(curarea->headertype==HEADERTOP) {
160 uiBlockSetDirection(block, UI_DOWN);
163 uiBlockSetDirection(block, UI_TOP);
164 uiBlockFlipOrder(block);
167 uiTextBoundsBlock(block, 50);
168 uiEndBlock(C, block);
173 /* Grease Pencil --------------------------- */
175 static void do_gplayermenu(bContext *C, void *arg, int event)
180 static uiBlock *action_gplayermenu(bContext *C, uiMenuBlockHandle *handle, void *arg_unused)
182 ScrArea *curarea= CTX_wm_area(C);
184 short yco= 0, menuwidth=120;
186 block= uiBeginBlock(C, handle->region, "dummy_gplayermenu", UI_EMBOSSP, UI_HELV);
187 uiBlockSetButmFunc(block, do_gplayermenu, NULL);
189 uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Nothing yet", 0, yco-=20,
190 menuwidth, 19, NULL, 0.0, 0.0, 1, 3, "");
192 if(curarea->headertype==HEADERTOP) {
193 uiBlockSetDirection(block, UI_DOWN);
196 uiBlockSetDirection(block, UI_TOP);
197 uiBlockFlipOrder(block);
200 uiTextBoundsBlock(block, 50);
201 uiEndBlock(C, block);
206 /* Channel menu --------------------------- */
208 static void do_channelmenu(bContext *C, void *arg, int event)
213 static uiBlock *action_channelmenu(bContext *C, uiMenuBlockHandle *handle, void *arg_unused)
215 ScrArea *curarea= CTX_wm_area(C);
217 short yco= 0, menuwidth=120;
219 block= uiBeginBlock(C, handle->region, "dummy_channelmenu", UI_EMBOSSP, UI_HELV);
220 uiBlockSetButmFunc(block, do_channelmenu, NULL);
222 uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Nothing yet", 0, yco-=20,
223 menuwidth, 19, NULL, 0.0, 0.0, 1, 3, "");
225 if(curarea->headertype==HEADERTOP) {
226 uiBlockSetDirection(block, UI_DOWN);
229 uiBlockSetDirection(block, UI_TOP);
230 uiBlockFlipOrder(block);
233 uiTextBoundsBlock(block, 50);
234 uiEndBlock(C, block);
239 /* Select menu --------------------------- */
241 static void do_selectmenu(bContext *C, void *arg, int event)
246 static uiBlock *action_selectmenu(bContext *C, uiMenuBlockHandle *handle, void *arg_unused)
248 ScrArea *curarea= CTX_wm_area(C);
250 short yco= 0, menuwidth=120;
252 block= uiBeginBlock(C, handle->region, "dummy_selectmenu", UI_EMBOSSP, UI_HELV);
253 uiBlockSetButmFunc(block, do_selectmenu, NULL);
255 uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Nothing yet", 0, yco-=20,
256 menuwidth, 19, NULL, 0.0, 0.0, 1, 3, "");
258 if(curarea->headertype==HEADERTOP) {
259 uiBlockSetDirection(block, UI_DOWN);
262 uiBlockSetDirection(block, UI_TOP);
263 uiBlockFlipOrder(block);
266 uiTextBoundsBlock(block, 50);
267 uiEndBlock(C, block);
272 /* View menu --------------------------- */
274 static void do_viewmenu(bContext *C, void *arg, int event)
279 static uiBlock *action_viewmenu(bContext *C, uiMenuBlockHandle *handle, void *arg_unused)
281 ScrArea *curarea= CTX_wm_area(C);
283 short yco= 0, menuwidth=120;
285 block= uiBeginBlock(C, handle->region, "dummy_viewmenu", UI_EMBOSSP, UI_HELV);
286 uiBlockSetButmFunc(block, do_viewmenu, NULL);
288 uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Nothing yet", 0, yco-=20,
289 menuwidth, 19, NULL, 0.0, 0.0, 1, 3, "");
291 if(curarea->headertype==HEADERTOP) {
292 uiBlockSetDirection(block, UI_DOWN);
295 uiBlockSetDirection(block, UI_TOP);
296 uiBlockFlipOrder(block);
299 uiTextBoundsBlock(block, 50);
300 uiEndBlock(C, block);
305 /* ************************ header area region *********************** */
307 static void do_action_buttons(bContext *C, void *arg, int event)
311 ED_region_tag_redraw(CTX_wm_region(C));
316 void action_header_buttons(const bContext *C, ARegion *ar)
318 ScrArea *sa= CTX_wm_area(C);
319 SpaceAction *saction= (SpaceAction *)CTX_wm_space_data(C);
322 int xco, yco= 3, xmax;
324 block= uiBeginBlock(C, ar, "header buttons", UI_EMBOSS, UI_HELV);
325 uiBlockSetHandleFunc(block, do_action_buttons, NULL);
327 xco= ED_area_header_standardbuttons(C, block, yco);
329 uiBlockSetEmboss(block, UI_EMBOSS);
331 /* get context... (also syncs data) */
332 ANIM_animdata_get_context(C, &ac);
334 if ((sa->flag & HEADER_NO_PULLDOWN)==0) {
335 /* pull down menus */
336 uiBlockSetEmboss(block, UI_EMBOSSP);
338 xmax= GetButStringLength("View");
339 uiDefPulldownBut(block, action_viewmenu, CTX_wm_area(C),
340 "View", xco, yco, xmax-3, 24, "");
343 xmax= GetButStringLength("Select");
344 uiDefPulldownBut(block, action_selectmenu, CTX_wm_area(C),
345 "Select", xco, yco, xmax-3, 24, "");
348 if ( (saction->mode == SACTCONT_DOPESHEET) ||
349 ((saction->action) && (saction->mode==SACTCONT_ACTION)) )
351 xmax= GetButStringLength("Channel");
352 uiDefPulldownBut(block, action_channelmenu, CTX_wm_area(C),
353 "Channel", xco, yco, xmax-3, 24, "");
356 else if (saction->mode==SACTCONT_GPENCIL) {
357 xmax= GetButStringLength("Channel");
358 uiDefPulldownBut(block, action_gplayermenu, CTX_wm_area(C),
359 "Channel", xco, yco, xmax-3, 24, "");
363 xmax= GetButStringLength("Marker");
364 uiDefPulldownBut(block, action_markermenu, CTX_wm_area(C),
365 "Marker", xco, yco, xmax-3, 24, "");
368 if (saction->mode == SACTCONT_GPENCIL) {
369 xmax= GetButStringLength("Frame");
370 uiDefPulldownBut(block, action_framemenu, CTX_wm_area(C),
371 "Frame", xco, yco, xmax-3, 24, "");
375 xmax= GetButStringLength("Key");
376 uiDefPulldownBut(block, action_keymenu, CTX_wm_area(C),
377 "Key", xco, yco, xmax-3, 24, "");
382 uiBlockSetEmboss(block, UI_EMBOSS);
385 uiDefButC(block, MENU, B_REDR,
386 "Editor Mode %t|DopeSheet %x3|Action Editor %x0|ShapeKey Editor %x1|Grease Pencil %x2",
387 xco,yco,90,YIC, &saction->mode, 0, 1, 0, 0,
388 "Editing modes for this editor");
394 /* MODE-DEPENDENT DRAWING */
395 if (saction->mode == SACTCONT_DOPESHEET) {
396 /* FILTERING OPTIONS */
399 //uiBlockBeginAlign(block);
400 uiDefIconButBitI(block, TOG, ADS_FILTER_ONLYSEL, B_REDR, ICON_RESTRICT_SELECT_OFF, (short)(xco+=XIC),yco,XIC,YIC, &(saction->ads.filterflag), 0, 0, 0, 0, "Only display selected Objects");
401 //uiBlockEndAlign(block);
404 uiBlockBeginAlign(block);
405 uiDefIconButBitI(block, TOGN, ADS_FILTER_NOOBJ, B_REDR, ICON_OBJECT, (short)(xco+=XIC),yco,XIC,YIC, &(saction->ads.filterflag), 0, 0, 0, 0, "Display Non-Armature Objects");
406 uiDefIconButBitI(block, TOGN, ADS_FILTER_NOARM, B_REDR, ICON_ARMATURE, (short)(xco+=XIC),yco,XIC,YIC, &(saction->ads.filterflag), 0, 0, 0, 0, "Display Armature Objects");
407 uiDefIconButBitI(block, TOGN, ADS_FILTER_NOSHAPEKEYS, B_REDR, ICON_EDIT, (short)(xco+=XIC),yco,XIC,YIC, &(saction->ads.filterflag), 0, 0, 0, 0, "Display ShapeKeys");
408 uiDefIconButBitI(block, TOGN, ADS_FILTER_NOMAT, B_REDR, ICON_MATERIAL, (short)(xco+=XIC),yco,XIC,YIC, &(saction->ads.filterflag), 0, 0, 0, 0, "Display Materials");
409 uiDefIconButBitI(block, TOGN, ADS_FILTER_NOLAM, B_REDR, ICON_LAMP, (short)(xco+=XIC),yco,XIC,YIC, &(saction->ads.filterflag), 0, 0, 0, 0, "Display Lamps");
410 uiDefIconButBitI(block, TOGN, ADS_FILTER_NOCAM, B_REDR, ICON_CAMERA, (short)(xco+=XIC),yco,XIC,YIC, &(saction->ads.filterflag), 0, 0, 0, 0, "Display Cameras");
411 uiDefIconButBitI(block, TOGN, ADS_FILTER_NOCUR, B_REDR, ICON_CURVE, (short)(xco+=XIC),yco,XIC,YIC, &(saction->ads.filterflag), 0, 0, 0, 0, "Display Curves");
412 uiBlockEndAlign(block);
415 uiBlockBeginAlign(block);
416 uiDefIconButBitI(block, TOGN, ADS_FILTER_NOIPOS, B_REDR, ICON_IPO, (short)(xco+=XIC),yco,XIC,YIC, &(saction->ads.filterflag), 0, 0, 0, 0, "Display Object IPO's");
417 uiDefIconButBitI(block, TOGN, ADS_FILTER_NOACTS, B_REDR, ICON_ACTION, (short)(xco+=XIC),yco,XIC,YIC, &(saction->ads.filterflag), 0, 0, 0, 0, "Display Actions");
418 uiDefIconButBitI(block, TOGN, ADS_FILTER_NOCONSTRAINTS, B_REDR, ICON_CONSTRAINT, (short)(xco+=XIC),yco,XIC,YIC, &(saction->ads.filterflag), 0, 0, 0, 0, "Display Object Constraints");
419 uiBlockEndAlign(block);
422 else if (saction->mode == SACTCONT_ACTION) { // not too appropriate for shapekeys atm...
424 // XXX missing stuff here!
428 //xco= std_libbuttons(block, xco, 0, B_ACTPIN, saction->pin,
429 // B_ACTIONBROWSE, ID_AC, 0, (ID*)saction->action,
430 // from, &(saction->actnr), B_ACTALONE,
431 // B_ACTLOCAL, B_ACTIONDELETE, 0, B_KEEPDATA);
439 uiBlockBeginAlign(block);
440 uiDefIconBut(block, BUT, B_ACTCOPYKEYS, ICON_COPYDOWN, xco,yco,XIC,YIC, 0, 0, 0, 0, 0, "Copies the selected keyframes from the selected channel(s) to the buffer");
441 uiDefIconBut(block, BUT, B_ACTPASTEKEYS, ICON_PASTEDOWN, xco+=XIC,yco,XIC,YIC, 0, 0, 0, 0, 0, "Pastes the keyframes from the buffer");
442 uiBlockEndAlign(block);
446 if (saction->mode != SACTCONT_GPENCIL) {
447 if (saction->flag & SACTION_DRAWTIME) {
448 uiDefButC(block, MENU, B_REDR,
449 "Auto-Snap Keyframes %t|No Snap %x0|Second Step %x1|Nearest Second %x2|Nearest Marker %x3",
450 xco,yco,70,YIC, &(saction->autosnap), 0, 1, 0, 0,
451 "Auto-snapping mode for keyframes when transforming");
454 uiDefButC(block, MENU, B_REDR,
455 "Auto-Snap Keyframes %t|No Snap %x0|Frame Step %x1|Nearest Frame %x2|Nearest Marker %x3",
456 xco,yco,70,YIC, &(saction->autosnap), 0, 1, 0, 0,
457 "Auto-snapping mode for keyframes when transforming");
464 uiDefIconButS(block, ICONTOG, 1, ICON_UNLOCKED, xco, yco, XIC, YIC,
465 &(saction->lock), 0, 0, 0, 0,
466 "Updates other affected window spaces automatically "
467 "to reflect changes in real time");
471 UI_view2d_totRect_set(&ar->v2d, xco+XIC+80, ar->v2d.tot.ymax-ar->v2d.tot.ymin);
473 uiEndBlock(C, block);
474 uiDrawBlock(C, block);