Skip to content

Commit

Permalink
setup enum'ed rotary slider gradients, implement in batch tools sliders
Browse files Browse the repository at this point in the history
  • Loading branch information
vsicurella committed Jul 17, 2024
1 parent 797af9d commit 3cdc39e
Show file tree
Hide file tree
Showing 4 changed files with 94 additions and 29 deletions.
92 changes: 66 additions & 26 deletions Source/LumatoneEditorLookAndFeel.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,29 +22,25 @@ 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();
}

}

// 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
{
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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));
Expand All @@ -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<float>& 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;
Expand Down
27 changes: 24 additions & 3 deletions Source/LumatoneEditorStyleCommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions Source/mapping_editors/BatchToolsColourControls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,23 @@ 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());

hue = std::make_unique<juce::Slider>("BatchToolsHueSlider");
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());

temperature = std::make_unique<juce::Slider>("BatchToolsTemperatureSlider");
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());

Expand Down
1 change: 1 addition & 0 deletions Source/mapping_editors/MappingSettingsControls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 3cdc39e

Please sign in to comment.