2.5
authorTon Roosendaal <ton@blender.org>
Sun, 14 Dec 2008 12:16:55 +0000 (12:16 +0000)
committerTon Roosendaal <ton@blender.org>
Sun, 14 Dec 2008 12:16:55 +0000 (12:16 +0000)
- Added file space (too) :) Andrea was first, this is more
  complete.
- Suggestion from Joshua: move all standard header buttons to
  1 function, makes it all easier, less code, and less area/space
  stuff needs to be exposed.

19 files changed:
source/Makefile
source/blender/editors/SConscript
source/blender/editors/include/ED_screen.h
source/blender/editors/include/ED_util.h
source/blender/editors/screen/area.c
source/blender/editors/space_buttons/buttons_header.c
source/blender/editors/space_file/Makefile
source/blender/editors/space_file/file_header.c
source/blender/editors/space_file/file_intern.h [new file with mode: 0644]
source/blender/editors/space_file/filesel.c [new file with mode: 0644]
source/blender/editors/space_file/space_file.c
source/blender/editors/space_image/image_header.c
source/blender/editors/space_info/info_header.c
source/blender/editors/space_ipo/ipo_header.c
source/blender/editors/space_node/node_header.c
source/blender/editors/space_outliner/outliner_header.c
source/blender/editors/space_time/time_header.c
source/blender/editors/space_view3d/view3d_header.c
source/blender/editors/util/ed_util.c

index 57d250b7d22622fa09c33a7608c36ae8eb0f1699..ec3abe5f8685b9395bee23c739a4c7bf8a7a08d5 100644 (file)
@@ -235,6 +235,7 @@ PULIB = $(NAN_MOTO)/lib/libmoto.a
 PULIB += $(NAN_ELBEEM)/lib/$(DEBUG_DIR)libelbeem.a
 PULIB += $(OCGDIR)/blender/readblenfile/$(DEBUG_DIR)libreadblenfile.a
 PULIB += $(OCGDIR)/blender/ed_space/libed_space.a
+PULIB += $(OCGDIR)/blender/ed_file/libed_file.a
 PULIB += $(OCGDIR)/blender/ed_info/libed_info.a
 PULIB += $(OCGDIR)/blender/ed_buttons/libed_buttons.a
 PULIB += $(OCGDIR)/blender/ed_node/libed_node.a
index 9a1dbe491a7e244d97756ff649553232470df2e6..8c7943a11082c40f08de688bee592c6282729233 100644 (file)
@@ -17,5 +17,6 @@ SConscript(['datafiles/SConscript',
                        'space_node/SConscript',
                        'space_buttons/SConscript',
                        'space_info/SConscript',
+                       'space_file/SConscript',
                        'transform/SConscript',
                        'screen/SConscript'])
index dd6137aa46c10c80054fa06cabf14ece0b885f5f..7292cc87366a889ce90c0cd717722ef2cf959687 100644 (file)
@@ -38,6 +38,7 @@ struct wmWindow;
 struct wmNotifier;
 struct SpaceType;
 struct AreagionType;
+struct uiBlock;
 
 /* regions */
 void   ED_region_do_listen(ARegion *ar, struct wmNotifier *note);
@@ -50,8 +51,8 @@ ARegion *ED_region_copy(ARegion *ar);
 /* spaces */
 void   ED_spacetypes_init(void);
 void   ED_spacetypes_keymap(struct wmWindowManager *wm);
-struct ARegionType *ED_regiontype_from_id(struct SpaceType *st, int regionid);
-void   ED_newspace(struct ScrArea *sa, int type);
+struct ARegionType *ED_regiontype_from_id(struct SpaceType *st, int regionid);
+int            ED_area_header_standardbuttons(const bContext *C, struct uiBlock *block, int yco);
 
 /* areas */
 void   ED_area_initialize(struct wmWindowManager *wm, struct wmWindow *win, struct ScrArea *sa);
