operator renaming for more consistent word ordering (_add/_remmove shold be last...
[blender-staging.git] / source / blender / editors / space_action / action_header.c
index e0e9a4d7a181247ad0a6ce7203406a162c945ea7..d2dbb5fe3b07628f457d3166362c3cfc69776086 100644 (file)
 #include <string.h>
 #include <stdio.h>
 
+#include "DNA_anim_types.h"
 #include "DNA_action_types.h"
+#include "DNA_key_types.h"
+#include "DNA_object_types.h"
 #include "DNA_space_types.h"
 #include "DNA_scene_types.h"
 #include "DNA_screen_types.h"
 
 #include "BLI_blenlib.h"
 
+#include "BKE_animsys.h"
+#include "BKE_action.h"
 #include "BKE_context.h"
 #include "BKE_screen.h"
 
 #include "ED_anim_api.h"
 #include "ED_screen.h"
+#include "ED_transform.h"
 #include "ED_types.h"
 #include "ED_util.h"
 
+#include "RNA_access.h"
+
 #include "WM_api.h"
 #include "WM_types.h"
 
 
 #include "action_intern.h"
 
-/* ********************************************************* */
-/* Menu Defines... */
-
-/* button events */
-enum {
-       B_REDR  = 0,
-       B_ACTCOPYKEYS,
-       B_ACTPASTEKEYS,
-} eActHeader_ButEvents;
-
-/* ------------------------------- */
-/* enums declaring constants that are used as menu event codes  */
-
-enum {
-       ACTMENU_VIEW_CENTERVIEW= 0,
-       ACTMENU_VIEW_AUTOUPDATE,
-       ACTMENU_VIEW_PLAY3D,
-       ACTMENU_VIEW_PLAYALL,
-       ACTMENU_VIEW_ALL,
-       ACTMENU_VIEW_MAXIMIZE,
-       ACTMENU_VIEW_LOCK,
-       ACTMENU_VIEW_SLIDERS,
-       ACTMENU_VIEW_NEXTMARKER,
-       ACTMENU_VIEW_PREVMARKER,
-       ACTMENU_VIEW_NEXTKEYFRAME,
-       ACTMENU_VIEW_PREVKEYFRAME,
-       ACTMENU_VIEW_TIME,
-       ACTMENU_VIEW_NOHIDE,
-       ACTMENU_VIEW_FRANUM,
-       ACTMENU_VIEW_TRANSDELDUPS,
-       ACTMENU_VIEW_HORIZOPTIMISE,
-       ACTMENU_VIEW_GCOLORS,
-       ACTMENU_VIEW_PREVRANGESET,
-       ACTMENU_VIEW_PREVRANGECLEAR,
-       ACTMENU_VIEW_PREVRANGEAUTO
-};
-
-enum {
-       ACTMENU_SEL_BORDER = 0,
-       ACTMENU_SEL_BORDERC,
-       ACTMENU_SEL_BORDERM,
-       ACTMENU_SEL_ALL_KEYS,
-       ACTMENU_SEL_ALL_CHAN,
-       ACTMENU_SEL_ALL_MARKERS,
-       ACTMENU_SEL_INVERSE_KEYS,
-       ACTMENU_SEL_INVERSE_MARKERS,
-       ACTMENU_SEL_INVERSE_CHANNELS,
-       ACTMENU_SEL_LEFTKEYS,
-       ACTMENU_SEL_RIGHTKEYS
-};
-
-enum {
-       ACTMENU_SEL_COLUMN_KEYS = 1,
-       ACTMENU_SEL_COLUMN_CFRA,
-       ACTMENU_SEL_COLUMN_MARKERSCOLUMN,
-       ACTMENU_SEL_COLUMN_MARKERSBETWEEN 
-};
-
-enum {
-       ACTMENU_CHANNELS_OPENLEVELS = 0,
-       ACTMENU_CHANNELS_CLOSELEVELS,
-       ACTMENU_CHANNELS_EXPANDALL,
-       ACTMENU_CHANNELS_SHOWACHANS,
-       ACTMENU_CHANNELS_DELETE
-};
-
-enum {
-       ACTMENU_CHANNELS_CHANPOS_MOVE_CHANNEL_UP        = 0,
-       ACTMENU_CHANNELS_CHANPOS_MOVE_CHANNEL_DOWN,
-       ACTMENU_CHANNELS_CHANPOS_MOVE_CHANNEL_TOP,
-       ACTMENU_CHANNELS_CHANPOS_MOVE_CHANNEL_BOTTOM
-};
-
-enum {
-       ACTMENU_CHANNELS_GROUP_ADD_TOACTIVE     = 0,
-       ACTMENU_CHANNELS_GROUP_ADD_TONEW,
-       ACTMENU_CHANNELS_GROUP_REMOVE,
-       ACTMENU_CHANNELS_GROUP_SYNCPOSE
-};
-
-enum {
-       ACTMENU_CHANNELS_SETTINGS_TOGGLE = 0,
-       ACTMENU_CHANNELS_SETTINGS_ENABLE,
-       ACTMENU_CHANNELS_SETTINGS_DISABLE,
-};
-
-enum {
-       ACTMENU_KEY_DUPLICATE = 0,
-       ACTMENU_KEY_DELETE,
-       ACTMENU_KEY_CLEAN,
-       ACTMENU_KEY_SAMPLEKEYS,
-       ACTMENU_KEY_INSERTKEY
-};
-
-enum {
-       ACTMENU_KEY_TRANSFORM_MOVE  = 0,
-       ACTMENU_KEY_TRANSFORM_SCALE,
-       ACTMENU_KEY_TRANSFORM_SLIDE,
-       ACTMENU_KEY_TRANSFORM_EXTEND
-};
-
-enum {
-       ACTMENU_KEY_HANDLE_AUTO = 0,
-       ACTMENU_KEY_HANDLE_ALIGN,
-       ACTMENU_KEY_HANDLE_FREE,
-       ACTMENU_KEY_HANDLE_VECTOR
-};
-
-enum {
-       ACTMENU_KEY_INTERP_CONST = 0,
-       ACTMENU_KEY_INTERP_LINEAR,
-       ACTMENU_KEY_INTERP_BEZIER
-};
-
-enum {
-       ACTMENU_KEY_EXTEND_CONST = 0,
-       ACTMENU_KEY_EXTEND_EXTRAPOLATION,
-       ACTMENU_KEY_EXTEND_CYCLIC,
-       ACTMENU_KEY_EXTEND_CYCLICEXTRAPOLATION
-};
-
-enum {
-       ACTMENU_KEY_SNAP_NEARFRAME = 1,
-       ACTMENU_KEY_SNAP_CURFRAME,
-       ACTMENU_KEY_SNAP_NEARMARK,
-       ACTMENU_KEY_SNAP_NEARTIME,
-       ACTMENU_KEY_SNAP_CFRA2KEY,
-};
-
 enum {
-       ACTMENU_KEY_MIRROR_CURFRAME = 1,
-       ACTMENU_KEY_MIRROR_YAXIS,
-       ACTMENU_KEY_MIRROR_XAXIS,
-       ACTMENU_KEY_MIRROR_MARKER
-};
+       B_REDR= 1,
+       B_MODECHANGE,
+} eActHeader_Events;
 
