Color Management: resolve TODOs related on HSV widgets

This commit is contained in:
Sergey Sharybin
2012-09-10 16:30:15 +00:00
parent ce3566a4cb
commit 3e881745e5
2 changed files with 27 additions and 25 deletions

View 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);
}

View 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;