index 10e9c0473a238912b3e0c1a1124f91e9c8c2b033..d0a4b93bfae85e172936656cca1fb98cabe01073 100644 (file)
@@ -35,7 +35,6 @@
 
 void apply_keyb_grid(float *val, float fac1, float fac2, float fac3, int invert);
 int GetButStringLength(char *str);
-char *windowtype_pup(void);
 
 #endif /* ED_UTIL_H */
 
index 32813041d2d4fc57329b7a6825d6175482f869de..1097062c526b49230c957dfc616672f4efefa7ba 100644 (file)
@@ -57,6 +57,8 @@
 #include "BPY_extern.h"
 #endif
 
+#include "ED_util.h"
+
 #include "screen_intern.h"
 
 /* general area and region code */
@@ -499,7 +501,10 @@ void area_copy_data(ScrArea *sa1, ScrArea *sa2, int swap_space)
 #endif
 }
 
-void ED_newspace(ScrArea *sa, int type)
+/* *********** Space switching code, local now *********** */
+/* XXX make operator for this */
+
+static void newspace(ScrArea *sa, int type)
 {
        if(sa->spacetype != type) {
                SpaceType *st= BKE_spacetype_from_id(type);
@@ -548,4 +553,86 @@ void ED_newspace(ScrArea *sa, int type)
        }
 }
 
+static char *windowtype_pup(void)
+{
+       return(
+                  "Window type:%t" //14
+                  "|3D View %x1" //30
+                  
+                  "|%l" // 33
+                  
+                  "|Ipo Curve Editor %x2" //54
+                  "|Action Editor %x12" //73
+                  "|NLA Editor %x13" //94
+                  
+                  "|%l" //97
+                  
+                  "|UV/Image Editor %x6" //117
+                  
+                  "|Video Sequence Editor %x8" //143
+                  "|Timeline %x15" //163
+                  "|Audio Window %x11" //163
+                  "|Text Editor %x9" //179
+                  
+                  "|%l" //192
+                  
+                  
+                  "|User Preferences %x7" //213
+                  "|Outliner %x3" //232
+                  "|Buttons Window %x4" //251
+                  "|Node Editor %x16"
+                  "|%l" //254
+                  
+                  "|Image Browser %x10" //273
+                  "|File Browser %x5" //290
+                  
+                  "|%l" //293
+                  
+                  "|Scripts Window %x14"//313
+                  );
+}
+
+static void spacefunc(struct bContext *C, void *arg1, void *arg2)
+{
+       newspace(C->area, C->area->butspacetype);
+       WM_event_add_notifier(C, WM_NOTE_SCREEN_CHANGED, 0, NULL);
+}
+
+/* returns offset for next button in header */
+int ED_area_header_standardbuttons(const bContext *C, uiBlock *block, int yco)
+{
+       uiBut *but;
+       int xco= 8;
+       
+       if(ED_screen_area_active(C)) uiBlockSetCol(block, TH_HEADER);
+       else uiBlockSetCol(block, TH_HEADERDESEL);
+       
+       but= uiDefIconTextButC(block, ICONTEXTROW, 0, 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.");
+       uiButSetFunc(but, spacefunc, NULL, NULL);
+       
+       xco += XIC + 14;
+       
+       uiBlockSetEmboss(block, UI_EMBOSSN);
+       if (C->area->flag & HEADER_NO_PULLDOWN) {
+               uiDefIconButBitS(block, TOG, HEADER_NO_PULLDOWN, 0, 
+                                                ICON_DISCLOSURE_TRI_RIGHT,
+                                                xco,yco,XIC,YIC-2,
+                                                &(C->area->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,
+                                                &(C->area->flag), 0, 0, 0, 0, 
+                                                "Hide pulldown menus");
+       }
+       xco+=XIC;
+       
+       return xco;
+}
 
index 7850a1dc81867ccf4b2805d7c70171443023954b..3f07b220b6401de1af37e76707606292eef911e7 100644 (file)
@@ -90,7 +90,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 +97,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;
@@ -119,36 +114,7 @@ void buttons_header_buttons(const bContext *C, ARegion *ar)
        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;
index 07811dc88d13643f85609ea65284214e49bc2a30..5376f01325d36f16cd86c304b3c043570c40aadf 100644 (file)
@@ -1,5 +1,5 @@
 #
-# $Id:  $
+# $Id: Makefile 14 2002-10-13 15:57:19Z hans $
 #
 # ***** BEGIN GPL LICENSE BLOCK *****
 #
index d52a35ffbb7937f6c86db19b8bd34fd12ce526e2..b4f2817d3cb1f8a011a60a27a84b8ae86f77570c 100644 (file)
@@ -54,6 +54,8 @@
 #include "UI_resources.h"
 #include "UI_view2d.h"
 
+#include "file_intern.h"
+
 
 /* ************************ header area region *********************** */
 
@@ -88,16 +90,11 @@ static uiBlock *dummy_viewmenu(bContext *C, uiMenuBlockHandle *handle, void *arg
        return block;
 }
 
-#define B_NEWSPACE             100
 
 static void do_file_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;
-               }
+       }
 }
 
 