-enum {
-       ACTMENU_MARKERS_ADD = 0,
-       ACTMENU_MARKERS_DUPLICATE,
-       ACTMENU_MARKERS_DELETE,
-       ACTMENU_MARKERS_NAME,
-       ACTMENU_MARKERS_MOVE,
-       ACTMENU_MARKERS_LOCALADD,
-       ACTMENU_MARKERS_LOCALRENAME,
-       ACTMENU_MARKERS_LOCALDELETE,
-       ACTMENU_MARKERS_LOCALMOVE
-};
-
-/* ------------------------------- */
-/* macros for easier state testing (only for use here) */
-
-/* test if active action editor is showing any markers */
-#if 0
-       #define G_SACTION_HASMARKERS \
-               ((G.saction->action && G.saction->action->markers.first) \
-                || (G.scene->markers.first))
-#endif
-
-/* ------------------------------- */
-
-/* *************************************************************** */
-/* menus */
-
-/* Key menu ---------------------------  */
+/* ********************************************************* */
+/* Menu Defines... */
 
-static void do_keymenu(bContext *C, void *arg, int event)
+static void act_viewmenu(bContext *C, uiLayout *layout, void *arg_unused)
 {
+       bScreen *sc= CTX_wm_screen(C);
+       ScrArea *sa= CTX_wm_area(C);
+       SpaceAction *sact= CTX_wm_space_action(C);
+       PointerRNA spaceptr;
        
-}
-
-static uiBlock *action_keymenu(bContext *C, uiMenuBlockHandle *handle, void *arg_unused)
-{
-       ScrArea *curarea= CTX_wm_area(C);
-       uiBlock *block;
-       short yco= 0, menuwidth=120;
+       /* retrieve state */
+       RNA_pointer_create(&sc->id, &RNA_SpaceDopeSheetEditor, sact, &spaceptr);
        
-       block= uiBeginBlock(C, handle->region, "dummy_keymenu", UI_EMBOSSP, UI_HELV);
-       uiBlockSetButmFunc(block, do_keymenu, NULL);
+       /* create menu */
+       //uiItemO(layout, NULL, ICON_MENU_PANEL, "ACTION_OT_properties");
        
-       uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Nothing yet", 0, yco-=20, 
-                                        menuwidth, 19, NULL, 0.0, 0.0, 1, 3, "");
+       //uiItemS(layout);
        
