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 /* ------------------------------- */
73 /* enums declaring constants that are used as menu event codes */
76 ACTMENU_VIEW_CENTERVIEW= 0,
77 ACTMENU_VIEW_AUTOUPDATE,
81 ACTMENU_VIEW_MAXIMIZE,
84 ACTMENU_VIEW_NEXTMARKER,
85 ACTMENU_VIEW_PREVMARKER,
86 ACTMENU_VIEW_NEXTKEYFRAME,
87 ACTMENU_VIEW_PREVKEYFRAME,
91 ACTMENU_VIEW_TRANSDELDUPS,
92 ACTMENU_VIEW_HORIZOPTIMISE,
94 ACTMENU_VIEW_PREVRANGESET,
95 ACTMENU_VIEW_PREVRANGECLEAR,
96 ACTMENU_VIEW_PREVRANGEAUTO
100 ACTMENU_SEL_BORDER = 0,
103 ACTMENU_SEL_ALL_KEYS,
104 ACTMENU_SEL_ALL_CHAN,
105 ACTMENU_SEL_ALL_MARKERS,
106 ACTMENU_SEL_INVERSE_KEYS,
107 ACTMENU_SEL_INVERSE_MARKERS,
108 ACTMENU_SEL_INVERSE_CHANNELS,
109 ACTMENU_SEL_LEFTKEYS,
110 ACTMENU_SEL_RIGHTKEYS
114 ACTMENU_SEL_COLUMN_KEYS = 1,
115 ACTMENU_SEL_COLUMN_CFRA,
116 ACTMENU_SEL_COLUMN_MARKERSCOLUMN,
117 ACTMENU_SEL_COLUMN_MARKERSBETWEEN
121 ACTMENU_CHANNELS_OPENLEVELS = 0,
122 ACTMENU_CHANNELS_CLOSELEVELS,
123 ACTMENU_CHANNELS_EXPANDALL,
124 ACTMENU_CHANNELS_SHOWACHANS,
125 ACTMENU_CHANNELS_DELETE
129 ACTMENU_CHANNELS_CHANPOS_MOVE_CHANNEL_UP = 0,
130 ACTMENU_CHANNELS_CHANPOS_MOVE_CHANNEL_DOWN,
131 ACTMENU_CHANNELS_CHANPOS_MOVE_CHANNEL_TOP,
132 ACTMENU_CHANNELS_CHANPOS_MOVE_CHANNEL_BOTTOM
136 ACTMENU_CHANNELS_GROUP_ADD_TOACTIVE = 0,
137 ACTMENU_CHANNELS_GROUP_ADD_TONEW,
138 ACTMENU_CHANNELS_GROUP_REMOVE,
139 ACTMENU_CHANNELS_GROUP_SYNCPOSE
143 ACTMENU_CHANNELS_SETTINGS_TOGGLE = 0,
144 ACTMENU_CHANNELS_SETTINGS_ENABLE,
145 ACTMENU_CHANNELS_SETTINGS_DISABLE,
149 ACTMENU_KEY_DUPLICATE = 0,
152 ACTMENU_KEY_SAMPLEKEYS,
153 ACTMENU_KEY_INSERTKEY
157 ACTMENU_KEY_TRANSFORM_MOVE = 0,
158 ACTMENU_KEY_TRANSFORM_SCALE,
159 ACTMENU_KEY_TRANSFORM_SLIDE,
160 ACTMENU_KEY_TRANSFORM_EXTEND
164 ACTMENU_KEY_HANDLE_AUTO = 0,
165 ACTMENU_KEY_HANDLE_ALIGN,
166 ACTMENU_KEY_HANDLE_FREE,
167 ACTMENU_KEY_HANDLE_VECTOR
171 ACTMENU_KEY_INTERP_CONST = 0,
172 ACTMENU_KEY_INTERP_LINEAR,
173 ACTMENU_KEY_INTERP_BEZIER
177 ACTMENU_KEY_EXTEND_CONST = 0,
178 ACTMENU_KEY_EXTEND_EXTRAPOLATION,
179 ACTMENU_KEY_EXTEND_CYCLIC,
180 ACTMENU_KEY_EXTEND_CYCLICEXTRAPOLATION
184 ACTMENU_KEY_SNAP_NEARFRAME = 1,
185 ACTMENU_KEY_SNAP_CURFRAME,
186 ACTMENU_KEY_SNAP_NEARMARK,
187 ACTMENU_KEY_SNAP_NEARTIME,
188 ACTMENU_KEY_SNAP_CFRA2KEY,
192 ACTMENU_KEY_MIRROR_CURFRAME = 1,
193 ACTMENU_KEY_MIRROR_YAXIS,
194 ACTMENU_KEY_MIRROR_XAXIS,
195 ACTMENU_KEY_MIRROR_MARKER
199 ACTMENU_MARKERS_ADD = 0,
200 ACTMENU_MARKERS_DUPLICATE,
201 ACTMENU_MARKERS_DELETE,
202 ACTMENU_MARKERS_NAME,
203 ACTMENU_MARKERS_MOVE,
204 ACTMENU_MARKERS_LOCALADD,
205 ACTMENU_MARKERS_LOCALRENAME,
206 ACTMENU_MARKERS_LOCALDELETE,
207 ACTMENU_MARKERS_LOCALMOVE
210 /* ------------------------------- */
211 /* macros for easier state testing (only for use here) */
213 /* test if active action editor is showing any markers */
215 #define G_SACTION_HASMARKERS \
216 ((G.saction->action && G.saction->action->markers.first) \
217 || (G.scene->markers.first))
220 /* ------------------------------- */
222 /* *************************************************************** */
225 /* Key menu --------------------------- */
227 static void do_keymenu(bContext *C, void *arg, int event)
232 static uiBlock *action_keymenu(bContext *C, uiMenuBlockHandle *handle, void *arg_unused)
234 ScrArea *curarea= CTX_wm_area(C);
236 short yco= 0, menuwidth=120;
238 block= uiBeginBlock(C, handle->region, "dummy_keymenu", UI_EMBOSSP, UI_HELV);
239 uiBlockSetButmFunc(block, do_keymenu, NULL);
241 uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Nothing yet", 0, yco-=20,
242 menuwidth, 19, NULL, 0.0, 0.0, 1, 3, "");
244 if(curarea->headertype==HEADERTOP) {
245 uiBlockSetDirection(block, UI_DOWN);
248 uiBlockSetDirection(block, UI_TOP);
249 uiBlockFlipOrder(block);
252 uiTextBoundsBlock(block, 50);
253 uiEndBlock(C, block);
258 /* Frame menu --------------------------- */
260 static void do_framemenu(bContext *C, void *arg, int event)
265 static uiBlock *action_framemenu(bContext *C, uiMenuBlockHandle *handle, void *arg_unused)
267 ScrArea *curarea= CTX_wm_area(C);
269 short yco= 0, menuwidth=120;
271 block= uiBeginBlock(C, handle->region, "dummy_framemenu", UI_EMBOSSP, UI_HELV);
272 uiBlockSetButmFunc(block, do_framemenu, NULL);
274 uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Nothing yet", 0, yco-=20,
275 menuwidth, 19, NULL, 0.0, 0.0, 1, 3, "");
277 if(curarea->headertype==HEADERTOP) {
278 uiBlockSetDirection(block, UI_DOWN);
281 uiBlockSetDirection(block, UI_TOP);
282 uiBlockFlipOrder(block);
285 uiTextBoundsBlock(block, 50);
286 uiEndBlock(C, block);
291 /* Marker menu --------------------------- */
293 static void do_markermenu(bContext *C, void *arg, int event)
298 static uiBlock *action_markermenu(bContext *C, uiMenuBlockHandle *handle, void *arg_unused)
300 ScrArea *curarea= CTX_wm_area(C);
302 short yco= 0, menuwidth=120;
304 block= uiBeginBlock(C, handle->region, "dummy_markermenu", UI_EMBOSSP, UI_HELV);
305 uiBlockSetButmFunc(block, do_markermenu, NULL);
307 uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Nothing yet", 0, yco-=20,
308 menuwidth, 19, NULL, 0.0, 0.0, 1, 3, "");
310 if(curarea->headertype==HEADERTOP) {
311 uiBlockSetDirection(block, UI_DOWN);
314 uiBlockSetDirection(block, UI_TOP);
315 uiBlockFlipOrder(block);
318 uiTextBoundsBlock(block, 50);
319 uiEndBlock(C, block);
324 /* Grease Pencil --------------------------- */
326 static void do_gplayermenu(bContext *C, void *arg, int event)
331 static uiBlock *action_gplayermenu(bContext *C, uiMenuBlockHandle *handle, void *arg_unused)
333 ScrArea *curarea= CTX_wm_area(C);
335 short yco= 0, menuwidth=120;
337 block= uiBeginBlock(C, handle->region, "dummy_gplayermenu", UI_EMBOSSP, UI_HELV);
338 uiBlockSetButmFunc(block, do_gplayermenu, NULL);
340 uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Nothing yet", 0, yco-=20,
341 menuwidth, 19, NULL, 0.0, 0.0, 1, 3, "");
343 if(curarea->headertype==HEADERTOP) {
344 uiBlockSetDirection(block, UI_DOWN);
347 uiBlockSetDirection(block, UI_TOP);
348 uiBlockFlipOrder(block);
351 uiTextBoundsBlock(block, 50);
352 uiEndBlock(C, block);
357 /* Channel menu --------------------------- */
359 static void do_channelmenu(bContext *C, void *arg, int event)
364 static uiBlock *action_channelmenu(bContext *C, uiMenuBlockHandle *handle, void *arg_unused)
366 ScrArea *curarea= CTX_wm_area(C);
368 short yco= 0, menuwidth=120;
370 block= uiBeginBlock(C, handle->region, "dummy_channelmenu", UI_EMBOSSP, UI_HELV);
371 uiBlockSetButmFunc(block, do_channelmenu, NULL);
373 uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Nothing yet", 0, yco-=20,
374 menuwidth, 19, NULL, 0.0, 0.0, 1, 3, "");
376 if(curarea->headertype==HEADERTOP) {
377 uiBlockSetDirection(block, UI_DOWN);
380 uiBlockSetDirection(block, UI_TOP);
381 uiBlockFlipOrder(block);
384 uiTextBoundsBlock(block, 50);
385 uiEndBlock(C, block);
390 /* Select menu --------------------------- */
392 static void do_selectmenu(bContext *C, void *arg, int event)
397 static uiBlock *action_selectmenu(bContext *C, uiMenuBlockHandle *handle, void *arg_unused)
399 ScrArea *curarea= CTX_wm_area(C);
401 short yco= 0, menuwidth=120;
403 block= uiBeginBlock(C, handle->region, "dummy_selectmenu", UI_EMBOSSP, UI_HELV);
404 uiBlockSetButmFunc(block, do_selectmenu, NULL);
406 uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Nothing yet", 0, yco-=20,
407 menuwidth, 19, NULL, 0.0, 0.0, 1, 3, "");
409 if(curarea->headertype==HEADERTOP) {
410 uiBlockSetDirection(block, UI_DOWN);
413 uiBlockSetDirection(block, UI_TOP);
414 uiBlockFlipOrder(block);
417 uiTextBoundsBlock(block, 50);
418 uiEndBlock(C, block);
423 /* View menu --------------------------- */
425 static void do_viewmenu(bContext *C, void *arg, int event)
430 static uiBlock *action_viewmenu(bContext *C, uiMenuBlockHandle *handle, void *arg_unused)
432 ScrArea *curarea= CTX_wm_area(C);
434 short yco= 0, menuwidth=120;
436 block= uiBeginBlock(C, handle->region, "dummy_viewmenu", UI_EMBOSSP, UI_HELV);
437 uiBlockSetButmFunc(block, do_viewmenu, NULL);
439 uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Nothing yet", 0, yco-=20,
440 menuwidth, 19, NULL, 0.0, 0.0, 1, 3, "");
442 if (curarea->headertype==HEADERTOP) {
443 uiBlockSetDirection(block, UI_DOWN);
446 uiBlockSetDirection(block, UI_TOP);
447 uiBlockFlipOrder(block);
450 uiTextBoundsBlock(block, 50);
451 uiEndBlock(C, block);
456 /* ************************ header area region *********************** */
458 static void do_action_buttons(bContext *C, void *arg, int event)
462 ED_region_tag_redraw(CTX_wm_region(C));
467 void action_header_buttons(const bContext *C, ARegion *ar)
469 ScrArea *sa= CTX_wm_area(C);
470 SpaceAction *saction= (SpaceAction *)CTX_wm_space_data(C);
473 int xco, yco= 3, xmax;
475 block= uiBeginBlock(C, ar, "header buttons", UI_EMBOSS, UI_HELV);
476 uiBlockSetHandleFunc(block, do_action_buttons, NULL);
478 xco= ED_area_header_standardbuttons(C, block, yco);
480 uiBlockSetEmboss(block, UI_EMBOSS);
482 /* get context... (also syncs data) */
483 ANIM_animdata_get_context(C, &ac);
485 if ((sa->flag & HEADER_NO_PULLDOWN)==0) {
486 /* pull down menus */
487 uiBlockSetEmboss(block, UI_EMBOSSP);
489 xmax= GetButStringLength("View");
490 uiDefPulldownBut(block, action_viewmenu, CTX_wm_area(C),
491 "View", xco, yco, xmax-3, 24, "");
494 xmax= GetButStringLength("Select");
495 uiDefPulldownBut(block, action_selectmenu, CTX_wm_area(C),
496 "Select", xco, yco, xmax-3, 24, "");
499 if ( (saction->mode == SACTCONT_DOPESHEET) ||
500 ((saction->action) && (saction->mode==SACTCONT_ACTION)) )
502 xmax= GetButStringLength("Channel");
503 uiDefPulldownBut(block, action_channelmenu, CTX_wm_area(C),
504 "Channel", xco, yco, xmax-3, 24, "");
507 else if (saction->mode==SACTCONT_GPENCIL) {
508 xmax= GetButStringLength("Channel");
509 uiDefPulldownBut(block, action_gplayermenu, CTX_wm_area(C),
510 "Channel", xco, yco, xmax-3, 24, "");
514 xmax= GetButStringLength("Marker");
515 uiDefPulldownBut(block, action_markermenu, CTX_wm_area(C),
516 "Marker", xco, yco, xmax-3, 24, "");
519 if (saction->mode == SACTCONT_GPENCIL) {
520 xmax= GetButStringLength("Frame");
521 uiDefPulldownBut(block, action_framemenu, CTX_wm_area(C),
522 "Frame", xco, yco, xmax-3, 24, "");
526 xmax= GetButStringLength("Key");
527 uiDefPulldownBut(block, action_keymenu, CTX_wm_area(C),
528 "Key", xco, yco, xmax-3, 24, "");
533 uiBlockSetEmboss(block, UI_EMBOSS);
536 uiDefButC(block, MENU, B_REDR,
537 "Editor Mode %t|DopeSheet %x3|Action Editor %x0|ShapeKey Editor %x1|Grease Pencil %x2",
538 xco,yco,90,YIC, &saction->mode, 0, 1, 0, 0,
539 "Editing modes for this editor");
545 /* MODE-DEPENDENT DRAWING */
546 if (saction->mode == SACTCONT_DOPESHEET) {
547 /* FILTERING OPTIONS */
550 //uiBlockBeginAlign(block);
551 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");
552 //uiBlockEndAlign(block);
555 uiBlockBeginAlign(block);
556 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");
557 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");
558 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");
559 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");
560 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");
561 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");
562 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");
563 uiBlockEndAlign(block);
566 uiBlockBeginAlign(block);
567 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");
568 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");
569 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");
570 uiBlockEndAlign(block);
573 else if (saction->mode == SACTCONT_ACTION) { // not too appropriate for shapekeys atm...
575 // XXX missing stuff here!
579 //xco= std_libbuttons(block, xco, 0, B_ACTPIN, saction->pin,
580 // B_ACTIONBROWSE, ID_AC, 0, (ID*)saction->action,
581 // from, &(saction->actnr), B_ACTALONE,
582 // B_ACTLOCAL, B_ACTIONDELETE, 0, B_KEEPDATA);
590 uiBlockBeginAlign(block);
591 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");
592 uiDefIconBut(block, BUT, B_ACTPASTEKEYS, ICON_PASTEDOWN, xco+=XIC,yco,XIC,YIC, 0, 0, 0, 0, 0, "Pastes the keyframes from the buffer");
593 uiBlockEndAlign(block);
597 if (saction->mode != SACTCONT_GPENCIL) {
598 if (saction->flag & SACTION_DRAWTIME) {
599 uiDefButC(block, MENU, B_REDR,
600 "Auto-Snap Keyframes %t|No Snap %x0|Second Step %x1|Nearest Second %x2|Nearest Marker %x3",
601 xco,yco,70,YIC, &(saction->autosnap), 0, 1, 0, 0,
602 "Auto-snapping mode for keyframes when transforming");
605 uiDefButC(block, MENU, B_REDR,
606 "Auto-Snap Keyframes %t|No Snap %x0|Frame Step %x1|Nearest Frame %x2|Nearest Marker %x3",
607 xco,yco,70,YIC, &(saction->autosnap), 0, 1, 0, 0,
608 "Auto-snapping mode for keyframes when transforming");
615 uiDefIconButS(block, ICONTOG, 1, ICON_UNLOCKED, xco, yco, XIC, YIC,
616 &(saction->lock), 0, 0, 0, 0,
617 "Updates other affected window spaces automatically "
618 "to reflect changes in real time");
622 UI_view2d_totRect_set(&ar->v2d, xco+XIC+80, ar->v2d.tot.ymax-ar->v2d.tot.ymin);
624 uiEndBlock(C, block);
625 uiDrawBlock(C, block);