2.5
[blender.git] / source / blender / editors / space_buttons / buttons_header.c
index 7850a1dc81867ccf4b2805d7c70171443023954b..cf0902180884a546be95fa042d297a0b21f7c252 100644 (file)
 
 #include "BLI_blenlib.h"
 
-#include "BKE_global.h"
+#include "BKE_context.h"
 #include "BKE_screen.h"
 
 #include "ED_screen.h"
+#include "ED_types.h"
 #include "ED_util.h"
 
 #include "WM_api.h"
@@ -66,7 +67,7 @@ static void do_viewmenu(bContext *C, void *arg, int event)
 
 static uiBlock *dummy_viewmenu(bContext *C, uiMenuBlockHandle *handle, void *arg_unused)
 {
-       ScrArea *curarea= C->area;
+       ScrArea *curarea= CTX_wm_area(C);
        uiBlock *block;
        short yco= 0, menuwidth=120;
        
@@ -90,7 +91,6 @@ static uiBlock *dummy_viewmenu(bContext *C, uiMenuBlockHandle *handle, void *arg
        return block;
 }
 
-#define B_NEWSPACE                     100
 #define B_CONTEXT_SWITCH       101
 #define B_BUTSPREVIEW          102
 #define B_NEWFRAME                     103
@@ -98,10 +98,6 @@ static uiBlock *dummy_viewmenu(bContext *C, uiMenuBlockHandle *handle, void *arg
 static void do_buttons_buttons(bContext *C, void *arg, int event)
 {
        switch(event) {
-               case B_NEWSPACE:
-                       ED_newspace(C->area, C->area->butspacetype);
-                       WM_event_add_notifier(C, WM_NOTE_SCREEN_CHANGED, 0, NULL);
-                       break;
                case B_NEWFRAME:
                        WM_event_add_notifier(C, WM_NOTE_WINDOW_REDRAW, 0, NULL);
                        break;
@@ -111,44 +107,15 @@ static void do_buttons_buttons(bContext *C, void *arg, int event)
 
 void buttons_header_buttons(const bContext *C, ARegion *ar)
 {
-       ScrArea *sa= C->area;
-       SpaceButs *sbuts= sa->spacedata.first;
+       ScrArea *sa= CTX_wm_area(C);
+       SpaceButs *sbuts= (SpaceButs*)CTX_wm_space_data(C);
        uiBlock *block;
        int xco, yco= 3;
        
        block= uiBeginBlock(C, ar, "header buttons", UI_EMBOSS, UI_HELV);
        uiBlockSetHandleFunc(block, do_buttons_buttons, NULL);
        
-       if(ED_screen_area_active(C)) uiBlockSetCol(block, TH_HEADER);
-       else uiBlockSetCol(block, TH_HEADERDESEL);
-
-       xco = 8;
-       
-       uiDefIconTextButC(block, ICONTEXTROW,B_NEWSPACE, ICON_VIEW3D, 
-                                         windowtype_pup(), xco, yco, XIC+10, YIC, 
-                                         &(C->area->butspacetype), 1.0, SPACEICONMAX, 0, 0, 
-                                         "Displays Current Window Type. "
-                                         "Click for menu of available types.");
-       
-       xco += XIC + 14;
-       
-       uiBlockSetEmboss(block, UI_EMBOSSN);
-       if (sa->flag & HEADER_NO_PULLDOWN) {
-               uiDefIconButBitS(block, TOG, HEADER_NO_PULLDOWN, 0, 
-                                                ICON_DISCLOSURE_TRI_RIGHT,
-                                                xco,yco,XIC,YIC-2,
-                                                &(sa->flag), 0, 0, 0, 0, 
-                                                "Show pulldown menus");
-       }
-       else {
-               uiDefIconButBitS(block, TOG, HEADER_NO_PULLDOWN, 0, 
-                                                ICON_DISCLOSURE_TRI_DOWN,
-                                                xco,yco,XIC,YIC-2,
-                                                &(sa->flag), 0, 0, 0, 0, 
-                                                "Hide pulldown menus");
-       }
-       uiBlockSetEmboss(block, UI_EMBOSS);
-       xco+=XIC;
+       xco= ED_area_header_standardbuttons(C, block, yco);
        
        if((sa->flag & HEADER_NO_PULLDOWN)==0) {
                int xmax;
@@ -157,7 +124,7 @@ void buttons_header_buttons(const bContext *C, ARegion *ar)
                uiBlockSetEmboss(block, UI_EMBOSSP);
                
                xmax= GetButStringLength("View");
-               uiDefPulldownBut(block, dummy_viewmenu, C->area
+               uiDefPulldownBut(block, dummy_viewmenu, CTX_wm_area(C)
                                                 "View", xco, yco-2, xmax-3, 24, "");
                
                xco+=XIC+xmax;
@@ -216,7 +183,7 @@ void buttons_header_buttons(const bContext *C, ARegion *ar)
        uiBlockEndAlign(block);
        
        xco+=XIC;
-       uiDefButI(block, NUM, B_NEWFRAME, "",   (xco+20),yco,60,YIC, &(C->scene->r.cfra), 1.0, MAXFRAMEF, 0, 0, "Displays Current Frame of animation. Click to change.");
+       uiDefButI(block, NUM, B_NEWFRAME, "",   (xco+20),yco,60,YIC, &(CTX_data_scene(C)->r.cfra), 1.0, MAXFRAMEF, 0, 0, "Displays Current Frame of animation. Click to change.");
        xco+= 80;
        
 // XXX buttons_active_id(&id, &idfrom);
@@ -225,7 +192,7 @@ void buttons_header_buttons(const bContext *C, ARegion *ar)
        
        
        /* always as last  */
-       sa->headbutlen= xco+XIC+80; // +80 because the last button is not an icon
+       UI_view2d_totRect_set(&ar->v2d, xco+XIC+80, ar->v2d.tot.ymax-ar->v2d.tot.ymin);
        
        uiEndBlock(C, block);
        uiDrawBlock(block);