-       if(curarea->headertype==HEADERTOP) {
-               uiBlockSetDirection(block, UI_DOWN);
-       }
-       else {
-               uiBlockSetDirection(block, UI_TOP);
-               uiBlockFlipOrder(block);
-       }
+       uiItemR(layout, NULL, 0, &spaceptr, "show_cframe_indicator", 0);
+       uiItemR(layout, NULL, 0, &spaceptr, "show_sliders", 0);
+       uiItemR(layout, NULL, 0, &spaceptr, "automerge_keyframes", 0);
        
-       uiTextBoundsBlock(block, 50);
-       uiEndBlock(C, block);
+       if (sact->flag & SACTION_DRAWTIME)
+               uiItemO(layout, "Show Frames", 0, "ANIM_OT_time_toggle");
+       else
+               uiItemO(layout, "Show Seconds", 0, "ANIM_OT_time_toggle");
        
-       return block;
-}
-
-/* Frame menu ---------------------------  */
-
-static void do_framemenu(bContext *C, void *arg, int event)
-{
+       uiItemS(layout);
        
-}
-
-static uiBlock *action_framemenu(bContext *C, uiMenuBlockHandle *handle, void *arg_unused)
-{
-       ScrArea *curarea= CTX_wm_area(C);
-       uiBlock *block;
-       short yco= 0, menuwidth=120;
+       uiItemO(layout, NULL, 0, "ANIM_OT_previewrange_set");
+       uiItemO(layout, NULL, 0, "ANIM_OT_previewrange_clear");
        
-       block= uiBeginBlock(C, handle->region, "dummy_framemenu", UI_EMBOSSP, UI_HELV);
-       uiBlockSetButmFunc(block, do_framemenu, NULL);
+       uiItemO(layout, NULL, 0, "ACTION_OT_previewrange_set");
        
-       uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Nothing yet", 0, yco-=20, 
-                                        menuwidth, 19, NULL, 0.0, 0.0, 1, 3, "");
+       uiItemS(layout);
        
-       if(curarea->headertype==HEADERTOP) {
-               uiBlockSetDirection(block, UI_DOWN);
-       }
-       else {
-               uiBlockSetDirection(block, UI_TOP);
-               uiBlockFlipOrder(block);
-       }
+       uiItemO(layout, NULL, 0, "ACTION_OT_frame_jump");
        
-       uiTextBoundsBlock(block, 50);
-       uiEndBlock(C, block);
+       uiItemO(layout, NULL, 0, "ACTION_OT_view_all");
        
-       return block;
+       if (sa->full) 
+               uiItemO(layout, NULL, 0, "SCREEN_OT_screen_full_area"); // "Tile Window", Ctrl UpArrow
+       else 
+               uiItemO(layout, NULL, 0, "SCREEN_OT_screen_full_area"); // "Maximize Window", Ctrl DownArrow
 }
 
-/* Marker menu ---------------------------  */
-
-static void do_markermenu(bContext *C, void *arg, int event)
+static void act_selectmenu(bContext *C, uiLayout *layout, void *arg_unused)
 {
+       uiItemO(layout, NULL, 0, "ACTION_OT_select_all_toggle");
+       uiItemBooleanO(layout, "Invert All", 0, "ACTION_OT_select_all_toggle", "invert", 1);
        
-}
-
-static uiBlock *action_markermenu(bContext *C, uiMenuBlockHandle *handle, void *arg_unused)
-{
-       ScrArea *curarea= CTX_wm_area(C);
-       uiBlock *block;
-       short yco= 0, menuwidth=120;
+       uiItemS(layout);
        
-       block= uiBeginBlock(C, handle->region, "dummy_markermenu", UI_EMBOSSP, UI_HELV);
-       uiBlockSetButmFunc(block, do_markermenu, NULL);
+       uiItemO(layout, NULL, 0, "ACTION_OT_select_border");
+       uiItemBooleanO(layout, "Border Axis Range", 0, "ACTION_OT_select_border", "axis_range", 1);
        
-       uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Nothing yet", 0, yco-=20, 
-                                        menuwidth, 19, NULL, 0.0, 0.0, 1, 3, "");
+       uiItemS(layout);
        
