From 0b49c6255fbff9aaccf8d3fbc34d94e2d0d64ece Mon Sep 17 00:00:00 2001 From: Daniel Salazar Date: Wed, 28 Apr 2010 09:29:17 +0000 Subject: [PATCH] patch 21737 by Elia Sarti (vekoon) Currently for ColorBands, when pressing the Add button, new elements are set with a medium gray in a medium position which often is not desired behaviour. This patch when possible sets new elements as averaged values between the current element and its preceding neighbour --- .../editors/interface/interface_templates.c | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index ec4412d03b0..a5eec8f3b7f 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -39,6 +39,7 @@ #include "BKE_global.h" #include "BKE_library.h" #include "BKE_main.h" +#include "BKE_texture.h" #include "BKE_utildefines.h" #include "ED_screen.h" @@ -1438,6 +1439,33 @@ static void colorband_add_cb(bContext *C, void *cb_v, void *coba_v) { ColorBand *coba= coba_v; + if(coba->tot > 0) { + CBData *xnew, *x1, *x2; + float col[4]; + + xnew= &coba->data[coba->tot]; + + if(coba->tot > 1) { + if(coba->cur > 0) { + x1= &coba->data[coba->cur-1]; + x2= &coba->data[coba->cur]; + } + else { + x1= &coba->data[coba->cur]; + x2= &coba->data[coba->cur+1]; + } + + xnew->pos = x1->pos + ((x2->pos - x1->pos) / 2); + } + + do_colorband(coba, xnew->pos, col); + + xnew->r= col[0]; + xnew->g= col[1]; + xnew->b= col[2]; + xnew->a= col[3]; + } + if(coba->tot < MAXCOLORBAND-1) coba->tot++; coba->cur= coba->tot-1;