Lots of small changes, all for UI in Blender;
authorTon Roosendaal <ton@blender.org>
Sun, 3 Oct 2004 13:49:54 +0000 (13:49 +0000)
committerTon Roosendaal <ton@blender.org>
Sun, 3 Oct 2004 13:49:54 +0000 (13:49 +0000)
----- Killed UI frontbuffer draw
The interface toolkit was drawing all live updates (while using menus/buttons)
in the frontbuffer. This isn't well supported cross-platform, so time to be
killed once. Now it uses *only* glReadPixels and glCopyPixels for frontbuffer
access.

Live updates or menus now are drawn in backbuffer always, and copied to
front when needed.

NOTE: it was tested, but needs thorough review! On PC systems I suspects
backbuffer selection to screw up (check!). On SGI/SUN workstations it
should work smooth; but I need evidence

----- Smaller fixes;

- AA fonts were garbled on ATI systems. Now the AA fonts are drawn exact
  on pixel positions. Needs the new FTGL libb too, patch is on maillist
- Rounded theme uses antialiased outlines
- Pulldown and popup menus have nice softshadow now
- New button type 'PULLDOWN', thats the one that callsup a pulldown menu.
  Should be added to themes, as is the full menu/pulldown drawing
- Screendump for 1 window does the full window now, including header
- Empty pulldowns (for example running blender without scripts) give no
  drawing error anymore

For review & fun;
- added curved lines as connectors, for Oops window

29 files changed:
source/blender/ftfont/intern/FTF_TTFont.h
source/blender/include/BIF_interface.h
source/blender/include/BIF_screen.h
source/blender/include/interface.h
source/blender/src/drawoops.c
source/blender/src/editmode_undo.c
source/blender/src/editscreen.c
source/blender/src/editview.c
source/blender/src/header_action.c
source/blender/src/header_buttonswin.c
source/blender/src/header_image.c
source/blender/src/header_info.c
source/blender/src/header_ipo.c
source/blender/src/header_nla.c
source/blender/src/header_oops.c
source/blender/src/header_script.c
source/blender/src/header_seq.c
source/blender/src/header_sound.c
source/blender/src/header_view3d.c
source/blender/src/headerbuttons.c
source/blender/src/interface.c
source/blender/src/interface_draw.c
source/blender/src/interface_panel.c
source/blender/src/mywindow.c
source/blender/src/screendump.c
source/blender/src/space.c
source/blender/src/swapbuffers.c
source/blender/src/toolbox.c
source/blender/src/view.c

index 18d30e944f3f1923f2a9cc88259ed3e648eb30e6..bec5df3265d72a609e0a420cb75b97b1e89bb03f 100644 (file)
@@ -38,6 +38,7 @@
 #define __FTF_TRUETYPE_FONT_H
 
 #include "FTGLPixmapFont.h"
+
 #include <stdio.h>
 //#include <iconv.h>
 
index a006c1ef44f211981d56a3dc0756c335cac04e8a..9f8afd76ea6da265e36e3bd74191e61a85ba0850 100644 (file)
@@ -147,6 +147,7 @@ struct ScrArea;
 #define KEYEVT (24<<9)
 #define ICONTEXTROW (25<<9)
 #define HSVCUBE (26<<9)
+#define PULLDOWN (27<<9)
 
 #define BUTTYPE        (31<<9)
 
@@ -156,7 +157,7 @@ typedef struct uiBut uiBut;
 typedef struct uiBlock uiBlock;
 
 void uiEmboss(float x1, float y1, float x2, float y2, int sel);
-void uiRoundBoxEmboss(float minx, float miny, float maxx, float maxy, float rad);
+void uiRoundBoxEmboss(float minx, float miny, float maxx, float maxy, float rad, int active);
 void uiRoundBox(float minx, float miny, float maxx, float maxy, float rad);
 void uiSetRoundBox(int type);
 void uiRoundRect(float minx, float miny, float maxx, float maxy, float rad);
