From 3cdc39e9650f83adb2e1ecc5354c1f328b87b7c7 Mon Sep 17 00:00:00 2001 From: Vincenzo Sicurella Date: Tue, 16 Jul 2024 20:59:42 -0400 Subject: [PATCH] setup enum'ed rotary slider gradients, implement in batch tools sliders --- Source/LumatoneEditorLookAndFeel.h | 92 +++++++++++++------ Source/LumatoneEditorStyleCommon.h | 27 +++++- .../BatchToolsColourControls.cpp | 3 + .../MappingSettingsControls.cpp | 1 + 4 files changed, 94 insertions(+), 29 deletions(-) diff --git a/Source/LumatoneEditorLookAndFeel.h b/Source/LumatoneEditorLookAndFeel.h index f172f8d..e1243c8 100644 --- a/Source/LumatoneEditorLookAndFeel.h +++ b/Source/LumatoneEditorLookAndFeel.h @@ -22,13 +22,13 @@ class LumatoneEditorLookAndFeel : public LookAndFeel_V4 { public: - LumatoneEditorLookAndFeel(const LumatoneEditorFontLibrary& appFontsIn, bool doImageCache = false) + LumatoneEditorLookAndFeel(const LumatoneEditorFontLibrary& appFontsIn, bool setupAssets = false) : appFonts(appFontsIn) , compactWindowStyle(this) { setupDefaultColours(); - if (doImageCache) + if (setupAssets) { cacheImages(); cacheIcons(); @@ -36,15 +36,11 @@ class LumatoneEditorLookAndFeel : public LookAndFeel_V4 } - // LumatoneEditorLookAndFeel(const LumatoneEditorLookAndFeel& lafCopy) - // : appFonts(lafCopy.appFonts), - // saveIconPath(lafCopy.saveIconPath), - // arrowUpIconPath(lafCopy.arrowUpIconPath), - // arrowDownIconPath(lafCopy.arrowDownIconPath), - // compactWindowStyle(this) - // { - // setupDefaultColours(); - // } + ~LumatoneEditorLookAndFeel() + { + colourGradientDictionary = nullptr; + colourGradients = nullptr; + } Font getAppFont(LumatoneEditorFont fontIdIn, float heightIn=12.0f) const { @@ -626,22 +622,13 @@ class LumatoneEditorLookAndFeel : public LookAndFeel_V4 addArcToPath(ring, innerBounds, rotaryAngleEnd, rotaryAngleStart, false); ring.closeSubPath(); - Colour minColour = findColour(LumatoneEditorColourIDs::RotaryGradientMin); - Colour maxColour = findColour(LumatoneEditorColourIDs::RotaryGradientMax); - Colour dialColour = Colours::white; - - if (!sld.isEnabled()) - { - minColour = minColour.overlaidWith(findColour(LumatoneEditorColourIDs::DisabledOverlay)); - maxColour = maxColour.overlaidWith(findColour(LumatoneEditorColourIDs::DisabledOverlay)); - dialColour = findColour(LumatoneEditorColourIDs::InactiveText); - } - - ColourGradient grad = ColourGradient::horizontal(minColour, maxColour, outerBounds); + LumatoneEditorColourGradients gradientId = LumatoneEditorColourGradients((int)sld.getProperties()[LumatoneEditorStyleIDs::sliderRotaryColourGradient]); + juce::ColourGradient grad = getColourGradient(gradientId, outerBounds); g.setGradientFill(grad); g.fillPath(ring); - g.setColour(Colours::white); + Colour dialColour = Colours::white; + g.setColour(dialColour); float dialRadius = size * dialRadiusFactor * 0.5f; float dialThickness = size * 0.025f; @@ -1381,11 +1368,22 @@ class LumatoneEditorLookAndFeel : public LookAndFeel_V4 setColour(LumatoneEditorColourIDs::CurveGradientMin, Colour(0xffbf961e)); setColour(LumatoneEditorColourIDs::CurveGradientMax, Colour(0xffcd6f2e)); setColour(LumatoneEditorColourIDs::CurveGridColour, Colour(0xff303030)); - setColour(LumatoneEditorColourIDs::RotaryGradientMin, Colour(0xff5497b6)); - setColour(LumatoneEditorColourIDs::RotaryGradientMax, Colour(0xff77a8b3)); setColour(LumatoneEditorColourIDs::DisabledOverlay, Colour(0x601b1b1b)); setColour(LumatoneEditorColourIDs::MenuBarBackground, Colour(0xff1a1b1c)); + // Gradients + setColour(LumatoneEditorColourIDs::ExprRotaryGradientMin, Colour(0xff5497b6)); + setColour(LumatoneEditorColourIDs::ExprRotaryGradientMax, Colour(0xff77a8b3)); + setColour(LumatoneEditorColourIDs::BrightnessRotaryGradientMin, Colour(0xff293044)); + setColour(LumatoneEditorColourIDs::BrightnessRotaryGradientMax, Colour(0xffaac1dd)); + setColour(LumatoneEditorColourIDs::HueRotaryGradientMin, Colour(0xffd4838b)); + setColour(LumatoneEditorColourIDs::HueRotaryGradientMid, Colour(0xff8dd48f)); + setColour(LumatoneEditorColourIDs::HueRotaryGradientMax, Colour(0xff8495d4)); + setColour(LumatoneEditorColourIDs::TempRotaryGradientMin, Colour(0xffd4838b)); + setColour(LumatoneEditorColourIDs::TempRotaryGradientMid, Colour(0xffe8e8e8)); + setColour(LumatoneEditorColourIDs::TempRotaryGradientMax, Colour(0xff8495d4)); + + // Component defaults setColour(TextButton::ColourIds::buttonOnColourId, Colour(0xff383b3d)); setColour(TextButton::ColourIds::buttonColourId, Colour(0xff383b3d)); @@ -1408,6 +1406,48 @@ class LumatoneEditorLookAndFeel : public LookAndFeel_V4 setColour(AlertWindow::ColourIds::outlineColourId, findColour(LumatoneEditorColourIDs::MediumBackground)); } +public: + + juce::ColourGradient LumatoneEditorLookAndFeel::getColourGradient(LumatoneEditorColourGradients gradientId, const juce::Rectangle& area) const + { + switch (gradientId) + { + default: + break; + + case LumatoneEditorColourGradients::ExpressionSlider: + return juce::ColourGradient::horizontal( + findColour(LumatoneEditorColourIDs::ExprRotaryGradientMin), + findColour(LumatoneEditorColourIDs::ExprRotaryGradientMax), + area); + case LumatoneEditorColourGradients::BrightnessSlider: + return juce::ColourGradient::horizontal( + findColour(LumatoneEditorColourIDs::BrightnessRotaryGradientMin), + findColour(LumatoneEditorColourIDs::BrightnessRotaryGradientMax), + area); + + case LumatoneEditorColourGradients::HueSlider: + { + juce::ColourGradient g = juce::ColourGradient(findColour(LumatoneEditorColourIDs::HueRotaryGradientMin), area.getTopLeft(), + findColour(LumatoneEditorColourIDs::HueRotaryGradientMax), area.getTopRight(), + false); + g.addColour(0.5f, findColour(LumatoneEditorColourIDs::HueRotaryGradientMid)); + return g; + } + + case LumatoneEditorColourGradients::TemperatureSlider: + { + juce::ColourGradient g = juce::ColourGradient(findColour(LumatoneEditorColourIDs::TempRotaryGradientMin), area.getTopLeft(), + findColour(LumatoneEditorColourIDs::TempRotaryGradientMax), area.getTopRight(), + false); + g.addColour(0.5f, findColour(LumatoneEditorColourIDs::TempRotaryGradientMid)); + return g; + } + } + + return juce::ColourGradient(); + } + private: const LumatoneEditorFontLibrary& appFonts; diff --git a/Source/LumatoneEditorStyleCommon.h b/Source/LumatoneEditorStyleCommon.h index 59be398..81150d4 100644 --- a/Source/LumatoneEditorStyleCommon.h +++ b/Source/LumatoneEditorStyleCommon.h @@ -624,10 +624,27 @@ enum LumatoneEditorColourIDs CurveGradientMin, CurveGradientMax, CurveGridColour, - RotaryGradientMin, - RotaryGradientMax, DisabledOverlay, - MenuBarBackground + MenuBarBackground, + + ExprRotaryGradientMax, + ExprRotaryGradientMin, + BrightnessRotaryGradientMin, + BrightnessRotaryGradientMax, + HueRotaryGradientMin, + HueRotaryGradientMid, + HueRotaryGradientMax, + TempRotaryGradientMin, + TempRotaryGradientMid, + TempRotaryGradientMax +}; + +enum LumatoneEditorColourGradients +{ + ExpressionSlider, + BrightnessSlider, + HueSlider, + TemperatureSlider }; namespace LumatoneEditorStyleIDs @@ -680,7 +697,11 @@ namespace LumatoneEditorStyleIDs static Identifier comboBoxEditorRestrictedChars = Identifier("ComboBoxEditorRestrictedChars"); static Identifier comboBoxEditorRestrictedLength = Identifier("ComboBoxEditorRestrictedLength"); + // Check combo box items for colour hex strings, render if they pass static Identifier comboBoxRenderColourItems = Identifier("ComboBoxRenderColourItems"); + + // Specify LumatoneEditorColourGradient id for rotary Slider + static Identifier sliderRotaryColourGradient = Identifier("SliderRotaryColourGradient"); } // LookAndFeel doesn't have Slider IncDec button access in drawIncDecButtonsBackground diff --git a/Source/mapping_editors/BatchToolsColourControls.cpp b/Source/mapping_editors/BatchToolsColourControls.cpp index a6fab8e..23128fb 100644 --- a/Source/mapping_editors/BatchToolsColourControls.cpp +++ b/Source/mapping_editors/BatchToolsColourControls.cpp @@ -11,6 +11,7 @@ BatchToolsColourControls::BatchToolsColourControls(const LumatoneEditorState & s brightness->setRange (0, 127, 1); brightness->setSliderStyle (juce::Slider::RotaryHorizontalVerticalDrag); brightness->setTextBoxStyle (juce::Slider::TextBoxBelow, false, 60, 20); + brightness->getProperties().set(LumatoneEditorStyleIDs::sliderRotaryColourGradient, (int)LumatoneEditorColourGradients::BrightnessSlider); brightness->onValueChange = [&] () {}; addAndMakeVisible (brightness.get()); @@ -18,6 +19,7 @@ BatchToolsColourControls::BatchToolsColourControls(const LumatoneEditorState & s hue->setRange (0, 127, 1); hue->setSliderStyle (juce::Slider::RotaryHorizontalVerticalDrag); hue->setTextBoxStyle (juce::Slider::TextBoxBelow, false, 60, 20); + hue->getProperties().set(LumatoneEditorStyleIDs::sliderRotaryColourGradient, (int)LumatoneEditorColourGradients::HueSlider); hue->onValueChange = [&] () {}; addAndMakeVisible (hue.get()); @@ -25,6 +27,7 @@ BatchToolsColourControls::BatchToolsColourControls(const LumatoneEditorState & s temperature->setRange (0, 127, 1); temperature->setSliderStyle (juce::Slider::RotaryHorizontalVerticalDrag); temperature->setTextBoxStyle (juce::Slider::TextBoxBelow, false, 60, 20); + temperature->getProperties().set(LumatoneEditorStyleIDs::sliderRotaryColourGradient, (int)LumatoneEditorColourGradients::TemperatureSlider); temperature->onValueChange = [&] () {}; addAndMakeVisible (temperature.get()); diff --git a/Source/mapping_editors/MappingSettingsControls.cpp b/Source/mapping_editors/MappingSettingsControls.cpp index cde48cc..cc8c2fb 100644 --- a/Source/mapping_editors/MappingSettingsControls.cpp +++ b/Source/mapping_editors/MappingSettingsControls.cpp @@ -70,6 +70,7 @@ MappingSettingsControls::MappingSettingsControls (const LumatoneEditorState& sta sldExprCtrlSensitivity->setRange (0, 127, 1); sldExprCtrlSensitivity->setSliderStyle (juce::Slider::RotaryHorizontalVerticalDrag); sldExprCtrlSensitivity->setTextBoxStyle (juce::Slider::TextBoxBelow, false, 60, 20); + sldExprCtrlSensitivity->getProperties().set(LumatoneEditorStyleIDs::sliderRotaryColourGradient, (int)LumatoneEditorColourGradients::ExpressionSlider); sldExprCtrlSensitivity->onValueChange = [&] () { exprSensitivitySliderCallback();