Revision: 17383
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=17383
Author:   broken
Date:     2008-11-10 05:40:09 +0100 (Mon, 10 Nov 2008)

Log Message:
-----------
Patch #17971 by Nathan Vegdahl:
Makes colorband GUI display proper color interpolation

This updates the colorband display to show the correct interpolation 
within the editable gradient itself.

thanks!

Modified Paths:
--------------
    trunk/blender/source/blender/src/interface_draw.c

Modified: trunk/blender/source/blender/src/interface_draw.c
===================================================================
--- trunk/blender/source/blender/src/interface_draw.c   2008-11-10 00:14:35 UTC 
(rev 17382)
+++ trunk/blender/source/blender/src/interface_draw.c   2008-11-10 04:40:09 UTC 
(rev 17383)
@@ -68,6 +68,7 @@
 #include "BKE_global.h"
 #include "BKE_key.h"
 #include "BKE_utildefines.h"
+#include "BKE_texture.h"
 
 #include "datatoc.h"            /* std font */
 
@@ -1978,6 +1979,7 @@
        CBData *cbd;
        float x1, y1, sizex, sizey;
        float dx, v3[2], v1[2], v2[2], v1a[2], v2a[2];
+       float pos, colf[4];
        int a;
                
        if(coba==NULL) return;
@@ -1998,7 +2000,7 @@
                v1[0]+= dx;
        }
        
-       glShadeModel(GL_SMOOTH);
+       glShadeModel(GL_FLAT);
        glEnable(GL_BLEND);
        
        cbd= coba->data;
@@ -2012,17 +2014,16 @@
        glColor4fv( &cbd->r );
        glVertex2fv(v1); glVertex2fv(v2);
        
-       for(a=0; a<coba->tot; a++, cbd++) {
-               
-               v1[0]=v2[0]= x1+ cbd->pos*sizex;
-               
-               glColor4fv( &cbd->r );
+       for( a = 1; a < sizex; a++ ) {
+               pos = ((float)a) / (sizex-1);
+               do_colorband( coba, pos, colf );
+
+               v1[0]=v2[0]= x1 + a;
+
+               glColor4fv( colf );
                glVertex2fv(v1); glVertex2fv(v2);
        }
-       
-       v1[0]=v2[0]= x1+ sizex;
-       glVertex2fv(v1); glVertex2fv(v2);
-       
+
        glEnd();
        glShadeModel(GL_FLAT);
        glDisable(GL_BLEND);
@@ -2203,11 +2204,17 @@
 static void ui_draw_but_CURVE(uiBut *but)
 {
        CurveMapping *cumap= (CurveMapping *)but->poin;
-       CurveMap *cuma= cumap->cm+cumap->cur;
+       CurveMap *cuma;
        CurveMapPoint *cmp;
        float fx, fy, dx, dy, fac[2], zoomx, zoomy, offsx, offsy;
        GLint scissor[4];
-       int a;
+       int a, i, c, tmp;
+
+       /* Check number of curves */
+       if(cumap->flag & CUMA_MULTI_CURVE)
+               c= 4;
+       else
+               c= 1;
        
        /* need scissor test, curve can draw outside of boundary */
        glGetIntegerv(GL_VIEWPORT, scissor);
@@ -2286,57 +2293,105 @@
                        glEnd();
                }
        }
+
+       /* Ugly hack to make sure all curves are there */
+    tmp= cumap->cur;
+       for(i= 0; i<c; i++) {
+        if (c>1) {
+            cumap->cur= i;
+               cuma= cumap->cm+i;
+        }
+        else
+            cuma= cumap->cm+cumap->cur;
+               if(cuma->table==NULL)
+                       curvemapping_changed(cumap, 0); /* 0 = no remove 
doubles */
+       }
+    cumap->cur= tmp;
        
        /* the curve */
