Added missing menu entries for Preview Range tools
[blender.git] / source / blender / src / header_action.c
1 /**
2  * header_action.c oct-2003
3  *
4  * Functions to draw the "Action Editor" window header
5  * and handle user events sent to it.
6  * 
7  * $Id$
8  *
9  * ***** BEGIN GPL LICENSE BLOCK *****
10  *
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.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program; if not, write to the Free Software Foundation,
23  * Inc., 59 Temple Place - Suite 330, Boston, MA        02111-1307, USA.
24  *
25  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
26  * All rights reserved.
27  *
28  * The Original Code is: all of this file.
29  *
30  * Contributor(s): 2007, Joshua Leung (Action Editor recode) 
31  *
32  * ***** END GPL LICENSE BLOCK *****
33  */
34
35 #include <stdlib.h>
36 #include <string.h>
37 #include <stdio.h>
38
39 #ifdef HAVE_CONFIG_H
40 #include <config.h>
41 #endif
42
43 #include "DNA_action_types.h"
44 #include "DNA_curve_types.h"
45 #include "DNA_ID.h"
46 #include "DNA_ipo_types.h"
47 #include "DNA_key_types.h"
48 #include "DNA_object_types.h"
49 #include "DNA_scene_types.h"
50 #include "DNA_screen_types.h"
51 #include "DNA_space_types.h"
52
53 #include "BIF_editaction.h"
54 #include "BIF_interface.h"
55 #include "BIF_poseobject.h"
56 #include "BIF_resources.h"
57 #include "BIF_screen.h"
58 #include "BIF_space.h"
59 #include "BIF_toolbox.h"
60
61 #include "BKE_action.h"
62 #include "BKE_armature.h"
63 #include "BKE_constraint.h"
64 #include "BKE_depsgraph.h"
65 #include "BKE_global.h"
66 #include "BKE_main.h"
67 #include "BKE_utildefines.h"
68
69 #include "BDR_drawaction.h"
70 #include "BSE_drawipo.h"
71 #include "BSE_headerbuttons.h"
72 #include "BSE_time.h"
73
74 #include "nla.h"
75
76 #include "blendef.h"
77 #include "mydevice.h"
78
79 /* enums declaring constants that are used as menu event codes  */
80
81 enum {
82         ACTMENU_VIEW_CENTERVIEW= 0,
83         ACTMENU_VIEW_AUTOUPDATE,
84         ACTMENU_VIEW_PLAY3D,
85         ACTMENU_VIEW_PLAYALL,
86         ACTMENU_VIEW_ALL,
87         ACTMENU_VIEW_MAXIMIZE,
88         ACTMENU_VIEW_LOCK,
89         ACTMENU_VIEW_SLIDERS,
90         ACTMENU_VIEW_NEXTMARKER,
91         ACTMENU_VIEW_PREVMARKER,
92         ACTMENU_VIEW_NEXTKEYFRAME,
93         ACTMENU_VIEW_PREVKEYFRAME,
94         ACTMENU_VIEW_TIME,
95         ACTMENU_VIEW_NOHIDE,
96         ACTMENU_VIEW_TRANSDELDUPS,
97         ACTMENU_VIEW_HORIZOPTIMISE,
98         ACTMENU_VIEW_GCOLORS,
99         ACTMENU_VIEW_PREVRANGESET,
100         ACTMENU_VIEW_PREVRANGECLEAR,
101         ACTMENU_VIEW_PREVRANGEAUTO
102 };
103
104 enum {
105         ACTMENU_SEL_BORDER = 0,
106         ACTMENU_SEL_BORDERC,
107         ACTMENU_SEL_BORDERM,
108         ACTMENU_SEL_ALL_KEYS,
109         ACTMENU_SEL_ALL_CHAN,
110         ACTMENU_SEL_ALL_MARKERS,
111         ACTMENU_SEL_INVERSE_KEYS,
112         ACTMENU_SEL_INVERSE_MARKERS,
113         ACTMENU_SEL_INVERSE_CHANNELS,
114         ACTMENU_SEL_LEFTKEYS,
115         ACTMENU_SEL_RIGHTKEYS
116 };
117
118 enum {
119         ACTMENU_SEL_COLUMN_KEYS = 1,
120         ACTMENU_SEL_COLUMN_CFRA,
121         ACTMENU_SEL_COLUMN_MARKERSCOLUMN,
122         ACTMENU_SEL_COLUMN_MARKERSBETWEEN 
123 };
124
125 enum {
126         ACTMENU_CHANNELS_OPENLEVELS = 0,
127         ACTMENU_CHANNELS_CLOSELEVELS,
128         ACTMENU_CHANNELS_EXPANDALL,
129         ACTMENU_CHANNELS_SHOWACHANS,
130         ACTMENU_CHANNELS_DELETE
131 };
132
133 enum {
134         ACTMENU_CHANNELS_CHANPOS_MOVE_CHANNEL_UP        = 0,
135         ACTMENU_CHANNELS_CHANPOS_MOVE_CHANNEL_DOWN,
136         ACTMENU_CHANNELS_CHANPOS_MOVE_CHANNEL_TOP,
137         ACTMENU_CHANNELS_CHANPOS_MOVE_CHANNEL_BOTTOM
138 };
139
140 enum {
141         ACTMENU_CHANNELS_GROUP_ADD_TOACTIVE     = 0,
142         ACTMENU_CHANNELS_GROUP_ADD_TONEW,
143         ACTMENU_CHANNELS_GROUP_REMOVE,
144         ACTMENU_CHANNELS_GROUP_SYNCPOSE
145 };
146
147 enum {
148         ACTMENU_CHANNELS_SETTINGS_TOGGLE = 0,
149         ACTMENU_CHANNELS_SETTINGS_ENABLE,
150         ACTMENU_CHANNELS_SETTINGS_DISABLE,
151 };
152
153 enum {
154         ACTMENU_KEY_DUPLICATE = 0,
155         ACTMENU_KEY_DELETE,
156         ACTMENU_KEY_CLEAN,
157         ACTMENU_KEY_SAMPLEKEYS,
158         ACTMENU_KEY_INSERTKEY
159 };
160
161 enum {
162         ACTMENU_KEY_TRANSFORM_MOVE  = 0,
163         ACTMENU_KEY_TRANSFORM_SCALE,
164         ACTMENU_KEY_TRANSFORM_SLIDE,
165         ACTMENU_KEY_TRANSFORM_EXTEND
166 };
167
168 enum {
169         ACTMENU_KEY_HANDLE_AUTO = 0,
170         ACTMENU_KEY_HANDLE_ALIGN,
171         ACTMENU_KEY_HANDLE_FREE,
172         ACTMENU_KEY_HANDLE_VECTOR
173 };
174
175 enum {
176         ACTMENU_KEY_INTERP_CONST = 0,
177         ACTMENU_KEY_INTERP_LINEAR,
178         ACTMENU_KEY_INTERP_BEZIER
179 };
180
181 enum {
182         ACTMENU_KEY_EXTEND_CONST = 0,
183         ACTMENU_KEY_EXTEND_EXTRAPOLATION,
184         ACTMENU_KEY_EXTEND_CYCLIC,
185         ACTMENU_KEY_EXTEND_CYCLICEXTRAPOLATION
186 };
187
188 enum {
189         ACTMENU_KEY_SNAP_NEARFRAME = 1,
190         ACTMENU_KEY_SNAP_CURFRAME,
191         ACTMENU_KEY_SNAP_NEARMARK,
192         ACTMENU_KEY_SNAP_NEARTIME,
193         ACTMENU_KEY_SNAP_CFRA2KEY,
194 };
195
196 enum {
197         ACTMENU_KEY_MIRROR_CURFRAME = 1,
198         ACTMENU_KEY_MIRROR_YAXIS,
199         ACTMENU_KEY_MIRROR_XAXIS,
200         ACTMENU_KEY_MIRROR_MARKER
201 };
202
203 enum {
204         ACTMENU_MARKERS_ADD = 0,
205         ACTMENU_MARKERS_DUPLICATE,
206         ACTMENU_MARKERS_DELETE,
207         ACTMENU_MARKERS_NAME,
208         ACTMENU_MARKERS_MOVE,
209         ACTMENU_MARKERS_LOCALADD,
210         ACTMENU_MARKERS_LOCALRENAME,
211         ACTMENU_MARKERS_LOCALDELETE,
212         ACTMENU_MARKERS_LOCALMOVE
213 };
214
215 void do_action_buttons(unsigned short event)
216 {
217         Object *ob= OBACT;
218
219         switch(event) {
220                 case B_ACTHOME: /* HOMEKEY in Action Editor */
221                         /*      Find X extents */
222                         G.v2d->cur.xmin = 0;
223                         G.v2d->cur.ymin=-SCROLLB;
224                         
225                         if (G.saction->action) {
226                                 float extra;
227                                 
228                                 calc_action_range(G.saction->action, &G.v2d->cur.xmin, &G.v2d->cur.xmax, 0);
229                                 if (G.saction->pin==0 && ob) {
230                                         G.v2d->cur.xmin= get_action_frame_inv(ob, G.v2d->cur.xmin);
231                                         G.v2d->cur.xmax= get_action_frame_inv(ob, G.v2d->cur.xmax);
232                                 }                               
233                                 extra= 0.05*(G.v2d->cur.xmax - G.v2d->cur.xmin);
234                                 G.v2d->cur.xmin-= extra;
235                                 G.v2d->cur.xmax+= extra;
236
237                                 if (G.v2d->cur.xmin==G.v2d->cur.xmax) {
238                                         G.v2d->cur.xmax= -5;
239                                         G.v2d->cur.xmax= 100;
240                                 }
241                         }
242                         else { /* shapekeys and/or no action */
243                                 G.v2d->cur.xmin= -5.0;
244                                 G.v2d->cur.xmax= 65.0;
245                         }
246                         
247                         G.v2d->cur.ymin= -75.0;
248                         G.v2d->cur.ymax= 5.0;
249                         
250                         G.v2d->tot= G.v2d->cur;
251                         test_view2d(G.v2d, curarea->winx, curarea->winy);
252                         view2d_do_locks(curarea, V2D_LOCK_COPY);
253                         
254                         addqueue (curarea->win, REDRAW, 1);
255                         
256                         break;
257                         
258                 /* copy/paste/paste-flip buttons in 3d-view header in PoseMode */
259                 case B_ACTCOPY:
260                         copy_posebuf();
261                         allqueue(REDRAWVIEW3D, 1);
262                         break;
263                 case B_ACTPASTE:
264                         paste_posebuf(0);
265                         allqueue(REDRAWVIEW3D, 1);
266                         break;
267                 case B_ACTPASTEFLIP:
268                         paste_posebuf(1);
269                         allqueue(REDRAWVIEW3D, 1);
270                         break;
271                         
272                 /* copy/paste buttons in Action Editor header */
273                 case B_ACTCOPYKEYS:
274                         copy_actdata();
275                         break;
276                 case B_ACTPASTEKEYS:
277                         paste_actdata();
278                         break;
279
280                 case B_ACTPIN:  /* __PINFAKE */
281 /*              if (G.saction->flag & SACTION_PIN) {
282                         if (G.saction->action)
283                                 G.saction->action->id.us ++;
284                 }
285                 else {
286                         if (G.saction->action)
287                                 G.saction->action->id.us --;
288                 }
289 */              /* end PINFAKE */
290                         allqueue(REDRAWACTION, 1);
291                         break;
292         }
293 }
294
295 static void do_action_viewmenu(void *arg, int event)
296 {
297         extern int play_anim(int mode);
298
299         switch(event) {
300                 case ACTMENU_VIEW_CENTERVIEW: /* Center View to Current Frame */
301                         center_currframe();
302                         break;
303                 case ACTMENU_VIEW_AUTOUPDATE: /* Update Automatically */
304                         if (BTST(G.saction->lock, 0)) 
305                                 G.saction->lock = BCLR(G.saction->lock, 0);
306                         else 
307                                 G.saction->lock = BSET(G.saction->lock, 0);
308                         break;
309                 case ACTMENU_VIEW_PLAY3D: /* Play Back Animation */
310                         play_anim(0);
311                         break;
312                 case ACTMENU_VIEW_PLAYALL: /* Play Back Animation in All */
313                         play_anim(1);
314                         break;  
315                 case ACTMENU_VIEW_ALL: /* View All */
316                         do_action_buttons(B_ACTHOME);
317                         break;
318                 case ACTMENU_VIEW_LOCK:
319                         G.v2d->flag ^= V2D_VIEWLOCK;
320                         if (G.v2d->flag & V2D_VIEWLOCK)
321                                 view2d_do_locks(curarea, 0);
322                         break;
323                 case ACTMENU_VIEW_SLIDERS:       /* Show sliders (when applicable) */
324                         G.saction->flag ^= SACTION_SLIDERS;
325                         break;
326                 case ACTMENU_VIEW_MAXIMIZE: /* Maximize Window */
327                         /* using event B_FULL */
328                         break;
329                 case ACTMENU_VIEW_NEXTMARKER: /* Jump to next marker */
330                         nextprev_marker(1);
331                         break;
332                 case ACTMENU_VIEW_PREVMARKER: /* Jump to previous marker */
333                         nextprev_marker(-1);
334                         break;
335                 case ACTMENU_VIEW_TIME: /* switch between frames and seconds display */
336                         G.saction->flag ^= SACTION_DRAWTIME;
337                         break;
338                 case ACTMENU_VIEW_NOHIDE: /* Show hidden channels */
339                         G.saction->flag ^= SACTION_NOHIDE;
340                         break;
341                 case ACTMENU_VIEW_NEXTKEYFRAME: /* Jump to next keyframe */
342                         nextprev_action_keyframe(1);
343                         break;
344                 case ACTMENU_VIEW_PREVKEYFRAME: /* Jump to previous keyframe */
345                         nextprev_action_keyframe(-1);
346                         break;
347                 case ACTMENU_VIEW_TRANSDELDUPS: /* Don't delete duplicate/overlapping keyframes after transform */
348                         G.saction->flag ^= SACTION_NOTRANSKEYCULL;
349                         break;
350                 case ACTMENU_VIEW_HORIZOPTIMISE: /* Include keyframes not in view (horizontally) when preparing to draw */
351                         G.saction->flag ^= SACTION_HORIZOPTIMISEON;
352                         break;
353                 case ACTMENU_VIEW_GCOLORS: /* Draw grouped-action channels using its group's color */
354                         G.saction->flag ^= SACTION_NODRAWGCOLORS;
355                         break;
356                 case ACTMENU_VIEW_PREVRANGESET: /* Set preview range */
357                         anim_previewrange_set();
358                         break;
359                 case ACTMENU_VIEW_PREVRANGECLEAR: /* Clear preview range */
360                         anim_previewrange_clear();
361                         break;
362                 case ACTMENU_VIEW_PREVRANGEAUTO: /* Auto preview-range length */
363                         action_previewrange_set(G.saction->action);
364                         break;
365         }
366         allqueue(REDRAWVIEW3D, 0);
367 }
368
369 static uiBlock *action_viewmenu(void *arg_unused)
370 {
371         uiBlock *block;
372         short yco= 0, menuwidth=120;
373         
374         block= uiNewBlock(&curarea->uiblocks, "action_viewmenu", 
375                                           UI_EMBOSSP, UI_HELV, curarea->headwin);
376         uiBlockSetButmFunc(block, do_action_viewmenu, NULL);
377         
378         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, 
379                                          "Center View to Current Frame|C", 0, yco-=20, 
380                                          menuwidth, 19, NULL, 0.0, 0.0, 1, 
381                                          ACTMENU_VIEW_CENTERVIEW, "");
382                 
383         uiDefBut(block, SEPR, 0, "", 0, yco-=6, 
384                          menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
385                          
386         if (G.saction->flag & SACTION_DRAWTIME) {
387                 uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, 
388                                                 "Show Frames|Ctrl T", 0, yco-=20, 
389                                                 menuwidth, 19, NULL, 0.0, 0.0, 1, 
390                                                 ACTMENU_VIEW_TIME, "");
391         }
392         else {
393                 uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, 
394                                                 "Show Seconds|Ctrl T", 0, yco-=20, 
395                                                 menuwidth, 19, NULL, 0.0, 0.0, 1, 
396                                                 ACTMENU_VIEW_TIME, "");
397         }
398         
399         uiDefBut(block, SEPR, 0, "",        0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
400         
401         uiDefIconTextBut(block, BUTM, 1, (G.saction->flag & SACTION_SLIDERS)?ICON_CHECKBOX_HLT:ICON_CHECKBOX_DEHLT, 
402                                          "Show Sliders|", 0, yco-=20, 
403                                          menuwidth, 19, NULL, 0.0, 0.0, 1, 
404                                          ACTMENU_VIEW_SLIDERS, "");
405                                          
406         uiDefIconTextBut(block, BUTM, 1, (G.saction->flag & SACTION_NOHIDE)?ICON_CHECKBOX_HLT:ICON_CHECKBOX_DEHLT, 
407                                          "Show Hidden Channels|", 0, yco-=20, 
408                                          menuwidth, 19, NULL, 0.0, 0.0, 1, 
409                                          ACTMENU_VIEW_NOHIDE, "");
410                                          
411         uiDefIconTextBut(block, BUTM, 1, (G.saction->flag & SACTION_NODRAWGCOLORS)?ICON_CHECKBOX_DEHLT:ICON_CHECKBOX_HLT, 
412                                          "Use Group Colors|", 0, yco-=20, 
413                                          menuwidth, 19, NULL, 0.0, 0.0, 1, 
414                                          ACTMENU_VIEW_GCOLORS, "");
415                                          
416                 // this option may get removed in future
417         uiDefIconTextBut(block, BUTM, 1, (G.saction->flag & SACTION_HORIZOPTIMISEON)?ICON_CHECKBOX_HLT:ICON_CHECKBOX_DEHLT, 
418                                          "Cull Out-of-View Keys (Time)|", 0, yco-=20, 
419                                          menuwidth, 19, NULL, 0.0, 0.0, 1, 
420                                          ACTMENU_VIEW_HORIZOPTIMISE, "");
421         
422         uiDefIconTextBut(block, BUTM, 1, (G.saction->flag & SACTION_NOTRANSKEYCULL)?ICON_CHECKBOX_DEHLT:ICON_CHECKBOX_HLT, 
423                                          "AutoMerge Keyframes|", 0, yco-=20, 
424                                          menuwidth, 19, NULL, 0.0, 0.0, 1, 
425                                          ACTMENU_VIEW_TRANSDELDUPS, "");
426                         
427                 
428         uiDefIconTextBut(block, BUTM, 1, (G.v2d->flag & V2D_VIEWLOCK)?ICON_CHECKBOX_HLT:ICON_CHECKBOX_DEHLT, 
429                                          "Lock Time to Other Windows|", 0, yco-=20, 
430                                          menuwidth, 19, NULL, 0.0, 0.0, 1, 
431                                          ACTMENU_VIEW_LOCK, "");
432                                          
433         uiDefIconTextBut(block, BUTM, 1, BTST(G.saction->lock, 0)?ICON_CHECKBOX_HLT:ICON_CHECKBOX_DEHLT, 
434                                          "Update Automatically|", 0, yco-=20, 
435                                          menuwidth, 19, NULL, 0.0, 0.0, 1, 
436                                          ACTMENU_VIEW_AUTOUPDATE, "");
437
438         uiDefBut(block, SEPR, 0, "", 0, yco-=6, 
439                                         menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
440                 
441         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, 
442                                 "Jump To Next Marker|PageUp", 0, yco-=20,
443                                 menuwidth, 19, NULL, 0.0, 0.0, 0, ACTMENU_VIEW_NEXTMARKER, "");
444         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, 
445                                 "Jump To Prev Marker|PageDown", 0, yco-=20, 
446                                 menuwidth, 19, NULL, 0.0, 0.0, 0, ACTMENU_VIEW_PREVMARKER, "");
447                                 
448         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, 
449                                 "Jump To Next Keyframe|Ctrl PageUp", 0, yco-=20,
450                                 menuwidth, 19, NULL, 0.0, 0.0, 0, ACTMENU_VIEW_NEXTKEYFRAME, "");
451         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, 
452                                 "Jump To Prev Keyframe|Ctrl PageDown", 0, yco-=20, 
453                                 menuwidth, 19, NULL, 0.0, 0.0, 0, ACTMENU_VIEW_PREVKEYFRAME, "");
454                                          
455         uiDefBut(block, SEPR, 0, "", 0, yco-=6, 
456                                         menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
457                         
458         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, 
459                                          "Play Back Animation|Alt A", 0, yco-=20, 
460                                          menuwidth, 19, NULL, 0.0, 0.0, 1, 
461                                          ACTMENU_VIEW_PLAY3D, "");
462         //uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, 
463         //                               "Play Back Animation in 3D View|Alt Shift A", 0, yco-=20,
464         //                               menuwidth, 19, NULL, 0.0, 0.0, 1, 
465         //                               ACTMENU_VIEW_PLAYALL, "");
466         
467         uiDefBut(block, SEPR, 0, "", 0, yco-=6, 
468                          menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
469                 
470         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, 
471                                          "Set Preview Range|Ctrl P", 0, yco-=20, 
472                                          menuwidth, 19, NULL, 0.0, 0.0, 1, 
473                                          ACTMENU_VIEW_PREVRANGESET, "");
474         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, 
475                                          "Clear Preview Range|Alt P", 0, yco-=20,
476                                          menuwidth, 19, NULL, 0.0, 0.0, 1, 
477                                          ACTMENU_VIEW_PREVRANGECLEAR, "");
478                 
479         if (G.saction->action) {
480                 uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, 
481                                          "Preview Range from Action Length|Ctrl Alt P", 0, yco-=20, 
482                                          menuwidth, 19, NULL, 0.0, 0.0, 1, 
483                                          ACTMENU_VIEW_PREVRANGEAUTO, "");
484         }
485                 
486         uiDefBut(block, SEPR, 0, "", 0, yco-=6, 
487                          menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
488         
489         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, 
490                                          "View All|Home", 0, yco-=20, 
491                                          menuwidth, 19, NULL, 0.0, 0.0, 1, 
492                                          ACTMENU_VIEW_ALL, "");
493         
494         if (!curarea->full) 
495                 uiDefIconTextBut(block, BUTM, B_FULL, ICON_BLANK1, 
496                                                  "Maximize Window|Ctrl UpArrow", 0, yco-=20, 
497                                                  menuwidth, 19, NULL, 0.0, 0.0, 0, 
498                                                  ACTMENU_VIEW_MAXIMIZE, "");
499         else 
500                 uiDefIconTextBut(block, BUTM, B_FULL, ICON_BLANK1, 
501                                                  "Tile Window|Ctrl DownArrow", 0, yco-=20, 
502                                                  menuwidth, 19, NULL, 0.0, 0.0, 0, 
503                                                  ACTMENU_VIEW_MAXIMIZE, "");
504         
505         if(curarea->headertype==HEADERTOP) {
506                 uiBlockSetDirection(block, UI_DOWN);
507         }
508         else {
509                 uiBlockSetDirection(block, UI_TOP);
510                 uiBlockFlipOrder(block);
511         }
512
513         uiTextBoundsBlock(block, 50);
514         
515         return block;
516 }
517
518 static void do_action_selectmenu_columnmenu(void *arg, int event)
519 {
520         switch (event) {
521                 case ACTMENU_SEL_COLUMN_MARKERSBETWEEN:
522                         markers_selectkeys_between();
523                         break;
524                 case ACTMENU_SEL_COLUMN_KEYS:
525                         column_select_action_keys(1);
526                         break;
527                 case ACTMENU_SEL_COLUMN_MARKERSCOLUMN:
528                         column_select_action_keys(2);
529                         break;
530                 case ACTMENU_SEL_COLUMN_CFRA:
531                         column_select_action_keys(3);
532                         break;
533         }
534                 
535         allqueue(REDRAWMARKER, 0);
536 }
537
538 static uiBlock *action_selectmenu_columnmenu(void *arg_unused)
539 {
540         uiBlock *block;
541         short yco= 0, menuwidth=120;
542
543         block= uiNewBlock(&curarea->uiblocks, "action_selectmenu_columnmenu", 
544                                           UI_EMBOSSP, UI_HELV, G.curscreen->mainwin);
545         uiBlockSetButmFunc(block, do_action_selectmenu_columnmenu, NULL);
546
547         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, 
548                                          "On Selected Keys|K", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0,  
549                                          ACTMENU_SEL_COLUMN_KEYS, "");
550         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, 
551                                          "On Current Frame|Ctrl K", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0,  
552                                          ACTMENU_SEL_COLUMN_CFRA, "");
553         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, 
554                                          "On Selected Markers|Shift K", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 
555                                          ACTMENU_SEL_COLUMN_MARKERSCOLUMN, "");
556         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, 
557                                          "Between Selected Markers|Alt K", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 
558                                          ACTMENU_SEL_COLUMN_MARKERSBETWEEN, "");
559         
560         
561         uiBlockSetDirection(block, UI_RIGHT);
562         uiTextBoundsBlock(block, 60);
563
564         return block;
565 }
566
567 static void do_action_selectmenu(void *arg, int event)
568 {       
569         SpaceAction *saction;
570         bAction *act;
571         Key *key;
572         
573         saction = curarea->spacedata.first;
574         if (saction == NULL) return;
575
576         act = saction->action;
577         key = get_action_mesh_key();
578         
579         switch(event)
580         {
581                 case ACTMENU_SEL_BORDER: /* Border Select */
582                         borderselect_action();
583                         break;
584                         
585                 case ACTMENU_SEL_BORDERC: /* Border Select */
586                         borderselect_actionchannels();
587                         break;
588                         
589                 case ACTMENU_SEL_BORDERM: /* Border Select */
590                         borderselect_markers();
591                         break;
592                         
593                 case ACTMENU_SEL_ALL_KEYS: /* Select/Deselect All Keys */
594                         deselect_action_keys(1, 1);
595                         BIF_undo_push("(De)Select Keys");
596                         allqueue(REDRAWACTION, 0);
597                         allqueue(REDRAWNLA, 0);
598                         allqueue(REDRAWIPO, 0);
599                         break;
600                         
601                 case ACTMENU_SEL_ALL_CHAN: /* Select/Deselect All Channels */
602                         deselect_action_channels(1);
603                         BIF_undo_push("(De)Select Action Channels");
604                         allqueue(REDRAWVIEW3D, 0);
605                         allqueue(REDRAWACTION, 0);
606                         allqueue(REDRAWNLA, 0);
607                         allqueue(REDRAWIPO, 0);
608                         break;
609                         
610                 case ACTMENU_SEL_ALL_MARKERS: /* select/deselect all markers */
611                         deselect_markers(1, 0);
612                         BIF_undo_push("(De)Select Markers");
613                         allqueue(REDRAWMARKER, 0);
614                         break;
615                         
616                 case ACTMENU_SEL_INVERSE_KEYS: /* invert selection status of keys */
617                         deselect_action_keys(0, 2);
618                         BIF_undo_push("Inverse Keys");
619                         allqueue(REDRAWACTION, 0);
620                         allqueue(REDRAWNLA, 0);
621                         allqueue(REDRAWIPO, 0);
622                         break;
623                         
624                 case ACTMENU_SEL_INVERSE_CHANNELS: /* invert selection status of channels */
625                         deselect_action_channels(2);
626                         BIF_undo_push("Inverse Action Channels");
627                         allqueue(REDRAWVIEW3D, 0);
628                         allqueue(REDRAWACTION, 0);
629                         allqueue(REDRAWNLA, 0);
630                         allqueue(REDRAWIPO, 0);
631                         break;
632                         
633                 case ACTMENU_SEL_INVERSE_MARKERS: /* invert selection of markers */
634                         deselect_markers(0, 2);
635                         BIF_undo_push("Inverse Action Channels");
636                         allqueue(REDRAWMARKER, 0);
637                         break;
638                         
639                 case ACTMENU_SEL_LEFTKEYS:
640                         selectkeys_leftright(1, SELECT_REPLACE);
641                         break;
642                         
643                 case ACTMENU_SEL_RIGHTKEYS:
644                         selectkeys_leftright(0, SELECT_REPLACE);
645                         break;
646         }
647 }
648
649 static uiBlock *action_selectmenu(void *arg_unused)
650 {
651         uiBlock *block;
652         short yco= 0, menuwidth=120;
653
654         block= uiNewBlock(&curarea->uiblocks, "action_selectmenu", 
655                                           UI_EMBOSSP, UI_HELV, curarea->headwin);
656         uiBlockSetButmFunc(block, do_action_selectmenu, NULL);
657
658         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, 
659                                          "Border Select Keys|B", 0, yco-=20, 
660                                          menuwidth, 19, NULL, 0.0, 0.0, 0, 
661                                          ACTMENU_SEL_BORDER, "");
662         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, 
663                                          "Border Select Channels|B", 0, yco-=20, 
664                                          menuwidth, 19, NULL, 0.0, 0.0, 0, 
665                                          ACTMENU_SEL_BORDERC, "");
666         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, 
667                                          "Border Select Markers|Ctrl B", 0, yco-=20, 
668                                          menuwidth, 19, NULL, 0.0, 0.0, 0, 
669                                          ACTMENU_SEL_BORDERM, "");
670                                          
671         uiDefBut(block, SEPR, 0, "", 0, yco-=6, 
672                          menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
673                          
674         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, 
675                                          "Select/Deselect All Keys|A", 0, yco-=20, 
676                                          menuwidth, 19, NULL, 0.0, 0.0, 0, 
677                                          ACTMENU_SEL_ALL_KEYS, "");
678         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, 
679                                          "Select/Deselect All Markers|Ctrl A", 0, yco-=20, 
680                                          menuwidth, 19, NULL, 0.0, 0.0, 0, 
681                                          ACTMENU_SEL_ALL_MARKERS, "");
682         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, 
683                                          "Select/Deselect All Channels|A", 0, yco-=20, 
684                                          menuwidth, 19, NULL, 0.0, 0.0, 0, 
685                                          ACTMENU_SEL_ALL_CHAN, "");
686                                          
687         uiDefBut(block, SEPR, 0, "", 0, yco-=6, 
688                          menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
689
690         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, 
691                                          "Inverse Keys|Ctrl I", 0, yco-=20, 
692                                          menuwidth, 19, NULL, 0.0, 0.0, 0, 
693                                          ACTMENU_SEL_INVERSE_KEYS, "");
694         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, 
695                                          "Inverse Markers|Ctrl Shift I", 0, yco-=20, 
696                                          menuwidth, 19, NULL, 0.0, 0.0, 0, 
697                                          ACTMENU_SEL_INVERSE_MARKERS, "");
698         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, 
699                                          "Inverse All Channels|Ctrl I", 0, yco-=20, 
700                                          menuwidth, 19, NULL, 0.0, 0.0, 0, 
701                                          ACTMENU_SEL_INVERSE_CHANNELS, "");
702                 
703         uiDefBut(block, SEPR, 0, "", 0, yco-=6, 
704                          menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
705                          
706         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, 
707                                          "Back In Time|Alt RMB", 0, yco-=20, 
708                                          menuwidth, 19, NULL, 0.0, 0.0, 0, 
709                                          ACTMENU_SEL_LEFTKEYS, "");
710                                                                  
711         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, 
712                                          "Ahead In Time|Alt RMB", 0, yco-=20, 
713                                          menuwidth, 19, NULL, 0.0, 0.0, 0, 
714                                          ACTMENU_SEL_RIGHTKEYS, "");             
715                          
716         uiDefBut(block, SEPR, 0, "", 0, yco-=6, 
717                          menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
718                          
719         uiDefIconTextBlockBut(block, action_selectmenu_columnmenu, 
720                                                   NULL, ICON_RIGHTARROW_THIN, "Column Select Keys", 0, yco-=20, 120, 20, "");
721         
722         if (curarea->headertype==HEADERTOP) {
723                 uiBlockSetDirection(block, UI_DOWN);
724         }
725         else {
726                 uiBlockSetDirection(block, UI_TOP);
727                 uiBlockFlipOrder(block);
728         }
729
730         uiTextBoundsBlock(block, 50);
731
732         return block;
733 }
734
735
736 static void do_action_channelmenu_posmenu(void *arg, int event)
737 {
738         switch(event)
739         {
740                 case ACTMENU_CHANNELS_CHANPOS_MOVE_CHANNEL_DOWN:
741                         rearrange_action_channels(REARRANGE_ACTCHAN_DOWN);
742                         break;
743                 case ACTMENU_CHANNELS_CHANPOS_MOVE_CHANNEL_UP:
744                         rearrange_action_channels(REARRANGE_ACTCHAN_UP);
745                         break;
746                 case ACTMENU_CHANNELS_CHANPOS_MOVE_CHANNEL_TOP:
747                         rearrange_action_channels(REARRANGE_ACTCHAN_TOP);
748                         break;
749                 case ACTMENU_CHANNELS_CHANPOS_MOVE_CHANNEL_BOTTOM:
750                         rearrange_action_channels(REARRANGE_ACTCHAN_BOTTOM);
751                         break;
752         }
753
754         scrarea_queue_winredraw(curarea);
755 }
756
757 static uiBlock *action_channelmenu_posmenu(void *arg_unused)
758 {
759         uiBlock *block;
760         short yco= 0, menuwidth=120;
761
762         block= uiNewBlock(&curarea->uiblocks, "action_channelmenu_posmenu", 
763                                           UI_EMBOSSP, UI_HELV, G.curscreen->mainwin);
764         uiBlockSetButmFunc(block, do_action_channelmenu_posmenu, NULL);
765
766         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, 
767                                          "Move Up|Shift Page Up", 0, yco-=20, 
768                                          menuwidth, 19, NULL, 0.0, 0.0, 0, 
769                                          ACTMENU_CHANNELS_CHANPOS_MOVE_CHANNEL_UP, "");
770         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, 
771                                          "Move Down|Shift Page Down", 0, yco-=20, 
772                                          menuwidth, 19, NULL, 0.0, 0.0, 0, 
773                                          ACTMENU_CHANNELS_CHANPOS_MOVE_CHANNEL_DOWN, "");
774         
775         uiDefBut(block, SEPR, 0, "", 0, yco-=6, 
776                                         menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
777                                         
778         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, 
779                                          "Move to Top|Ctrl Shift Page Up", 0, yco-=20, 
780                                          menuwidth, 19, NULL, 0.0, 0.0, 0, 
781                                          ACTMENU_CHANNELS_CHANPOS_MOVE_CHANNEL_TOP, "");
782         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, 
783                                          "Move to Bottom|Ctrl Shift Page Down", 0, yco-=20, 
784                                          menuwidth, 19, NULL, 0.0, 0.0, 0, 
785                                          ACTMENU_CHANNELS_CHANPOS_MOVE_CHANNEL_BOTTOM, "");
786
787         uiBlockSetDirection(block, UI_RIGHT);
788         uiTextBoundsBlock(block, 60);
789
790         return block;
791 }
792
793 static void do_action_channelmenu_groupmenu(void *arg, int event)
794 {
795         switch(event)
796         {
797                 case ACTMENU_CHANNELS_GROUP_ADD_TOACTIVE:
798                         action_groups_group(0);
799                         break;
800                 case ACTMENU_CHANNELS_GROUP_ADD_TONEW:
801                         action_groups_group(1);
802                         break;
803                 case ACTMENU_CHANNELS_GROUP_REMOVE:
804                         action_groups_ungroup();
805                         break;
806                 case ACTMENU_CHANNELS_GROUP_SYNCPOSE: /* Syncronise Pose-data and Action-data */
807                         sync_pchan2achan_grouping();
808                         break;
809         }
810 }
811
812 static uiBlock *action_channelmenu_groupmenu(void *arg_unused)
813 {
814         uiBlock *block;
815         short yco= 0, menuwidth=120;
816
817         block= uiNewBlock(&curarea->uiblocks, "action_channelmenu_groupmenu", 
818                                           UI_EMBOSSP, UI_HELV, G.curscreen->mainwin);
819         uiBlockSetButmFunc(block, do_action_channelmenu_groupmenu, NULL);
820
821         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, 
822                                          "Add to Active Group|Shift G", 0, yco-=20, 
823                                          menuwidth, 19, NULL, 0.0, 0.0, 0, 
824                                          ACTMENU_CHANNELS_GROUP_ADD_TOACTIVE, "");
825         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, 
826                                          "Add to New Group|Ctrl Shift G", 0, yco-=20, 
827                                          menuwidth, 19, NULL, 0.0, 0.0, 0, 
828                                          ACTMENU_CHANNELS_GROUP_ADD_TONEW, "");
829                 
830         uiDefBut(block, SEPR, 0, "", 0, yco-=6, 
831                                         menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
832                                         
833         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, 
834                                          "Remove From Group|Alt G", 0, yco-=20, 
835                                          menuwidth, 19, NULL, 0.0, 0.0, 0, 
836                                          ACTMENU_CHANNELS_GROUP_REMOVE, "");
837                                          
838         uiDefBut(block, SEPR, 0, "", 0, yco-=6, 
839                                         menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
840                                         
841         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, 
842                                          "Synchronise with Armature", 0, yco-=20, 
843                                          menuwidth, 19, NULL, 0.0, 0.0, 0, 
844                                          ACTMENU_CHANNELS_GROUP_SYNCPOSE, "");
845
846         uiBlockSetDirection(block, UI_RIGHT);
847         uiTextBoundsBlock(block, 60);
848
849         return block;
850 }
851
852 static void do_action_channelmenu_settingsmenu(void *arg, int event)
853 {
854         setflag_action_channels(event);
855 }
856
857 static uiBlock *action_channelmenu_settingsmenu(void *arg_unused)
858 {
859         uiBlock *block;
860         short yco= 0, menuwidth=120;
861
862         block= uiNewBlock(&curarea->uiblocks, "action_channelmenu_settingsmenu", 
863                                           UI_EMBOSSP, UI_HELV, G.curscreen->mainwin);
864         uiBlockSetButmFunc(block, do_action_channelmenu_settingsmenu, NULL);
865
866         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, 
867                                          "Toggle a Setting|Shift W", 0, yco-=20, 
868                                          menuwidth, 19, NULL, 0.0, 0.0, 0, 
869                                          ACTMENU_CHANNELS_SETTINGS_TOGGLE, "");
870                                          
871         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, 
872                                          "Enable a Setting|Ctrl Shift W", 0, yco-=20, 
873                                          menuwidth, 19, NULL, 0.0, 0.0, 0, 
874                                          ACTMENU_CHANNELS_SETTINGS_ENABLE, "");
875                                         
876         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, 
877                                          "Disable a Setting|Alt W", 0, yco-=20, 
878                                          menuwidth, 19, NULL, 0.0, 0.0, 0, 
879                                          ACTMENU_CHANNELS_SETTINGS_DISABLE, "");
880
881         uiBlockSetDirection(block, UI_RIGHT);
882         uiTextBoundsBlock(block, 60);
883
884         return block;
885 }
886
887 static void do_action_channelmenu(void *arg, int event)
888 {       
889         SpaceAction *saction;
890         
891         saction = curarea->spacedata.first;
892         if (saction == NULL) return;
893         
894         switch(event)
895         {
896                 case ACTMENU_CHANNELS_OPENLEVELS: /* Unfold selected channels one step */
897                         openclose_level_action(1);
898                         break;
899                 case ACTMENU_CHANNELS_CLOSELEVELS: /* Fold selected channels one step */
900                         openclose_level_action(-1);
901                         break;
902                 case ACTMENU_CHANNELS_EXPANDALL: /* Expands all channels */
903                         expand_all_action();
904                         break;
905                 case ACTMENU_CHANNELS_SHOWACHANS: /* Unfold groups that are hiding selected achans */
906                         expand_obscuregroups_action();
907                         break;
908                 case ACTMENU_CHANNELS_DELETE: /* Deletes selected channels */
909                         delete_action_channels();
910                         break;
911         }
912 }
913
914 static uiBlock *action_channelmenu(void *arg_unused)
915 {
916         uiBlock *block;
917         short yco= 0, menuwidth=120;
918
919         block= uiNewBlock(&curarea->uiblocks, "action_channelmenu", 
920                                           UI_EMBOSSP, UI_HELV, curarea->headwin);
921         uiBlockSetButmFunc(block, do_action_channelmenu, NULL);
922         
923         uiDefIconTextBlockBut(block, action_channelmenu_groupmenu, 
924                                                   NULL, ICON_RIGHTARROW_THIN, 
925                                                   "Grouping", 0, yco-=20, 120, 20, "");  
926                                                   
927         uiDefIconTextBlockBut(block, action_channelmenu_posmenu, 
928                                                   NULL, ICON_RIGHTARROW_THIN, 
929                                                   "Ordering", 0, yco-=20, 120, 20, "");
930         
931         uiDefIconTextBlockBut(block, action_channelmenu_settingsmenu, 
932                                                   NULL, ICON_RIGHTARROW_THIN, 
933                                                   "Settings", 0, yco-=20, 120, 20, ""); 
934         
935         uiDefBut(block, SEPR, 0, "", 0, yco-=6, 
936                                         menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
937         
938         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, 
939                         "Delete|X", 0, yco-=20,
940                         menuwidth, 19, NULL, 0.0, 0.0, 0, ACTMENU_CHANNELS_DELETE, "");
941         
942         uiDefBut(block, SEPR, 0, "", 0, yco-=6, 
943                                         menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
944                 
945         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, 
946                         "Toggle Show Hierachy|~", 0, yco-=20,
947                         menuwidth, 19, NULL, 0.0, 0.0, 0, ACTMENU_CHANNELS_EXPANDALL, "");
948                         
949         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, 
950                         "Show Group-Hidden Channels|Shift ~", 0, yco-=20,
951                         menuwidth, 19, NULL, 0.0, 0.0, 0, ACTMENU_CHANNELS_SHOWACHANS, "");
952                         
953         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, 
954                         "Expand One Level|Ctrl NumPad+", 0, yco-=20,
955                         menuwidth, 19, NULL, 0.0, 0.0, 0, ACTMENU_CHANNELS_OPENLEVELS, "");
956                         
957         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, 
958                         "Collapse One Level|Ctrl NumPad-", 0, yco-=20,
959                         menuwidth, 19, NULL, 0.0, 0.0, 0, ACTMENU_CHANNELS_CLOSELEVELS, "");
960         
961         if (curarea->headertype==HEADERTOP) {
962                 uiBlockSetDirection(block, UI_DOWN);
963         }
964         else {
965                 uiBlockSetDirection(block, UI_TOP);
966                 uiBlockFlipOrder(block);
967         }
968
969         uiTextBoundsBlock(block, 50);
970
971         return block;
972 }
973
974 static void do_action_keymenu_transformmenu(void *arg, int event)
975 {       
976         switch (event)
977         {
978                 case ACTMENU_KEY_TRANSFORM_MOVE:
979                         transform_action_keys('g', 0);
980                         break;
981                 case ACTMENU_KEY_TRANSFORM_SCALE:
982                         transform_action_keys('s', 0);
983                         break;
984                 case ACTMENU_KEY_TRANSFORM_SLIDE:
985                         transform_action_keys('t', 0);
986                         break;
987                 case ACTMENU_KEY_TRANSFORM_EXTEND:
988                         transform_action_keys('e', 0);
989                         break;
990         }
991
992         scrarea_queue_winredraw(curarea);
993 }
994
995 static uiBlock *action_keymenu_transformmenu(void *arg_unused)
996 {
997         uiBlock *block;
998         short yco= 0, menuwidth=120;
999
1000         block= uiNewBlock(&curarea->uiblocks, "action_keymenu_transformmenu", 
1001                                           UI_EMBOSSP, UI_HELV, G.curscreen->mainwin);
1002         uiBlockSetButmFunc(block, do_action_keymenu_transformmenu, NULL);
1003
1004         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, 
1005                                          "Grab/Move|G", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0,  
1006                                          ACTMENU_KEY_TRANSFORM_MOVE, "");
1007         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, 
1008                                          "Grab/Extend from Frame|E", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 
1009                                          ACTMENU_KEY_TRANSFORM_EXTEND, "");
1010         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, 
1011                                          "Scale|S", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 
1012                                          ACTMENU_KEY_TRANSFORM_SCALE, "");
1013         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, 
1014                                          "Time Slide|T", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 
1015                                          ACTMENU_KEY_TRANSFORM_SLIDE, "");
1016         
1017         
1018         uiBlockSetDirection(block, UI_RIGHT);
1019         uiTextBoundsBlock(block, 60);
1020
1021         return block;
1022 }
1023
1024 static void do_action_keymenu_handlemenu(void *arg, int event)
1025 {
1026         switch (event) {
1027                 case ACTMENU_KEY_HANDLE_AUTO:
1028                         sethandles_action_keys(HD_AUTO);
1029                         break;
1030
1031                 case ACTMENU_KEY_HANDLE_ALIGN:
1032                 case ACTMENU_KEY_HANDLE_FREE:
1033                         /* OK, this is kinda dumb, need to fix the
1034                          * toggle crap in sethandles_ipo_keys() 
1035                          */
1036                         sethandles_action_keys(HD_ALIGN);
1037                         break;
1038
1039                 case ACTMENU_KEY_HANDLE_VECTOR:
1040                         sethandles_action_keys(HD_VECT);        
1041                         break;
1042         }
1043 }
1044
1045 static uiBlock *action_keymenu_handlemenu(void *arg_unused)
1046 {
1047         uiBlock *block;
1048         short yco= 0, menuwidth=120;
1049
1050         block= uiNewBlock(&curarea->uiblocks, "action_keymenu_handlemenu", UI_EMBOSSP, UI_HELV, G.curscreen->mainwin);
1051         uiBlockSetButmFunc(block, do_action_keymenu_handlemenu, NULL);
1052
1053         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, 
1054                                          "Auto|Shift H", 0, yco-=20, 
1055                                          menuwidth, 19, NULL, 0.0, 0.0, 0, 
1056                                          ACTMENU_KEY_HANDLE_AUTO, "");
1057         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, 
1058                                          "Aligned|H", 0, yco-=20, 
1059                                          menuwidth, 19, NULL, 0.0, 0.0, 0, 
1060                                          ACTMENU_KEY_HANDLE_ALIGN, "");
1061         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, 
1062                                          "Free|H", 0, yco-=20, menuwidth, 
1063                                          19, NULL, 0.0, 0.0, 0, 
1064                                          ACTMENU_KEY_HANDLE_FREE, "");
1065         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, 
1066                                          "Vector|V", 0, yco-=20, 
1067                                          menuwidth, 19, NULL, 0.0, 0.0, 0, 
1068                                          ACTMENU_KEY_HANDLE_VECTOR, "");
1069
1070         uiBlockSetDirection(block, UI_RIGHT);
1071         uiTextBoundsBlock(block, 60);
1072
1073         return block;
1074 }
1075
1076 static void do_action_keymenu_intpolmenu(void *arg, int event)
1077 {
1078         switch(event)
1079         {
1080                 case ACTMENU_KEY_INTERP_CONST:
1081                         action_set_ipo_flags(SET_IPO_MENU, SET_IPO_CONSTANT);
1082                         break;
1083                 case ACTMENU_KEY_INTERP_LINEAR:
1084                         action_set_ipo_flags(SET_IPO_MENU, SET_IPO_LINEAR);
1085                         break;
1086                 case ACTMENU_KEY_INTERP_BEZIER:
1087                         action_set_ipo_flags(SET_IPO_MENU, SET_IPO_BEZIER);
1088                         break;
1089         }
1090
1091         scrarea_queue_winredraw(curarea);
1092 }
1093
1094 static uiBlock *action_keymenu_intpolmenu(void *arg_unused)
1095 {
1096         uiBlock *block;
1097         short yco= 0, menuwidth=120;
1098
1099         block= uiNewBlock(&curarea->uiblocks, "action_keymenu_intpolmenu", 
1100                                           UI_EMBOSSP, UI_HELV, G.curscreen->mainwin);
1101         uiBlockSetButmFunc(block, do_action_keymenu_intpolmenu, NULL);
1102
1103         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, 
1104                                          "Constant|Shift T, 1", 0, yco-=20, 
1105                                          menuwidth, 19, NULL, 0.0, 0.0, 0, 
1106                                          ACTMENU_KEY_INTERP_CONST, "");
1107         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, 
1108                                          "Linear|Shift T, 2", 0, yco-=20, 
1109                                          menuwidth, 19, NULL, 0.0, 0.0, 0, 
1110                                          ACTMENU_KEY_INTERP_LINEAR, "");
1111         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, 
1112                                          "Bezier|Shift T, 3", 0, yco-=20, 
1113                                          menuwidth, 19, NULL, 0.0, 0.0, 0, 
1114                                          ACTMENU_KEY_INTERP_BEZIER, "");
1115
1116         uiBlockSetDirection(block, UI_RIGHT);
1117         uiTextBoundsBlock(block, 60);
1118
1119         return block;
1120 }
1121
1122 static void do_action_keymenu_extendmenu(void *arg, int event)
1123 {
1124         switch(event)
1125         {
1126                 case ACTMENU_KEY_EXTEND_CONST:
1127                         action_set_ipo_flags(SET_EXTEND_MENU, SET_EXTEND_CONSTANT);
1128                         break;
1129                 case ACTMENU_KEY_EXTEND_EXTRAPOLATION:
1130                         action_set_ipo_flags(SET_EXTEND_MENU, SET_EXTEND_EXTRAPOLATION);
1131                         break;
1132                 case ACTMENU_KEY_EXTEND_CYCLIC:
1133                         action_set_ipo_flags(SET_EXTEND_MENU, SET_EXTEND_CYCLIC);
1134                         break;
1135                 case ACTMENU_KEY_EXTEND_CYCLICEXTRAPOLATION:
1136                         action_set_ipo_flags(SET_EXTEND_MENU, SET_EXTEND_CYCLICEXTRAPOLATION);
1137                         break;
1138         }
1139
1140         scrarea_queue_winredraw(curarea);
1141 }
1142
1143 static uiBlock *action_keymenu_extendmenu(void *arg_unused)
1144 {
1145         uiBlock *block;
1146         short yco= 0, menuwidth=120;
1147
1148         block= uiNewBlock(&curarea->uiblocks, "action_keymenu_extendmenu", 
1149                                           UI_EMBOSSP, UI_HELV, G.curscreen->mainwin);
1150         uiBlockSetButmFunc(block, do_action_keymenu_extendmenu, NULL);
1151
1152         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, 
1153                                          "Constant", 0, yco-=20, 
1154                                          menuwidth, 19, NULL, 0.0, 0.0, 0, 
1155                                          ACTMENU_KEY_EXTEND_CONST, "");
1156         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, 
1157                                          "Extrapolation", 0, yco-=20, 
1158                                          menuwidth, 19, NULL, 0.0, 0.0, 0, 
1159                                          ACTMENU_KEY_EXTEND_EXTRAPOLATION, "");
1160         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, 
1161                                          "Cyclic", 0, yco-=20, 
1162                                          menuwidth, 19, NULL, 0.0, 0.0, 0, 
1163                                          ACTMENU_KEY_EXTEND_CYCLIC, "");
1164         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, 
1165                                          "Cyclic Extrapolation", 0, yco-=20, 
1166                                          menuwidth, 19, NULL, 0.0, 0.0, 0, 
1167                                          ACTMENU_KEY_EXTEND_CYCLICEXTRAPOLATION, "");
1168
1169         uiBlockSetDirection(block, UI_RIGHT);
1170         uiTextBoundsBlock(block, 60);
1171
1172         return block;
1173 }
1174
1175 static void do_action_keymenu_snapmenu(void *arg, int event)
1176 {
1177         switch(event)
1178         {
1179                 case ACTMENU_KEY_SNAP_NEARFRAME:
1180                 case ACTMENU_KEY_SNAP_CURFRAME:
1181                 case ACTMENU_KEY_SNAP_NEARMARK:
1182                 case ACTMENU_KEY_SNAP_NEARTIME:
1183                         snap_action_keys(event);
1184                         break;
1185                         
1186                 case ACTMENU_KEY_SNAP_CFRA2KEY:
1187                         snap_cfra_action();
1188                         break;
1189         }
1190
1191         scrarea_queue_winredraw(curarea);
1192 }
1193
1194 static uiBlock *action_keymenu_snapmenu(void *arg_unused)
1195 {
1196         uiBlock *block;
1197         short yco= 0, menuwidth=120;
1198
1199         block= uiNewBlock(&curarea->uiblocks, "action_keymenu_snapmenu", 
1200                                           UI_EMBOSSP, UI_HELV, G.curscreen->mainwin);
1201         uiBlockSetButmFunc(block, do_action_keymenu_snapmenu, NULL);
1202
1203         if (G.saction->flag & SACTION_DRAWTIME) {
1204                 uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, 
1205                                                  "Key -> Nearest Second|Shift S, 1", 0, yco-=20, 
1206                                                  menuwidth, 19, NULL, 0.0, 0.0, 0, 
1207                                                  ACTMENU_KEY_SNAP_NEARTIME, "");
1208                 uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, 
1209                                                  "Key -> Current Time|Shift S, 2", 0, yco-=20, 
1210                                                  menuwidth, 19, NULL, 0.0, 0.0, 0, 
1211                                                  ACTMENU_KEY_SNAP_CURFRAME, "");
1212
1213         }
1214         else {
1215                 uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, 
1216                                                  "Key -> Nearest Frame|Shift S, 1", 0, yco-=20, 
1217                                                  menuwidth, 19, NULL, 0.0, 0.0, 0, 
1218                                                  ACTMENU_KEY_SNAP_NEARFRAME, "");
1219                 uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, 
1220                                                  "Key -> Current Frame|Shift S, 2", 0, yco-=20, 
1221                                                  menuwidth, 19, NULL, 0.0, 0.0, 0, 
1222                                                  ACTMENU_KEY_SNAP_CURFRAME, "");
1223         }
1224         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, 
1225                                          "Key -> Nearest Marker|Shift S, 3", 0, yco-=20, 
1226                                          menuwidth, 19, NULL, 0.0, 0.0, 0, 
1227                                          ACTMENU_KEY_SNAP_NEARMARK, "");
1228                                          
1229         uiDefBut(block, SEPR, 0, "", 0, yco-=6, 
1230                          menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
1231                          
1232         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, 
1233                                          "Current Frame -> Key|Ctrl Shift S", 0, yco-=20, 
1234                                          menuwidth, 19, NULL, 0.0, 0.0, 0, 
1235                                          ACTMENU_KEY_SNAP_NEARMARK, "");
1236
1237         uiBlockSetDirection(block, UI_RIGHT);
1238         uiTextBoundsBlock(block, 60);
1239
1240         return block;
1241 }
1242
1243 static void do_action_keymenu_mirrormenu(void *arg, int event)
1244 {
1245         switch(event)
1246         {
1247                 case ACTMENU_KEY_MIRROR_CURFRAME:
1248                 case ACTMENU_KEY_MIRROR_YAXIS:
1249                         mirror_action_keys(event);
1250                         break;
1251         }
1252
1253         scrarea_queue_winredraw(curarea);
1254 }
1255
1256 static uiBlock *action_keymenu_mirrormenu(void *arg_unused)
1257 {
1258         uiBlock *block;
1259         short yco= 0, menuwidth=120;
1260
1261         block= uiNewBlock(&curarea->uiblocks, "action_keymenu_mirrormenu", 
1262                                           UI_EMBOSSP, UI_HELV, G.curscreen->mainwin);
1263         uiBlockSetButmFunc(block, do_action_keymenu_mirrormenu, NULL);
1264
1265         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, 
1266                                          "Current Frame|Shift M, 1", 0, yco-=20, 
1267                                          menuwidth, 19, NULL, 0.0, 0.0, 0, 
1268                                          ACTMENU_KEY_MIRROR_CURFRAME, "");
1269         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, 
1270                                          "Vertical Axis|Shift M, 2", 0, yco-=20, 
1271                                          menuwidth, 19, NULL, 0.0, 0.0, 0, 
1272                                          ACTMENU_KEY_MIRROR_YAXIS, "");
1273         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, 
1274                                          "Horizontal Axis|Shift M, 3", 0, yco-=20, 
1275                                          menuwidth, 19, NULL, 0.0, 0.0, 0, 
1276                                          ACTMENU_KEY_MIRROR_XAXIS, "");
1277         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, 
1278                                          "Selected Marker|Shift M, 4", 0, yco-=20, 
1279                                          menuwidth, 19, NULL, 0.0, 0.0, 0, 
1280                                          ACTMENU_KEY_MIRROR_MARKER, "");
1281
1282         uiBlockSetDirection(block, UI_RIGHT);
1283         uiTextBoundsBlock(block, 60);
1284
1285         return block;
1286 }
1287
1288 static void do_action_keymenu(void *arg, int event)
1289 {       
1290         SpaceAction *saction;
1291         bAction *act;
1292         Key *key;
1293         
1294         saction = curarea->spacedata.first;
1295         if (!saction) return;
1296
1297         act = saction->action;
1298         key = get_action_mesh_key();
1299
1300         switch(event)
1301         {
1302                 case ACTMENU_KEY_DUPLICATE:
1303                         duplicate_action_keys();
1304                         break;
1305                 case ACTMENU_KEY_DELETE:
1306                         delete_action_keys();
1307                         break;
1308                 case ACTMENU_KEY_CLEAN:
1309                         clean_action();
1310                         break;
1311                 case ACTMENU_KEY_SAMPLEKEYS:
1312                         sample_action_keys();
1313                         break;
1314                 case ACTMENU_KEY_INSERTKEY:
1315                         insertkey_action();
1316                         break;
1317         }
1318 }
1319
1320 static uiBlock *action_keymenu(void *arg_unused)
1321 {
1322         uiBlock *block;
1323         short yco= 0, menuwidth=120;
1324
1325         block= uiNewBlock(&curarea->uiblocks, "action_keymenu", 
1326                                           UI_EMBOSSP, UI_HELV, curarea->headwin);
1327         uiBlockSetButmFunc(block, do_action_keymenu, NULL);
1328         
1329         uiDefIconTextBlockBut(block, action_keymenu_transformmenu, 
1330                                                   NULL, ICON_RIGHTARROW_THIN, "Transform", 0, yco-=20, 120, 20, "");
1331         
1332         uiDefIconTextBlockBut(block, action_keymenu_snapmenu, 
1333                                                   NULL, ICON_RIGHTARROW_THIN, "Snap", 0, yco-=20, 120, 20, "");
1334         
1335         uiDefIconTextBlockBut(block, action_keymenu_mirrormenu, 
1336                                                   NULL, ICON_RIGHTARROW_THIN, "Mirror", 0, yco-=20, 120, 20, "");
1337         
1338         uiDefBut(block, SEPR, 0, "", 0, yco-=6, 
1339                                         menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
1340         
1341         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, 
1342                                         "Insert Key|I", 0, yco-=20, 
1343                                         menuwidth, 19, NULL, 0.0, 0.0, 0, 
1344                                         ACTMENU_KEY_INSERTKEY, "");
1345
1346         uiDefBut(block, SEPR, 0, "", 0, yco-=6, 
1347                          menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
1348                                         
1349         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, 
1350                                         "Duplicate|Shift D", 0, yco-=20, 
1351                                         menuwidth, 19, NULL, 0.0, 0.0, 0, 
1352                                         ACTMENU_KEY_DUPLICATE, "");
1353         
1354         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, 
1355                                         "Delete|X", 0, yco-=20, 
1356                                         menuwidth, 19, NULL, 0.0, 0.0, 0, 
1357                                         ACTMENU_KEY_DELETE, "");
1358
1359         uiDefBut(block, SEPR, 0, "", 0, yco-=6, 
1360                          menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
1361
1362         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, 
1363                                          "Clean Action|O", 0, yco-=20, 
1364                                          menuwidth, 19, NULL, 0.0, 0.0, 0, 
1365                                          ACTMENU_KEY_CLEAN, "");
1366                                          
1367         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, 
1368                                          "Sample Keys|Alt O", 0, yco-=20, 
1369                                          menuwidth, 19, NULL, 0.0, 0.0, 0, 
1370                                          ACTMENU_KEY_SAMPLEKEYS, "");
1371
1372         uiDefBut(block, SEPR, 0, "", 0, yco-=6, 
1373                          menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
1374
1375         uiDefIconTextBlockBut(block, action_keymenu_handlemenu, 
1376                                                   NULL, ICON_RIGHTARROW_THIN, 
1377                                                   "Handle Type", 0, yco-=20, 120, 20, "");
1378         
1379         uiDefBut(block, SEPR, 0, "", 0, yco-=6, 
1380                          menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
1381
1382         uiDefIconTextBlockBut(block, action_keymenu_extendmenu, 
1383                                                   NULL, ICON_RIGHTARROW_THIN, 
1384                                                   "Extend Mode", 0, yco-=20, 120, 20, "");
1385         uiDefIconTextBlockBut(block, action_keymenu_intpolmenu, 
1386                                                   NULL, ICON_RIGHTARROW_THIN, 
1387                                                   "Interpolation Mode", 0, yco-=20, 120, 20, "");
1388
1389         
1390         if(curarea->headertype==HEADERTOP) {
1391                 uiBlockSetDirection(block, UI_DOWN);
1392         }
1393         else {
1394                 uiBlockSetDirection(block, UI_TOP);
1395                 uiBlockFlipOrder(block);
1396         }
1397
1398         uiTextBoundsBlock(block, 50);
1399
1400         return block;
1401 }
1402
1403 static void do_action_markermenu(void *arg, int event)
1404 {       
1405         switch(event)
1406         {
1407                 case ACTMENU_MARKERS_ADD:
1408                         add_marker(CFRA);
1409                         break;
1410                 case ACTMENU_MARKERS_DUPLICATE:
1411                         duplicate_marker();
1412                         break;
1413                 case ACTMENU_MARKERS_DELETE:
1414                         remove_marker();
1415                         break;
1416                 case ACTMENU_MARKERS_NAME:
1417                         rename_marker();
1418                         break;
1419                 case ACTMENU_MARKERS_MOVE:
1420                         transform_markers('g', 0);
1421                         break;
1422                         
1423                 case ACTMENU_MARKERS_LOCALADD:
1424                         action_add_localmarker(G.saction->action, CFRA);
1425                         break;
1426                 case ACTMENU_MARKERS_LOCALDELETE:
1427                         action_remove_localmarkers(G.saction->action);
1428                         break;
1429                 case ACTMENU_MARKERS_LOCALRENAME:
1430                         action_rename_localmarker(G.saction->action);
1431                         break;
1432                 case ACTMENU_MARKERS_LOCALMOVE:
1433                         G.saction->flag |= SACTION_POSEMARKERS_MOVE;
1434                         transform_markers('g', 0);
1435                         G.saction->flag &= ~SACTION_POSEMARKERS_MOVE;
1436                         break;
1437         }
1438         
1439         allqueue(REDRAWMARKER, 0);
1440 }
1441
1442 static uiBlock *action_markermenu(void *arg_unused)
1443 {
1444         uiBlock *block;
1445         short yco= 0, menuwidth=120;
1446
1447         block= uiNewBlock(&curarea->uiblocks, "action_markermenu", 
1448                                           UI_EMBOSSP, UI_HELV, curarea->headwin);
1449         uiBlockSetButmFunc(block, do_action_markermenu, NULL);
1450
1451         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Add Marker|M", 0, yco-=20, 
1452                                          menuwidth, 19, NULL, 0.0, 0.0, 1, ACTMENU_MARKERS_ADD, "");
1453         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Duplicate Marker|Ctrl Shift D", 0, yco-=20, 
1454                                          menuwidth, 19, NULL, 0.0, 0.0, 1, ACTMENU_MARKERS_DUPLICATE, "");
1455         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Delete Marker|X", 0, yco-=20,
1456                                          menuwidth, 19, NULL, 0.0, 0.0, 1, ACTMENU_MARKERS_DELETE, "");
1457                                         
1458         uiDefBut(block, SEPR, 0, "",        0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
1459                                         
1460         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "(Re)Name Marker|Ctrl M", 0, yco-=20,
1461                                          menuwidth, 19, NULL, 0.0, 0.0, 1, ACTMENU_MARKERS_NAME, "");
1462         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Grab/Move Marker|Ctrl G", 0, yco-=20,
1463                                          menuwidth, 19, NULL, 0.0, 0.0, 1, ACTMENU_MARKERS_MOVE, "");
1464                                          
1465         uiDefBut(block, SEPR, 0, "",        0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
1466         
1467         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Add Pose Marker|Shift L", 0, yco-=20, 
1468                                          menuwidth, 19, NULL, 0.0, 0.0, 1, ACTMENU_MARKERS_LOCALADD, "");
1469         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Rename Pose Marker|Ctrl Shift L", 0, yco-=20, 
1470                                          menuwidth, 19, NULL, 0.0, 0.0, 1, ACTMENU_MARKERS_LOCALRENAME, "");
1471         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Delete Pose Marker|Alt L", 0, yco-=20,
1472                                          menuwidth, 19, NULL, 0.0, 0.0, 1, ACTMENU_MARKERS_LOCALDELETE, "");
1473         uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Grab/Move Pose Marker|Ctrl L", 0, yco-=20, 
1474                                          menuwidth, 19, NULL, 0.0, 0.0, 1, ACTMENU_MARKERS_LOCALMOVE, "");
1475         
1476         if(curarea->headertype==HEADERTOP) {
1477                 uiBlockSetDirection(block, UI_DOWN);
1478         }
1479         else {
1480                 uiBlockSetDirection(block, UI_TOP);
1481                 uiBlockFlipOrder(block);
1482         }
1483
1484         uiTextBoundsBlock(block, 50);
1485
1486         return block;
1487 }
1488
1489 void action_buttons(void)
1490 {
1491         uiBlock *block;
1492         short xco, xmax;
1493         char name[256];
1494         Object *ob;
1495         ID *from;
1496
1497         if (G.saction == NULL)
1498                 return;
1499
1500         /* copied from drawactionspace.... */
1501         if (!G.saction->pin) {
1502                 if (OBACT)
1503                         G.saction->action = OBACT->action;
1504                 else
1505                         G.saction->action= NULL;
1506         }
1507
1508         sprintf(name, "header %d", curarea->headwin);
1509         block= uiNewBlock(&curarea->uiblocks, name, 
1510                                           UI_EMBOSS, UI_HELV, curarea->headwin);
1511
1512         if (area_is_active_area(curarea)) 
1513                 uiBlockSetCol(block, TH_HEADER);
1514         else 
1515                 uiBlockSetCol(block, TH_HEADERDESEL);
1516
1517         curarea->butspacetype= SPACE_ACTION;
1518         
1519         xco = 8;
1520         
1521         uiDefIconTextButC(block, ICONTEXTROW,B_NEWSPACE, ICON_VIEW3D, 
1522                                           windowtype_pup(), xco, 0, XIC+10, YIC, 
1523                                           &(curarea->butspacetype), 1.0, SPACEICONMAX, 0, 0, 
1524                                           "Displays Current Window Type. "
1525                                           "Click for menu of available types.");
1526
1527         xco += XIC + 14;
1528
1529         uiBlockSetEmboss(block, UI_EMBOSSN);
1530         if (curarea->flag & HEADER_NO_PULLDOWN) {
1531                 uiDefIconButBitS(block, TOG, HEADER_NO_PULLDOWN, B_FLIPINFOMENU, 
1532                                           ICON_DISCLOSURE_TRI_RIGHT,
1533                                           xco,2,XIC,YIC-2,
1534                                           &(curarea->flag), 0, 0, 0, 0, 
1535                                           "Show pulldown menus");
1536         }
1537         else {
1538                 uiDefIconButBitS(block, TOG, HEADER_NO_PULLDOWN, B_FLIPINFOMENU, 
1539                                           ICON_DISCLOSURE_TRI_DOWN,
1540                                           xco,2,XIC,YIC-2,
1541                                           &(curarea->flag), 0, 0, 0, 0, 
1542                                           "Hide pulldown menus");
1543         }
1544         uiBlockSetEmboss(block, UI_EMBOSS);
1545         xco+=XIC;
1546
1547         if ((curarea->flag & HEADER_NO_PULLDOWN)==0) {
1548                 /* pull down menus */
1549                 uiBlockSetEmboss(block, UI_EMBOSSP);
1550                 
1551                 xmax= GetButStringLength("View");
1552                 uiDefPulldownBut(block, action_viewmenu, NULL, 
1553                                           "View", xco, -2, xmax-3, 24, "");
1554                 xco+= xmax;
1555                 
1556                 xmax= GetButStringLength("Select");
1557                 uiDefPulldownBut(block, action_selectmenu, NULL, 
1558                                           "Select", xco, -2, xmax-3, 24, "");
1559                 xco+= xmax;
1560                 
1561                 if (G.saction->action) {
1562                         xmax= GetButStringLength("Channel");
1563                         uiDefPulldownBut(block, action_channelmenu, NULL, 
1564                                                   "Channel", xco, -2, xmax-3, 24, "");
1565                         xco+= xmax;
1566                 }
1567                 
1568                 xmax= GetButStringLength("Marker");
1569                 uiDefPulldownBut(block, action_markermenu, NULL, 
1570                                           "Marker", xco, -2, xmax-3, 24, "");
1571                 xco+= xmax;
1572                 
1573                 xmax= GetButStringLength("Key");
1574                 uiDefPulldownBut(block, action_keymenu, NULL, 
1575                                           "Key", xco, -2, xmax-3, 24, "");
1576                 xco+= xmax;
1577         }
1578
1579         uiBlockSetEmboss(block, UI_EMBOSS);
1580         
1581         /* NAME ETC */
1582         ob= OBACT;
1583         from = (ID *)ob;
1584
1585         xco= std_libbuttons(block, xco, 0, B_ACTPIN, &G.saction->pin, 
1586                                                 B_ACTIONBROWSE, ID_AC, 0, (ID*)G.saction->action, 
1587                                                 from, &(G.saction->actnr), B_ACTALONE, 
1588                                                 B_ACTLOCAL, B_ACTIONDELETE, 0, B_KEEPDATA);     
1589
1590         uiClearButLock();
1591
1592         xco += 8;
1593         
1594         /* COPY PASTE */
1595         uiBlockBeginAlign(block);
1596         if (curarea->headertype==HEADERTOP) {
1597                 uiDefIconBut(block, BUT, B_ACTCOPYKEYS, ICON_COPYUP,    xco,0,XIC,YIC, 0, 0, 0, 0, 0, "Copies the selected keyframes from the selected channel(s) to the buffer");
1598                 uiDefIconBut(block, BUT, B_ACTPASTEKEYS, ICON_PASTEUP,  xco+=XIC,0,XIC,YIC, 0, 0, 0, 0, 0, "Pastes the keyframes from the buffer");
1599         }
1600         else {
1601                 uiDefIconBut(block, BUT, B_ACTCOPYKEYS, ICON_COPYDOWN,  xco,0,XIC,YIC, 0, 0, 0, 0, 0, "Copies the selected keyframes from the selected channel(s) to the buffer");
1602                 uiDefIconBut(block, BUT, B_ACTPASTEKEYS, ICON_PASTEDOWN,        xco+=XIC,0,XIC,YIC, 0, 0, 0, 0, 0, "Pastes the keyframes from the buffer");
1603         }
1604         uiBlockEndAlign(block);
1605         xco += (XIC + 8);
1606         
1607         /* draw AUTOSNAP */
1608         if (G.saction->flag & SACTION_DRAWTIME) {
1609                 uiDefButS(block, MENU, B_REDR,
1610                                 "Auto-Snap Keyframes %t|No Snap %x0|Second Step %x1|Nearest Second %x2|Nearest Marker %x3", 
1611                                 xco,0,70,YIC, &(G.saction->autosnap), 0, 1, 0, 0, 
1612                                 "Auto-snapping mode for keyframes when transforming");
1613         }
1614         else {
1615                 uiDefButS(block, MENU, B_REDR, 
1616                                 "Auto-Snap Keyframes %t|No Snap %x0|Frame Step %x1|Nearest Frame %x2|Nearest Marker %x3", 
1617                                 xco,0,70,YIC, &(G.saction->autosnap), 0, 1, 0, 0, 
1618                                 "Auto-snapping mode for keyframes when transforming");
1619         }
1620         
1621         xco += (70 + 8);
1622         
1623         /* draw LOCK */
1624         uiDefIconButS(block, ICONTOG, 1, ICON_UNLOCKED, xco, 0, XIC, YIC, 
1625                                   &(G.saction->lock), 0, 0, 0, 0, 
1626                                   "Updates other affected window spaces automatically "
1627                                   "to reflect changes in real time");
1628         
1629         /* always as last  */
1630         curarea->headbutlen = xco + 2*XIC;
1631
1632         uiDrawBlock(block);
1633 }