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