@@ -105,41 +102,12 @@ void file_header_buttons(const bContext *C, ARegion *ar)
 {
        ScrArea *sa= C->area;
        uiBlock *block;
-       short xco, yco= 3;
+       int xco, yco= 3;
        
        block= uiBeginBlock(C, ar, "header buttons", UI_EMBOSS, UI_HELV);
        uiBlockSetHandleFunc(block, do_file_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;
diff --git a/source/blender/editors/space_file/file_intern.h b/source/blender/editors/space_file/file_intern.h
new file mode 100644 (file)
index 0000000..2322c60
--- /dev/null
@@ -0,0 +1,42 @@
+/**
+ * $Id:
+ *
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version. 
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ *
+ * The Original Code is Copyright (C) 2008 Blender Foundation.
+ * All rights reserved.
+ *
+ * 
+ * Contributor(s): Blender Foundation
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+#ifndef ED_FILE_INTERN_H
+#define ED_FILE_INTERN_H
+
+/* internal exports only */
+
+
+/* file_header.c */
+void file_header_buttons(const bContext *C, ARegion *ar);
+
+/* filesel.c */
+
+void freefilelist(SpaceFile *sfile);
+
+#endif /* ED_FILE_INTERN_H */
+
diff --git a/source/blender/editors/space_file/filesel.c b/source/blender/editors/space_file/filesel.c
new file mode 100644 (file)
index 0000000..36e2bae
--- /dev/null
@@ -0,0 +1,92 @@
+/**
+ * $Id$
+ *
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version. 
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ *
+ * The Original Code is Copyright (C) 2008 Blender Foundation.
+ * All rights reserved.
+ *
+ * 
+ * Contributor(s): Blender Foundation
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#include <string.h>
+#include <stdio.h>
+#include <math.h>
+
+#include <sys/stat.h>
+#include <sys/types.h>
+
+#ifdef WIN32
+#include <io.h>
+#include <direct.h>
+#include "BLI_winstuff.h"
+#else
+#include <unistd.h>
+#include <sys/times.h>
+#endif   
+
+#include "DNA_space_types.h"
+#include "DNA_scene_types.h"
+#include "DNA_screen_types.h"
+#include "DNA_windowmanager_types.h"
+
+#include "MEM_guardedalloc.h"
+
+#include "BLI_blenlib.h"
+#include "BLI_linklist.h"
+#include "BLI_storage_types.h"
+#include "BLI_dynstr.h"
+
+#include "BKE_global.h"
+#include "BKE_screen.h"
+
+#include "ED_screen.h"
+#include "ED_util.h"
+
+#include "WM_api.h"
+#include "WM_types.h"
+
+#include "BIF_gl.h"
+#include "BIF_glutil.h"
+
+#include "UI_interface.h"
+#include "UI_resources.h"
+#include "UI_view2d.h"
+
+#include "file_intern.h"
+
+
+void freefilelist(SpaceFile *sfile)
+{
+       int num;
+       
+       num= sfile->totfile-1;
+       
+       if (sfile->filelist==0) return;
+       
+       for(; num>=0; num--){
+               MEM_freeN(sfile->filelist[num].relname);
+               
+               if (sfile->filelist[num].string) MEM_freeN(sfile->filelist[num].string);
+       }
+       free(sfile->filelist);
+       sfile->filelist= 0;
+}
+
index 9a7ffe77ebaeaaaa92545b9430b629c27f19b0a9..b6d87ee022408de782fa2cb0c106ba07c17dc814 100644 (file)
@@ -29,7 +29,6 @@
 #include <string.h>
 #include <stdio.h>
 
-#include "DNA_image_types.h"
 #include "DNA_object_types.h"
 #include "DNA_space_types.h"
 #include "DNA_scene_types.h"
@@ -37,6 +36,8 @@
 
 #include "MEM_guardedalloc.h"
 
+#include "BLO_readfile.h"
+
 #include "BLI_blenlib.h"
 #include "BLI_arithb.h"
 #include "BLI_rand.h"
 #include "UI_resources.h"
 #include "UI_view2d.h"
 
+#include "ED_markers.h"
+
+#include "file_intern.h"       // own include
 
-/* ******************** default callbacks for image space ***************** */
+/* ******************** default callbacks for file space ***************** */
 
 static SpaceLink *file_new(void)
 {
        ARegion *ar;
        SpaceFile *sfile;
        
-       sfile= MEM_callocN(sizeof(SpaceImage), "initimage");
+       sfile= MEM_callocN(sizeof(SpaceFile), "initfile");
        sfile->spacetype= SPACE_FILE;
        
-       /* XXX init cleaned up file space */
+       sfile->dir[0]= '/';
+       sfile->type= FILE_UNIX;
        
        /* header */
        ar= MEM_callocN(sizeof(ARegion), "header for file");
@@ -84,9 +89,8 @@ static SpaceLink *file_new(void)
        BLI_addtail(&sfile->regionbase, ar);
        ar->regiontype= RGN_TYPE_WINDOW;
        
-       /* bookmark region XXX */
+       /* channel list region XXX */
 
-       /* button region XXX */
        
        return (SpaceLink *)sfile;
 }
@@ -94,9 +98,14 @@ static SpaceLink *file_new(void)
 /* not spacelink itself */
 static void file_free(SpaceLink *sl)
 {      
-       SpaceFile *sfile= (SpaceFile*) sl;
-       
-       /* XXX free necessary items */
+       SpaceFile *sfile= (SpaceFile *) sl;
+
+       if(sfile->libfiledata)  
+               BLO_blendhandle_close(sfile->libfiledata);
+       if(sfile->filelist)
+               freefilelist(sfile);
+       if(sfile->pupmenu)
+               MEM_freeN(sfile->pupmenu);
        
 }
 
@@ -109,11 +118,11 @@ static void file_init(struct wmWindowManager *wm, ScrArea *sa)
 
 static SpaceLink *file_duplicate(SpaceLink *sl)
 {
-       SpaceImage *file_dup= MEM_dupallocN(sl);
+       SpaceFile *sfilen= MEM_dupallocN(sl);
        
        /* clear or remove stuff from old */
        
-       return (SpaceLink *)file_dup;
+       return (SpaceLink *)sfilen;
 }
 
 
@@ -126,14 +135,14 @@ static void file_main_area_init(wmWindowManager *wm, ARegion *ar)
        UI_view2d_size_update(&ar->v2d, ar->winx, ar->winy);
        
        /* own keymap */
-       keymap= WM_keymap_listbase(wm, "Image", SPACE_IMAGE, 0);        /* XXX weak? */
+       keymap= WM_keymap_listbase(wm, "File", SPACE_FILE, 0);  /* XXX weak? */
        WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
 }
 
 static void file_main_area_draw(const bContext *C, ARegion *ar)
 {
        /* draw entirely, view changes should be handled here */
-       // SpaceImage *simage= C->area->spacedata.first;
+       // SpaceFile *sfile= C->area->spacedata.first;
        View2D *v2d= &ar->v2d;
        float col[3];
        
@@ -224,13 +233,26 @@ void ED_spacetype_file(void)
        /* regions: header */
        art= MEM_callocN(sizeof(ARegionType), "spacetype file region");
        art->regionid = RGN_TYPE_HEADER;
+       art->minsizey= HEADERY;
+       art->keymapflag= ED_KEYMAP_UI|ED_KEYMAP_VIEW2D;
+       
        art->init= file_header_area_init;
        art->draw= file_header_area_draw;
-       art->minsizey= HEADERY;
-       art->keymapflag= ED_KEYMAP_UI|ED_KEYMAP_VIEW2D; 
        
        BLI_addhead(&st->regiontypes, art);
-
+       
+       /* regions: channels */
+       art= MEM_callocN(sizeof(ARegionType), "spacetype file region");
+       art->regionid = RGN_TYPE_CHANNELS;
+       art->minsizex= 80;
+       art->keymapflag= ED_KEYMAP_UI|ED_KEYMAP_VIEW2D;
+       
+//     art->init= file_channel_area_init;
+//     art->draw= file_channel_area_draw;
+       
+       BLI_addhead(&st->regiontypes, art);
+       
+       
        BKE_spacetype_register(st);
 }
 
index 9022dedabebc2c14305cee092f82bd7e8189dd5c..44b068cebc17d67c7d841610148467abf96860be 100644 (file)
@@ -90,16 +90,10 @@ static uiBlock *dummy_viewmenu(bContext *C, uiMenuBlockHandle *handle, void *arg
        return block;
 }
 
-#define B_NEWSPACE             100
-
 static void do_image_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;
-               }
+       }
 }
 
 