@@ -237,6 +238,7 @@ void uiDefIDPoinBut(struct uiBlock *block,
 
 typedef uiBlock* (*uiBlockFuncFP)      (void *arg1);
 uiBut *uiDefBlockBut(uiBlock *block, uiBlockFuncFP func, void *func_arg1, char *str, short x1, short y1, short x2, short y2, char *tip);
+uiBut *uiDefPulldownBut(uiBlock *block, uiBlockFuncFP func, void *func_arg1, char *str, short x1, short y1, short x2, short y2, char *tip);
 
 uiBut *uiDefIconTextBlockBut(uiBlock *block, uiBlockFuncFP func, void *arg, int icon, char *str, short x1, short y1, short x2, short y2, char *tip);
 
index c99ea545bb1163c3898e49b4a59a5410b85e987e..021ce12dea5fda397f6c55431a423e3d83feda7e 100644 (file)
@@ -89,7 +89,11 @@ void add_readfile_event(char *filename);
 short ext_qtest(void);
 unsigned short extern_qread(short *val);
 unsigned short extern_qread_ext(short *val, char *ascii);
-void markdirty_all(void);
+
+extern void markdirty_all(void); // also sets redraw event
+extern void markdirty_all_back(void);
+extern void markdirty_win_back(short winid);
+       
 void screen_swapbuffers(void);
 void set_debug_swapbuffers_ovveride(struct bScreen *sc, int mode);
 int is_allowed_to_change_screen(struct bScreen *newp);
index 7ebc9ffb72e617a58b0b54954a47623c64311993..281e2e4be10ad1a57ce67a7581e751452bff8951 100644 (file)
@@ -51,9 +51,8 @@
 /* warn: rest of uiBut->flag in BIF_interface.c */
 
 
-/* block->frontbuf: (only internal here), to nice localize the old global var uiFrontBuf */
-#define UI_NEED_DRAW_FRONT             1
-#define UI_HAS_DRAW_FRONT              2
+/* block->frontbuf: (only internal here). this signals something was drawn, for flush */
+#define UI_HAS_DRAWN   1
 
 
 /* internal panel drawing defines */
@@ -141,7 +140,7 @@ struct uiBut {
        BIFIconID icon;
        short but_align;        /* aligning buttons, horiz/vertical */
        short lock, win;
-       short iconadd;
+       short iconadd, dt;
 
                /* IDPOIN data */
        uiIDPoinFuncFP idpoin_func;
@@ -187,34 +186,41 @@ struct uiBlock {
        int afterval, flag;
        void *curfont;
        
-       short autofill, win, winq, direction, dt, frontbuf, auto_open;  //frontbuf see below
-       void *saveunder;
+       short autofill, win, winq, direction, dt, frontbuf, auto_open, pad;  //frontbuf see below
+       void *overdraw;
        
        float xofs, yofs;       // offset to parent button
        rctf parentrct;         // for pulldowns, rect the mouse is allowed outside of menu (parent button)
        rctf safety;            // pulldowns, to detect outside, can differ per case how it is created
        
+       rctf flush;                     // rect to be flushed to frontbuffer
        int handler;            // for panels in other windows than buttonswin... just event code
 };
 
 /* interface.c */
+
+extern void ui_graphics_to_window(int win, float *x, float *y);
+extern void ui_window_to_graphics(int win, float *x, float *y);
+
+extern void ui_block_flush_back(uiBlock *block);
+extern void ui_block_set_flush(uiBlock *block, uiBut *but);
+
 extern void ui_check_but(uiBut *but);
 extern double ui_get_but_val(uiBut *but);
 extern void ui_get_but_vectorf(uiBut *but, float *vec);
 extern void ui_set_but_vectorf(uiBut *but, float *vec);
 extern void ui_autofill(uiBlock *block);
-extern void ui_graphics_to_window(int win, float *x, float *y);
-extern void ui_window_to_graphics(int win, float *x, float *y);
 
 /* interface_panel.c */
 extern void ui_draw_panel(uiBlock *block);
 extern void ui_do_panel(uiBlock *block, uiEvent *uevent);
 extern void gl_round_box(int mode, float minx, float miny, float maxx, float maxy, float rad);
-extern void gl_round_box_shade(int mode, float minx, float miny, float maxx, float maxy, float rad, float shade);
+extern void gl_round_box_shade(int mode, float minx, float miny, float maxx, float maxy, float rad, float shadetop, float shadedown);
 
 /* interface_draw.c */
 extern void ui_set_embossfunc(uiBut *but, int drawtype);
 extern void ui_draw_but(uiBut *but);
+extern void ui_rasterpos_safe(float x, float y, float aspect);
 
 
 #endif
index 0ebc6ff443ec6572cb2a005ac6ef56fc4b0042e9..dacbf86b60ac1a5239a6046a65ee67f851ead0ed 100644 (file)
@@ -129,7 +129,8 @@ void give_oopslink_line(Oops *oops, OopsLink *ol, float *v1, float *v2)
 void draw_oopslink(Oops *oops)
 {
        OopsLink *ol;
-       float vec[4];
+       float vec[4][3], dist;
+       int a;
        
        if(oops->type==ID_SCE) {
                if(oops->flag & SELECT) {
@@ -146,15 +147,36 @@ void draw_oopslink(Oops *oops)
                else cpack(0x0);
        }
        
+       glEnable(GL_MAP1_VERTEX_3);
+       vec[0][2]= vec[1][2]= vec[2][2]= vec[3][2]= 0.0;
+       
        ol= oops->link.first;
        while(ol) {
                if(ol->to && ol->to->hide==0) {
                        
-                       give_oopslink_line(oops, ol, vec, vec+2);
+                       give_oopslink_line(oops, ol, vec[0], vec[3]);
+                       
+                       dist= 0.5*VecLenf(vec[0], vec[3]);
+                       
+                       /* check ol->xof and yof for direction */
+                       if(ol->xof <= 0.0) {
+                               vec[1][0]= vec[0][0]-dist;
+                               vec[1][1]= vec[0][1];
+                       }
+                       else {
+                               vec[1][0]= vec[0][0];
+                               vec[1][1]= vec[0][1]+dist;
+                       }
+                       /* v3 is always pointing down */
+                       vec[2][0]= vec[3][0];
+                       vec[2][1]= vec[3][1] - dist;
+
+                       glMap1f(GL_MAP1_VERTEX_3, 0.0, 1.0, 3, 4, vec[0]);
                        
                        glBegin(GL_LINE_STRIP);
-                       glVertex2fv(vec);
-                       glVertex2fv(vec+2);
+                       for(a=0; a<=30; a++) {
+                               glEvalCoord1f((float)a/30.0);
+                       }
                        glEnd();
                }
                ol= ol->next;
index 7ae8613041acc22b0531ee881afc2ef53e9c6d36..d21e290f3227be2ce4fa1e0ff91a26bf16fcde6f 100644 (file)
@@ -207,7 +207,7 @@ void undo_editmode_step(int step)
        undo_clean_stack();
        
        if(step==0) {
-               undo_restore(curundo);  // if NULL, reloads editmesh
+               undo_restore(curundo);
        }
        else if(step==1) {
                
@@ -215,7 +215,7 @@ void undo_editmode_step(int step)
                else {
                        printf("undo %s\n", curundo->name);
                        curundo= curundo->prev;
-                       undo_restore(curundo);  // if NULL, reloads editmesh
+                       undo_restore(curundo);
                }
        }
        else {
@@ -311,6 +311,8 @@ uiBlock *editmode_undohistorymenu(void *arg_unused)
        short yco = 20, menuwidth = 120;
        short item=2;
        
+       undo_clean_stack();     // removes other objects from it
+
        block= uiNewBlock(&curarea->uiblocks, "view3d_edit_mesh_undohistorymenu", UI_EMBOSSP, UI_HELV, G.curscreen->mainwin);
        uiBlockSetButmFunc(block, do_editmode_undohistorymenu, NULL);
        
@@ -319,6 +321,7 @@ uiBlock *editmode_undohistorymenu(void *arg_unused)
        for(uel= undobase.first; uel; uel= uel->next, item++) {
                if (uel==curundo) uiDefBut(block, SEPR, 0, "",          0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
                uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, uel->name, 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, (float)item, "");
+               if (uel==curundo) uiDefBut(block, SEPR, 0, "",          0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
        }
        
        uiBlockSetDirection(block, UI_RIGHT);
index 65a206351d9debb80274371c7622974555d24305..4fcba65801515cddef0956713a102e54ac2138c3 100644 (file)
@@ -314,21 +314,24 @@ void areawinset(short win)
 void headerbox(ScrArea *area)
 {
        float width= area->winx;
+       int active=0;
 
        glClearColor(SCR_BACK, SCR_BACK, SCR_BACK, 0.0);
        glClear(GL_COLOR_BUFFER_BIT);
 
-       if(area_is_active_area(area)) BIF_ThemeColor(TH_HEADER);
+       active= area_is_active_area(area);
+
+       if(active) BIF_ThemeColor(TH_HEADER);
        else BIF_ThemeColor(TH_HEADERDESEL);
 
        /* weird values here... is because of window matrix that centres buttons */
        if(area->headertype==HEADERTOP) {
                uiSetRoundBox(3);
-               uiRoundBoxEmboss(-0.5+area->headbutofs, -10.0, width-1.5+area->headbutofs, HEADERY-2.0, SCR_ROUND);
+               uiRoundBoxEmboss(-0.5+area->headbutofs, -10.0, width-1.5+area->headbutofs, HEADERY-2.0, SCR_ROUND, active);
        }
        else {
                uiSetRoundBox(12);
-               uiRoundBoxEmboss(-0.5+area->headbutofs, -3.5, width-1.5+area->headbutofs, HEADERY+10, SCR_ROUND);
+               uiRoundBoxEmboss(-0.5+area->headbutofs, -3.5, width-1.5+area->headbutofs, HEADERY+10, SCR_ROUND, active);
        }
        
        uiSetRoundBox(15);
@@ -552,7 +555,6 @@ static void scrarea_dispatch_events(ScrArea *sa)
 void markdirty_all()
 {
        ScrArea *sa;
-
        for (sa= G.curscreen->areabase.first; sa; sa= sa->next) {
                if(sa->win) {
                        scrarea_queue_winredraw(sa);
@@ -565,6 +567,31 @@ void markdirty_all()
        }
 }
 
+/* but no redraw! */
+void markdirty_all_back(void)
+{
+       ScrArea *sa;
+       
+       for (sa= G.curscreen->areabase.first; sa; sa= sa->next) {
+               if(sa->win) {
+                       sa->win_swap &= ~WIN_BACK_OK;
+               }
+               if(sa->headwin) {
+                       sa->head_swap &= ~WIN_BACK_OK;
+               }
+       }
+}
+
+void markdirty_win_back(short winid)
+{
+       ScrArea *sa= areawinar[winid];
+       if(sa) {
+               if(sa->win==winid) sa->win_swap &= ~WIN_BACK_OK;
+               else sa->head_swap &= ~WIN_BACK_OK;
+       }
+}
+
+
 int is_allowed_to_change_screen(bScreen *new)
 {
        /* not when curscreen is full
@@ -2923,7 +2950,7 @@ void draw_area_emboss(ScrArea *sa)
        if(FALSE && sa->spacetype==SPACE_VIEW3D) {
        cpack(0xA0A0A0);
        uiSetRoundBox(31);
-       uiRoundBoxEmboss(5.0, 5.0, 25.0, 100.0, 8.0);
+       uiRoundBoxEmboss(5.0, 5.0, 25.0, 100.0, 8.0, 0);
 
        glEnable(GL_BLEND);
        glBlendFunc(GL_SRC_ALPHA,  GL_ONE_MINUS_SRC_ALPHA); 
index 9d063c0266a160b7d7be043b795a6e04462d7f3d..888ca07d566a2e4cf10f9e74fcf289ec0294a42b 100644 (file)
@@ -564,6 +564,7 @@ int gesture(void)
                        PIL_sleep_ms(10);
                        timer++;
                        if(timer>=10*U.tb_leftmouse) {
+                               glDrawBuffer(GL_BACK); /* !! */
                                toolbox_n();
                                return 1;
                        }
index c75c737c5c173a635b425d474c57b649f6dc200c..00d18b27afee7614f26068507b785940f517de42 100644 (file)
@@ -730,17 +730,17 @@ void action_buttons(void)
                uiBlockSetEmboss(block, UI_EMBOSSP);
        
                xmax= GetButStringLength("View");
-               uiDefBlockBut(block, action_viewmenu, NULL, 
+               uiDefPulldownBut(block, action_viewmenu, NULL, 
                                          "View", xco, -2, xmax-3, 24, "");
                xco+= xmax;
                
                xmax= GetButStringLength("Select");
-               uiDefBlockBut(block, action_selectmenu, NULL, 
+               uiDefPulldownBut(block, action_selectmenu, NULL, 
                                          "Select", xco, -2, xmax-3, 24, "");
                xco+= xmax;
        
                xmax= GetButStringLength("Key");
-               uiDefBlockBut(block, action_keymenu, NULL, 
+               uiDefPulldownBut(block, action_keymenu, NULL, 
                                          "Key", xco, -2, xmax-3, 24, "");
                xco+= xmax;
        }
index 9487aa0ab9f399d18b64f42a917556d130a4b134..70c3b0717f6df1335f97cc0c8aa985582d440064 100644 (file)
@@ -678,7 +678,7 @@ void buts_buttons(void)
                uiBlockSetEmboss(block, UI_EMBOSSP);
        
                xmax= GetButStringLength("Panels");
-               uiDefBlockBut(block, buts_viewmenu, NULL, 
+               uiDefPulldownBut(block, buts_viewmenu, NULL, 
                                          "Panels", xco, -2, xmax-3, 24, "");
                xco+= xmax;
 
index 51cfcccfcb327f8e412ab967aed32ee2b79e1774..aa4c2eef845b9b456ddf167dbc221b5626e7a6eb 100644 (file)
@@ -1003,20 +1003,20 @@ void image_buttons(void)
                uiBlockSetEmboss(block, UI_EMBOSSP);
        
                xmax= GetButStringLength("View");
-               uiDefBlockBut(block, image_viewmenu, NULL, "View", xco, -2, xmax-3, 24, "");
+               uiDefPulldownBut(block, image_viewmenu, NULL, "View", xco, -2, xmax-3, 24, "");
                xco+= xmax;
                
                xmax= GetButStringLength("Select");
-               uiDefBlockBut(block, image_selectmenu, NULL, "Select", xco, -2, xmax-3, 24, "");
+               uiDefPulldownBut(block, image_selectmenu, NULL, "Select", xco, -2, xmax-3, 24, "");
         
                xco+= xmax;
                
                xmax= GetButStringLength("Image");
-               uiDefBlockBut(block, image_imagemenu, NULL, "Image", xco, -2, xmax-3, 24, "");
+               uiDefPulldownBut(block, image_imagemenu, NULL, "Image", xco, -2, xmax-3, 24, "");
                xco+= xmax;
                
                xmax= GetButStringLength("UVs");
-               uiDefBlockBut(block, image_uvsmenu, NULL, "UVs", xco, -2, xmax-3, 24, "");
+               uiDefPulldownBut(block, image_uvsmenu, NULL, "UVs", xco, -2, xmax-3, 24, "");
                xco+= xmax;
        }
        
index 2c53eed6eddda365bdd03877e07ebc9e0a9c4158..f267a19f4289b4afaf2c01f36cb25fc1dff12a11 100644 (file)
@@ -381,7 +381,6 @@ void do_info_buttons(unsigned short event)
        int nr;
 
        switch(event) {
-
        case B_INFOSCR:         /* menu select screen */
 
                if( G.curscreen->screennr== -2) {
@@ -1802,37 +1801,39 @@ static void info_text(int x, int y)
                strcat(infostr, ob->id.name+2);
        }
 
+       if (g_progress_bar && g_progress_info) {
+               headerstr= g_progress_info;
+       } else {
+               headerstr= versionstr; 
+       }
+
        if      (g_progress_bar) {
                hsize = 4 + (138.0 * g_done);
                fac1 = 0.5 * g_done; // do some rainbow colours on progress
                fac2 = 1.0;
                fac3 = 0.9;
        } else {
-               hsize = 142;
+               hsize= 30+BIF_GetStringWidth(G.font, headerstr, (U.transopts & USER_TR_BUTTONS));
+
                /* promise! Never change these lines again! (zr & ton did!) */
                fac1= fabs(hashvectf[ 2*G.version+4]);
                fac2= 0.5+0.1*hashvectf[ G.version+3];
                fac3= 0.7;
        }
-
-       if (g_progress_bar && g_progress_info) {
-               headerstr= g_progress_info;
-       } else {
-               headerstr= versionstr; 
-       }
        
        swatch_color= hsv_to_cpack(fac1, fac2, fac3);
 
        cpack( swatch_color );
-       glRecti(x-24,  y-6,  x-22+hsize,        y+14);
+       glRecti(x-24,  y-6,  x-30+hsize,        y+14);
 
        glColor3ub(0, 0, 0);
 
        glRasterPos2i(x, y);
 
        BIF_DrawString(G.font, headerstr, (U.transopts & USER_TR_MENUS));
-               
-       glRasterPos2i(x+122,    y);
+       hsize= BIF_GetStringWidth(G.font, headerstr, (U.transopts & USER_TR_BUTTONS));
+       
+       glRasterPos2i(x+hsize+10,       y);
 
        BIF_DrawString(G.font, infostr, (U.transopts & USER_TR_MENUS));
 }
@@ -1867,27 +1868,27 @@ void info_buttons(void)
                 * menu is drawn wider than it should be. The ypos of -1 is to make it properly fill the
                 * height of the header */
                xmax= GetButStringLength("File");
-               uiDefBlockBut(block, info_filemenu, NULL, "File",       xco, -1, xmax-3, 22, "");
+               uiDefPulldownBut(block, info_filemenu, NULL, "File",    xco, -1, xmax-3, 22, "");
                xco+= xmax;
 
                xmax= GetButStringLength("Add");
-               uiDefBlockBut(block, info_addmenu, NULL, "Add", xco, -1, xmax-3, 22, "");
+               uiDefPulldownBut(block, info_addmenu, NULL, "Add",      xco, -1, xmax-3, 22, "");
                xco+= xmax;
 
                xmax= GetButStringLength("Timeline");
-               uiDefBlockBut(block, info_timelinemenu, NULL, "Timeline",       xco, -1, xmax-3, 22, "");
+               uiDefPulldownBut(block, info_timelinemenu, NULL, "Timeline",    xco, -1, xmax-3, 22, "");
                xco+= xmax;
 
                xmax= GetButStringLength("Game");
-               uiDefBlockBut(block, info_gamemenu, NULL, "Game",       xco, -1, xmax-3, 22, "");
+               uiDefPulldownBut(block, info_gamemenu, NULL, "Game",    xco, -1, xmax-3, 22, "");
                xco+= xmax;
 
                xmax= GetButStringLength("Render");
-               uiDefBlockBut(block, info_rendermenu, NULL, "Render",   xco, -1, xmax-3, 22, "");
+               uiDefPulldownBut(block, info_rendermenu, NULL, "Render",        xco, -1, xmax-3, 22, "");
                xco+= xmax;
 
                xmax= GetButStringLength("Help");
-               uiDefBlockBut(block, info_helpmenu, NULL, "Help",       xco, -1, xmax-3, 22, "");
+               uiDefPulldownBut(block, info_helpmenu, NULL, "Help",    xco, -1, xmax-3, 22, "");
                xco+= xmax;
 
        }
index 812ffcdda2fe3575c649067f48b12110e8193d3c..b2e5ca3df2c3b0752777d36c555eac26a0faefc9 100644 (file)
@@ -813,24 +813,24 @@ void ipo_buttons(void)
                ei = get_editipo();
        
                xmax= GetButStringLength("View");
-               uiDefBlockBut(block,ipo_viewmenu, NULL, "View", xco, -2, xmax-3, 24, "");
+               uiDefPulldownBut(block,ipo_viewmenu, NULL, "View", xco, -2, xmax-3, 24, "");
                xco+=xmax;
        
                xmax= GetButStringLength("Select");
-               uiDefBlockBut(block,ipo_selectmenu, NULL, "Select", xco, -2, xmax-3, 24, "");
+               uiDefPulldownBut(block,ipo_selectmenu, NULL, "Select", xco, -2, xmax-3, 24, "");
                xco+=xmax;
        
                if (G.sipo->showkey) {
                        xmax= GetButStringLength("Key");
-                       uiDefBlockBut(block,ipo_editmenu, NULL, "Key", xco, -2, xmax-3, 24, "");
+                       uiDefPulldownBut(block,ipo_editmenu, NULL, "Key", xco, -2, xmax-3, 24, "");
                }
                else if(ei != NULL && (ei->flag & IPO_EDIT)) {
                        xmax= GetButStringLength("Point");
-                       uiDefBlockBut(block,ipo_editmenu, NULL, "Point", xco, -2, xmax-3, 24, "");
+                       uiDefPulldownBut(block,ipo_editmenu, NULL, "Point", xco, -2, xmax-3, 24, "");
                }
                else {
                        xmax= GetButStringLength("Curve");
-                       uiDefBlockBut(block,ipo_editmenu, NULL, "Curve", xco, -2, xmax-3, 24, "");
+                       uiDefPulldownBut(block,ipo_editmenu, NULL, "Curve", xco, -2, xmax-3, 24, "");
                }
                        
                xco+=xmax;
index 65ac387c8cf360aaa01f58972c41b61278eed0f6..56c4ed52479d4a34f159a2d6a49fb7ca21604e75 100644 (file)
@@ -353,15 +353,15 @@ void nla_buttons(void)
                uiBlockSetEmboss(block, UI_EMBOSSP);
        
                xmax= GetButStringLength("View");
-               uiDefBlockBut(block, nla_viewmenu, NULL, "View", xco, -2, xmax-3, 24, "");
+               uiDefPulldownBut(block, nla_viewmenu, NULL, "View", xco, -2, xmax-3, 24, "");
                xco+= xmax;
                
                xmax= GetButStringLength("Select");
-               uiDefBlockBut(block, nla_selectmenu, NULL, "Select", xco, -2, xmax-3, 24, "");
+               uiDefPulldownBut(block, nla_selectmenu, NULL, "Select", xco, -2, xmax-3, 24, "");
                xco+= xmax;
 
                xmax= GetButStringLength("Strip");
-               uiDefBlockBut(block, nla_stripmenu, NULL, "Strip", xco, -2, xmax-3, 24, "");
+               uiDefPulldownBut(block, nla_stripmenu, NULL, "Strip", xco, -2, xmax-3, 24, "");
                xco+= xmax;
 
        }
index 84a1d1008ab3ce010e54c2bcafda9d6b316af2d5..7a3a089425830a9896a4c0dd56cbbaf00d394bfa 100644 (file)
@@ -286,15 +286,15 @@ void oops_buttons(void)
                uiBlockSetEmboss(block, UI_EMBOSSP);
        
                xmax= GetButStringLength("View");
-               uiDefBlockBut(block, oops_viewmenu, NULL, "View", xco, -2, xmax-3, 24, "");
+               uiDefPulldownBut(block, oops_viewmenu, NULL, "View", xco, -2, xmax-3, 24, "");
                xco+= xmax;
                
                xmax= GetButStringLength("Select");
-               uiDefBlockBut(block, oops_selectmenu, NULL, "Select", xco, -2, xmax-3, 24, "");
+               uiDefPulldownBut(block, oops_selectmenu, NULL, "Select", xco, -2, xmax-3, 24, "");
                xco+= xmax;
                
                xmax= GetButStringLength("Block");
-               uiDefBlockBut(block, oops_blockmenu, NULL, "Block", xco, -2, xmax-3, 24, "");
+               uiDefPulldownBut(block, oops_blockmenu, NULL, "Block", xco, -2, xmax-3, 24, "");
                xco+= xmax;
 
        }
index 01d400bcbbf5c8f76236cab1aaec734b443ad6bb..345636fe2ce605a59f81a2ba88ba9e93c3f34ef5 100644 (file)
@@ -255,7 +255,7 @@ void script_buttons(void)
                uiBlockSetEmboss(block, UI_EMBOSSP);
        
                xmax= GetButStringLength("Scripts");
-               uiDefBlockBut(block,script_scriptsmenu, NULL, "Scripts", xco, 0, xmax, 20, "");
+               uiDefPulldownBut(block,script_scriptsmenu, NULL, "Scripts", xco, 0, xmax, 20, "");
                xco+=xmax;
        }
 
index 893b5f7c68e3657cf854ad04d65117b0de2eec7c..c29ebbaaa43b17778826e7773035c9b2312ec6d8 100644 (file)
@@ -460,19 +460,19 @@ void seq_buttons()
                uiBlockSetEmboss(block, UI_EMBOSSP);
 
                xmax= GetButStringLength("View");
-               uiDefBlockBut(block,seq_viewmenu, NULL, "View", xco, -2, xmax-3, 24, "");
+               uiDefPulldownBut(block,seq_viewmenu, NULL, "View", xco, -2, xmax-3, 24, "");
                xco+=xmax;
 
                xmax= GetButStringLength("Select");
-               uiDefBlockBut(block,seq_selectmenu, NULL, "Select", xco, -2, xmax-3, 24, "");
+               uiDefPulldownBut(block,seq_selectmenu, NULL, "Select", xco, -2, xmax-3, 24, "");
                xco+=xmax;
 
                xmax= GetButStringLength("Add");
-               uiDefBlockBut(block, seq_addmenu, NULL, "Add", xco, -2, xmax-3, 24, "");
+               uiDefPulldownBut(block, seq_addmenu, NULL, "Add", xco, -2, xmax-3, 24, "");
                xco+= xmax;
 
                xmax= GetButStringLength("Strip");
-               uiDefBlockBut(block, seq_editmenu, NULL, "Strip", xco, -2, xmax-3, 24, "");
+               uiDefPulldownBut(block, seq_editmenu, NULL, "Strip", xco, -2, xmax-3, 24, "");
                xco+= xmax;
 
                /* end of pull down menus */
index 12ca5993f8a6b506a888627179ec1862915da42b..3446830a5861dc42179cf593be6cc91f3b651b6e 100644 (file)
@@ -280,7 +280,7 @@ void sound_buttons(void)
                uiBlockSetEmboss(block, UI_EMBOSSP);
        
                xmax= GetButStringLength("View");
-               uiDefBlockBut(block, sound_viewmenu, NULL, 
+               uiDefPulldownBut(block, sound_viewmenu, NULL, 
                                          "View", xco, -2, xmax-3, 24, "");
                xco+= xmax;
 
index 3bfb47c15561e66644c933db2422d4a0c6d54d6e..9d28b7746c64e17bb7deff647d621bb85e31ec59 100644 (file)
@@ -3720,36 +3720,36 @@ static void view3d_header_pulldowns(uiBlock *block, short *xcoord)
         * height of the header */
        
        xmax= GetButStringLength("View");
-       uiDefBlockBut(block, view3d_viewmenu, NULL, "View", xco, -2, xmax-3, 24, "");
+       uiDefPulldownBut(block, view3d_viewmenu, NULL, "View", xco, -2, xmax-3, 24, "");
        xco+= xmax;
        
        xmax= GetButStringLength("Select");
        if (G.obedit) {
                if (OBACT && OBACT->type == OB_MESH) {
-                       uiDefBlockBut(block, view3d_select_meshmenu, NULL, "Select",    xco,-2, xmax-3, 24, "");
+                       uiDefPulldownBut(block, view3d_select_meshmenu, NULL, "Select", xco,-2, xmax-3, 24, "");
                } else if (OBACT && (OBACT->type == OB_CURVE || OBACT->type == OB_SURF)) {
-                       uiDefBlockBut(block, view3d_select_curvemenu, NULL, "Select", xco,-2, xmax-3, 24, "");
+                       uiDefPulldownBut(block, view3d_select_curvemenu, NULL, "Select", xco,-2, xmax-3, 24, "");
                } else if (OBACT && OBACT->type == OB_FONT) {
-                       uiDefBlockBut(block, view3d_select_meshmenu, NULL, "Select",    xco, -2, xmax-3, 24, "");
+                       uiDefPulldownBut(block, view3d_select_meshmenu, NULL, "Select", xco, -2, xmax-3, 24, "");
                } else if (OBACT && OBACT->type == OB_MBALL) {
-                       uiDefBlockBut(block, view3d_select_metaballmenu, NULL, "Select",        xco,-2, xmax-3, 24, "");
+                       uiDefPulldownBut(block, view3d_select_metaballmenu, NULL, "Select",     xco,-2, xmax-3, 24, "");
                } else if (OBACT && OBACT->type == OB_LATTICE) {
-                       uiDefBlockBut(block, view3d_select_latticemenu, NULL, "Select", xco,-2, xmax-3, 24, "");
+                       uiDefPulldownBut(block, view3d_select_latticemenu, NULL, "Select", xco,-2, xmax-3, 24, "");
                } else if (OBACT && OBACT->type == OB_ARMATURE) {
-                       uiDefBlockBut(block, view3d_select_armaturemenu, NULL, "Select",        xco,-2, xmax-3, 24, "");
+                       uiDefPulldownBut(block, view3d_select_armaturemenu, NULL, "Select",     xco,-2, xmax-3, 24, "");
                }
        } else if (G.f & G_FACESELECT) {
                if (OBACT && OBACT->type == OB_MESH) {
-                       uiDefBlockBut(block, view3d_select_faceselmenu, NULL, "Select", xco,-2, xmax-3, 24, "");
+                       uiDefPulldownBut(block, view3d_select_faceselmenu, NULL, "Select", xco,-2, xmax-3, 24, "");
                }
        } else if (G.obpose) {
                if (OBACT && OBACT->type == OB_ARMATURE) {
-                       uiDefBlockBut(block, view3d_select_pose_armaturemenu, NULL, "Select", xco,-2, xmax-3, 24, "");
+                       uiDefPulldownBut(block, view3d_select_pose_armaturemenu, NULL, "Select", xco,-2, xmax-3, 24, "");
                }
        } else if ((G.f & G_VERTEXPAINT) || (G.f & G_TEXTUREPAINT) || (G.f & G_WEIGHTPAINT)) {
                uiDefBut(block, LABEL,0,"", xco, 0, xmax, 20, 0, 0, 0, 0, 0, "");
        } else {
-               uiDefBlockBut(block, view3d_select_objectmenu, NULL, "Select",  xco,-2, xmax-3, 24, "");
+               uiDefPulldownBut(block, view3d_select_objectmenu, NULL, "Select",       xco,-2, xmax-3, 24, "");
        }
        xco+= xmax;
        
@@ -3757,54 +3757,54 @@ static void view3d_header_pulldowns(uiBlock *block, short *xcoord)
        if (G.obedit) {
                if (OBACT && OBACT->type == OB_MESH) {
                        xmax= GetButStringLength("Mesh");
-                       uiDefBlockBut(block, view3d_edit_meshmenu, NULL, "Mesh",        xco,-2, xmax-3, 24, "");
+                       uiDefPulldownBut(block, view3d_edit_meshmenu, NULL, "Mesh",     xco,-2, xmax-3, 24, "");
                        xco+= xmax;
                } else if (OBACT && OBACT->type == OB_CURVE) {
                        xmax= GetButStringLength("Curve");
-                       uiDefBlockBut(block, view3d_edit_curvemenu, NULL, "Curve",      xco,-2, xmax-3, 24, "");
+                       uiDefPulldownBut(block, view3d_edit_curvemenu, NULL, "Curve",   xco,-2, xmax-3, 24, "");
                        xco+= xmax;
                } else if (OBACT && OBACT->type == OB_SURF) {
                        xmax= GetButStringLength("Surface");
-                       uiDefBlockBut(block, view3d_edit_curvemenu, NULL, "Surface",    xco,-2, xmax-3, 24, "");
+                       uiDefPulldownBut(block, view3d_edit_curvemenu, NULL, "Surface", xco,-2, xmax-3, 24, "");
                        xco+= xmax;
                } else if (OBACT && OBACT->type == OB_FONT) {
                        xmax= GetButStringLength("Text");
-                       uiDefBlockBut(block, view3d_edit_textmenu, NULL, "Text",        xco,-2, xmax-3, 24, "");
+                       uiDefPulldownBut(block, view3d_edit_textmenu, NULL, "Text",     xco,-2, xmax-3, 24, "");
                        xco+= xmax;
                } else if (OBACT && OBACT->type == OB_MBALL) {
                        xmax= GetButStringLength("Metaball");
-                       uiDefBlockBut(block, view3d_edit_metaballmenu, NULL, "Metaball",        xco,-2, xmax-3, 24, "");
+                       uiDefPulldownBut(block, view3d_edit_metaballmenu, NULL, "Metaball",     xco,-2, xmax-3, 24, "");
                        xco+= xmax;
                } else if (OBACT && OBACT->type == OB_LATTICE) {
                        xmax= GetButStringLength("Lattice");
-                       uiDefBlockBut(block, view3d_edit_latticemenu, NULL, "Lattice",  xco,-2, xmax-3, 24, "");
+                       uiDefPulldownBut(block, view3d_edit_latticemenu, NULL, "Lattice",       xco,-2, xmax-3, 24, "");
                        xco+= xmax;
                } else if (OBACT && OBACT->type == OB_ARMATURE) {
                        xmax= GetButStringLength("Armature");
-                       uiDefBlockBut(block, view3d_edit_armaturemenu, NULL, "Armature",        xco,-2, xmax-3, 24, "");
+                       uiDefPulldownBut(block, view3d_edit_armaturemenu, NULL, "Armature",     xco,-2, xmax-3, 24, "");
                        xco+= xmax;
                }
        }
        else if ((G.f & G_VERTEXPAINT) || (G.f & G_TEXTUREPAINT) || (G.f & G_WEIGHTPAINT)) {
                xmax= GetButStringLength("Paint");
-               uiDefBlockBut(block, view3d_paintmenu, NULL, "Paint", xco,-2, xmax-3, 24, "");
+               uiDefPulldownBut(block, view3d_paintmenu, NULL, "Paint", xco,-2, xmax-3, 24, "");
                xco+= xmax;
        } 
        else if (G.f & G_FACESELECT) {
                if (OBACT && OBACT->type == OB_MESH) {
                        xmax= GetButStringLength("Face");
-                       uiDefBlockBut(block, view3d_faceselmenu, NULL, "Face",  xco,-2, xmax-3, 24, "");
+                       uiDefPulldownBut(block, view3d_faceselmenu, NULL, "Face",       xco,-2, xmax-3, 24, "");
                        xco+= xmax;
                }
        } else if (G.obpose) {
                if (OBACT && OBACT->type == OB_ARMATURE) {
                        xmax= GetButStringLength("Armature");
-                       uiDefBlockBut(block, view3d_pose_armaturemenu, NULL, "Armature",        xco,-2, xmax-3, 24, "");
+                       uiDefPulldownBut(block, view3d_pose_armaturemenu, NULL, "Armature",     xco,-2, xmax-3, 24, "");
                        xco+= xmax;
                }
        } else {
                xmax= GetButStringLength("Object");
-               uiDefBlockBut(block, view3d_edit_objectmenu, NULL, "Object",    xco,-2, xmax-3, 24, "");
+               uiDefPulldownBut(block, view3d_edit_objectmenu, NULL, "Object", xco,-2, xmax-3, 24, "");
                xco+= xmax;
        }
 
index 0e930263a3b78e7706b135c8bae3c7bbffb1c6e7..96aa97f0a22da3cf6cf5741e3c06f73d46ff81b6 100644 (file)
@@ -1542,7 +1542,6 @@ void do_global_buttons(unsigned short event)
 
        /* END Fileselect windows for user preferences file paths */
 
-
 #ifdef INTERNATIONAL
        case B_LOADUIFONT:      /* is button from space.c  *info* */
                if(curarea->spacetype==SPACE_INFO) {
index 635df026e11a0315e1826e88e88c304653ccfd4e..3e7917029583e76439f282a50ef66b1238c94282 100644 (file)
@@ -146,8 +146,8 @@ void ui_graphics_to_window(int win, float *x, float *y)     /* for rectwrite  */
 
        gx= *x;
        gy= *y;
-       *x= sx + getsizex*(0.5+ 0.5*(gx*UIwinmat[0][0]+ gy*UIwinmat[1][0]+ UIwinmat[3][0]));
-       *y= sy + getsizey*(0.5+ 0.5*(gx*UIwinmat[0][1]+ gy*UIwinmat[1][1]+ UIwinmat[3][1]));
+       *x= ((float)sx) + ((float)getsizex)*(0.5+ 0.5*(gx*UIwinmat[0][0]+ gy*UIwinmat[1][0]+ UIwinmat[3][0]));
+       *y= ((float)sy) + ((float)getsizey)*(0.5+ 0.5*(gx*UIwinmat[0][1]+ gy*UIwinmat[1][1]+ UIwinmat[3][1]));
 }
 
 
@@ -159,13 +159,13 @@ void ui_window_to_graphics(int win, float *x, float *y)   /* for mouse cursor */
                
        bwin_getsize(win, &getsizex, &getsizey);
 
-       a= .5*getsizex*UIwinmat[0][0];
-       b= .5*getsizex*UIwinmat[1][0];
-       c= .5*getsizex*(1.0+UIwinmat[3][0]);
+       a= .5*((float)getsizex)*UIwinmat[0][0];
+       b= .5*((float)getsizex)*UIwinmat[1][0];
+       c= .5*((float)getsizex)*(1.0+UIwinmat[3][0]);
 
-       d= .5*getsizey*UIwinmat[0][1];
-       e= .5*getsizey*UIwinmat[1][1];
-       f= .5*getsizey*(1.0+UIwinmat[3][1]);
+       d= .5*((float)getsizey)*UIwinmat[0][1];
+       e= .5*((float)getsizey)*UIwinmat[1][1];
+       f= .5*((float)getsizey)*(1.0+UIwinmat[3][1]);
        
        px= *x;
        py= *y;
@@ -178,107 +178,193 @@ void ui_window_to_graphics(int win, float *x, float *y) /* for mouse cursor */
 
 /* ************* SAVE UNDER ************ */
 
+/* new method: 
+
+OverDraw *ui_begin_overdraw(int minx, int miny, int maxx, int maxy);
+- enforces mainwindow to become active
+- grabs copy from frontbuffer, pastes in back
+
+void ui_flush_overdraw(OverDraw *od);
+- copies backbuffer to front
+
+void ui_refresh_overdraw(Overdraw *od);
+- pastes in back copy of frontbuffer again for fresh drawing
+
+void ui_end_overdraw(OverDraw *od);
+- puts back on frontbuffer saved image
+- frees copy
+- sets back active blender area
+- signals backbuffer to be corrupt (sel buffer!)
+
+*/
+
+/* frontbuffer updates now glCopyPixels too, with block->flush rect */
+
+/* new idea for frontbuffer updates:
+
+- hilites: with blended poly?
+
+- full updates... thats harder, but:
+  - copy original
+  - before draw, always paste to backbuf
+  - flush
+  - always end with redraw event for full update
+
+*/
+
 typedef struct {
        short x, y, sx, sy, oldwin;
-       int oldcursor;
        unsigned int *rect;
-} uiSaveUnder;
+} uiOverDraw;
 
 
-static void ui_paste_under(uiSaveUnder *su)
+static uiOverDraw *ui_begin_overdraw(int minx, int miny, int maxx, int maxy)
 {
+       uiOverDraw *od=NULL;
        
-       if(su) {
-               glDisable(GL_DITHER);
-               glRasterPos2f( su->x,  su->y );
-               glDrawPixels(su->sx, su->sy, GL_RGBA, GL_UNSIGNED_BYTE, su->rect);
-               glEnable(GL_DITHER);
+       // dirty patch removed for sun and sgi to mywindow.c commented out
+       
+       /* clip with actual window size */
+       if(minx < 0) minx= 0;
+       if(miny < 0) miny= 0;
+       if(maxx >= G.curscreen->sizex) maxx= G.curscreen->sizex-1;
+       if(maxy >= G.curscreen->sizey) maxy= G.curscreen->sizey-1;
 
-               if(su->oldwin) {
-                       mywinset(su->oldwin);
-                       if (su->oldcursor) {
-                               set_cursor(su->oldcursor);
-                       }
-               }
+       if(minx<maxx && miny<maxy) {
+               od= MEM_callocN(sizeof(uiOverDraw), "overdraw");        
                
-               MEM_freeN(su->rect);
-               MEM_freeN(su);
+               od->x= minx;
+               od->y= miny;
+               od->sx= maxx-minx;
+               od->sy= maxy-miny;
+               od->rect= MEM_mallocN(od->sx*od->sy*4, "temp_frontbuffer_image");
+
+               od->oldwin= mywinget();
+               mywinset(G.curscreen->mainwin);
+               /* grab front */
+               glReadBuffer(GL_FRONT);
+               glReadPixels(od->x, od->y, od->sx, od->sy, GL_RGBA, GL_UNSIGNED_BYTE, od->rect);
+               glReadBuffer(GL_BACK);
+               /* paste in back */
+               glDisable(GL_DITHER);
+               glRasterPos2f(od->x, od->y);
+               glDrawPixels(od->sx, od->sy, GL_RGBA, GL_UNSIGNED_BYTE, od->rect);
+               glEnable(GL_DITHER);
        }
+       
+       return od;
 }
 
-
-static uiSaveUnder *ui_save_under(int x, int y, int sx, int sy)
+static void ui_flush_overdraw(uiOverDraw *od)
 {
-       uiSaveUnder *su=NULL;
-       
-       if(sx>1 && sy>1) {
-               
-               su= MEM_callocN(sizeof(uiSaveUnder), "save under");     
-               
-               su->rect= MEM_mallocN(sx*sy*4, "temp_frontbuffer_image");
-               su->x= x;
-               su->y= y;
-               su->sx= sx;
-               su->sy= sy;
-               glReadPixels(x, y, sx, sy, GL_RGBA, GL_UNSIGNED_BYTE, su->rect);
-       }
-       
-       return su;
-}
 
+       if(od==NULL) return;
+       glDisable(GL_DITHER);
+       glDrawBuffer(GL_FRONT);
+       glRasterPos2s(od->x, od->y);
+       glCopyPixels(od->x, od->y, od->sx, od->sy, GL_COLOR);
+       glEnable(GL_DITHER);
+       glFlush();
+       glDrawBuffer(GL_BACK);
+}
 
-static uiSaveUnder *ui_bgnpupdraw(int startx, int starty, int endx, int endy, int cursor)
+static void ui_end_overdraw(uiOverDraw *od)
 {
-       uiSaveUnder *su;
-       short oldwin;
+       if(od==NULL) return;
        
-       #if defined(__sgi) || defined(__sun) || defined(__sun__) || defined (__sparc) || defined (__sparc__)
+       glDisable(GL_DITHER);
 
-       /* this is a dirty patch: gets sometimes the backbuffer */
-       my_get_frontbuffer_image(0, 0, 1, 1);
-       my_put_frontbuffer_image();
-       #endif
+       // clear in back
+       glRasterPos2s(od->x, od->y);
+       glDrawPixels(od->sx, od->sy, GL_RGBA, GL_UNSIGNED_BYTE, od->rect);
 
-       oldwin= mywinget();
+       // clear in front
+       glDrawBuffer(GL_FRONT);
+       glRasterPos2s(od->x, od->y);
+       glDrawPixels(od->sx, od->sy, GL_RGBA, GL_UNSIGNED_BYTE, od->rect);
 
-       mywinset(G.curscreen->mainwin);
-       
-       /* tinsy bit larger, 1 pixel on the edge */
+       glFlush();
+       glDrawBuffer(GL_BACK);
+       glEnable(GL_DITHER);
        
-       glReadBuffer(GL_FRONT);
-       glDrawBuffer(GL_FRONT);
+       if(od->oldwin) mywinset(od->oldwin);
        
-       /* for geforce and other cards */
-       glFlush();
+       MEM_freeN(od->rect);
+       MEM_freeN(od);
 
-       su= ui_save_under(startx-1, starty-1, endx-startx+2, endy-starty+6);
-       if(su) su->oldwin= oldwin;
-       
-       if(su && cursor) {
-               su->oldcursor= get_cursor();
-               set_cursor(CURSOR_STD);
-       }
+       markdirty_all_back();   // sets flags only
        
-       return su;
+       /* todo; backbuffer selection redraw */
 }
 
-static void ui_endpupdraw(uiSaveUnder *su)
+/* ****************** live updates for hilites and button presses *********** */
+
+void ui_block_flush_back(uiBlock *block)
 {
+       int minx, miny, sizex, sizey;
+       
+       /* note; this routine also has to work for block loop */
+       if(block->frontbuf==0) return;
 
-       /* for geforce and other cards */
+       /* copy pixels works on window coords, so we move to window space */
 
-       glReadBuffer(GL_FRONT);
-       glDrawBuffer(GL_FRONT);
-       
-       glFlush();
+       ui_graphics_to_window(block->win, &block->flush.xmin, &block->flush.ymin);
+       ui_graphics_to_window(block->win, &block->flush.xmax, &block->flush.ymax);
+       minx= floor(block->flush.xmin);
+       miny= floor(block->flush.ymin);
+       sizex= ceil(block->flush.xmax-block->flush.xmin);
+       sizey= ceil(block->flush.ymax-block->flush.ymin);
 
-       if(su) {
-               ui_paste_under(su);
+       if(sizex>0 && sizey>0) {
+               glPushMatrix();
+               mywinset(G.curscreen->mainwin);
+               
+               glDisable(GL_DITHER);
+               glDrawBuffer(GL_FRONT);
+               glRasterPos2i(minx, miny);
+               glCopyPixels(minx, miny, sizex, sizey, GL_COLOR);
+               glEnable(GL_DITHER);
+               glFlush();
+               glDrawBuffer(GL_BACK);
+
+               mywinset(block->win);
+               glPopMatrix();
+               
+               markdirty_win_back(block->win);
        }
-       glReadBuffer(GL_BACK);
-       glDrawBuffer(GL_BACK);
+       
+       block->frontbuf= 0; 
 }
 
+/* merge info for live updates in frontbuf */
+void ui_block_set_flush(uiBlock *block, uiBut *but)
+{
+       /* clear signal */
+       if(but==NULL) {
+               block->frontbuf= 0; 
+
+               block->flush.xmin= 0.0;
+               block->flush.xmax= 0.0;
+       }
+       else {
+               if(block->frontbuf==0) {
+                       /* first rect */
+                       block->flush.xmin= but->x1;
+                       block->flush.xmax= but->x2;
+                       block->flush.ymin= but->y1;
+                       block->flush.ymax= but->y2;
+               }
+               else {
+                       /* union of rects */
+                       if(block->flush.xmin > but->x1) block->flush.xmin= but->x1;
+                       if(block->flush.xmax < but->x2) block->flush.xmax= but->x2;
+                       if(block->flush.ymin > but->y1) block->flush.ymin= but->y1;
+                       if(block->flush.ymax < but->y2) block->flush.ymax= but->y2;
+               }
+               block->frontbuf= UI_HAS_DRAWN;
+               
+       }
+}
 
 
 /* ******************* block calc ************************* */
@@ -365,20 +451,27 @@ static void ui_positionblock(uiBlock *block, uiBut *but)
        block->parentrct= butrct;       // will use that for pulldowns later
 
        /* calc block rect */
-       block->minx= block->miny= 10000;
-       block->maxx= block->maxy= -10000;
-       
-       bt= block->buttons.first;
-       while(bt) {
-               if(bt->x1 < block->minx) block->minx= bt->x1;
-               if(bt->y1 < block->miny) block->miny= bt->y1;
-
-               if(bt->x2 > block->maxx) block->maxx= bt->x2;
-               if(bt->y2 > block->maxy) block->maxy= bt->y2;
+       if(block->buttons.first) {
+               block->minx= block->miny= 10000;
+               block->maxx= block->maxy= -10000;
                
-               bt= bt->next;
+               bt= block->buttons.first;
+               while(bt) {
+                       if(bt->x1 < block->minx) block->minx= bt->x1;
+                       if(bt->y1 < block->miny) block->miny= bt->y1;
+
+                       if(bt->x2 > block->maxx) block->maxx= bt->x2;
+                       if(bt->y2 > block->maxy) block->maxy= bt->y2;
+                       
+                       bt= bt->next;
+               }
        }
-       
+       else {
+               /* we're nice and allow empty blocks too */
+               block->minx= block->miny= 0;
+               block->maxx= block->maxy= 20;
+       }
+
        ui_graphics_to_window(block->win, &block->minx, &block->miny);
        ui_graphics_to_window(block->win, &block->maxx, &block->maxy);
 
@@ -599,14 +692,6 @@ static void ui_draw_linkline(uiBut *but, uiLinkLine *line)
 
        if(line->from==NULL || line->to==NULL) return;
        
-       if(but->block->frontbuf==UI_NEED_DRAW_FRONT) {
-               but->block->frontbuf= UI_HAS_DRAW_FRONT;
-       
-               glDrawBuffer(GL_FRONT);
-               if(but->win==curarea->headwin) curarea->head_swap= WIN_FRONT_OK;
-               else curarea->win_swap= WIN_FRONT_OK;
-       }
-
        vec1[0]= (line->from->x1+line->from->x2)/2.0;
        vec1[1]= (line->from->y1+line->from->y2)/2.0;
        vec2[0]= (line->to->x1+line->to->x2)/2.0;
@@ -926,7 +1011,12 @@ static int ui_do_but_MENU(uiBut *but)
        /* and lets go */
        block->direction= UI_TOP;
        ui_positionblock(block, but);
+       
+       /* blocks can come (and get scaled) from a normal window, now we go to screenspace */
        block->win= G.curscreen->mainwin;
+       for(bt= block->buttons.first; bt; bt= bt->next) bt->win= block->win;
+       bwin_getsinglematrix(block->win, block->winmat);
+
        event= uiDoBlocks(&listb, 0);
        
        menudata_free(md);
@@ -1032,7 +1122,7 @@ static int ui_do_but_BUT(uiBut *but)
 
                if (but->flag != oflag) {
                        ui_draw_but(but);
-                       glFlush(); // flush display in subloops
+                       ui_block_flush_back(but->block);
                }
                
                PIL_sleep_ms(10);
@@ -1181,7 +1271,7 @@ static int ui_do_but_TEX(uiBut *but)
        BLI_strncpy(backstr, but->poin, UI_MAX_DRAW_STR);
 
        ui_draw_but(but);
-       glFlush(); // flush display in subloops
+       ui_block_flush_back(but->block);
        
        while (get_mbut() & L_MOUSE) BIF_wait_for_statechange();
        len= strlen(str);
@@ -1274,10 +1364,11 @@ static int ui_do_but_TEX(uiBut *but)
                        }
                }
 
+               
                if(dodraw) {
                        ui_check_but(but);
                        ui_draw_but(but);
-                       glFlush(); // flush display in subloops
+                       ui_block_flush_back(but->block);
                }
        }
        
@@ -1364,7 +1455,7 @@ static int ui_do_but_NUM(uiBut *but)
 
        but->flag |= UI_SELECT;
        ui_draw_but(but);
-       glFlush(); // flush display before subloop
+       ui_block_flush_back(but->block);
        
        uiGetMouse(mywinget(), mval);
        value= ui_get_but_val(but);
@@ -1422,8 +1513,8 @@ static int ui_do_but_NUM(uiBut *but)
                                                        ui_set_but_val(but, (double)temp);
                                                        ui_check_but(but);
                                                        ui_draw_but(but);
-                                                       glFlush(); // flush display in subloops
-                                                       
+                                                       ui_block_flush_back(but->block);
+
                                                        uibut_do_func(but);
                                                }
                                        }
@@ -1446,7 +1537,7 @@ static int ui_do_but_NUM(uiBut *but)
                                                        ui_set_but_val(but, tempf);
                                                        ui_check_but(but);
                                                        ui_draw_but(but);
-                                                       glFlush(); // flush display in subloops
+                                                       ui_block_flush_back(but->block);
                                                }
                                        }
        
@@ -1494,7 +1585,7 @@ static int ui_do_but_NUM(uiBut *but)
        but->flag &= ~UI_SELECT;
        ui_check_but(but);
        ui_draw_but(but);       
-       glFlush(); // flush display in subloops
+       ui_block_flush_back(but->block);
        
        uibut_do_func(but);
        
@@ -1724,7 +1815,7 @@ static int ui_do_but_SLI(uiBut *but)
                        ui_set_but_val(but, tempf);
                        ui_check_but(but);
                        ui_draw_but(but);
-                       glFlush(); // flush display in subloops
+                       ui_block_flush_back(but->block);
                        
                        if(but->a1) {   /* color number */
                                uiBut *bt= but->prev;
@@ -1776,7 +1867,7 @@ static int ui_do_but_SLI(uiBut *but)
        }
        ui_check_but(but);
        ui_draw_but(but);
-       glFlush(); // flush display in subloops
+       ui_block_flush_back(but->block);
        
        return but->retval;
 }
@@ -1847,7 +1938,7 @@ static int ui_do_but_BLOCK(uiBut *but)
        ui_positionblock(block, but);
        block->flag |= UI_BLOCK_LOOP;
        
-       /* blocks can come from a normal window, but we go to screenspace */
+       /* blocks can come (and get scaled) from a normal window, now we go to screenspace */
        block->win= G.curscreen->mainwin;
        for(bt= block->buttons.first; bt; bt= bt->next) bt->win= block->win;
        bwin_getsinglematrix(block->win, block->winmat);
@@ -2150,7 +2241,8 @@ static void do_palette_cb(void *bt1, void *col1)
        for (but= but1->block->buttons.first; but; but= but->next) {
                ui_draw_but(but);
        }
-       glFlush(); // flush display in subloops
+       but= but1->block->buttons.first;
+       ui_block_flush_back(but->block);
 }
 
 /* bt1 is num but, col1 is pointer to original color */
