[Bf-blender-cvs] [25560a3] master: Fix T37545: SV+H color cube display changes H slider position when modifying S or V.
Lukas Tönne
noreply at git.blender.org
Wed Nov 20 11:41:34 CET 2013
Commit: 25560a3734a18657518652366fe24ce4574d54ff
Author: Lukas Tönne
Date: Wed Nov 20 11:34:18 2013 +0100
http://developer.blender.org/rB25560a3734a18657518652366fe24ce4574d54ff
Fix T37545: SV+H color cube display changes H slider position when modifying S or V.
The widget for the SV gradient was disabling display colorspace transform, but this was not happening for the H slider below, leading to varying H values used to calculate the slider position.
===================================================================
M source/blender/editors/interface/interface_handlers.c
M source/blender/editors/interface/interface_intern.h
M source/blender/editors/interface/interface_widgets.c
===================================================================
diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c
index 05d7700..2b8b764 100644
--- a/source/blender/editors/interface/interface_handlers.c
+++ b/source/blender/editors/interface/interface_handlers.c
@@ -3879,8 +3879,8 @@ static bool ui_numedit_but_HSVCUBE(uiBut *but, uiHandleButtonData *data,
float x, y;
float mx_fl, my_fl;
bool changed = true;
- int color_profile = but->block->color_profile;
-
+ bool use_display_colorspace = ui_hsvcube_use_display_colorspace(but);
+
ui_mouse_scale_warp(data, mx, my, &mx_fl, &my_fl, shift);
#ifdef USE_CONT_MOUSE_CORRECT
@@ -3892,14 +3892,9 @@ static bool ui_numedit_but_HSVCUBE(uiBut *but, uiHandleButtonData *data,
}
#endif
- if (but->rnaprop) {
- if (RNA_property_subtype(but->rnaprop) == PROP_COLOR_GAMMA)
- color_profile = FALSE;
- }
-
ui_get_but_vectorf(but, rgb);
- if (color_profile && (int)but->a1 != UI_GRAD_SV)
+ if (use_display_colorspace)
ui_block_to_display_space_v3(but->block, rgb);
rgb_to_hsv_compat_v(rgb, hsv);
@@ -3913,7 +3908,7 @@ static bool ui_numedit_but_HSVCUBE(uiBut *but, uiHandleButtonData *data,
/* calculate original hsv again */
copy_v3_v3(rgb, data->origvec);
- if (color_profile && (int)but->a1 != UI_GRAD_SV)
+ if (use_display_colorspace)
ui_block_to_display_space_v3(but->block, rgb);
copy_v3_v3(hsvo, ui_block_hsv_get(but->block));
@@ -3974,7 +3969,7 @@ static bool ui_numedit_but_HSVCUBE(uiBut *but, uiHandleButtonData *data,
hsv_to_rgb_v(hsv, rgb);
- if (color_profile && ((int)but->a1 != UI_GRAD_SV))
+ if (use_display_colorspace)
ui_block_to_scene_linear_v3(but->block, rgb);
/* clamp because with color conversion we can exceed range [#34295] */
@@ -3997,17 +3992,11 @@ static void ui_ndofedit_but_HSVCUBE(uiBut *but, uiHandleButtonData *data,
float *hsv = ui_block_hsv_get(but->block);
float rgb[3];
float sensitivity = (shift ? 0.15f : 0.3f) * ndof->dt;
-
- int color_profile = but->block->color_profile;
-
- if (but->rnaprop) {
- if (RNA_property_subtype(but->rnaprop) == PROP_COLOR_GAMMA)
- color_profile = FALSE;
- }
+ bool use_display_colorspace = ui_hsvcube_use_display_colorspace(but);
ui_get_but_vectorf(but, rgb);
- if (color_profile && (int)but->a1 != UI_GRAD_SV)
+ if (use_display_colorspace)
ui_block_to_display_space_v3(but->block, rgb);
rgb_to_hsv_compat_v(rgb, hsv);
@@ -4055,7 +4044,7 @@ static void ui_ndofedit_but_HSVCUBE(uiBut *but, uiHandleButtonData *data,
hsv_to_rgb_v(hsv, rgb);
- if (color_profile && (int)but->a1 != UI_GRAD_SV)
+ if (use_display_colorspace)
ui_block_to_scene_linear_v3(but->block, rgb);
copy_v3_v3(data->vec, rgb);
diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h
index be0a281..5ecd1e5 100644
--- a/source/blender/editors/interface/interface_intern.h
+++ b/source/blender/editors/interface/interface_intern.h
@@ -385,6 +385,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);
extern void ui_get_but_string_ex(uiBut *but, char *str, const size_t maxlen, const int float_precision);
extern void ui_get_but_string(uiBut *but, char *str, const size_t maxlen);
diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c
index c26998a..97dd4f5 100644
--- a/source/blender/editors/interface/interface_widgets.c
+++ b/source/blender/editors/interface/interface_widgets.c
@@ -2146,6 +2146,19 @@ void ui_draw_gradient(const rcti *rect, const float hsv[3], const int type, cons
}
+bool ui_hsvcube_use_display_colorspace(uiBut *but)
+{
+ bool color_profile = but->block->color_profile;
+
+ if (but->rnaprop) {
+ if (RNA_property_subtype(but->rnaprop) == PROP_COLOR_GAMMA)
+ color_profile = FALSE;
+ }
+
+ /* SV+H gradient does not use display colorspace */
+ return color_profile && !ELEM((int)but->a1, UI_GRAD_SV, UI_GRAD_H);
+}
+
void ui_hsvcube_pos_from_vals(uiBut *but, const rcti *rect, float *hsv, float *xp, float *yp)
{
float x, y;
@@ -2182,16 +2195,13 @@ 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];
- int color_profile = but->block->color_profile;
-
- if (but->rnaprop && RNA_property_subtype(but->rnaprop) == PROP_COLOR_GAMMA)
- color_profile = FALSE;
+ bool use_display_colorspace = ui_hsvcube_use_display_colorspace(but);
copy_v3_v3(hsv_n, hsv);
ui_get_but_vectorf(but, rgb);
- if (color_profile && (int)but->a1 != UI_GRAD_SV)
+ if (use_display_colorspace)
ui_block_to_display_space_v3(but->block, rgb);
rgb_to_hsv_compat_v(rgb, hsv_n);
More information about the Bf-blender-cvs
mailing list