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

This commit is contained in:
Campbell Barton 2009-09-21 10:57:46 +00:00
parent 551ddd1002
commit 61c79adb8b

@ -1336,7 +1336,7 @@ static void colorband_del_cb(bContext *C, void *cb_v, void *coba_v)
/* offset aligns from bottom, standard width 300, height 115 */ /* offset aligns from bottom, standard width 300, height 115 */
static void colorband_buttons_large(uiBlock *block, ColorBand *coba, int xoffs, int yoffs, RNAUpdateCb *cb) static void colorband_buttons_large(uiBlock *block, ColorBand *coba, int xoffs, int yoffs, RNAUpdateCb *cb)
{ {
CBData *cbd;
uiBut *bt; uiBut *bt;
if(coba==NULL) return; if(coba==NULL) return;
@ -1347,7 +1347,7 @@ static void colorband_buttons_large(uiBlock *block, ColorBand *coba, int xoffs,
bt= uiDefBut(block, BUT, 0, "Delete", 60+xoffs,100+yoffs,50,20, 0, 0, 0, 0, 0, "Delete the active position"); 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); 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", 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"); 210+xoffs, 100+yoffs, 90, 20, &coba->ipotype, 0.0, 0.0, 0, 0, "Set interpolation between color stops");
@ -1357,36 +1357,38 @@ static void colorband_buttons_large(uiBlock *block, ColorBand *coba, int xoffs,
bt= uiDefBut(block, BUT_COLORBAND, 0, "", xoffs,65+yoffs,300,30, coba, 0, 0, 0, 0, ""); 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); 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"); 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); 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"); 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); 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"); 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); uiButSetNFunc(bt, rna_update_cb, MEM_dupallocN(cb), NULL);
}
} }
static void colorband_buttons_small(uiBlock *block, ColorBand *coba, rctf *butr, RNAUpdateCb *cb) static void colorband_buttons_small(uiBlock *block, ColorBand *coba, rctf *butr, RNAUpdateCb *cb)
{ {
CBData *cbd;
uiBut *bt; uiBut *bt;
float unit= (butr->xmax-butr->xmin)/14.0f; float unit= (butr->xmax-butr->xmin)/14.0f;
float xs= butr->xmin; 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"); 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); 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"); 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); 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"); if(coba->tot) {
uiButSetNFunc(bt, rna_update_cb, MEM_dupallocN(cb), NULL); CBData *cbd= coba->data + coba->cur;
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"); 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); 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", 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"); xs+10.0f*unit, butr->ymin+20.0f, unit*4, 20, &coba->ipotype, 0.0, 0.0, 0, 0, "Set interpolation between color stops");