diff options
author | Antony Riakiotakis <kalast@gmail.com> | 2014-03-14 04:30:27 +0400 |
---|---|---|
committer | Antony Riakiotakis <kalast@gmail.com> | 2014-03-14 04:30:27 +0400 |
commit | 8f1a6e26b6d32fd4b293ab06d22a34c8a8cd2505 (patch) | |
tree | 58e6345e3032fffa2f830d6501fc2a2b1e168508 /source/blender/editors/interface | |
parent | f19899b474f19bf5cbf982fc3827b6468a2bf2aa (diff) |
Fix Circle picker not liking linear color properties much. Again, visual
result for picked color was different from what was displayed on color
wheel under the cursor.
Diffstat (limited to 'source/blender/editors/interface')
-rw-r--r-- | source/blender/editors/interface/interface_handlers.c | 20 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_intern.h | 2 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_widgets.c | 15 |
3 files changed, 22 insertions, 15 deletions
diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index e43b84c9113..11e361d0311 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -4298,7 +4298,7 @@ static bool ui_numedit_but_HSVCUBE(uiBut *but, uiHandleButtonData *data, float x, y; float mx_fl, my_fl; bool changed = true; - bool use_display_colorspace = ui_hsvcube_use_display_colorspace(but); + bool use_display_colorspace = ui_color_picker_use_display_colorspace(but); ui_mouse_scale_warp(data, mx, my, &mx_fl, &my_fl, shift); @@ -4413,7 +4413,7 @@ static void ui_ndofedit_but_HSVCUBE(uiBut *but, uiHandleButtonData *data, const float hsv_v_max = max_ff(hsv[2], but->softmax); float rgb[3]; float sensitivity = (shift ? 0.15f : 0.3f) * ndof->dt; - bool use_display_colorspace = ui_hsvcube_use_display_colorspace(but); + bool use_display_colorspace = ui_color_picker_use_display_colorspace(but); ui_get_but_vectorf(but, rgb); @@ -4604,7 +4604,8 @@ static bool ui_numedit_but_HSVCIRCLE(uiBut *but, uiHandleButtonData *data, float mx_fl, my_fl; float rgb[3]; float hsv[3]; - + bool use_display_colorspace = ui_color_picker_use_display_colorspace(but); + ui_mouse_scale_warp(data, mx, my, &mx_fl, &my_fl, shift); #ifdef USE_CONT_MOUSE_CORRECT @@ -4626,6 +4627,9 @@ static bool ui_numedit_but_HSVCIRCLE(uiBut *but, uiHandleButtonData *data, BLI_rcti_rctf_copy(&rect, &but->rect); ui_get_but_vectorf(but, rgb); + if (use_display_colorspace) + ui_block_to_display_space_v3(but->block, rgb); + copy_v3_v3(hsv, ui_block_hsv_get(but->block)); ui_rgb_to_color_picker_compat_v(rgb, hsv); @@ -4638,12 +4642,15 @@ static bool ui_numedit_but_HSVCIRCLE(uiBut *but, uiHandleButtonData *data, /* only apply the delta motion, not absolute */ if (shift) { - float xpos, ypos, hsvo[3]; + float xpos, ypos, hsvo[3], rgbo[3]; /* calculate original hsv again */ copy_v3_v3(hsvo, ui_block_hsv_get(but->block)); + copy_v3_v3(rgbo, data->origvec); + if (use_display_colorspace) + ui_block_to_display_space_v3(but->block, rgbo); - ui_rgb_to_color_picker_compat_v(data->origvec, hsvo); + ui_rgb_to_color_picker_compat_v(rgbo, hsvo); /* and original position */ ui_hsvcircle_pos_from_vals(but, &rect, hsvo, &xpos, &ypos); @@ -4669,6 +4676,9 @@ static bool ui_numedit_but_HSVCIRCLE(uiBut *but, uiHandleButtonData *data, mul_v3_fl(rgb, but->a2); } + if (use_display_colorspace) + ui_block_to_scene_linear_v3(but->block, rgb); + ui_set_but_vectorf(but, rgb); data->draglastx = mx; diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h index 9cdd85d8dc0..2c6486b587c 100644 --- a/source/blender/editors/interface/interface_intern.h +++ b/source/blender/editors/interface/interface_intern.h @@ -386,7 +386,7 @@ extern void ui_hsvcircle_vals_from_pos(float *val_rad, float *val_dist, const rc const float mx, const float my); extern void ui_hsvcircle_pos_from_vals(struct uiBut *but, const rcti *rect, float *hsv, float *xpos, float *ypos); extern void ui_hsvcube_pos_from_vals(struct uiBut *but, const rcti *rect, float *hsv, float *xp, float *yp); -bool ui_hsvcube_use_display_colorspace(struct uiBut *but); +bool ui_color_picker_use_display_colorspace(struct uiBut *but); extern void ui_get_but_string_ex(uiBut *but, char *str, const size_t maxlen, const int float_precision) ATTR_NONNULL(); extern void ui_get_but_string(uiBut *but, char *str, const size_t maxlen) ATTR_NONNULL(); diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c index e2f3aaca39c..b696005001f 100644 --- a/source/blender/editors/interface/interface_widgets.c +++ b/source/blender/editors/interface/interface_widgets.c @@ -2050,11 +2050,8 @@ static void ui_draw_but_HSVCIRCLE(uiBut *but, uiWidgetColors *wcol, const rcti * float xpos, ypos, ang = 0.0f; float rgb[3], hsvo[3], hsv[3], col[3], colcent[3]; int a; - bool color_profile = but->block->color_profile; - - if (but->rnaprop && RNA_property_subtype(but->rnaprop) == PROP_COLOR_GAMMA) - color_profile = false; - + bool color_profile = ui_color_picker_use_display_colorspace(but); + /* color */ ui_get_but_vectorf(but, rgb); @@ -2063,11 +2060,11 @@ static void ui_draw_but_HSVCIRCLE(uiBut *but, uiWidgetColors *wcol, const rcti * hsvo[1] = hsv[1] = hsv_ptr[1]; hsvo[2] = hsv[2] = hsv_ptr[2]; - ui_rgb_to_color_picker_compat_v(rgb, hsvo); - if (color_profile) ui_block_to_display_space_v3(but->block, rgb); + ui_rgb_to_color_picker_compat_v(rgb, hsvo); + ui_rgb_to_color_picker_compat_v(rgb, hsv); /* exception: if 'lock' is set @@ -2261,7 +2258,7 @@ void ui_draw_gradient(const rcti *rect, const float hsv[3], const int type, cons } -bool ui_hsvcube_use_display_colorspace(uiBut *but) +bool ui_color_picker_use_display_colorspace(uiBut *but) { bool color_profile = but->block->color_profile; @@ -2310,7 +2307,7 @@ static void ui_draw_but_HSVCUBE(uiBut *but, const rcti *rect) float x = 0.0f, y = 0.0f; float *hsv = ui_block_hsv_get(but->block); float hsv_n[3]; - bool use_display_colorspace = ui_hsvcube_use_display_colorspace(but); + bool use_display_colorspace = ui_color_picker_use_display_colorspace(but); copy_v3_v3(hsv_n, hsv); |