diff --git a/data/pref.xml b/data/pref.xml
index 9893ce8bf..68be7d352 100644
--- a/data/pref.xml
+++ b/data/pref.xml
@@ -214,6 +214,7 @@
+
diff --git a/data/strings/en.ini b/data/strings/en.ini
index 98660eaea..f87691588 100644
--- a/data/strings/en.ini
+++ b/data/strings/en.ini
@@ -1303,6 +1303,7 @@ new_render_engine = New render engine for sprite editor
native_clipboard = Use native clipboard
native_file_dialog = Use native file dialog
shaders_for_color_selectors = Use shaders for color selectors
+hue_with_sat_value = Apply Saturation/Value to Hue slider on Tint/Shade/Tone selector
one_finger_as_mouse_movement = Interpret one finger as mouse movement
one_finger_as_mouse_movement_tooltip = <<
-
+
+
diff --git a/src/app/ui/color_selector.cpp b/src/app/ui/color_selector.cpp
index 87389fde3..c83b7e4c8 100644
--- a/src/app/ui/color_selector.cpp
+++ b/src/app/ui/color_selector.cpp
@@ -626,6 +626,7 @@ void ColorSelector::updateColorSpace()
}
#if SK_ENABLE_SKSL
+
// static
const char* ColorSelector::getAlphaBarShader()
{
@@ -678,6 +679,12 @@ sk_sp ColorSelector::buildEffect(const char* code)
return result.effect;
}
}
+
+void ColorSelector::resetBottomEffect()
+{
+ m_bottomEffect.reset();
+}
+
#endif // SK_ENABLE_SKSL
} // namespace app
diff --git a/src/app/ui/color_selector.h b/src/app/ui/color_selector.h
index df2256520..438cd591b 100644
--- a/src/app/ui/color_selector.h
+++ b/src/app/ui/color_selector.h
@@ -104,6 +104,11 @@ namespace app {
// atomic because we need atomic bitwise operations.
std::atomic m_paintFlags;
+ protected:
+#if SK_ENABLE_SKSL
+ void resetBottomEffect();
+#endif
+
private:
app::Color getAlphaBarColor(const int u, const int umax);
void onPaintAlphaBar(ui::Graphics* g, const gfx::Rect& rc);
diff --git a/src/app/ui/color_tint_shade_tone.cpp b/src/app/ui/color_tint_shade_tone.cpp
index 86953b4ad..1eebf94f3 100644
--- a/src/app/ui/color_tint_shade_tone.cpp
+++ b/src/app/ui/color_tint_shade_tone.cpp
@@ -12,6 +12,7 @@
#include "app/ui/color_tint_shade_tone.h"
#include "app/color_utils.h"
+#include "app/pref/preferences.h"
#include "app/ui/skin/skin_theme.h"
#include "app/util/shader_helpers.h"
#include "ui/graphics.h"
@@ -26,6 +27,18 @@ using namespace ui;
ColorTintShadeTone::ColorTintShadeTone()
{
+ m_conn = Preferences::instance()
+ .experimental.hueWithSatValueForColorSelector.AfterChange.connect(
+ [this](){
+ m_paintFlags |= AllAreasFlag;
+
+#if SK_ENABLE_SKSL
+ m_bottomShader.clear();
+ resetBottomEffect();
+#endif
+
+ invalidate();
+ });
}
#if SK_ENABLE_SKSL
@@ -55,12 +68,20 @@ const char* ColorTintShadeTone::getBottomBarShader()
m_bottomShader += "uniform half3 iRes;"
"uniform half4 iHsv;";
m_bottomShader += kHSV_to_RGB_sksl;
- // TODO should we display the hue bar with the current sat/value?
- m_bottomShader += R"(
+
+ if (m_hueWithSatValue)
+ m_bottomShader += R"(
half4 main(vec2 fragcoord) {
half h = (fragcoord.x / iRes.x);
return hsv_to_rgb(half3(h, iHsv.y, iHsv.z)).rgb1;
}
+)";
+ else
+ m_bottomShader += R"(
+half4 main(vec2 fragcoord) {
+ half h = (fragcoord.x / iRes.x);
+ return hsv_to_rgb(half3(h, 1.0, 1.0)).rgb1;
+}
)";
}
return m_bottomShader.c_str();
@@ -107,11 +128,22 @@ void ColorTintShadeTone::onPaintMainArea(ui::Graphics* g, const gfx::Rect& rc)
}
}
+void ColorTintShadeTone::onPaint(ui::PaintEvent& ev)
+{
+ m_hueWithSatValue = Preferences::instance().experimental.hueWithSatValueForColorSelector();
+ ColorSelector::onPaint(ev);
+}
+
void ColorTintShadeTone::onPaintBottomBar(ui::Graphics* g, const gfx::Rect& rc)
{
if (m_color.getType() != app::Color::MaskType) {
double hue = m_color.getHsvHue();
- double val = m_color.getHsvValue();
+ double val;
+ if (m_hueWithSatValue)
+ val = m_color.getHsvValue();
+ else
+ val = 1.0;
+
gfx::Point pos(rc.x + int(rc.w * hue / 360.0),
rc.y + rc.h/2);
paintColorIndicator(g, pos, val < 0.5);
@@ -151,9 +183,16 @@ void ColorTintShadeTone::onPaintSurfaceInBgThread(
if (m_paintFlags & BottomBarFlag) {
os::Paint paint;
+ double sat, val;
- const double sat = m_color.getHsvSaturation();
- const double val = m_color.getHsvValue();
+ if (m_hueWithSatValue) {
+ sat = m_color.getHsvSaturation();
+ val = m_color.getHsvValue();
+ }
+ else {
+ sat = 1.0;
+ val = 1.0;
+ }
for (int x=0; x