@@ -112,36 +106,7 @@ void image_header_buttons(const bContext *C, ARegion *ar)
        block= uiBeginBlock(C, ar, "header buttons", UI_EMBOSS, UI_HELV);
        uiBlockSetHandleFunc(block, do_image_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;
index e41177f196ac1d10754401c60a97f34c62261a6f..0ecb0c27b656e48934d68e40d709ae04b6b7be31 100644 (file)
@@ -90,16 +90,11 @@ static uiBlock *dummy_viewmenu(bContext *C, uiMenuBlockHandle *handle, void *arg
        return block;
 }
 
-#define B_NEWSPACE             100
 
 static void do_info_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;
-               }
+       }
 }
 
 
@@ -112,36 +107,7 @@ void info_header_buttons(const bContext *C, ARegion *ar)
        block= uiBeginBlock(C, ar, "header buttons", UI_EMBOSS, UI_HELV);
        uiBlockSetHandleFunc(block, do_info_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;
index 4f5ebfbae2b6807909d0692bb3646970c411848f..62b553991d6b6f52b52143c02116478d4f5d3237 100644 (file)
@@ -90,16 +90,10 @@ static uiBlock *dummy_viewmenu(bContext *C, uiMenuBlockHandle *handle, void *arg
        return block;
 }
 
-#define B_NEWSPACE             100
-
 static void do_ipo_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;
-               }
+       }
 }
 
 
