hue color display still was shifted, turned out the resolution was a bit too low.
authorCampbell Barton <ideasman42@gmail.com>
Thu, 21 Jun 2012 19:45:36 +0000 (19:45 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Thu, 21 Jun 2012 19:45:36 +0000 (19:45 +0000)
source/blender/editors/interface/interface_intern.h
source/blender/editors/interface/interface_widgets.c

index 9af3ff3..1f88db0 100644 (file)
@@ -447,7 +447,7 @@ extern void ui_draw_aligned_panel(struct uiStyle *style, uiBlock *block, rcti *r
 /* interface_draw.c */
 extern void ui_dropshadow(rctf *rct, float radius, float aspect, float alpha, int select);
 
-void ui_draw_gradient(rcti *rect, const float hsv[3], int type, float alpha);
+void ui_draw_gradient(rcti *rect, const float hsv[3], const int type, const float alpha);
 
 void ui_draw_but_HISTOGRAM(ARegion *ar, uiBut *but, struct uiWidgetColors *wcol, rcti *rect);
 void ui_draw_but_WAVEFORM(ARegion *ar, uiBut *but, struct uiWidgetColors *wcol, rcti *rect);
index 464298f..07b1217 100644 (file)
@@ -1946,8 +1946,9 @@ static void ui_draw_but_HSVCIRCLE(uiBut *but, uiWidgetColors *wcol, rcti *rect)
 /* ************ custom buttons, old stuff ************** */
 
 /* draws in resolution of 20x4 colors */
-void ui_draw_gradient(rcti *rect, const float hsv[3], int type, float alpha)
+void ui_draw_gradient(rcti *rect, const float hsv[3], const int type, const float alpha)
 {
+       const float color_step = (type == UI_GRAD_H) ? 0.02 : 0.05f;
        int a;
        float h = hsv[0], s = hsv[1], v = hsv[2];
        float dx, dy, sx1, sx2, sy;
@@ -2004,7 +2005,7 @@ void ui_draw_gradient(rcti *rect, const float hsv[3], int type, float alpha)
        
        /* old below */
        
-       for (dx = 0.0f; dx < 1.0f; dx += 0.05f) {
+       for (dx = 0.0f; dx < 1.0f; dx += color_step) {
                // previous color
                copy_v3_v3(col0[0], col1[0]);
                copy_v3_v3(col0[1], col1[1]);
@@ -2032,11 +2033,15 @@ void ui_draw_gradient(rcti *rect, const float hsv[3], int type, float alpha)
                                hsv_to_rgb(dx, 1.0, v,   &col1[3][0], &col1[3][1], &col1[3][2]);
                                break;
                        case UI_GRAD_H:
-                               hsv_to_rgb(dx + 0.05f, 1.0, 1.0,   &col1[0][0], &col1[0][1], &col1[0][2]);
+                       {
+                               /* annoying but without this the color shifts - could be solved some other way
+                                * - campbell */
+                               hsv_to_rgb(dx + color_step, 1.0, 1.0,   &col1[0][0], &col1[0][1], &col1[0][2]);
                                copy_v3_v3(col1[1], col1[0]);
                                copy_v3_v3(col1[2], col1[0]);
                                copy_v3_v3(col1[3], col1[0]);
                                break;
+                       }
                        case UI_GRAD_S:
                                hsv_to_rgb(h, dx, 1.0,   &col1[1][0], &col1[1][1], &col1[1][2]);
                                copy_v3_v3(col1[0], col1[1]);
@@ -2053,7 +2058,7 @@ void ui_draw_gradient(rcti *rect, const float hsv[3], int type, float alpha)
                
                // rect
                sx1 = rect->xmin + dx * (rect->xmax - rect->xmin);
-               sx2 = rect->xmin + (dx + 0.05f) * (rect->xmax - rect->xmin);
+               sx2 = rect->xmin + (dx + color_step) * (rect->xmax - rect->xmin);
                sy = rect->ymin;
                dy = (rect->ymax - rect->ymin) / 3.0;