gearmulator

Emulation of classic VA synths of the late 90s/2000s that are based on Motorola 56300 family DSPs
Log | Files | Refs | Submodules | README | LICENSE

commit 645a6cfa159cff05de5dba6b15bfc262647440fc
parent d673b338464d1141b52fac55ebe20b374f03df22
Author: dsp56300 <dsp56300@users.noreply.github.com>
Date:   Sun, 13 Mar 2022 20:00:22 +0100

support toggle buttons, radio group ID and horizontal tiling

Diffstat:
Msource/jucePlugin/genericUI/buttonStyle.cpp | 20++++++++++++++++++--
Msource/jucePlugin/genericUI/buttonStyle.h | 5++++-
Msource/jucePlugin/genericUI/uiObject.cpp | 2+-
3 files changed, 23 insertions(+), 4 deletions(-)

diff --git a/source/jucePlugin/genericUI/buttonStyle.cpp b/source/jucePlugin/genericUI/buttonStyle.cpp @@ -8,6 +8,9 @@ namespace genericUI { UiObjectStyle::apply(_editor, _object); + m_isToggle = _object.getPropertyInt("isToggle") != 0; + m_radioGroupId = _object.getPropertyInt("radioGroupId"); + if(!m_drawable) return; @@ -33,6 +36,8 @@ namespace genericUI "disabledImageOn" }; + const bool isVerticalTiling = m_tileSizeY <= (m_drawable->getHeight()>>1); + static_assert(std::size(imageDrawables) == std::size(properties), "arrays must have same size"); std::map<int, juce::Drawable*> drawables; @@ -57,7 +62,10 @@ namespace genericUI { m_createdDrawables.emplace_back(d->createCopy()); d = m_createdDrawables.back().get(); - d->setOriginWithOriginalSize({0, static_cast<float>(-imageIndex * m_tileSizeY)}); + if(isVerticalTiling) + d->setOriginWithOriginalSize({0, static_cast<float>(-imageIndex * m_tileSizeY)}); + else + d->setOriginWithOriginalSize({static_cast<float>(-imageIndex * m_tileSizeX), 0.0f}); } *imageDrawables[i] = d; drawables.insert(std::make_pair(imageIndex, d)); @@ -65,8 +73,16 @@ namespace genericUI } } - void ButtonStyle::setImages(juce::DrawableButton& _button) const + void ButtonStyle::apply(juce::DrawableButton& _button) const { + _button.setColour(juce::DrawableButton::ColourIds::backgroundColourId, juce::Colours::transparentBlack); + _button.setColour(juce::DrawableButton::ColourIds::backgroundOnColourId, juce::Colours::transparentBlack); + + _button.setClickingTogglesState(m_isToggle); + + if(m_radioGroupId) + _button.setRadioGroupId(m_radioGroupId); + _button.setImages(m_normalImage, m_overImage, m_downImage, m_disabledImage, m_normalImageOn, m_overImageOn, m_downImageOn, m_disabledImageOn); } } diff --git a/source/jucePlugin/genericUI/buttonStyle.h b/source/jucePlugin/genericUI/buttonStyle.h @@ -8,9 +8,12 @@ namespace genericUI { public: void apply(Editor& _editor, const UiObject& _object) override; - void setImages(juce::DrawableButton& _button) const; + void apply(juce::DrawableButton& _button) const; private: + bool m_isToggle = false; + int m_radioGroupId = 0; + juce::Drawable* m_normalImage = nullptr; juce::Drawable* m_overImage = nullptr; juce::Drawable* m_downImage = nullptr; diff --git a/source/jucePlugin/genericUI/uiObject.cpp b/source/jucePlugin/genericUI/uiObject.cpp @@ -88,7 +88,7 @@ namespace genericUI apply(_editor, static_cast<juce::Component&>(_target)); auto* s = new ButtonStyle(); createStyle(_editor, _target, s); - s->setImages(_target); + s->apply(_target); bindParameter(_editor, _target); }