-       BIF_ThemeColorBlend(TH_TEXT, TH_BUT_NEUTRAL, 0.35);
-       glEnable(GL_LINE_SMOOTH);
-       glEnable(GL_BLEND);
-       glBegin(GL_LINE_STRIP);
-       
-       if(cuma->table==NULL)
-               curvemapping_changed(cumap, 0); /* 0 = no remove doubles */
-       cmp= cuma->table;
-       
-       /* first point */
-       if((cuma->flag & CUMA_EXTEND_EXTRAPOLATE)==0)
-               glVertex2f(but->x1, but->y1 + zoomy*(cmp[0].y-offsy));
-       else {
-               fx= but->x1 + zoomx*(cmp[0].x-offsx + cuma->ext_in[0]);
-               fy= but->y1 + zoomy*(cmp[0].y-offsy + cuma->ext_in[1]);
-               glVertex2f(fx, fy);
-       }
-       for(a=0; a<=CM_TABLE; a++) {
-               fx= but->x1 + zoomx*(cmp[a].x-offsx);
-               fy= but->y1 + zoomy*(cmp[a].y-offsy);
-               glVertex2f(fx, fy);
-       }
-       /* last point */
-       if((cuma->flag & CUMA_EXTEND_EXTRAPOLATE)==0)
-               glVertex2f(but->x2, but->y1 + zoomy*(cmp[CM_TABLE].y-offsy));   
-       else {
-               fx= but->x1 + zoomx*(cmp[CM_TABLE].x-offsx - cuma->ext_out[0]);
-               fy= but->y1 + zoomy*(cmp[CM_TABLE].y-offsy - cuma->ext_out[1]);
-               glVertex2f(fx, fy);
-       }
-       glEnd();
-       glDisable(GL_LINE_SMOOTH);
-       glDisable(GL_BLEND);
+       for(i=0; i<c; i++) {
+               if(c>1) {
+                       cuma= cumap->cm+i;
+                       switch (i) {
+                               case 0:
+                                       glColor3ub(240,20,20);
+                                       break;
+                               case 1:
+                                       glColor3ub(20,240,20);
+                                       break;
+                               case 2:
+                                       glColor3ub(20,20,240);
+                                       break;
+                               default:
+                                       BIF_ThemeColorBlend(TH_TEXT, 
TH_BUT_NEUTRAL, 0.35);
+                                       break;                  
+                       }
+               }
+               else {
+                       cuma= cumap->cm+cumap->cur;
+                       switch(cumap->cur) {
+                               case 0:
+                                       glColor3ub(240,20,20);
+                                       break;
+                               case 1:
+                                       glColor3ub(20,240,20);
+                                       break;
+                               case 2:
+                                       glColor3ub(20,20,240);
+                                       break;
+                               default:
+                                       BIF_ThemeColorBlend(TH_TEXT, 
TH_BUT_NEUTRAL, 0.35);
+                                       break;
+                       }
+               }
+               glEnable(GL_LINE_SMOOTH);
+               glEnable(GL_BLEND);
+               glBegin(GL_LINE_STRIP);
+               
+               cmp= cuma->table;
+               
+               /* first point */
+               if((cuma->flag & CUMA_EXTEND_EXTRAPOLATE)==0)
+                       glVertex2f(but->x1, but->y1 + zoomy*(cmp[0].y-offsy));
+               else {
+                       fx= but->x1 + zoomx*(cmp[0].x-offsx + cuma->ext_in[0]);
+                       fy= but->y1 + zoomy*(cmp[0].y-offsy + cuma->ext_in[1]);
+                       glVertex2f(fx, fy);
+               }
+               /* Points inbetween first and last */
+               for(a=0; a<=CM_TABLE; a++) {
+                       fx= but->x1 + zoomx*(cmp[a].x-offsx);
+                       fy= but->y1 + zoomy*(cmp[a].y-offsy);
+                       glVertex2f(fx, fy);
+               }
+               /* last point */
+               if((cuma->flag & CUMA_EXTEND_EXTRAPOLATE)==0)
+                       glVertex2f(but->x2, but->y1 + 
zoomy*(cmp[CM_TABLE].y-offsy));   
+               else {
+                       fx= but->x1 + zoomx*(cmp[CM_TABLE].x-offsx - 
cuma->ext_out[0]);
+                       fy= but->y1 + zoomy*(cmp[CM_TABLE].y-offsy - 
cuma->ext_out[1]);
+                       glVertex2f(fx, fy);
+               }
+               glEnd();
+               glDisable(GL_LINE_SMOOTH);
+               glDisable(GL_BLEND);
 
-       /* the points, use aspect to make them visible on edges */
-       cmp= cuma->curve;
-       glPointSize(3.0f);
-       bglBegin(GL_POINTS);
-       for(a=0; a<cuma->totpoint; a++) {
-               if(cmp[a].flag & SELECT)
-                       BIF_ThemeColor(TH_TEXT_HI);
-               else
-                       BIF_ThemeColor(TH_TEXT);
-               fac[0]= but->x1 + zoomx*(cmp[a].x-offsx);
-               fac[1]= but->y1 + zoomy*(cmp[a].y-offsy);
-               bglVertex2fv(fac);
-       }
-       bglEnd();
-       glPointSize(1.0f);
+        /* the points, use aspect to make them visible on edges */
+        cmp= cuma->curve;
+        glPointSize(3.0f);
+        bglBegin(GL_POINTS);
+        for(a=0; a<cuma->totpoint; a++) {
+            if(cmp[a].flag & SELECT)
+                BIF_ThemeColor(TH_TEXT_HI);
+            else
+                BIF_ThemeColor(TH_TEXT);
+            fac[0]= but->x1 + zoomx*(cmp[a].x-offsx);
+            fac[1]= but->y1 + zoomy*(cmp[a].y-offsy);
+            bglVertex2fv(fac);
+        }
+        bglEnd();
+        glPointSize(1.0f);
+    }
        
        /* restore scissortest */
        glScissor(scissor[0], scissor[1], scissor[2], scissor[3]);


_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to