@@ -2175,8 +2267,10 @@ static void do_palette1_cb(void *bt1, void *col1)
        for (but= but1->block->buttons.first; but; but= but->next) {
                ui_draw_but(but);
        }
+       
+       but= but1->block->buttons.first;
+       ui_block_flush_back(but->block);
 
-       glFlush(); // flush display in subloops
 }
 
 /* color picker, Gimp version. mode: 'f' = floating panel, 'p' =  popup */
@@ -2249,6 +2343,7 @@ void uiBlockPickerButtons(uiBlock *block, float *col, float *hsv, float *old, ch
 static int ui_do_but_COL(uiBut *but)
 {
        uiBlock *block;
+       uiBut *bt;
        ListBase listb={NULL, NULL};
        float hsv[3], old[3], *poin= NULL, colstore[3];
        short event;
@@ -2278,7 +2373,12 @@ static int ui_do_but_COL(uiBut *but)
        /* and lets go */
        block->direction= UI_TOP;
        ui_positionblock(block, but);
+
+       /* blocks can come from a normal window, but we go to screenspace */
        block->win= G.curscreen->mainwin;
+       for(bt= block->buttons.first; bt; bt= bt->next) bt->win= block->win;
+       bwin_getsinglematrix(block->win, block->winmat);
+
        event= uiDoBlocks(&listb, 0);
        
        if(but->pointype==CHA) ui_set_but_vectorf(but, colstore);
@@ -2338,7 +2438,7 @@ static int ui_do_but_HSVCUBE(uiBut *but)
                        for (bt= but->block->buttons.first; bt; bt= bt->next) {
                                ui_draw_but(bt);
                        }
-                       glFlush(); // flush display in subloops
+                       ui_block_flush_back(but->block);
                }
                else BIF_wait_for_statechange();
        }
