Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2010-06-26 21:12:55 +0400
committerCampbell Barton <ideasman42@gmail.com>2010-06-26 21:12:55 +0400
commit7ad1491fce07e3c7d3c26902fc1a5d4142e9ad5d (patch)
treea49d778eb5b733de3138d0eb2b7ed4f649b6319e /source/blender/editors/interface/interface_widgets.c
parentbd03f26c3a281cd2080e6c4ec1aacdb8049d88c5 (diff)
alpha drawing for color picker, move alpha button into the picker.
Diffstat (limited to 'source/blender/editors/interface/interface_widgets.c')
-rw-r--r--source/blender/editors/interface/interface_widgets.c77
1 files changed, 69 insertions, 8 deletions
diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c
index 8f0f794585a..2cfdf2d5e04 100644
--- a/source/blender/editors/interface/interface_widgets.c
+++ b/source/blender/editors/interface/interface_widgets.c
@@ -608,14 +608,67 @@ static void widgetbase_draw(uiWidgetBase *wtb, uiWidgetColors *wcol)
/* backdrop non AA */
if(wtb->inner) {
if(wcol->shaded==0) {
-
- /* filled center, solid */
- glColor4ubv((unsigned char*)wcol->inner);
- glBegin(GL_POLYGON);
- for(a=0; a<wtb->totvert; a++)
- glVertex2fv(wtb->inner_v[a]);
- glEnd();
+ if (wcol->alpha_check) {
+ GLubyte checker_stipple_sml[32*32/8] =
+ {
+ 255,0,255,0,255,0,255,0,255,0,255,0,255,0,255,0, \
+ 255,0,255,0,255,0,255,0,255,0,255,0,255,0,255,0, \
+ 0,255,0,255,0,255,0,255,0,255,0,255,0,255,0,255, \
+ 0,255,0,255,0,255,0,255,0,255,0,255,0,255,0,255, \
+ 255,0,255,0,255,0,255,0,255,0,255,0,255,0,255,0, \
+ 255,0,255,0,255,0,255,0,255,0,255,0,255,0,255,0, \
+ 0,255,0,255,0,255,0,255,0,255,0,255,0,255,0,255, \
+ 0,255,0,255,0,255,0,255,0,255,0,255,0,255,0,255, \
+ };
+
+ float x_mid= 0.0f; /* used for dumb clamping of values */
+
+ /* dark checkers */
+ glColor4ub(100, 100, 100, 255);
+ glBegin(GL_POLYGON);
+ for(a=0; a<wtb->totvert; a++) {
+ glVertex2fv(wtb->inner_v[a]);
+ }
+ glEnd();
+ /* light checkers */
+ glEnable(GL_POLYGON_STIPPLE);
+ glColor4ub(160, 160, 160, 255);
+ glPolygonStipple(checker_stipple_sml);
+ glBegin(GL_POLYGON);
+ for(a=0; a<wtb->totvert; a++) {
+ glVertex2fv(wtb->inner_v[a]);
+ }
+ glEnd();
+ glDisable(GL_POLYGON_STIPPLE);
+
+ /* alpha fill */
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+
+ glColor4ubv((unsigned char*)wcol->inner);
+ glBegin(GL_POLYGON);
+ for(a=0; a<wtb->totvert; a++) {
+ glVertex2fv(wtb->inner_v[a]);
+ x_mid += wtb->inner_v[a][0];
+ }
+ x_mid /= wtb->totvert;
+ glEnd();
+
+ /* 1/2 solid color */
+ glColor4ub(wcol->inner[0], wcol->inner[1], wcol->inner[2], 255);
+ glBegin(GL_POLYGON);
+ for(a=0; a<wtb->totvert; a++)
+ glVertex2f(MIN2(wtb->inner_v[a][0], x_mid), wtb->inner_v[a][1]);
+ glEnd();
+ }
+ else {
+ /* simple fill */
+ glColor4ubv((unsigned char*)wcol->inner);
+ glBegin(GL_POLYGON);
+ for(a=0; a<wtb->totvert; a++)
+ glVertex2fv(wtb->inner_v[a]);
+ glEnd();
+ }
}
else {
char col1[4], col2[4];
@@ -2208,9 +2261,15 @@ static void widget_swatch(uiBut *but, uiWidgetColors *wcol, rcti *rect, int stat
float col[4];
int color_profile = but->block->color_profile;
+ col[3]= 1.0f;
+
if (but->rnaprop) {
if (RNA_property_subtype(but->rnaprop) == PROP_COLOR_GAMMA)
color_profile = BLI_PR_NONE;
+
+ if(RNA_property_array_length(&but->rnapoin, but->rnaprop)==4) {
+ col[3]= RNA_property_float_get_index(&but->rnapoin, but->rnaprop, 3);
+ }
}
widget_init(&wtb);
@@ -2226,8 +2285,10 @@ static void widget_swatch(uiBut *but, uiWidgetColors *wcol, rcti *rect, int stat
wcol->inner[0]= FTOCHAR(col[0]);
wcol->inner[1]= FTOCHAR(col[1]);
wcol->inner[2]= FTOCHAR(col[2]);
+ wcol->inner[3]= FTOCHAR(col[3]);
wcol->shaded = 0;
-
+ wcol->alpha_check = (wcol->inner[3] < 255);
+
widgetbase_draw(&wtb, wcol);
}