Revision: 23390
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=23390
Author:   campbellbarton
Date:     2009-09-21 12:57:46 +0200 (Mon, 21 Sep 2009)

Log Message:
-----------
colorbands could display with no items in the colorband array, letting you set 
0 and -1 colorband index.

Modified Paths:
--------------
    trunk/blender/source/blender/editors/interface/interface_templates.c

Modified: trunk/blender/source/blender/editors/interface/interface_templates.c
===================================================================
--- trunk/blender/source/blender/editors/interface/interface_templates.c        
2009-09-21 10:54:15 UTC (rev 23389)
+++ trunk/blender/source/blender/editors/interface/interface_templates.c        
2009-09-21 10:57:46 UTC (rev 23390)
@@ -1336,7 +1336,7 @@
 /* offset aligns from bottom, standard width 300, height 115 */
 static void colorband_buttons_large(uiBlock *block, ColorBand *coba, int 
xoffs, int yoffs, RNAUpdateCb *cb)
 {
-       CBData *cbd;
+       
        uiBut *bt;
 
        if(coba==NULL) return;
@@ -1347,7 +1347,7 @@
        bt= uiDefBut(block, BUT, 0,     "Delete",               
60+xoffs,100+yoffs,50,20, 0, 0, 0, 0, 0, "Delete the active position");
        uiButSetNFunc(bt, colorband_del_cb, MEM_dupallocN(cb), coba);
 
-       uiDefButS(block, NUM, 0,                "",                             
120+xoffs,100+yoffs,80, 20, &coba->cur, 0.0, (float)(coba->tot-1), 0, 0, 
"Choose active color stop");
+       uiDefButS(block, NUM, 0,                "",                             
120+xoffs,100+yoffs,80, 20, &coba->cur, 0.0, (float)(MAX2(0, coba->tot-1)), 0, 
0, "Choose active color stop");
 
        bt= uiDefButS(block, MENU, 0,           "Interpolation %t|Ease 
%x1|Cardinal %x3|Linear %x0|B-Spline %x2|Constant %x4",
                        210+xoffs, 100+yoffs, 90, 20,           &coba->ipotype, 
0.0, 0.0, 0, 0, "Set interpolation between color stops");
@@ -1357,36 +1357,38 @@
        bt= uiDefBut(block, BUT_COLORBAND, 0, "",       xoffs,65+yoffs,300,30, 
coba, 0, 0, 0, 0, "");
        uiButSetNFunc(bt, rna_update_cb, MEM_dupallocN(cb), NULL);
 
-       cbd= coba->data + coba->cur;
+       if(coba->tot) {
+               CBData *cbd= coba->data + coba->cur;
 
-       bt= uiDefButF(block, NUM, 0, "Pos:",                    
0+xoffs,40+yoffs,100, 20, &cbd->pos, 0.0, 1.0, 10, 0, "The position of the 
active color stop");
-       uiButSetNFunc(bt, colorband_pos_cb, MEM_dupallocN(cb), coba);
-       bt= uiDefButF(block, COL, 0,            "",                             
110+xoffs,40+yoffs,80,20, &(cbd->r), 0, 0, 0, B_BANDCOL, "The color value for 
the active color stop");
-       uiButSetNFunc(bt, rna_update_cb, MEM_dupallocN(cb), NULL);
-       bt= uiDefButF(block, NUMSLI, 0, "A ",                   
200+xoffs,40+yoffs,100,20, &cbd->a, 0.0, 1.0, 10, 0, "The alpha value of the 
active color stop");
-       uiButSetNFunc(bt, rna_update_cb, MEM_dupallocN(cb), NULL);
+               bt= uiDefButF(block, NUM, 0, "Pos:",                    
0+xoffs,40+yoffs,100, 20, &cbd->pos, 0.0, 1.0, 10, 0, "The position of the 
active color stop");
+               uiButSetNFunc(bt, colorband_pos_cb, MEM_dupallocN(cb), coba);
+               bt= uiDefButF(block, COL, 0,            "",                     
        110+xoffs,40+yoffs,80,20, &(cbd->r), 0, 0, 0, B_BANDCOL, "The color 
value for the active color stop");
+               uiButSetNFunc(bt, rna_update_cb, MEM_dupallocN(cb), NULL);
+               bt= uiDefButF(block, NUMSLI, 0, "A ",                   
200+xoffs,40+yoffs,100,20, &cbd->a, 0.0, 1.0, 10, 0, "The alpha value of the 
active color stop");
+               uiButSetNFunc(bt, rna_update_cb, MEM_dupallocN(cb), NULL);
+       }
 
 }
 
 static void colorband_buttons_small(uiBlock *block, ColorBand *coba, rctf 
*butr, RNAUpdateCb *cb)
 {
-       CBData *cbd;
        uiBut *bt;
        float unit= (butr->xmax-butr->xmin)/14.0f;
        float xs= butr->xmin;
 
-       cbd= coba->data + coba->cur;
 
-
        bt= uiDefBut(block, BUT, 0,     "Add",                  
xs,butr->ymin+20.0f,2.0f*unit,20,       NULL, 0, 0, 0, 0, "Add a new color stop 
to the colorband");
        uiButSetNFunc(bt, colorband_add_cb, MEM_dupallocN(cb), coba);
        bt= uiDefBut(block, BUT, 0,     "Delete",               
xs+2.0f*unit,butr->ymin+20.0f,2.0f*unit,20,     NULL, 0, 0, 0, 0, "Delete the 
active position");
        uiButSetNFunc(bt, colorband_del_cb, MEM_dupallocN(cb), coba);
 
-       bt= uiDefButF(block, COL, 0,            "",                     
xs+4.0f*unit,butr->ymin+20.0f,2.0f*unit,20,                             
&(cbd->r), 0, 0, 0, B_BANDCOL, "The color value for the active color stop");
-       uiButSetNFunc(bt, rna_update_cb, MEM_dupallocN(cb), NULL);
-       bt= uiDefButF(block, NUMSLI, 0,         "A:",           
xs+6.0f*unit,butr->ymin+20.0f,4.0f*unit,20,     &(cbd->a), 0.0f, 1.0f, 10, 2, 
"The alpha value of the active color stop");
-       uiButSetNFunc(bt, rna_update_cb, MEM_dupallocN(cb), NULL);
+       if(coba->tot) {
+               CBData *cbd= coba->data + coba->cur;
+               bt= uiDefButF(block, COL, 0,            "",                     
xs+4.0f*unit,butr->ymin+20.0f,2.0f*unit,20,                             
&(cbd->r), 0, 0, 0, B_BANDCOL, "The color value for the active color stop");
+               uiButSetNFunc(bt, rna_update_cb, MEM_dupallocN(cb), NULL);
+               bt= uiDefButF(block, NUMSLI, 0,         "A:",           
xs+6.0f*unit,butr->ymin+20.0f,4.0f*unit,20,     &(cbd->a), 0.0f, 1.0f, 10, 2, 
"The alpha value of the active color stop");
+               uiButSetNFunc(bt, rna_update_cb, MEM_dupallocN(cb), NULL);
+       }
 
        bt= uiDefButS(block, MENU, 0,           "Interpolation %t|Ease 
%x1|Cardinal %x3|Linear %x0|B-Spline %x2|Constant %x4",
                        xs+10.0f*unit, butr->ymin+20.0f, unit*4, 20,            
&coba->ipotype, 0.0, 0.0, 0, 0, "Set interpolation between color stops");


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

Reply via email to