@@ -2455,7 +2555,7 @@ static void edit_but(uiBlock *block, uiBut *but, uiEvent *uevent)
                        but->y2 += dy;
                        
                        ui_draw_but(but);
-                       glFlush();
+                       ui_block_flush_back(but->block);
                        didit= 1;
                        but->rt[3]= 1;
 
@@ -2563,6 +2663,7 @@ static int ui_do_button(uiBlock *block, uiBut *but, uiEvent *uevent)
                break;
        
        case BLOCK:
+       case PULLDOWN:
                if(uevent->val) {
                        retval= ui_do_but_BLOCK(but);
                        if(block->auto_open==0) block->auto_open= 1;
@@ -2683,31 +2784,9 @@ static void ui_do_active_linklines(uiBlock *block, short *mval)
                }
        }
 
-       /* check for a 'found one' to prevent going to 'frontbuffer' mode.
-          this slows done gfx quite some, and at OSX the 'finish' forces a swapbuffer */
+       /* no frontbuffer draw anymore, redraw is fast enuf */
        if(foundone) {
-       
-               /* draw */
-               but= block->buttons.first;
-               while(but) {
-                       if(but->type==LINK && but->link) {
-                               line= but->link->lines.first;
-                               while(line) {
-                                       if(line==act) {
-                                               if((line->flag & UI_SELECT)==0) {
-                                                       line->flag |= UI_SELECT;
-                                                       ui_draw_linkline(but, line);
-                                               }
-                                       }
-                                       else if(line->flag & UI_SELECT) {
-                                               line->flag &= ~UI_SELECT;
-                                               ui_draw_linkline(but, line);
-                                       }
-                                       line= line->next;
-                               }
-                       }
-                       but= but->next;
-               }
+               addqueue(block->win, REDRAW, 1);
        }
 }
 
