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:
Diffstat (limited to 'source/blender/editors/interface/interface_handlers.c')
-rw-r--r--source/blender/editors/interface/interface_handlers.c83
1 files changed, 63 insertions, 20 deletions
diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c
index 8ead084f756..f25e045f237 100644
--- a/source/blender/editors/interface/interface_handlers.c
+++ b/source/blender/editors/interface/interface_handlers.c
@@ -4300,7 +4300,10 @@ static bool ui_numedit_but_HSVCUBE(uiBut *but, uiHandleButtonData *data,
if (use_display_colorspace)
ui_block_to_display_space_v3(but->block, rgb);
- rgb_to_hsv_compat_v(rgb, hsv);
+ if (but->a1 == UI_GRAD_L_ALT)
+ rgb_to_hsl_compat_v(rgb, hsv);
+ else
+ rgb_to_hsv_compat_v(rgb, hsv);
/* only apply the delta motion, not absolute */
if (shift) {
@@ -4315,7 +4318,10 @@ static bool ui_numedit_but_HSVCUBE(uiBut *but, uiHandleButtonData *data,
ui_block_to_display_space_v3(but->block, rgb);
copy_v3_v3(hsvo, ui_block_hsv_get(but->block));
- rgb_to_hsv_compat_v(rgb, hsvo);
+ if (but->a1 == UI_GRAD_L_ALT)
+ rgb_to_hsl_compat_v(rgb, hsvo);
+ else
+ rgb_to_hsv_compat_v(rgb, hsvo);
/* and original position */
ui_hsvcube_pos_from_vals(but, &rect_i, hsvo, &xpos, &ypos);
@@ -4353,11 +4359,11 @@ static bool ui_numedit_but_HSVCUBE(uiBut *but, uiHandleButtonData *data,
hsv[2] = x;
break;
case UI_GRAD_V_ALT:
+ case UI_GRAD_L_ALT:
/* vertical 'value' strip */
/* exception only for value strip - use the range set in but->min/max */
hsv[2] = y * (but->softmax - but->softmin) + but->softmin;
-
break;
default:
BLI_assert(0);
@@ -4370,13 +4376,16 @@ static bool ui_numedit_but_HSVCUBE(uiBut *but, uiHandleButtonData *data,
}
}
- hsv_to_rgb_v(hsv, rgb);
+ if (but->a1 == UI_GRAD_L_ALT)
+ hsl_to_rgb_v(hsv, rgb);
+ else
+ hsv_to_rgb_v(hsv, rgb);
if (use_display_colorspace)
ui_block_to_scene_linear_v3(but->block, rgb);
/* clamp because with color conversion we can exceed range [#34295] */
- if ((int)but->a1 == UI_GRAD_V_ALT) {
+ if (ELEM((int)but->a1, UI_GRAD_V_ALT, UI_GRAD_L_ALT)) {
clamp_axis_max_v3(rgb, but->softmax);
}
@@ -4403,8 +4412,11 @@ static void ui_ndofedit_but_HSVCUBE(uiBut *but, uiHandleButtonData *data,
if (use_display_colorspace)
ui_block_to_display_space_v3(but->block, rgb);
- rgb_to_hsv_compat_v(rgb, hsv);
-
+ if (but->a1 == UI_GRAD_L_ALT)
+ rgb_to_hsl_compat_v(rgb, hsv);
+ else
+ rgb_to_hsv_compat_v(rgb, hsv);
+
switch ((int)but->a1) {
case UI_GRAD_SV:
hsv[2] += ndof->rvec[2] * sensitivity;
@@ -4428,6 +4440,7 @@ static void ui_ndofedit_but_HSVCUBE(uiBut *but, uiHandleButtonData *data,
hsv[2] += ndof->rvec[2] * sensitivity;
break;
case UI_GRAD_V_ALT:
+ case UI_GRAD_L_ALT:
/* vertical 'value' strip */
/* exception only for value strip - use the range set in but->min/max */
@@ -4449,7 +4462,10 @@ static void ui_ndofedit_but_HSVCUBE(uiBut *but, uiHandleButtonData *data,
/* ndof specific: the changes above aren't clamping */
hsv_clamp_v(hsv, hsv_v_max);
- hsv_to_rgb_v(hsv, rgb);
+ if (but->a1 == UI_GRAD_L_ALT)
+ hsl_to_rgb_v(hsv, rgb);
+ else
+ hsv_to_rgb_v(hsv, rgb);
if (use_display_colorspace)
ui_block_to_scene_linear_v3(but->block, rgb);
@@ -4501,11 +4517,10 @@ static int ui_do_but_HSVCUBE(bContext *C, uiBlock *block, uiBut *but, uiHandleBu
/* reset only value */
len = RNA_property_array_length(&but->rnapoin, but->rnaprop);
- if (len >= 3) {
+ if (ELEM(len, 3, 4)) {
float rgb[3], def_hsv[3];
- float *def;
+ float def[4];
float *hsv = ui_block_hsv_get(but->block);
- def = MEM_callocN(sizeof(float) * len, "reset_defaults - float");
RNA_property_float_get_default_array(&but->rnapoin, but->rnaprop, def);
rgb_to_hsv_v(def, def_hsv);
@@ -4519,9 +4534,34 @@ static int ui_do_but_HSVCUBE(bContext *C, uiBlock *block, uiBut *but, uiHandleBu
hsv_to_rgb_v(def_hsv, rgb);
ui_set_but_vectorf(but, rgb);
+ RNA_property_update(C, &but->rnapoin, but->rnaprop);
+ }
+ return WM_UI_HANDLER_BREAK;
+ }
+ else if (but->a1 == UI_GRAD_L_ALT) {
+ int len;
+
+ /* reset only value */
+
+ len = RNA_property_array_length(&but->rnapoin, but->rnaprop);
+ if (ELEM(len, 3, 4)) {
+ float rgb[3], def_hsl[3];
+ float def[4];
+ float *hsl = ui_block_hsv_get(but->block);
+
+ RNA_property_float_get_default_array(&but->rnapoin, but->rnaprop, def);
+ rgb_to_hsl_v(def, def_hsl);
+
+ ui_get_but_vectorf(but, rgb);
+ rgb_to_hsl_compat_v(rgb, hsl);
+
+ def_hsl[0] = hsl[0];
+ def_hsl[1] = hsl[1];
+
+ hsl_to_rgb_v(def_hsl, rgb);
+ ui_set_but_vectorf(but, rgb);
+
RNA_property_update(C, &but->rnapoin, but->rnaprop);
-
- MEM_freeN(def);
}
return WM_UI_HANDLER_BREAK;
}
@@ -4585,8 +4625,9 @@ static bool ui_numedit_but_HSVCIRCLE(uiBut *but, uiHandleButtonData *data,
ui_get_but_vectorf(but, rgb);
copy_v3_v3(hsv, ui_block_hsv_get(but->block));
- rgb_to_hsv_compat_v(rgb, hsv);
-
+
+ ui_rgb_to_color_picker_compat_v(rgb, hsv);
+
/* exception, when using color wheel in 'locked' value state:
* allow choosing a hue for black values, by giving a tiny increment */
if (but->flag & UI_BUT_COLOR_LOCK) { // lock
@@ -4599,10 +4640,12 @@ static bool ui_numedit_but_HSVCIRCLE(uiBut *but, uiHandleButtonData *data,
/* calculate original hsv again */
copy_v3_v3(hsvo, ui_block_hsv_get(but->block));
- rgb_to_hsv_compat_v(data->origvec, hsvo);
+
+ ui_rgb_to_color_picker_compat_v(data->origvec, hsvo);
+
/* and original position */
ui_hsvcircle_pos_from_vals(but, &rect, hsvo, &xpos, &ypos);
-
+
mx_fl = xpos - (data->dragstartx - mx_fl);
my_fl = ypos - (data->dragstarty - my_fl);
@@ -4617,7 +4660,7 @@ static bool ui_numedit_but_HSVCIRCLE(uiBut *but, uiHandleButtonData *data,
ui_color_snap_hue(snap, &hsv[0]);
}
- hsv_to_rgb_v(hsv, rgb);
+ ui_color_picker_to_rgb_v(hsv, rgb);
if ((but->flag & UI_BUT_VEC_SIZE_LOCK) && (rgb[0] || rgb[1] || rgb[2])) {
normalize_v3(rgb);
@@ -4642,7 +4685,7 @@ static void ui_ndofedit_but_HSVCIRCLE(uiBut *but, uiHandleButtonData *data,
float sensitivity = (shift ? 0.06f : 0.3f) * ndof->dt;
ui_get_but_vectorf(but, rgb);
- rgb_to_hsv_compat_v(rgb, hsv);
+ ui_rgb_to_color_picker_compat_v(rgb, hsv);
/* Convert current color on hue/sat disc to circular coordinates phi, r */
phi = fmodf(hsv[0] + 0.25f, 1.0f) * -2.0f * (float)M_PI;
@@ -4680,7 +4723,7 @@ static void ui_ndofedit_but_HSVCIRCLE(uiBut *but, uiHandleButtonData *data,
hsv_clamp_v(hsv, FLT_MAX);
- hsv_to_rgb_v(hsv, data->vec);
+ ui_color_picker_to_rgb_v(hsv, data->vec);
if ((but->flag & UI_BUT_VEC_SIZE_LOCK) && (data->vec[0] || data->vec[1] || data->vec[2])) {
normalize_v3(data->vec);