From 729e50ff2e3bd15a1ab9353db30fdf2a3f67f80f Mon Sep 17 00:00:00 2001 From: Alberto Griggio Date: Fri, 8 Dec 2017 15:54:05 +0100 Subject: [PATCH] color toning: properly draw hue and strength gradients for the highlights and shadows sliders Fixes #4209 --- rtgui/colortoning.cc | 22 ++++++++++------------ rtgui/thresholdselector.cc | 3 +++ 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/rtgui/colortoning.cc b/rtgui/colortoning.cc index c5d9252cd..b53f7e5db 100644 --- a/rtgui/colortoning.cc +++ b/rtgui/colortoning.cc @@ -954,36 +954,34 @@ void ColorToning::colorForValue (double valX, double valY, enum ColorCaller::Ele if (callerId == 1) { // ch - main curve Color::hsv2rgb01(float(valY), 1.0f, 0.5f, R, G, B); } else if (callerId == 2) { // Slider 1 background - if (valY > 0.5) + if (valY <= 0.5) // the hue range { Color::hsv2rgb01(float(valX), 1.0f, 0.5f, R, G, B); } else { // the strength applied to the current hue double strength, hue; - float r_, g_, b_; hlColSat->getValue(strength, hue); - Color::hsv2rgb01(valY * 2.f, 1.f, 1.f, r_, g_, b_); Color::hsv2rgb01(hue / 360.f, 1.f, 1.f, R, G, B); - R = r_ + (R - r_) * valX; - G = g_ + (G - g_) * valX; - B = b_ + (B - b_) * valX; + const double gray = 0.46; + R = (gray * (1.0 - valX)) + R * valX; + G = (gray * (1.0 - valX)) + G * valX; + B = (gray * (1.0 - valX)) + B * valX; } } else if (callerId == 3) { // Slider 2 background - if (valY > 0.5) + if (valY <= 0.5) // the hue range { Color::hsv2rgb01(float(valX), 1.0f, 0.5f, R, G, B); } else { // the strength applied to the current hue double strength, hue; - float r_, g_, b_; shadowsColSat->getValue(strength, hue); - Color::hsv2rgb01(valY * 2.f, 1.f, 1.f, r_, g_, b_); Color::hsv2rgb01(hue / 360.f, 1.f, 1.f, R, G, B); - R = r_ + (R - r_) * valX; - G = g_ + (G - g_) * valX; - B = b_ + (B - b_) * valX; + const double gray = 0.46; + R = (gray * (1.0 - valX)) + R * valX; + G = (gray * (1.0 - valX)) + G * valX; + B = (gray * (1.0 - valX)) + B * valX; } } diff --git a/rtgui/thresholdselector.cc b/rtgui/thresholdselector.cc index 0f9b11cf2..891095e6f 100644 --- a/rtgui/thresholdselector.cc +++ b/rtgui/thresholdselector.cc @@ -284,6 +284,9 @@ void ThresholdSelector::updateBackBuffer() cr->set_line_cap(Cairo::LINE_CAP_BUTT); if (is_sensitive() && coloredBar.canGetColors()) { + if (updatePolicy == RTUP_DYNAMIC) { + coloredBar.setDirty(true); + } // this will eventually create/update the off-screen Surface for the gradient area only ! coloredBar.setDrawRectangle(hb + hwslider, int(float(h) * 1.5f / 7.f + 0.5f), iw + 1, int(float(h) * 4.f / 7.f + 0.5f)); // that we're displaying here