@@ -3044,7 +3123,7 @@ static int ui_do_block(uiBlock *block, uiEvent *uevent)
                                                if(but->type != LABEL && (but->flag & UI_NO_HILITE)==0) ui_draw_but(but);
                                        }
                                }
-                               else if(but->type==BLOCK || but->type==MENU) {  // automatic opens block button (pulldown)
+                               else if(but->type==BLOCK || but->type==MENU || but->type==PULLDOWN || but->type==ICONTEXTROW) { // automatic opens block button (pulldown)
                                        int time;
                                        if(uevent->event!=LEFTMOUSE ) {
                                                if(block->auto_open==2) time= 1;        // test for toolbox
@@ -3112,9 +3191,15 @@ static int ui_do_block(uiBlock *block, uiEvent *uevent)
                but= but->next;
        }
 
+       /* flush to frontbuffer */
+       if((block->flag & UI_BLOCK_LOOP)==0) {
+               ui_block_flush_back(block);
+       }
+
        uiPanelPop(block); // pop matrix; no return without pop!
 
-       /* the linkines... why not make buttons from it? Speed? Memory? */
+
+/* the linkines... why not make buttons from it? Speed? Memory? */
        if(uevent->val && (uevent->event==XKEY || uevent->event==DELKEY)) 
                ui_delete_active_linkline(block);
 
@@ -3144,9 +3229,9 @@ static int ui_do_block(uiBlock *block, uiEvent *uevent)
        return retval;
 }
 
-static uiSaveUnder *ui_draw_but_tip(uiBut *but)
+static uiOverDraw *ui_draw_but_tip(uiBut *but)
 {
-       uiSaveUnder *su;
+       uiOverDraw *od;
        float x1, x2, y1, y2;
 
                
@@ -3197,7 +3282,7 @@ static uiSaveUnder *ui_draw_but_tip(uiBut *but)
                y2 -= G.ui_international ? 5:1;         //tip is from a windowheader
 //     else y2 += 1;                                                   //tip is from button area
 
-       su= ui_bgnpupdraw((int)(x1-1), (int)(y1-2), (int)(x2+4), (int)(y2+4), 0);
+       od= ui_begin_overdraw((int)(x1-1), (int)(y1-2), (int)(x2+4), (int)(y2+4));
 
        glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
        glEnable(GL_BLEND);
@@ -3218,17 +3303,17 @@ static uiSaveUnder *ui_draw_but_tip(uiBut *but)
        glRectf(x1, y1, x2, y2);
        
        glColor3ub(0,0,0);
-       glRasterPos2f( x1+3, y1+5.0/but->aspect);
+       ui_rasterpos_safe( x1+3, y1+5.0/but->aspect, but->aspect);
        BIF_DrawString(but->font, but->tip, (U.transopts & USER_TR_TOOLTIPS));
        
-       glFlush();              /* to show it in the frontbuffer */
-       return su;
+       ui_flush_overdraw(od);          /* to show it in the frontbuffer */
+       return od;
 }
 
 /* inside this function no global UIbuttip... qread is not safe */
 static void ui_do_but_tip(uiBut *buttip)
 {
-       uiSaveUnder *su;
+       uiOverDraw *od;
        int time;
        
        if (buttip && buttip->tip && buttip->tip[0]) {
@@ -3249,7 +3334,7 @@ static void ui_do_but_tip(uiBut *buttip)
                         * of the button that owns it.
                         */
                uiPanelPush(buttip->block); // panel matrix
-               su= ui_draw_but_tip(buttip);
+               od= ui_draw_but_tip(buttip);
                
                while (1) {
                        char ascii;
@@ -3258,7 +3343,7 @@ static void ui_do_but_tip(uiBut *buttip)
 
                        if (evt==MOUSEX || evt==MOUSEY) {
                                short mouse[2];
-                               uiGetMouse(su->oldwin, mouse);
+                               uiGetMouse(od->oldwin, mouse);
                                
                                if (!uibut_contains_pt(buttip, mouse))
                                        break;
@@ -3268,7 +3353,7 @@ static void ui_do_but_tip(uiBut *buttip)
                        }
                }
                
-               ui_endpupdraw(su);
+               ui_end_overdraw(od);
                uiPanelPop(buttip->block); // panel matrix
                /* still the evil global.... */
                UIbuttip= NULL;
@@ -3303,7 +3388,7 @@ int uiDoBlocks(ListBase *lb, int event)
        /* this is a caching mechanism, to prevent too many calls to glFrontBuffer and glFlush, which slows down interface */
        block= lb->first;
        while(block) {
-               block->frontbuf= UI_NEED_DRAW_FRONT;    // signal
+               ui_block_set_flush(block, NULL); // clears all flushing info
                block= block->next;
        }
 
@@ -3321,8 +3406,7 @@ int uiDoBlocks(ListBase *lb, int event)
                         */
                        if(block->flag & UI_BLOCK_REDRAW) {
                                if( block->flag & UI_BLOCK_LOOP) {
-                                       block->saveunder= ui_bgnpupdraw((int)block->minx-1, (int)block->miny-6, (int)block->maxx+6, (int)block->maxy+1, 1);
-                                       block->frontbuf= UI_HAS_DRAW_FRONT;
+                                       block->overdraw= ui_begin_overdraw((int)block->minx-1, (int)block->miny-6, (int)block->maxx+6, (int)block->maxy+1);
                                }
                                uiDrawBlock(block);
                                block->flag &= ~UI_BLOCK_REDRAW;
@@ -3334,11 +3418,10 @@ int uiDoBlocks(ListBase *lb, int event)
                        /* now a new block could be created for menus, this is 
                           inserted in the beginning of a list */
                        
-                       /* is there a glfinish cached? */
-                       if(block->frontbuf == UI_HAS_DRAW_FRONT) {
-                               glFlush();
-                               glDrawBuffer(GL_BACK);
-                               block->frontbuf= UI_NEED_DRAW_FRONT;
+                       /* is there a flush cached? */
+                       if(block->frontbuf == UI_HAS_DRAWN) {
+                               ui_flush_overdraw(block->overdraw);
+                               block->frontbuf= 0;
                        }
                        
                        /* to make sure the matrix of the panel works for menus too */
@@ -3359,36 +3442,33 @@ int uiDoBlocks(ListBase *lb, int event)
                        if(block->flag & UI_BLOCK_REDRAW) {
 
                                if( block->flag & UI_BLOCK_LOOP) {
-                                       block->saveunder= ui_bgnpupdraw((int)block->minx-1, (int)block->miny-6, (int)block->maxx+6, (int)block->maxy+1, 1);
-                                       block->frontbuf= UI_HAS_DRAW_FRONT;
+                                       block->overdraw= ui_begin_overdraw((int)block->minx-1, (int)block->miny-6, (int)block->maxx+6, (int)block->maxy+1);
                                }
                                uiDrawBlock(block);
                                block->flag &= ~UI_BLOCK_REDRAW;
+                               ui_flush_overdraw(block->overdraw);
+                               block->frontbuf= 0;
                        }
-
-                       /* need to reveil drawing? (not in end of loop, because of free block */
-                       if(block->frontbuf == UI_HAS_DRAW_FRONT) {
-                               glFlush();
-                               block->frontbuf= UI_NEED_DRAW_FRONT;
-                       }
-
+                       
                        uevent.event= extern_qread(&uevent.val);
                        
                        if(uevent.event) {
-                       
                                retval= ui_do_block(block, &uevent);
                        
+                               if(block->frontbuf == UI_HAS_DRAWN) { // flush now, maybe new menu was opened
+                                       ui_flush_overdraw(block->overdraw);
+                                       block->frontbuf= 0;
+                               }
+
                                if(retval & UI_RETURN) {
-                                       /* free this block */
-                                       ui_endpupdraw(block->saveunder);
-                                       
+                                       ui_end_overdraw(block->overdraw);
                                        BLI_remlink(lb, block);
                                        uiFreeBlock(block);
                                }
                                if(retval & (UI_RETURN_OK|UI_RETURN_CANCEL)) {
                                        /* free other menus */
                                        while( (block= lb->first) && (block->flag & UI_BLOCK_LOOP)) {
-                                               ui_endpupdraw(block->saveunder);
+                                               ui_end_overdraw(block->overdraw);
                                                BLI_remlink(lb, block);
                                                uiFreeBlock(block);
                                        }
@@ -3405,28 +3485,17 @@ int uiDoBlocks(ListBase *lb, int event)
                if(retval==UI_CONT || (retval & UI_RETURN_OK)) cont= 0;
        }
        
-       /* cleanup frontbuffer & flags */
-       block= lb->first;
-       while(block) {
-               if(block->frontbuf==UI_HAS_DRAW_FRONT) glFlush();
-               block->frontbuf= 0;
-               block= block->next;
-       }
-       
        /* afterfunc is used for fileloading too, so after this call, the blocks pointers are invalid */
        if(retval & UI_RETURN_OK) {
                if(UIafterfunc) UIafterfunc(UIafterfunc_arg, UIafterval);
                UIafterfunc= NULL;
        }
-
+       
        /* tooltip */   
        if(retval==UI_NOTHING && (uevent.event==MOUSEX || uevent.event==MOUSEY)) {
                if(U.flag & USER_TOOLTIPS) ui_do_but_tip(UIbuttip);
        }
 
-       /* doesnt harm :-) */
-       glDrawBuffer(GL_BACK);
-
        return retval;
 }
 
@@ -3925,6 +3994,7 @@ static int ui_auto_themecol(uiBut *but)
                return TH_BUT_NUM;
        case TEX:
                return TH_BUT_TEXTFIELD;
+       case PULLDOWN:
        case BLOCK:
        case MENU:
        case BUTM:
@@ -4157,7 +4227,7 @@ static uiBut *ui_def_but(uiBlock *block, int type, int retval, char *str, short
 
        but->aspect= block->aspect;
        but->win= block->win;
-       but->block= block;              // pointer back, used for frontbuffer status
+       but->block= block;              // pointer back, used for frontbuffer status, and picker
 
        if(block->themecol==TH_AUTO) but->themecol= ui_auto_themecol(but);
        else but->themecol= block->themecol;
@@ -4532,6 +4602,14 @@ uiBut *uiDefBlockBut(uiBlock *block, uiBlockFuncFP func, void *arg, char *str, s
        return but;
 }
 
+uiBut *uiDefPulldownBut(uiBlock *block, uiBlockFuncFP func, void *arg, char *str, short x1, short y1, short x2, short y2, char *tip)
+{
+       uiBut *but= ui_def_but(block, PULLDOWN, 0, str, x1, y1, x2, y2, arg, 0.0, 0.0, 0.0, 0.0, tip);
+       but->block_func= func;
+       ui_check_but(but);
+       return but;
+}
+
 /* Block button containing both string label and icon */
 uiBut *uiDefIconTextBlockBut(uiBlock *block, uiBlockFuncFP func, void *arg, int icon, char *str, short x1, short y1, short x2, short y2, char *tip)
 {
index 0684f4cb9e0392747254e36a4f162dc28374e8b9..ea16229074cbdb3ec483a863f034082c1228b706 100644 (file)
 // globals
 extern float UIwinmat[4][4];
 
+/* ************** safe rasterpos for pixmap alignment with pixels ************* */
 
+void ui_rasterpos_safe(float x, float y, float aspect)
+{
+       float vals[4], remainder;
+       int doit=0;
+       
+       glRasterPos2f(x, y);
+       glGetFloatv(GL_CURRENT_RASTER_POSITION, vals);
+
+       remainder= vals[0] - floor(vals[0]);
+       if(remainder > 0.4 && remainder < 0.6) {
+               if(remainder < 0.5) x -= 0.1*aspect;
+               else x += 0.1*aspect;
+               doit= 1;
+       }
+       remainder= vals[1] - floor(vals[1]);
+       if(remainder > 0.4 && remainder < 0.6) {
+               if(remainder < 0.5) y -= 0.1*aspect;
+               else y += 0.1*aspect;
+               doit= 1;
+       }
+       
+       if(doit) glRasterPos2f(x, y);
+}
 
 /* ************** generic embossed rect, for window sliders etc ************* */
 
@@ -1039,7 +1063,12 @@ static void round_button(float x1, float y1, float x2, float y2, float asp, int
 
        BIF_ThemeColorBlendShade(colorid, TH_BACK, 0.5, -70);
        
+       glEnable( GL_LINE_SMOOTH );
+       glEnable( GL_BLEND );
+       glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
        gl_round_box(GL_LINE_LOOP, x1, y1, x2, y2, rad);
+       glDisable( GL_LINE_SMOOTH );
+       glDisable( GL_BLEND );
 }
 
 /* button in midst of alignment row */
@@ -1278,59 +1307,75 @@ static void ui_draw_slider(int colorid, float fac, float aspect, float x1, float
 
 }
 
-/* ************** STANDARD MENU DRAWING FUNCTION (no callback yet) ************* */
+/* ************** STANDARD MENU DRAWING FUNCTION ************* */
+
 
+static void ui_shadowbox(float minx, float miny, float maxx, float maxy, float shadsize, unsigned char alpha)
+{
+       glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+       glEnable(GL_BLEND);
+       glShadeModel(GL_SMOOTH);
+       
+       /* right quad */
+       glBegin(GL_POLYGON);
+       glColor4ub(0, 0, 0, alpha);
+       glVertex2f(maxx, miny);
+       glVertex2f(maxx, maxy-shadsize);
+       glColor4ub(0, 0, 0, 0);
+       glVertex2f(maxx+shadsize, maxy-shadsize-shadsize);
+       glVertex2f(maxx+shadsize, miny);
+       glEnd();
+       
+       /* corner shape */
+       glBegin(GL_POLYGON);
+       glColor4ub(0, 0, 0, alpha);
+       glVertex2f(maxx, miny);
+       glColor4ub(0, 0, 0, 0);
+       glVertex2f(maxx+shadsize, miny);
+       glVertex2f(maxx+0.7*shadsize, miny-0.7*shadsize);
+       glVertex2f(maxx, miny-shadsize);
+       glEnd();
+       
+       /* bottom quad */               
+       glBegin(GL_POLYGON);
+       glColor4ub(0, 0, 0, alpha);
+       glVertex2f(minx+shadsize, miny);
+       glVertex2f(maxx, miny);
+       glColor4ub(0, 0, 0, 0);
+       glVertex2f(maxx, miny-shadsize);
+       glVertex2f(minx+shadsize+shadsize, miny-shadsize);
+       glEnd();
+       
+       glDisable(GL_BLEND);
+       glShadeModel(GL_FLAT);
+}
 
-// background for pulldowns, pullups, and other frontbuffer drawing temporal menus....
+// background for pulldowns, pullups, and other drawing temporal menus....
 // has to be made themable still (now only color)
 
 void uiDrawMenuBox(float minx, float miny, float maxx, float maxy, short flag)
 {
 
        if( (flag & UI_BLOCK_NOSHADOW)==0) {
-               glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
-               glEnable(GL_BLEND);
-               
-               glColor4ub(0, 0, 0, 20);
+               /* accumulated outline boxes to make shade not linear, is more pleasant */
+               ui_shadowbox(minx, miny, maxx, maxy, 6.0, 30);
+               ui_shadowbox(minx, miny, maxx, maxy, 4.0, 70);
+               ui_shadowbox(minx, miny, maxx, maxy, 2.0, 100);
                
-               /* to prevent gaps being drawn between box and shadow (rounding errors?) */
-               fdrawline(minx+3, miny+0.25, maxx+0.25, miny+0.25);
-               fdrawline(maxx+0.25, miny+0.25, maxx+0.25, maxy-3);
-               
-               glColor4ub(0, 0, 0, 70);
-               fdrawline(minx+3, miny, maxx+1, miny);
-               fdrawline(maxx+1, miny, maxx+1, maxy-3);
-               
-               glColor4ub(0, 0, 0, 70);
-               fdrawline(minx+3, miny-1, maxx+1, miny-1);
-               fdrawline(maxx+1, miny-1, maxx+1, maxy-3);
-       
-               glColor4ub(0, 0, 0, 55);
-               fdrawline(minx+3, miny-2, maxx+2, miny-2);
-               fdrawline(maxx+2, miny-2, maxx+2, maxy-3);
-       
-               glColor4ub(0, 0, 0, 35);
-               fdrawline(minx+3, miny-3, maxx+3, miny-3);
-               fdrawline(maxx+3, miny-3, maxx+3, maxy-3);
-       
-               glColor4ub(0, 0, 0, 20);
-               fdrawline(minx+3, miny-4, maxx+4, miny-4);
-               fdrawline(maxx+4, miny-4, maxx+4, maxy-3);
-               
-               glDisable(GL_BLEND);
        }
        BIF_ThemeColor(TH_MENU_BACK);
 
        glRectf(minx, miny, maxx, maxy);
 }
 
-/* pulldown menu */
-static void ui_draw_pulldown(int type, int colorid, float asp, float x1, float y1, float x2, float y2, int flag)
+/* pulldown menu item */
+static void ui_draw_pulldown_item(int type, int colorid, float asp, float x1, float y1, float x2, float y2, int flag)
 {
 
        if(flag & UI_ACTIVE) {
                BIF_ThemeColor(TH_MENU_HILITE);
                glRectf(x1-1, y1, x2+2, y2);
+       
 
        } else {
                BIF_ThemeColor(colorid);        // is set at TH_MENU_ITEM when pulldown opened.
@@ -1339,7 +1384,29 @@ static void ui_draw_pulldown(int type, int colorid, float asp, float x1, float y
 
 }
 
+/* pulldown menu calling button */
+static void ui_draw_pulldown_round(int type, int colorid, float asp, float x1, float y1, float x2, float y2, int flag)
+{
+       
+       if(flag & UI_ACTIVE) {
+               BIF_ThemeColor(TH_MENU_HILITE);
 
+               uiSetRoundBox(15);
+               gl_round_box(GL_POLYGON, x1, y1+3, x2, y2-3, 7.0);
+
+               glEnable( GL_LINE_SMOOTH );
+               glEnable( GL_BLEND );
+               glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+               gl_round_box(GL_LINE_LOOP, x1, y1+3, x2, y2-3, 7.0);
+               glDisable( GL_LINE_SMOOTH );
+               glDisable( GL_BLEND );
+               
+       } else {
+               BIF_ThemeColor(colorid);        // is set at TH_MENU_ITEM when pulldown opened.
+               glRectf(x1-1, y1+2, x2+1, y2-2);
+       }
+       
+}
 
 
 /* ************** TEXT AND ICON DRAWING FUNCTIONS ************* */
@@ -1395,7 +1462,7 @@ static void ui_draw_text_icon(uiBut *but)
                }
                
                /* text color, with pulldown item exception */
-               if(but->embossfunc==ui_draw_pulldown) {
+               if(but->dt==UI_EMBOSSP) {
                        if(but->flag & (UI_SELECT|UI_ACTIVE)) {         
                                BIF_ThemeColor(TH_MENU_TEXT_HI);
                        } else {
@@ -1429,13 +1496,13 @@ static void ui_draw_text_icon(uiBut *but)
                /* LABEL button exception */
                if(but->type==LABEL && but->min!=0.0) BIF_ThemeColor(TH_BUT_TEXT_HI);
        
-               glRasterPos2f( floor(x), floor((but->y1+but->y2- 9.0)/2.0));
+               ui_rasterpos_safe(x, (but->y1+but->y2- 9.0)/2.0, but->aspect);
                BIF_DrawString(but->font, but->drawstr+but->ofs, (U.transopts & USER_TR_BUTTONS));
 
                /* part text right aligned */
                if(cpoin) {
                        len= BIF_GetStringWidth(but->font, cpoin+1, (U.transopts & USER_TR_BUTTONS));
-                       glRasterPos2f( but->x2 - len*but->aspect-3, (but->y1+but->y2- 9.0)/2.0);
+                       ui_rasterpos_safe( but->x2 - len*but->aspect-3, (but->y1+but->y2- 9.0)/2.0, but->aspect);
                        BIF_DrawString(but->font, cpoin+1, (U.transopts & USER_TR_BUTTONS));
                        *cpoin= '|';
                }
@@ -1608,15 +1675,18 @@ static void ui_draw_nothing(int type, int colorid, float asp, float x1, float y1
 
 void ui_set_embossfunc(uiBut *but, int drawtype)
 {
-
+       // this aded for evaluating textcolor for example
+       but->dt= drawtype;
+       
        // not really part of standard minimal themes, just make sure it is set
        but->sliderfunc= ui_draw_slider;
 
        // standard builtin first:
        if(but->type==LABEL) but->embossfunc= ui_draw_nothing;
+       else if(but->type==PULLDOWN) but->embossfunc= ui_draw_pulldown_round;
        else if(drawtype==UI_EMBOSSM) but->embossfunc= ui_draw_minimal;
        else if(drawtype==UI_EMBOSSN) but->embossfunc= ui_draw_nothing;
-       else if(drawtype==UI_EMBOSSP) but->embossfunc= ui_draw_pulldown;
+       else if(drawtype==UI_EMBOSSP) but->embossfunc= ui_draw_pulldown_item;
        else {
                int theme= BIF_GetThemeValue(TH_BUT_DRAWTYPE);
                
@@ -1647,14 +1717,9 @@ void ui_draw_but(uiBut *but)
        
        if(but==0) return;
 
-       if(but->block->frontbuf==UI_NEED_DRAW_FRONT) {
-               but->block->frontbuf= UI_HAS_DRAW_FRONT;
-       
-               glDrawBuffer(GL_FRONT);
-               if(but->win==curarea->headwin) curarea->head_swap= WIN_FRONT_OK;
-               else curarea->win_swap= WIN_FRONT_OK;
-       }
-       
+       /* signal for flush buttons and menus */
+       ui_block_set_flush(but->block, but);
+               
        switch (but->type) {
 
        case NUMSLI:
index 9cac338c0f9582d5c33a7051f261cc2c98ced52c..0617b222aa241101b335afcd64b9c67fd0fba526 100644 (file)
@@ -182,7 +182,7 @@ static void round_box_shade_col(float *col1, float *col2, float fac)
 }
 
 /* linear horizontal shade within button or in outline */
-void gl_round_box_shade(int mode, float minx, float miny, float maxx, float maxy, float rad, float shade)
+void gl_round_box_shade(int mode, float minx, float miny, float maxx, float maxy, float rad, float shadetop, float shadedown)
 {
        float vec[7][2]= {{0.195, 0.02}, {0.383, 0.067}, {0.55, 0.169}, {0.707, 0.293},
                          {0.831, 0.45}, {0.924, 0.617}, {0.98, 0.805}};
@@ -198,12 +198,12 @@ void gl_round_box_shade(int mode, float minx, float miny, float maxx, float maxy
        glGetFloatv(GL_CURRENT_COLOR, color);
 
        /* 'shade' defines strength of shading */       
-       coltop[0]= color[0]+shade; if(coltop[0]>1.0) coltop[0]= 1.0;
-       coltop[1]= color[1]+shade; if(coltop[1]>1.0) coltop[1]= 1.0;
-       coltop[2]= color[2]+shade; if(coltop[2]>1.0) coltop[2]= 1.0;
-       coldown[0]= color[0]-shade; if(coldown[0]<0.0) coldown[0]= 0.0;
-       coldown[1]= color[1]-shade; if(coldown[1]<0.0) coldown[1]= 0.0;
-       coldown[2]= color[2]-shade; if(coldown[2]<0.0) coldown[2]= 0.0;
+       coltop[0]= color[0]+shadetop; if(coltop[0]>1.0) coltop[0]= 1.0;
+       coltop[1]= color[1]+shadetop; if(coltop[1]>1.0) coltop[1]= 1.0;
+       coltop[2]= color[2]+shadetop; if(coltop[2]>1.0) coltop[2]= 1.0;
+       coldown[0]= color[0]+shadedown; if(coldown[0]<0.0) coldown[0]= 0.0;
+       coldown[1]= color[1]+shadedown; if(coldown[1]<0.0) coldown[1]= 0.0;
+       coldown[2]= color[2]+shadedown; if(coldown[2]<0.0) coldown[2]= 0.0;
 
        glShadeModel(GL_SMOOTH);
        glBegin(mode);
@@ -235,7 +235,7 @@ void gl_round_box_shade(int mode, float minx, float miny, float maxx, float maxy
                
                for(a=0; a<7; a++) {
                        round_box_shade_col(coltop, coldown, (div-rad+vec[a][1])/div);
-                       glVertex2f( maxx-vec[a][1], maxy-rad+vec[a][1]);
+                       glVertex2f( maxx-vec[a][1], maxy-rad+vec[a][0]);
                }
                round_box_shade_col(coltop, coldown, 1.0);
                glVertex2f( maxx-rad, maxy);
@@ -336,7 +336,7 @@ static void gl_round_box_topshade(float minx, float miny, float maxx, float maxy
 }
 
 /* for headers and floating panels */
-void uiRoundBoxEmboss(float minx, float miny, float maxx, float maxy, float rad)
+void uiRoundBoxEmboss(float minx, float miny, float maxx, float maxy, float rad, int active)
 {
        float color[4];
        
@@ -349,6 +349,10 @@ void uiRoundBoxEmboss(float minx, float miny, float maxx, float maxy, float rad)
        }
        
        /* solid part */
+       //if(active)
+       //      gl_round_box_shade(GL_POLYGON, minx, miny, maxx, maxy, rad, 0.10, -0.05);
+       // else
+       /* shading doesnt work for certain buttons yet (pulldown) need smarter buffer caching (ton) ยง*/
        gl_round_box(GL_POLYGON, minx, miny, maxx, maxy, rad);
        
        /* set antialias line */
@@ -881,7 +885,7 @@ static void ui_draw_panel_header(uiBlock *block)
                /* active tab */
                /* draw text label */
                BIF_ThemeColor(TH_TEXT_HI);
-               glRasterPos2f(4+block->minx+pnl_icons, block->maxy+5);
+               ui_rasterpos_safe(4+block->minx+pnl_icons, block->maxy+5, block->aspect);
                BIF_DrawString(block->curfont, block->panel->panelname, (U.transopts & USER_TR_BUTTONS));
                return;
        }
@@ -901,7 +905,7 @@ static void ui_draw_panel_header(uiBlock *block)
 
                        /* draw the active text label */
                        BIF_ThemeColor(TH_TEXT);
-                       glRasterPos2f(16+pnl_icons+a*width, panel->sizey+4);
+                       ui_rasterpos_safe(16+pnl_icons+a*width, panel->sizey+4, block->aspect);
                        str= ui_block_cut_str(block, pa->panelname, (short)(width-10));
                        BIF_DrawString(block->curfont, str, (U.transopts & USER_TR_BUTTONS));
 
@@ -915,7 +919,7 @@ static void ui_draw_panel_header(uiBlock *block)
                        
                        /* draw an inactive tab label */
                        BIF_ThemeColorShade(TH_TEXT_HI, -40);
-                       glRasterPos2f(16+pnl_icons+a*width, panel->sizey+4);
+                       ui_rasterpos_safe(16+pnl_icons+a*width, panel->sizey+4, block->aspect);
                        str= ui_block_cut_str(block, pa->panelname, (short)(width-10));
                        BIF_DrawString(block->curfont, str, (U.transopts & USER_TR_BUTTONS));
                                
@@ -953,7 +957,7 @@ void ui_draw_panel(uiBlock *block)
                ofsx= PNL_ICON+8;
                if(panel->control & UI_PNL_CLOSE) ofsx+= PNL_ICON;
                BIF_ThemeColor(TH_TEXT_HI);
-               glRasterPos2f(4+block->minx+ofsx, block->maxy+5);
+               ui_rasterpos_safe(4+block->minx+ofsx, block->maxy+5, block->aspect);
                BIF_DrawString(block->curfont, panel->panelname, (U.transopts & USER_TR_BUTTONS));
 
                /*  border */
@@ -992,7 +996,7 @@ void ui_draw_panel(uiBlock *block)
                for(a=0; a<end; a++) {
                        str[0]= panel->panelname[a];
                        if( isupper(str[0]) ) {
-                               glRasterPos2f(block->minx+5, block->maxy-ofs);
+                               ui_rasterpos_safe(block->minx+5, block->maxy-ofs, block->aspect);
                                BIF_DrawString(block->curfont, str, 0);
                                ofs+= 15;
                        }
index f7738ce0800d642e6eb3c19f170e78815e90a4df..634c393f88cee1f34f89fc1601bda60cae8c2468 100644 (file)
@@ -611,6 +611,14 @@ void setlinestyle(int nr)
 static int *frontbuffer_save= NULL;
 static int ov_x, ov_y, ov_sx, ov_sy;
 
+/*
+#if defined(__sgi) || defined(__sun) || defined(__sun__) || defined (__sparc) || defined (__sparc__)
+/* this is a dirty patch: gets sometimes the backbuffer */
+/* my_get_frontbuffer_image(0, 0, 1, 1);
+my_put_frontbuffer_image();
+#endif
+*/
+
 void my_put_frontbuffer_image(void)
 {
        if (frontbuffer_save) {
index 00cce259954e29d1dbcf4c9a2428aab3275701e9..0cb032620ed34b7aa88edc49e9e7480e2526c4e4 100644 (file)
@@ -143,10 +143,14 @@ void BIF_screendump(int fscreen)
        } 
        else {
                {       /* a window */
-                       int win= mywinget();
-
-                       bwin_getsuborigin(win, &x, &y);
-                       bwin_getsize(win, &dumpsx, &dumpsy);
+                       //int win= mywinget();
+
+                       //bwin_getsuborigin(win, &x, &y);
+                       //bwin_getsize(win, &dumpsx, &dumpsy);
+                       x= curarea->totrct.xmin;
+                       y= curarea->totrct.ymin;
+                       dumpsx= curarea->totrct.xmax-x;
+                       dumpsy= curarea->totrct.ymax-y;
                }
        }
        
@@ -155,6 +159,8 @@ void BIF_screendump(int fscreen)
                dumprect= MEM_mallocN(sizeof(int)*dumpsx*dumpsy, "dumprect");
                glReadBuffer(GL_FRONT);
                glReadPixels(x, y, dumpsx, dumpsy, GL_RGBA, GL_UNSIGNED_BYTE, dumprect);
+               glFinish();
+               glReadBuffer(GL_BACK);
                
                if(UIbuttip==NULL) {
                        wasmenu= 0;
index ac21a92399017681ded145ef3a9e1df0c2886edb..161d6d727b797de53784300632e218d12e5bb42b 100644 (file)
@@ -4230,6 +4230,7 @@ void allqueue(unsigned short event, short val)
                                break;
                        case REDRAWINFO:
                                if(sa->spacetype==SPACE_INFO) {
+                                       scrarea_queue_winredraw(sa);
                                        scrarea_queue_headredraw(sa);
                                }
                                break;
index 3cedfdf6302a57b88d5706781cbc538ca03a659e..1a696747290fa5f031b7864de7c29df5c48e6686 100644 (file)
@@ -40,6 +40,7 @@
 
 
 #include <stdlib.h>
+#include <stdio.h>
 
 #ifdef HAVE_CONFIG_H
 #include <config.h>
@@ -114,7 +115,6 @@ static void screen_swapbuffers_REDRAW(bScreen *sc)
        while(sa) {
                swap= sa->win_swap;
                if( (swap & WIN_BACK_OK) == 0) {
-                       
                        scrarea_do_windraw(sa);
 
                        doswap= 1;
index bfa411639348094de5234d0429853622e871b9f5..149fcea2df379fd2c9541366a0d4ade7c1189f06 100644 (file)
@@ -2185,7 +2185,7 @@ static uiBlock *tb_makemenu(void *arg)
        
        if(arg==NULL) return NULL;
        
-       sprintf(str, "tb %d\n", counter++);
+       sprintf(str, "tb %d", counter++);
        block= uiNewBlock(&tb_listb, str, UI_EMBOSSP, UI_HELV, G.curscreen->mainwin);
        uiBlockSetCol(block, TH_MENU_ITEM);
 
index 1327e60dc998b2f70d7fef2f244d544eb3a519ee..a31c5a5617c183f4d5628fee3771b36b3651fd5e 100644 (file)
@@ -411,7 +411,6 @@ void viewmove(int mode)
        
        /* sometimes this routine is called from headerbuttons */
        areawinset(curarea->win);
-       curarea->head_swap= 0;
        
        initgrabz(-G.vd->ofs[0], -G.vd->ofs[1], -G.vd->ofs[2]);
        
@@ -580,8 +579,6 @@ void viewmove(int mode)
                /* this in the end, otherwise get_mbut does not work on a PC... */
                if( !(get_mbut() & (L_MOUSE|M_MOUSE))) break;
        }
-
-       curarea->head_swap= WIN_FRONT_OK;
 }
 
 short v3d_windowmode=0;