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:
authorAntony Riakiotakis <kalast@gmail.com>2014-04-07 21:43:47 +0400
committerAntony Riakiotakis <kalast@gmail.com>2014-04-11 16:13:11 +0400
commit2d655d370d84d39e296e1744ac412a5968a5657d (patch)
tree6fb06da9845c57f9d8c4c2064118f1d8be0efed5 /source/blender/editors
parent0b50ea5a8802e2db48101f5e0e1b0465afb907a5 (diff)
Fix T39627
HSL sliders jumping. The issue here is that we store HSV in display space. To correctly account for that, made sure HSV/HSL is now using the displayed color to compute the values in the sliders. RGB values still show the property values (linear for linear, gamma corrected for gamma corrected) We could change the way we store HSV uniformly (ie in all the code), but we would need to add many more conversions in the picker code to account for storing it that way. Also it doesn't make sense: Color pickers should help with -visible- color selection. It may be worth changing the RGB sliders as well. My fix takes into account the way HSV is stored in HSVCube as well in the code.
Diffstat (limited to 'source/blender/editors')
-rw-r--r--source/blender/editors/interface/interface_regions.c45
1 files changed, 34 insertions, 11 deletions
diff --git a/source/blender/editors/interface/interface_regions.c b/source/blender/editors/interface/interface_regions.c
index 37cfbbb2cff..346f908d1ad 100644
--- a/source/blender/editors/interface/interface_regions.c
+++ b/source/blender/editors/interface/interface_regions.c
@@ -1652,16 +1652,25 @@ void ui_set_but_hsv(uiBut *but)
}
/* also used by small picker, be careful with name checks below... */
-static void ui_update_block_buts_rgb(uiBlock *block, const float rgb[3])
+static void ui_update_block_buts_rgb(uiBlock *block, const float rgb[3], bool is_display_space)
{
uiBut *bt;
float *hsv = ui_block_hsv_get(block);
struct ColorManagedDisplay *display = NULL;
-
/* this is to keep the H and S value when V is equal to zero
* and we are working in HSV mode, of course!
*/
- ui_rgb_to_color_picker_compat_v(rgb, hsv);
+ if (is_display_space) {
+ ui_rgb_to_color_picker_compat_v(rgb, hsv);
+ }
+ else {
+ /* we need to convert to display space to use hsv, because hsv is stored in display space */
+ float rgb_display[3];
+
+ copy_v3_v3(rgb_display, rgb);
+ ui_block_to_display_space_v3(block, rgb_display);
+ ui_rgb_to_color_picker_compat_v(rgb_display, hsv);
+ }
if (block->color_profile)
display = ui_block_display_get(block);
@@ -1734,7 +1743,7 @@ static void do_picker_rna_cb(bContext *UNUSED(C), void *bt1, void *UNUSED(arg))
if (prop) {
RNA_property_float_get_array(&ptr, prop, rgb);
- ui_update_block_buts_rgb(but->block, rgb);
+ ui_update_block_buts_rgb(but->block, rgb, (RNA_property_subtype(prop) == PROP_COLOR_GAMMA));
}
if (popup)
@@ -1747,10 +1756,16 @@ static void do_color_wheel_rna_cb(bContext *UNUSED(C), void *bt1, void *UNUSED(a
uiPopupBlockHandle *popup = but->block->handle;
float rgb[3];
float *hsv = ui_block_hsv_get(but->block);
-
+ bool use_display_colorspace = ui_color_picker_use_display_colorspace(but);
+
ui_color_picker_to_rgb_v(hsv, rgb);
- ui_update_block_buts_rgb(but->block, rgb);
+ /* hsv is saved in display space so convert back */
+ if (use_display_colorspace) {
+ ui_block_to_scene_linear_v3(but->block, rgb);
+ }
+
+ ui_update_block_buts_rgb(but->block, rgb, !use_display_colorspace);
if (popup)
popup->menuretval = UI_RETURN_UPDATE;
@@ -1771,7 +1786,7 @@ static void do_hex_rna_cb(bContext *UNUSED(C), void *bt1, void *hexcl)
ui_block_to_scene_linear_v3(but->block, rgb);
}
- ui_update_block_buts_rgb(but->block, rgb);
+ ui_update_block_buts_rgb(but->block, rgb, false);
if (popup)
popup->menuretval = UI_RETURN_UPDATE;
@@ -2002,16 +2017,24 @@ static int ui_picker_small_wheel_cb(const bContext *UNUSED(C), uiBlock *block, c
uiPopupBlockHandle *popup = block->handle;
float rgb[3];
float *hsv = ui_block_hsv_get(block);
+ bool use_display_colorspace = ui_color_picker_use_display_colorspace(but);
ui_get_but_vectorf(but, rgb);
-
- rgb_to_hsv_compat_v(rgb, hsv);
+
+ if (use_display_colorspace)
+ ui_block_to_display_space_v3(block, rgb);
+
+ ui_rgb_to_color_picker_compat_v(rgb, hsv);
+
hsv[2] = CLAMPIS(hsv[2] + add, 0.0f, 1.0f);
- hsv_to_rgb_v(hsv, rgb);
+ ui_color_picker_to_rgb_v(hsv, rgb);
+
+ if (use_display_colorspace)
+ ui_block_to_scene_linear_v3(block, rgb);
ui_set_but_vectorf(but, rgb);
- ui_update_block_buts_rgb(block, rgb);
+ ui_update_block_buts_rgb(block, rgb, !use_display_colorspace);
if (popup)
popup->menuretval = UI_RETURN_UPDATE;