svn merge -r 15392:15551 https://svn.blender.org/svnroot/bf-blender/trunk/blender
[blender.git] / source / blender / src / interface_draw.c
index 2af1892de1c29f23e8525d7823591f3a4cccf5a0..e7041e6000373b2433e278780822dc7eb9d01aba 100644 (file)
@@ -2,15 +2,12 @@
 /**
  * $Id$
  *
- * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
+ * ***** BEGIN GPL LICENSE BLOCK *****
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
  * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version. The Blender
- * Foundation also sells licenses for use in proprietary software under
- * the Blender License.  See http://www.blender.org/BL/ for information
- * about this.
+ * of the License, or (at your option) any later version.
  *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -28,7 +25,7 @@
  *
  * Contributor(s): none yet.
  *
- * ***** END GPL/BL DUAL LICENSE BLOCK *****
+ * ***** END GPL LICENSE BLOCK *****
  */
 
 /* 
@@ -183,8 +180,12 @@ static void ui_draw_icon(uiBut *but, BIFIconID icon, int blend)
                height= ICON_HEIGHT;
        
        if(but->flag & UI_ICON_LEFT) {
-               if (but->type==BUT_TOGDUAL && but->drawstr[0]) {
-                       xs= but->x1-1.0;
+               if (but->type==BUT_TOGDUAL) {
+                       if (but->drawstr[0]) {
+                               xs= but->x1-1.0;
+                       } else {
+                               xs= (but->x1+but->x2- height)/2.0;
+                       }
                }
                else if (but->type==BUTM ) {
                        xs= but->x1+1.0;
@@ -849,6 +850,7 @@ static void ui_default_flat(int type, int colorid, float asp, float x1, float y1
        /* *** EXTRA DRAWING FOR SPECIFIC CONTROL TYPES *** */
        switch(type) {
        case NUM:
+       case NUMABS:
                /* SIDE ARROWS */
                /* left */
                if(flag & UI_SELECT) {
@@ -875,11 +877,12 @@ static void ui_default_slider(int colorid, float fac, float aspect, float x1, fl
        
        if(flag & UI_SELECT) 
                        BIF_ThemeColorShade(TH_BUT_NUM, -5);
-       else
+       else {
                if(flag & UI_ACTIVE) 
                        BIF_ThemeColorShade(TH_BUT_NUM, +35); 
                else
                        BIF_ThemeColorShade(TH_BUT_NUM, +25); 
+       }
 
        glRectf(x1, ymid-yc, x2, ymid+yc);
        
@@ -946,6 +949,7 @@ static void ui_draw_default(int type, int colorid, float aspect, float x1, float
        case TEX:
        case IDPOIN:
        case NUM:
+       case NUMABS:
                ui_default_flat(type, colorid, aspect, x1, y1, x2, y2, flag);
                break;
        case ICONROW: 
@@ -1029,6 +1033,7 @@ static void ui_draw_oldskool(int type, int colorid, float asp, float x1, float y
        /* special type decorations */
        switch(type) {
        case NUM:
+       case NUMABS:
                if(flag & UI_SELECT) BIF_ThemeColorShade(colorid, -60);
                else BIF_ThemeColorShade(colorid, -30);
                ui_default_num_arrows(x1, y1, x2, y2);
@@ -1179,6 +1184,7 @@ static void ui_draw_round(int type, int colorid, float asp, float x1, float y1,
        /* special type decorations */
        switch(type) {
        case NUM:
+       case NUMABS:
                BIF_ThemeColorShade(colorid, curshade-60);
                ui_default_num_arrows(x1, y1, x2, y2);
                break;
@@ -1288,6 +1294,7 @@ static void ui_draw_minimal(int type, int colorid, float asp, float x1, float y1
        /* special type decorations */
        switch(type) {
        case NUM:
+       case NUMABS:
                if(flag & UI_SELECT) BIF_ThemeColorShade(colorid, -60);
                else BIF_ThemeColorShade(colorid, -30);
                ui_default_num_arrows(x1, y1, x2, y2);
@@ -1842,7 +1849,7 @@ static void ui_draw_but_CHARTAB(uiBut *but)
                        int err;
 
                        strcpy(tmpStr, G.selfont->name);
-                       BLI_convertstringcode(tmpStr, G.sce, 0);
+                       BLI_convertstringcode(tmpStr, G.sce);
                        err = FTF_SetFont((unsigned char *)tmpStr, 0, 14.0);
                }
        }
@@ -1970,7 +1977,7 @@ static void ui_draw_but_COLORBAND(uiBut *but)
        ColorBand *coba= (ColorBand *)but->poin;
        CBData *cbd;
        float x1, y1, sizex, sizey;
-       float dx, v3[2], v1[2], v2[2];
+       float dx, v3[2], v1[2], v2[2], v1a[2], v2a[2];
        int a;
                
        if(coba==NULL) return;
@@ -2038,39 +2045,55 @@ static void ui_draw_but_COLORBAND(uiBut *but)
        /* help lines */
        v1[0]= v2[0]=v3[0]= x1;
        v1[1]= y1;
+       v1a[1]= y1+0.25*sizey;
        v2[1]= y1+0.5*sizey;
+       v2a[1]= y1+0.75*sizey;
        v3[1]= y1+sizey;
        
+       
        cbd= coba->data;
        glBegin(GL_LINES);
        for(a=0; a<coba->tot; a++, cbd++) {
-               v1[0]=v2[0]=v3[0]= x1+ cbd->pos*sizex;
-               
-               glColor3ub(0, 0, 0);
-               glVertex2fv(v1);
-               glVertex2fv(v2);
-               
-               if(a==coba->cur) {
-                       glVertex2f(v1[0]-1, v1[1]);
-                       glVertex2f(v2[0]-1, v2[1]);
-                       glVertex2f(v1[0]+1, v1[1]);
-                       glVertex2f(v2[0]+1, v2[1]);
-               }
-               
-               glColor3ub(255, 255, 255);
-               glVertex2fv(v2);
-               glVertex2fv(v3);
+               v1[0]=v2[0]=v3[0]=v1a[0]=v2a[0]= x1+ cbd->pos*sizex;
                
                if(a==coba->cur) {
-                       if(cbd->pos>0.01) {
-                               glVertex2f(v2[0]-1, v2[1]);
-                               glVertex2f(v3[0]-1, v3[1]);
-                       }
-                       if(cbd->pos<0.99) {
-                               glVertex2f(v2[0]+1, v2[1]);
-                               glVertex2f(v3[0]+1, v3[1]);
-                       }
+                       glColor3ub(0, 0, 0);
+                       glVertex2fv(v1);
+                       glVertex2fv(v3);
+                       glEnd();
+                       
+                       setlinestyle(2);
+                       glBegin(GL_LINES);
+                       glColor3ub(255, 255, 255);
+                       glVertex2fv(v1);
+                       glVertex2fv(v3);
+                       glEnd();
+                       setlinestyle(0);
+                       glBegin(GL_LINES);
+                       
+                       /* glColor3ub(0, 0, 0);
+                       glVertex2fv(v1);
+                       glVertex2fv(v1a);
+                       glColor3ub(255, 255, 255);
+                       glVertex2fv(v1a);
+                       glVertex2fv(v2);
+                       glColor3ub(0, 0, 0);
+                       glVertex2fv(v2);
+                       glVertex2fv(v2a);
+                       glColor3ub(255, 255, 255);
+                       glVertex2fv(v2a);
+                       glVertex2fv(v3);
+                       */
                }
+               else {
+                       glColor3ub(0, 0, 0);
+                       glVertex2fv(v1);
+                       glVertex2fv(v2);
+                       
+                       glColor3ub(255, 255, 255);
+                       glVertex2fv(v2);
+                       glVertex2fv(v3);
+               }       
        }
        glEnd();
 }
@@ -2234,13 +2257,40 @@ static void ui_draw_but_CURVE(uiBut *but)
        if(cumap->flag & CUMA_DRAW_CFRA) {
                glColor3ub(0x60, 0xc0, 0x40);
                glBegin(GL_LINES);
-               glVertex2f(but->x1 + zoomx*(cumap->black[0]-offsx), but->y1);
-               glVertex2f(but->x1 + zoomx*(cumap->black[0]-offsx), but->y2);
+               glVertex2f(but->x1 + zoomx*(cumap->sample[0]-offsx), but->y1);
+               glVertex2f(but->x1 + zoomx*(cumap->sample[0]-offsx), but->y2);
                glEnd();
        }
+       /* sample option */
+       if(cumap->flag & CUMA_DRAW_SAMPLE) {
+               if(cumap->cur==3) {
+                       float lum= cumap->sample[0]*0.35f + cumap->sample[1]*0.45f + cumap->sample[2]*0.2f;
+                       glColor3ub(240, 240, 240);
+                       
+                       glBegin(GL_LINES);
+                       glVertex2f(but->x1 + zoomx*(lum-offsx), but->y1);
+                       glVertex2f(but->x1 + zoomx*(lum-offsx), but->y2);
+                       glEnd();
+               }
+               else {
+                       if(cumap->cur==0)
+                               glColor3ub(240, 100, 100);
+                       else if(cumap->cur==1)
+                               glColor3ub(100, 240, 100);
+                       else
+                               glColor3ub(100, 100, 240);
+                       
+                       glBegin(GL_LINES);
+                       glVertex2f(but->x1 + zoomx*(cumap->sample[cumap->cur]-offsx), but->y1);
+                       glVertex2f(but->x1 + zoomx*(cumap->sample[cumap->cur]-offsx), but->y2);
+                       glEnd();
+               }
+       }
        
        /* the curve */
-       BIF_ThemeColor(TH_TEXT);
+       BIF_ThemeColorBlend(TH_TEXT, TH_BUT_NEUTRAL, 0.35);
+       glEnable(GL_LINE_SMOOTH);
+       glEnable(GL_BLEND);
        glBegin(GL_LINE_STRIP);
        
        if(cuma->table==NULL)
@@ -2269,6 +2319,8 @@ static void ui_draw_but_CURVE(uiBut *but)
                glVertex2f(fx, fy);
        }
        glEnd();
+       glDisable(GL_LINE_SMOOTH);
+       glDisable(GL_BLEND);
 
        /* the points, use aspect to make them visible on edges */
        cmp= cuma->curve;
@@ -2431,3 +2483,33 @@ void ui_draw_but(uiBut *but)
        }
 }
 
+void ui_dropshadow(rctf *rct, float radius, float aspect, int select)
+{
+       float rad;
+       float a;
+       char alpha= 2;
+       
+       glEnable(GL_BLEND);
+       
+       if(radius > (rct->ymax-rct->ymin-10.0f)/2.0f)
+               rad= (rct->ymax-rct->ymin-10.0f)/2.0f;
+       else
+               rad= radius;
+       
+       if(select) a= 12.0f*aspect; else a= 12.0f*aspect;
+       for(; a>0.0f; a-=aspect) {
+               /* alpha ranges from 2 to 20 or so */
+               glColor4ub(0, 0, 0, alpha);
+               alpha+= 2;
+               
+               gl_round_box(GL_POLYGON, rct->xmin - a, rct->ymin - a, rct->xmax + a, rct->ymax-10.0f + a, rad+a);
+       }
+       
+       /* outline emphasis */
+       glEnable( GL_LINE_SMOOTH );
+       glColor4ub(0, 0, 0, 100);
+       gl_round_box(GL_LINE_LOOP, rct->xmin-0.5f, rct->ymin-0.5f, rct->xmax+0.5f, rct->ymax+0.5f, radius);
+       glDisable( GL_LINE_SMOOTH );
+       
+       glDisable(GL_BLEND);
+}