-       if(curarea->headertype==HEADERTOP) {
-               uiBlockSetDirection(block, UI_DOWN);
-       }
-       else {
-               uiBlockSetDirection(block, UI_TOP);
-               uiBlockFlipOrder(block);
-       }
-       
-       uiTextBoundsBlock(block, 50);
-       uiEndBlock(C, block);
-       
-       return block;
-}
-
-/* Grease Pencil ---------------------------  */
-
-static void do_gplayermenu(bContext *C, void *arg, int event)
-{
+       uiItemEnumO(layout, "Columns on Selected Keys", 0, "ACTION_OT_select_column", "mode", ACTKEYS_COLUMNSEL_KEYS);
+       uiItemEnumO(layout, "Column on Current Frame", 0, "ACTION_OT_select_column", "mode", ACTKEYS_COLUMNSEL_CFRA);
        
+       uiItemEnumO(layout, "Columns on Selected Markers", 0, "ACTION_OT_select_column", "mode", ACTKEYS_COLUMNSEL_MARKERS_COLUMN);
+       uiItemEnumO(layout, "Between Selected Markers", 0, "ACTION_OT_select_column", "mode", ACTKEYS_COLUMNSEL_MARKERS_BETWEEN);
 }
 
-static uiBlock *action_gplayermenu(bContext *C, uiMenuBlockHandle *handle, void *arg_unused)
+static void act_channelmenu(bContext *C, uiLayout *layout, void *arg_unused)
 {
-       ScrArea *curarea= CTX_wm_area(C);
-       uiBlock *block;
-       short yco= 0, menuwidth=120;
-       
-       block= uiBeginBlock(C, handle->region, "dummy_gplayermenu", UI_EMBOSSP, UI_HELV);
-       uiBlockSetButmFunc(block, do_gplayermenu, NULL);
-       
-       uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Nothing yet", 0, yco-=20, 
-                                        menuwidth, 19, NULL, 0.0, 0.0, 1, 3, "");
+       uiItemO(layout, NULL, 0, "ANIM_OT_channels_setting_toggle");
+       uiItemO(layout, NULL, 0, "ANIM_OT_channels_setting_enable");
+       uiItemO(layout, NULL, 0, "ANIM_OT_channels_setting_disable");
        
-       if(curarea->headertype==HEADERTOP) {
-               uiBlockSetDirection(block, UI_DOWN);
-       }
-       else {
-               uiBlockSetDirection(block, UI_TOP);
-               uiBlockFlipOrder(block);
-       }
+       uiItemS(layout);
        
-       uiTextBoundsBlock(block, 50);
-       uiEndBlock(C, block);
+       uiItemO(layout, NULL, 0, "ANIM_OT_channels_editable_toggle");
        
-       return block;
-}
-
-/* Channel menu ---------------------------  */
-
-static void do_channelmenu(bContext *C, void *arg, int event)
-{
+       uiItemS(layout);
        
+       uiItemO(layout, NULL, 0, "ANIM_OT_channels_expand");
+       uiItemO(layout, NULL, 0, "ANIM_OT_channels_collapse");
 }
 
-static uiBlock *action_channelmenu(bContext *C, uiMenuBlockHandle *handle, void *arg_unused)
+static void act_gplayermenu(bContext *C, uiLayout *layout, void *arg_unused)
 {
-       ScrArea *curarea= CTX_wm_area(C);
-       uiBlock *block;
-       short yco= 0, menuwidth=120;
-       
-       block= uiBeginBlock(C, handle->region, "dummy_channelmenu", UI_EMBOSSP, UI_HELV);
-       uiBlockSetButmFunc(block, do_channelmenu, NULL);
-       
-       uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Nothing yet", 0, yco-=20, 
-                                        menuwidth, 19, NULL, 0.0, 0.0, 1, 3, "");
-       
-       if(curarea->headertype==HEADERTOP) {
-               uiBlockSetDirection(block, UI_DOWN);
-       }
-       else {
-               uiBlockSetDirection(block, UI_TOP);
-               uiBlockFlipOrder(block);
-       }
-       
-       uiTextBoundsBlock(block, 50);
-       uiEndBlock(C, block);
-       
-       return block;
+       //uiItemMenuF(layout, "Transform", 0, nla_edit_transformmenu, NULL, NULL);
+       //uiItemS(layout);
+       //uiItemO(layout, NULL, 0, "NLAEDIT_OT_duplicate");
 }
 
