Color Management: resolve TODOs related on HSV widgets
authorSergey Sharybin <sergey.vfx@gmail.com>
Mon, 10 Sep 2012 16:30:15 +0000 (16:30 +0000)
committerSergey Sharybin <sergey.vfx@gmail.com>
Mon, 10 Sep 2012 16:30:15 +0000 (16:30 +0000)
source/blender/editors/interface/interface_handlers.c
source/blender/editors/interface/interface_widgets.c

index a1a6e34f7b469484698bd8f0c30011d624a17482..b47dc661e5016a1fdf513638f5cd86efd6b2e11f 100644 (file)
@@ -3163,8 +3163,10 @@ static int ui_numedit_but_HSVCUBE(uiBut *but, uiHandleButtonData *data, int mx,
 
        ui_get_but_vectorf(but, rgb);
 
-       rgb_to_hsv_compat_v(rgb, hsv);
+       if (color_profile && (int)but->a1)
+               ui_block_to_display_space_v3(but->block, rgb);
 
+       rgb_to_hsv_compat_v(rgb, hsv);
 
        /* relative position within box */
        x = ((float)mx_fl - but->rect.xmin) / BLI_RCT_SIZE_X(&but->rect);
@@ -3200,19 +3202,16 @@ static int ui_numedit_but_HSVCUBE(uiBut *but, uiHandleButtonData *data, int mx,
                        /* exception only for value strip - use the range set in but->min/max */
                        hsv[2] = y * (but->softmax - but->softmin) + but->softmin;
 
-                       if (color_profile) {
-                               /* OCIO_TODO: how to handle this situation? */
-                               hsv[2] = srgb_to_linearrgb(hsv[2]);
-                       }
-
-                       if (hsv[2] > but->softmax)
-                               hsv[2] = but->softmax;
                        break;
                default:
                        assert(!"invalid hsv type");
        }
 
        hsv_to_rgb_v(hsv, rgb);
+
+       if (color_profile && (int)but->a1)
+               ui_block_to_scene_linear_v3(but->block, rgb);
+
        copy_v3_v3(data->vec, rgb);
 
        data->draglastx = mx;
@@ -3235,6 +3234,10 @@ static void ui_ndofedit_but_HSVCUBE(uiBut *but, uiHandleButtonData *data, wmNDOF
        }
 
        ui_get_but_vectorf(but, rgb);
+
+       if (color_profile && (int)but->a1)
+               ui_block_to_display_space_v3(but->block, rgb);
+
        rgb_to_hsv_compat_v(rgb, hsv);
        
        switch ((int)but->a1) {
@@ -3265,17 +3268,16 @@ static void ui_ndofedit_but_HSVCUBE(uiBut *but, uiHandleButtonData *data, wmNDOF
                        /* exception only for value strip - use the range set in but->min/max */
                        hsv[2] += ndof->rx * sensitivity;
                        
-                       if (color_profile) {
-                               /* OCIO_TODO: how to handle this situation? */
-                               hsv[2] = srgb_to_linearrgb(hsv[2]);
-                       }
-                       
                        CLAMP(hsv[2], but->softmin, but->softmax);
                default:
                        assert(!"invalid hsv type");
        }
-       
+
        hsv_to_rgb_v(hsv, rgb);
+
+       if (color_profile && (int)but->a1)
+               ui_block_to_scene_linear_v3(but->block, rgb);
+
        copy_v3_v3(data->vec, rgb);
        ui_set_but_vectorf(but, data->vec);
 }
index 522c567e27fb42486947f91935343157adc62c2c..ee22393c08faa8157b18ac4fe96d8da2c1ea8eca 100644 (file)
@@ -1885,19 +1885,20 @@ static void ui_draw_but_HSVCIRCLE(uiBut *but, uiWidgetColors *wcol, rcti *rect)
        
        /* color */
        ui_get_but_vectorf(but, rgb);
-       copy_v3_v3(hsv, ui_block_hsv_get(but->block));
+       /* copy_v3_v3(hsv, ui_block_hsv_get(but->block)); */ /* UNUSED */
+
+       rgb_to_hsv_compat_v(rgb, hsvo);
+
+       if (color_profile)
+               ui_block_to_display_space_v3(but->block, rgb);
+
        rgb_to_hsv_compat_v(rgb, hsv);
-       copy_v3_v3(hsvo, hsv);
        
        /* exception: if 'lock' is set
         * lock the value of the color wheel to 1.
         * Useful for color correction tools where you're only interested in hue. */
        if (but->flag & UI_BUT_COLOR_LOCK)
                hsv[2] = 1.f;
-       else if (color_profile) {
-               /* OCIO_TODO: how to handle this situation? */
-               hsv[2] = linearrgb_to_srgb(hsv[2]);
-       }
        
        hsv_to_rgb(0.f, 0.f, hsv[2], colcent, colcent + 1, colcent + 2);
        
@@ -2142,14 +2143,13 @@ static void ui_draw_but_HSV_v(uiBut *but, rcti *rect)
                color_profile = FALSE;
 
        ui_get_but_vectorf(but, rgb);
+
+       if (color_profile)
+               ui_block_to_display_space_v3(but->block, rgb);
+
        rgb_to_hsv_v(rgb, hsv);
        v = hsv[2];
        
-       if (color_profile) {
-               /* OCIO_TODO: how to handle this situation? */
-               v = linearrgb_to_srgb(v);
-       }
-
        /* map v from property range to [0,1] */
        range = but->softmax - but->softmin;
        v = (v - but->softmin) / range;