2.5
authorTon Roosendaal <ton@blender.org>
Sun, 21 Dec 2008 17:18:36 +0000 (17:18 +0000)
committerTon Roosendaal <ton@blender.org>
Sun, 21 Dec 2008 17:18:36 +0000 (17:18 +0000)
Added 'header print' feature back.

ED_area_headerprint(ScrArea *sa, const char *str);

Give it a NULL string to disable the feature.
On each call it tags the header for redraw.

source/blender/blenloader/intern/readfile.c
source/blender/editors/include/ED_screen.h
source/blender/editors/screen/Makefile
source/blender/editors/screen/SConscript
source/blender/editors/screen/area.c
source/blender/editors/screen/screen_edit.c
source/blender/makesdna/DNA_screen_types.h

index c0d23c8..94d215b 100644 (file)
@@ -4151,6 +4151,7 @@ static void direct_link_region(FileData *fd, ARegion *ar)
 {
        ar->handlers.first= ar->handlers.last= NULL;
        ar->uiblocks.first= ar->uiblocks.last= NULL;
+       ar->headerstr= NULL;
        ar->regiondata= NULL;
        ar->swinid= 0;
        ar->type= NULL;
index 0629309..22b74ea 100644 (file)
@@ -64,6 +64,7 @@ void  ED_area_initialize(struct wmWindowManager *wm, struct wmWindow *win, struct
 void   ED_area_exit(struct bContext *C, struct ScrArea *sa);
 int            ED_screen_area_active(const struct bContext *C);
 void   ED_area_tag_redraw(ScrArea *sa);
+void   ED_area_headerprint(ScrArea *sa, const char *str);
 
 /* screens */
 void   ED_screens_initialize(struct wmWindowManager *wm);
index 16ff886..1960ff2 100644 (file)
@@ -37,6 +37,7 @@ CFLAGS += $(LEVEL_1_C_WARNINGS)
 
 CPPFLAGS += -I$(NAN_GLEW)/include
 CPPFLAGS += -I$(OPENGL_HEADERS)
+CPPFLAGS += -I$(NAN_BMFONT)/include
 
 # not very neat....
 CPPFLAGS += -I../../windowmanager
index 57a8e1a..ce92a54 100644 (file)
@@ -5,7 +5,7 @@ sources = env.Glob('*.c')
 
 incs = '../include ../../blenlib ../../blenkernel ../../makesdna ../../imbuf'
 incs += ' ../../blenloader ../../windowmanager ../../python ../../makesrna'
-incs += ' #/intern/guardedalloc #/extern/glew/include'
+incs += ' #/intern/guardedalloc #/extern/glew/include #intern/bmfont'
 
 defs = ''
 
index fcee872..f90c247 100644 (file)
@@ -36,6 +36,7 @@
 #include "BLI_rand.h"
 
 #include "BKE_context.h"
+#include "BKE_global.h"
 #include "BKE_screen.h"
 #include "BKE_utildefines.h"
 
@@ -54,6 +55,8 @@
 #include "UI_resources.h"
 #include "UI_view2d.h"
 
+#include "BMF_Api.h"
+
 #ifndef DISABLE_PYTHON
 #include "BPY_extern.h"
 #endif
@@ -181,30 +184,31 @@ void ED_region_do_draw(bContext *C, ARegion *ar)
        /* note; this sets state, so we can use wmOrtho and friends */
        wmSubWindowSet(win, ar->swinid);
        
-       if(ar->swinid && at->draw) {
-               UI_SetTheme(sa);
-               at->draw(C, ar);
-               UI_SetTheme(NULL);
-       }
-       else {
-               float fac= 0.1*ar->swinid;
-               
-               fac= fac - (int)fac;
+       if(ar->swinid) {
+               /* optional header info instead? */
+               if(ar->headerstr) {
+                       float col[3];
+                       UI_SetTheme(sa);
+                       UI_GetThemeColor3fv(TH_HEADER, col);
+                       glClearColor(col[0], col[1], col[2], 0.0);
+                       glClear(GL_COLOR_BUFFER_BIT);
+                       
+                       UI_ThemeColor(TH_MENU_TEXT);
+                       glRasterPos2i(20, 6);
+                       BMF_DrawString(G.font, ar->headerstr);
+               }
+               else if(at->draw) {
+                       UI_SetTheme(sa);
+                       at->draw(C, ar);
+                       UI_SetTheme(NULL);
+               }
                
-               glClearColor(0.5, fac, 1.0f-fac, 0.0); 
-               glClear(GL_COLOR_BUFFER_BIT);
+               if(sa)
+                       region_draw_emboss(ar);
                
-               /* swapbuffers indicator */
-               fac= BLI_frand();
-               glColor3f(fac, fac, fac);
-               glRecti(20,  2,  30,  12);
+               /* XXX test: add convention to end regions always in pixel space, for drawing of borders/gestures etc */
+               ED_region_pixelspace(ar);
        }
-
-       if(sa)
-               region_draw_emboss(ar);
-       
-       /* XXX test: add convention to end regions always in pixel space, for drawing of borders/gestures etc */
-       ED_region_pixelspace(ar);
        
        ar->do_draw= 0;
 }
@@ -230,6 +234,28 @@ void ED_area_tag_redraw(ScrArea *sa)
 }
 
 
+/* *************************************************************** */
+
+/* use NULL to disable it */
+void ED_area_headerprint(ScrArea *sa, const char *str)
+{
+       ARegion *ar;
+       
+       for(ar= sa->regionbase.first; ar; ar= ar->next) {
+               if(ar->regiontype==RGN_TYPE_HEADER) {
+                       if(str) {
+                               if(ar->headerstr==NULL)
+                                       ar->headerstr= MEM_mallocN(256, "headerprint");
+                               BLI_strncpy(ar->headerstr, str, 256);
+                       }
+                       else if(ar->headerstr) {
+                               MEM_freeN(ar->headerstr);
+                               ar->headerstr= NULL;
+                       }
+                       ED_region_tag_redraw(ar);
+               }
+       }
+}
 
 /* *************************************************************** */
 
index cef98a7..1022fea 100644 (file)
@@ -1024,6 +1024,10 @@ void ED_region_exit(bContext *C, ARegion *ar)
                wm_subwindow_close(CTX_wm_window(C), ar->swinid);
        ar->swinid= 0;
        
+       if(ar->headerstr)
+               MEM_freeN(ar->headerstr);
+       ar->headerstr= NULL;
+       
        CTX_wm_region_set(C, prevar);
 }
 
index 486d160..c932c0b 100644 (file)
@@ -140,6 +140,7 @@ typedef struct ARegion {
        ListBase uiblocks;
        ListBase handlers;                      /* wmEventHandler */
        
+       char *headerstr;                        /* use this string to draw info */
        void *regiondata;                       /* XXX 2.50, need spacedata equivalent? */
 } ARegion;