-/* Select menu ---------------------------  */
-
-static void do_selectmenu(bContext *C, void *arg, int event)
+static void act_edit_transformmenu(bContext *C, uiLayout *layout, void *arg_unused)
 {
-       
+       uiItemEnumO(layout, "Grab/Move", 0, "TFM_OT_transform", "mode", TFM_TIME_TRANSLATE);
+       uiItemEnumO(layout, "Extend", 0, "TFM_OT_transform", "mode", TFM_TIME_EXTEND);
+       uiItemEnumO(layout, "Scale", 0, "TFM_OT_transform", "mode", TFM_TIME_SCALE);
 }
 
-static uiBlock *action_selectmenu(bContext *C, uiMenuBlockHandle *handle, void *arg_unused)
+static void act_editmenu(bContext *C, uiLayout *layout, void *arg_unused)
 {
-       ScrArea *curarea= CTX_wm_area(C);
-       uiBlock *block;
-       short yco= 0, menuwidth=120;
-       
-       block= uiBeginBlock(C, handle->region, "dummy_selectmenu", UI_EMBOSSP, UI_HELV);
-       uiBlockSetButmFunc(block, do_selectmenu, NULL);
+       uiItemMenuF(layout, "Transform", 0, act_edit_transformmenu, NULL);
+       uiItemMenuEnumO(layout, "Snap", 0, "ACTION_OT_snap", "type");
+       uiItemMenuEnumO(layout, "Mirror", 0, "ACTION_OT_mirror", "type");
        
-       uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Nothing yet", 0, yco-=20, 
-                                        menuwidth, 19, NULL, 0.0, 0.0, 1, 3, "");
+       uiItemS(layout);
        
-       if(curarea->headertype==HEADERTOP) {
-               uiBlockSetDirection(block, UI_DOWN);
-       }
-       else {
-               uiBlockSetDirection(block, UI_TOP);
-               uiBlockFlipOrder(block);
-       }
+       uiItemO(layout, NULL, 0, "ACT_OT_keyframe_insert");
        
-       uiTextBoundsBlock(block, 50);
-       uiEndBlock(C, block);
+       uiItemS(layout);
        
-       return block;
-}
-
-/* View menu ---------------------------  */
-
-static void do_viewmenu(bContext *C, void *arg, int event)
-{
+       uiItemO(layout, NULL, 0, "ACTION_OT_duplicate");
+       uiItemO(layout, NULL, 0, "ACTION_OT_delete");
        
-}
-
-static uiBlock *action_viewmenu(bContext *C, uiMenuBlockHandle *handle, void *arg_unused)
-{
-       ScrArea *curarea= CTX_wm_area(C);
-       uiBlock *block;
-       short yco= 0, menuwidth=120;
+       uiItemS(layout);
        
-       block= uiBeginBlock(C, handle->region, "dummy_viewmenu", UI_EMBOSSP, UI_HELV);
-       uiBlockSetButmFunc(block, do_viewmenu, NULL);
+       uiItemMenuEnumO(layout, "Keyframe Type", 0, "ACTION_OT_keyframe_type", "type");
+       uiItemMenuEnumO(layout, "Handle Type", 0, "ACTION_OT_handle_type", "type");
+       uiItemMenuEnumO(layout, "Interpolation Type", 0, "ACTION_OT_interpolation_type", "type");
+       uiItemMenuEnumO(layout, "Extrapolation Type", 0, "ACTION_OT_extrapolation_type", "type");
        
-       uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Nothing yet", 0, yco-=20, 
-                                        menuwidth, 19, NULL, 0.0, 0.0, 1, 3, "");
+       uiItemS(layout);
        
-       if (curarea->headertype==HEADERTOP) {
-               uiBlockSetDirection(block, UI_DOWN);
-       }
-       else {
-               uiBlockSetDirection(block, UI_TOP);
-               uiBlockFlipOrder(block);
-       }
+       uiItemO(layout, NULL, 0, "ACTION_OT_clean");
+       uiItemO(layout, NULL, 0, "ACTION_OT_sample");
        
-       uiTextBoundsBlock(block, 50);
-       uiEndBlock(C, block);
+       uiItemS(layout);
        
