Final merge of HEAD (bf-blender) into the orange branch.
[blender.git] / source / blender / src / drawoops.c
index 2cc39627d9d0da617e6bf192486b340421c91fa5..dbf245179dfc91f14b46c6be6621dfb69d87c561 100644 (file)
@@ -55,6 +55,7 @@
 #include "BKE_global.h"
 
 #include "BIF_interface.h"
+#include "BIF_interface_icons.h"
 #include "BIF_gl.h"
 #include "BIF_glutil.h"
 #include "BIF_mywindow.h"
@@ -71,7 +72,7 @@
 float oopscalex;
 struct BMF_Font *font; /* for using different sized fonts */
 
-void boundbox_oops()
+void boundbox_oops(short sel)
 {
        Oops *oops;
        float min[2], max[2];
@@ -80,13 +81,13 @@ void boundbox_oops()
        if(G.soops==0) return;
        
        min[0]= 1000.0;
-       max[0]= -10000.0;
+       max[0]= -1000.0;
        min[1]= 1000.0;
        max[1]= -1000.0;
        
        oops= G.soops->oops.first;
        while(oops) {
-               if(oops->hide==0) {
+               if ((oops->hide==0 && !sel) || (sel && oops->flag & SELECT )) {
                        ok= 1;
                        
                        min[0]= MIN2(min[0], oops->x);
@@ -131,7 +132,9 @@ void draw_oopslink(Oops *oops)
        
        if(oops->type==ID_SCE) {
                if(oops->flag & SELECT) {
-                       if(oops->id->lib) cpack(0x4080A0);
+                       /* when using python Mesh to make meshes a file was saved
+                       that had an oops with no ID, stops a segfault when looking for lib */
+                       if(oops->id && oops->id->lib) cpack(0x4080A0);
                        else cpack(0x808080);
                }
                else cpack(0x606060);
@@ -220,7 +223,7 @@ void draw_icon_oops(float *co, short type)
        glEnable(GL_BLEND);
        glBlendFunc(GL_SRC_ALPHA,  GL_ONE_MINUS_SRC_ALPHA); 
 
-       BIF_draw_icon(co[0], co[1]-0.2, icon);
+       BIF_icon_draw(co[0], co[1]-0.2, icon);
 
        glBlendFunc(GL_ONE,  GL_ZERO); 
        glDisable(GL_BLEND);
@@ -345,7 +348,10 @@ void draw_oops(Oops *oops)
 
                glRectf(x1,  y1,  x2,  y2);
        }
-       if(oops->id->lib) {
+       
+       /* it has never happened that an oops was missing an ID at
+       this point but has occured elseware so lets be safe */
+       if(oops->id && oops->id->lib) { 
                if(oops->id->flag & LIB_INDIRECT) cpack(0x1144FF);
                else cpack(0x11AAFF);
 
@@ -368,8 +374,8 @@ void draw_oops(Oops *oops)
        } else { /* NO ICON, UNINDENT*/
                v1[0] -= 1.3 / oopscalex;
        }
-       if(oops->flag & SELECT) cpack(0xFFFFFF); 
-       else cpack(0x0);
+       if(oops->flag & SELECT) BIF_ThemeColor(TH_TEXT_HI);
+       else BIF_ThemeColor(TH_TEXT);
        glRasterPos3f(v1[0],  v1[1], 0.0);
        BMF_DrawString(font, str);
 
@@ -422,6 +428,12 @@ void drawoopsspace(ScrArea *sa, void *spacedata)
        float col[3];
        
        BIF_GetThemeColor3fv(TH_BACK, col);
+       
+       /* darker background for oops */
+       if(soops->type!=SO_OUTLINER) {
+               col[0] = col[0] * 0.75; col[1] = col[1] * 0.75; col[2] = col[2] * 0.75;
+       }
+       
        glClearColor(col[0], col[1], col[2], 0.0);
        glClear(GL_COLOR_BUFFER_BIT);
        if(soops==0) return;    
@@ -430,14 +442,27 @@ void drawoopsspace(ScrArea *sa, void *spacedata)
        else {
                build_oops();   /* changed to become first call... */
                
-               boundbox_oops();
+               boundbox_oops(0);
                calc_scrollrcts(sa, G.v2d, curarea->winx, curarea->winy);
 
                myortho2(G.v2d->cur.xmin, G.v2d->cur.xmax, G.v2d->cur.ymin, G.v2d->cur.ymax);
 
                oopscalex= .14*((float)curarea->winx)/(G.v2d->cur.xmax-G.v2d->cur.xmin);
                calc_ipogrid(); /* for scrollvariables */
-
+               
+               
+               /* Draw a page about the oops */
+               BIF_GetThemeColor3fv(TH_BACK, col);
+               glColor3fv(col);
+               glRectf(G.v2d->tot.xmin-2, G.v2d->tot.ymin-2,  G.v2d->tot.xmax+2, G.v2d->tot.ymax+2); /* light square in the centre */
+               BIF_ThemeColorShade(TH_BACK, -96); /* drop shadow color */
+               glRectf(G.v2d->tot.xmin-1, G.v2d->tot.ymin-2,  G.v2d->tot.xmax+3, G.v2d->tot.ymin-3); /* bottom dropshadow */
+               glRectf(G.v2d->tot.xmax+2, G.v2d->tot.ymin-2,  G.v2d->tot.xmax+3, G.v2d->tot.ymax+1); /* right hand dropshadow */
+               /* box around the oops. */
+               cpack(0x0);
+               mysbox(G.v2d->tot.xmin-2, G.v2d->tot.ymin-2,  G.v2d->tot.xmax+2, G.v2d->tot.ymax+2);
+               
+               
                /* Set the font size for the oops based on the zoom level */
                if (oopscalex > 6.0) font = BMF_GetFont(BMF_kScreen15);
                else if (oopscalex > 3.5) font = G.font;