@@ -112,36 +106,7 @@ void ipo_header_buttons(const bContext *C, ARegion *ar)
        block= uiBeginBlock(C, ar, "header buttons", UI_EMBOSS, UI_HELV);
        uiBlockSetHandleFunc(block, do_ipo_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;
index 14e626c6c936e46b10849c0799611219ff5068a4..11f8a38ce18406de93ce560e93b96d0aada4bc34 100644 (file)
@@ -90,16 +90,10 @@ static uiBlock *dummy_viewmenu(bContext *C, uiMenuBlockHandle *handle, void *arg
        return block;
 }
 
-#define B_NEWSPACE             100
-
 static void do_node_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;
-               }
+       }
 }
 
 
@@ -112,36 +106,7 @@ void node_header_buttons(const bContext *C, ARegion *ar)
        block= uiBeginBlock(C, ar, "header buttons", UI_EMBOSS, UI_HELV);
        uiBlockSetHandleFunc(block, do_node_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;
index 2765d80cf8cede59b2b461e8ba0bb52c0215ed68..16b64e0a3281543d494595612700229c97d7163c 100644 (file)
@@ -90,16 +90,10 @@ static uiBlock *dummy_viewmenu(bContext *C, uiMenuBlockHandle *handle, void *arg
        return block;
 }
 
-#define B_NEWSPACE             100
-
 static void do_outliner_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;
-               }
+       }
 }
 
 