-       return block;
+       uiItemO(layout, NULL, 0, "ACTION_OT_copy");
+       uiItemO(layout, NULL, 0, "ACTION_OT_paste");
 }
 
 /* ************************ header area region *********************** */
 
 static void do_action_buttons(bContext *C, void *arg, int event)
 {
-       switch(event) {
-               case B_REDR:
-                       ED_region_tag_redraw(CTX_wm_region(C));
-                       break;
-                       
-               case B_ACTCOPYKEYS:
-                       WM_operator_name_call(C, "ACT_OT_keyframes_copy", WM_OP_EXEC_REGION_WIN, NULL, NULL);
-                       break;
-               case B_ACTPASTEKEYS:
-                       WM_operator_name_call(C, "ACT_OT_keyframes_paste", WM_OP_EXEC_REGION_WIN, NULL, NULL);
-                       break;
+       /* special exception for mode changing - enable custom settings? */
+       if (event == B_MODECHANGE) {
+               SpaceAction *saction= CTX_wm_space_action(C);
+               
+               /* if the new mode is ShapeKeys editor, enable sliders */
+               if (saction->mode == SACTCONT_SHAPEKEY)
+                       saction->flag |= SACTION_SLIDERS;
        }
+       
+       ED_area_tag_refresh(CTX_wm_area(C));
+       ED_area_tag_redraw(CTX_wm_area(C));
 }
 
 void action_header_buttons(const bContext *C, ARegion *ar)
 {
        ScrArea *sa= CTX_wm_area(C);
-       SpaceAction *saction= (SpaceAction *)CTX_wm_space_data(C);
+       SpaceAction *saction= CTX_wm_space_action(C);
        bAnimContext ac;
        uiBlock *block;
        int xco, yco= 3, xmax;
        
-       block= uiBeginBlock(C, ar, "header buttons", UI_EMBOSS, UI_HELV);
+       block= uiBeginBlock(C, ar, "header buttons", UI_EMBOSS);
        uiBlockSetHandleFunc(block, do_action_buttons, NULL);
        
        xco= ED_area_header_standardbuttons(C, block, yco);
@@ -490,49 +236,40 @@ void action_header_buttons(const bContext *C, ARegion *ar)
        ANIM_animdata_get_context(C, &ac);
        
        if ((sa->flag & HEADER_NO_PULLDOWN)==0) {
-               /* pull down menus */
-               uiBlockSetEmboss(block, UI_EMBOSSP);
                
                xmax= GetButStringLength("View");
-               uiDefPulldownBut(block, action_viewmenu, CTX_wm_area(C), 
-                                         "View", xco, yco-2, xmax-3, 24, "");
+               uiDefMenuBut(block, act_viewmenu, NULL, "View", xco, yco, xmax-3, 20, "");
                xco+= xmax;
                
                xmax= GetButStringLength("Select");
-               uiDefPulldownBut(block, action_selectmenu, CTX_wm_area(C), 
-                                         "Select", xco, yco-2, xmax-3, 24, "");
+               uiDefMenuBut(block, act_selectmenu, NULL, "Select", xco, yco, xmax-3, 20, "");
                xco+= xmax;
                
                if ( (saction->mode == SACTCONT_DOPESHEET) ||
                         ((saction->action) && (saction->mode==SACTCONT_ACTION)) ) 
                {
                        xmax= GetButStringLength("Channel");
-                       uiDefPulldownBut(block, action_channelmenu, CTX_wm_area(C), 
-                                                 "Channel", xco, yco-2, xmax-3, 24, "");
+                       uiDefMenuBut(block, act_channelmenu, NULL, "Channel", xco, yco, xmax-3, 20, "");
                        xco+= xmax;
                }
                else if (saction->mode==SACTCONT_GPENCIL) {
                        xmax= GetButStringLength("Channel");
-                       uiDefPulldownBut(block, action_gplayermenu, CTX_wm_area(C), 
-                                                 "Channel", xco, yco-2, xmax-3, 24, "");
+                       uiDefMenuBut(block, act_gplayermenu, NULL, "Channel", xco, yco, xmax-3, 20, "");
                        xco+= xmax;
                }
                
-               xmax= GetButStringLength("Marker");
-               uiDefPulldownBut(block, action_markermenu, CTX_wm_area(C), 
-                                         "Marker", xco, yco-2, xmax-3, 24, "");
-               xco+= xmax;
+               //xmax= GetButStringLength("Marker");
+               //uiDefMenuBut(block, act_markermenu, NULL, "Marker", xco, yco, xmax-3, 20, "");
+               //xco+= xmax;
                
                if (saction->mode == SACTCONT_GPENCIL) {
-                       xmax= GetButStringLength("Frame");
-                       uiDefPulldownBut(block, action_framemenu, CTX_wm_area(C), 
-                                                 "Frame", xco, yco-2, xmax-3, 24, "");
-                       xco+= xmax;
+                       //xmax= GetButStringLength("Frame");
+                       //uiDefMenuBut(block, act_selectmenu, NULL, "Frame", xco, yco, xmax-3, 20, "");
+                       //xco+= xmax;
                }
                else {
                        xmax= GetButStringLength("Key");
-                       uiDefPulldownBut(block, action_keymenu, CTX_wm_area(C), 
-                                                 "Key", xco, yco-2, xmax-3, 24, "");
+                       uiDefMenuBut(block, act_editmenu, NULL, "Key", xco, yco, xmax-3, 20, "");
                        xco+= xmax;
                }
        }
@@ -540,7 +277,7 @@ void action_header_buttons(const bContext *C, ARegion *ar)
        uiBlockSetEmboss(block, UI_EMBOSS);
        
        /* MODE SELECTOR */
-       uiDefButC(block, MENU, B_REDR
+       uiDefButC(block, MENU, B_MODECHANGE
                        "Editor Mode %t|DopeSheet %x3|Action Editor %x0|ShapeKey Editor %x1|Grease Pencil %x2", 
                        xco,yco,90,YIC, &saction->mode, 0, 1, 0, 0, 
                        "Editing modes for this editor");
@@ -548,84 +285,60 @@ void action_header_buttons(const bContext *C, ARegion *ar)
        
        xco += (90 + 8);
        
-       if (ac.data) {
+       /* SUMMARY CHANNEL */
+       uiDefIconTextButBitI(block, TOG, ADS_FILTER_SUMMARY, B_REDR, ICON_BORDERMOVE, "Summary", xco,yco,XIC*4,YIC, &(saction->ads.filterflag), 0, 0, 0, 0, "Include DopeSheet summary row"); // TODO: needs a better icon
+       xco += (XIC*4.5);
+       
+       /*if (ac.data)*/ 
+       {
                /* MODE-DEPENDENT DRAWING */
                if (saction->mode == SACTCONT_DOPESHEET) {
                        /* FILTERING OPTIONS */
-                       xco -= 10;
-                       
-                       //uiBlockBeginAlign(block);
-                               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");
-                       //uiBlockEndAlign(block);
-                       xco += 5;
-                       
-                       uiBlockBeginAlign(block);
-                               uiDefIconButBitI(block, TOGN, ADS_FILTER_NOOBJ, B_REDR, ICON_OBJECT,    (short)(xco+=XIC),yco,XIC,YIC, &(saction->ads.filterflag), 0, 0, 0, 0, "Display Non-Armature Objects");
-                               uiDefIconButBitI(block, TOGN, ADS_FILTER_NOARM, B_REDR, ICON_ARMATURE,  (short)(xco+=XIC),yco,XIC,YIC, &(saction->ads.filterflag), 0, 0, 0, 0, "Display Armature Objects");
-                               uiDefIconButBitI(block, TOGN, ADS_FILTER_NOSHAPEKEYS, B_REDR, ICON_EDIT,        (short)(xco+=XIC),yco,XIC,YIC, &(saction->ads.filterflag), 0, 0, 0, 0, "Display ShapeKeys");
-                               uiDefIconButBitI(block, TOGN, ADS_FILTER_NOMAT, B_REDR, ICON_MATERIAL,  (short)(xco+=XIC),yco,XIC,YIC, &(saction->ads.filterflag), 0, 0, 0, 0, "Display Materials");
-                               uiDefIconButBitI(block, TOGN, ADS_FILTER_NOLAM, B_REDR, ICON_LAMP,      (short)(xco+=XIC),yco,XIC,YIC, &(saction->ads.filterflag), 0, 0, 0, 0, "Display Lamps");
-                               uiDefIconButBitI(block, TOGN, ADS_FILTER_NOCAM, B_REDR, ICON_CAMERA,    (short)(xco+=XIC),yco,XIC,YIC, &(saction->ads.filterflag), 0, 0, 0, 0, "Display Cameras");
-                               uiDefIconButBitI(block, TOGN, ADS_FILTER_NOCUR, B_REDR, ICON_CURVE,     (short)(xco+=XIC),yco,XIC,YIC, &(saction->ads.filterflag), 0, 0, 0, 0, "Display Curves");
-                       uiBlockEndAlign(block);
-                       xco += 5;
-                       
-                       uiBlockBeginAlign(block);               
-                               uiDefIconButBitI(block, TOGN, ADS_FILTER_NOIPOS, B_REDR, ICON_IPO,      (short)(xco+=XIC),yco,XIC,YIC, &(saction->ads.filterflag), 0, 0, 0, 0, "Display Object IPO's");
-                               uiDefIconButBitI(block, TOGN, ADS_FILTER_NOACTS, B_REDR, ICON_ACTION,   (short)(xco+=XIC),yco,XIC,YIC, &(saction->ads.filterflag), 0, 0, 0, 0, "Display Actions");
-                               uiDefIconButBitI(block, TOGN, ADS_FILTER_NOCONSTRAINTS, B_REDR, ICON_CONSTRAINT,        (short)(xco+=XIC),yco,XIC,YIC, &(saction->ads.filterflag), 0, 0, 0, 0, "Display Object Constraints");
-                       uiBlockEndAlign(block);
-                       xco += 30;
+                       xco -= XIC; // XXX first button incurs this offset...
+                       xco= ANIM_headerUI_standard_buttons(C, &saction->ads, block, xco, yco);
                }
-               else if (saction->mode == SACTCONT_ACTION) { // not too appropriate for shapekeys atm...
-                       /* NAME ETC */
-                               // XXX missing stuff here!
-                       //ob= OBACT;
-                       //from = (ID *)ob;
+               else if (saction->mode == SACTCONT_ACTION) {
+                       uiLayout *layout;
+                       bScreen *sc= CTX_wm_screen(C);
+                       PointerRNA ptr;
                        
-                       //xco= std_libbuttons(block, xco, 0, B_ACTPIN, saction->pin, 
-                       //                                      B_ACTIONBROWSE, ID_AC, 0, (ID*)saction->action, 
-                       //                                      from, &(saction->actnr), B_ACTALONE, 
-                       //                                      B_ACTLOCAL, B_ACTIONDELETE, 0, B_KEEPDATA);     
+                       RNA_pointer_create(&sc->id, &RNA_SpaceDopeSheetEditor, saction, &ptr);
                        
-                       //uiClearButLock();
+                       layout= uiBlockLayout(block, UI_LAYOUT_HORIZONTAL, UI_LAYOUT_HEADER, xco, 20+3, 20, 1, U.uistyles.first);
+                       uiTemplateID(layout, (bContext*)C, &ptr, "action", "ACTION_OT_new", NULL, NULL);
+                       uiBlockLayoutResolve(block, &xco, NULL);
                        
                        xco += 8;
                }
                
-               /* COPY PASTE */
-               uiBlockBeginAlign(block);
-               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");
-               uiDefIconBut(block, BUT, B_ACTPASTEKEYS, ICON_PASTEDOWN,        xco+=XIC,yco,XIC,YIC, 0, 0, 0, 0, 0, "Pastes the keyframes from the buffer");
-               uiBlockEndAlign(block);
-               xco += (XIC + 8);
-               
                /* draw AUTOSNAP */
                if (saction->mode != SACTCONT_GPENCIL) {
                        if (saction->flag & SACTION_DRAWTIME) {
                                uiDefButC(block, MENU, B_REDR,
                                                "Auto-Snap Keyframes %t|No Snap %x0|Second Step %x1|Nearest Second %x2|Nearest Marker %x3", 
-                                               xco,yco,70,YIC, &(saction->autosnap), 0, 1, 0, 0, 
+                                               xco,yco,90,YIC, &(saction->autosnap), 0, 1, 0, 0, 
                                                "Auto-snapping mode for keyframes when transforming");
                        }
                        else {
                                uiDefButC(block, MENU, B_REDR, 
                                                "Auto-Snap Keyframes %t|No Snap %x0|Frame Step %x1|Nearest Frame %x2|Nearest Marker %x3", 
-                                               xco,yco,70,YIC, &(saction->autosnap), 0, 1, 0, 0, 
+                                               xco,yco,90,YIC, &(saction->autosnap), 0, 1, 0, 0, 
                                                "Auto-snapping mode for keyframes when transforming");
                        }
                        
-                       xco += (70 + 8);
+                       xco += (90 + 8);
                }
                
-               /* draw LOCK */
-               uiDefIconButS(block, ICONTOG, 1, ICON_UNLOCKED, xco, yco, XIC, YIC, 
-                                         &(saction->lock), 0, 0, 0, 0, 
-                                         "Updates other affected window spaces automatically "
-                                         "to reflect changes in real time");
+               /* COPY PASTE */
+               uiBlockBeginAlign(block);
+                       uiDefIconButO(block, BUT, "ACTION_OT_copy", WM_OP_INVOKE_REGION_WIN, ICON_COPYDOWN, xco,yco,XIC,YIC, "Copies the selected keyframes to the buffer.");
+                       xco += XIC;
+                       uiDefIconButO(block, BUT, "ACTION_OT_paste", WM_OP_INVOKE_REGION_WIN, ICON_PASTEDOWN, xco,yco,XIC,YIC, "Pastes the keyframes from the buffer into the selected channels.");
+               uiBlockEndAlign(block);
+               xco += (XIC + 8);
        }
 
-       /* always as last  */
+       /* always as last */
        UI_view2d_totRect_set(&ar->v2d, xco+XIC+80, (int)(ar->v2d.tot.ymax-ar->v2d.tot.ymin));
        
        uiEndBlock(C, block);