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