@@ -114,36 +108,7 @@ void outliner_header_buttons(const bContext *C, ARegion *ar)
        block= uiBeginBlock(C, ar, "header buttons", UI_EMBOSS, UI_HELV);
        uiBlockSetHandleFunc(block, do_outliner_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;
index 8898fb296dbd5022dbe6c33545fb752e99248eec..e996c29d61c52797828788b5e4b6a303009c05ff 100644 (file)
@@ -371,7 +371,6 @@ static void end_animated_screen(SpaceTime *stime)
 #define B_TL_PREVIEWON 757
 #define B_TL_INSERTKEY 758
 #define B_TL_DELETEKEY 759
-#define B_NEWSPACE             760
 
 #define B_FLIPINFOMENU 0
 #define B_NEWFRAME 0
@@ -384,10 +383,6 @@ void do_time_buttons(bContext *C, void *arg, int event)
        SpaceTime *stime= C->area->spacedata.first;
        
        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_REDRAWALL:
                        WM_event_add_notifier(C, WM_NOTE_WINDOW_REDRAW, 0, NULL);
                        break;
@@ -455,36 +450,7 @@ void time_header_buttons(const bContext *C, ARegion *ar)
        block= uiBeginBlock(C, ar, "header buttons", UI_EMBOSS, UI_HELV);
        uiBlockSetHandleFunc(block, do_time_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, B_FLIPINFOMENU, 
-                                                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, B_FLIPINFOMENU, 
-                                                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;
index a0e166bc8b19b320441c4b66ec49ea09d0b1239e..f85ecc468e35140ceec4b3e00bb60854de44812f 100644 (file)
@@ -90,16 +90,11 @@ static uiBlock *dummy_viewmenu(bContext *C, uiMenuBlockHandle *handle, void *arg
        return block;
 }
 
-#define B_NEWSPACE             100
 
 static void do_view3d_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;
-               }
+       }
 }
 
 
@@ -112,36 +107,7 @@ void view3d_header_buttons(const bContext *C, ARegion *ar)
        block= uiBeginBlock(C, ar, "header buttons", UI_EMBOSS, UI_HELV);
        uiBlockSetHandleFunc(block, do_view3d_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;
index 94579c5e91f8e18d71444be8983b765a41d6e918..841c5cd3cb51422c814c92f92c0e709da4e62b4b 100644 (file)
@@ -38,6 +38,8 @@
 
 #include "BKE_global.h"
 
+#include "ED_util.h"
+
 #include "UI_text.h"
 
 /* ********* general editor util funcs, not BKE stuff please! ********* */
@@ -78,41 +80,3 @@ int GetButStringLength(char *str)
        return rt + 15;
 }
 
-char *windowtype_pup(void)
-{
-       return(
-                  "Window type:%t" //14
-                  "|3D View %x1" //30
-                  
-                  "|%l" // 33
-                  
-                  "|Ipo Curve Editor %x2" //54
-                  "|Action Editor %x12" //73
-                  "|NLA Editor %x13" //94
-                  
-                  "|%l" //97
-                  
-                  "|UV/Image Editor %x6" //117
-                  
-                  "|Video Sequence Editor %x8" //143
-                  "|Timeline %x15" //163
-                  "|Audio Window %x11" //163
-                  "|Text Editor %x9" //179
-                  
-                  "|%l" //192
-                  
-                  
-                  "|User Preferences %x7" //213
-                  "|Outliner %x3" //232
-                  "|Buttons Window %x4" //251
-                  "|Node Editor %x16"
-                  "|%l" //254
-                  
-                  "|Image Browser %x10" //273
-                  "|File Browser %x5" //290
-                  
-                  "|%l" //293
-                  
-                  "|Scripts Window %x14"//313
-                  );
-}