diff --git a/include/sst/jucegui/components/BaseStyles.h b/include/sst/jucegui/components/BaseStyles.h index 59b50ae..bfd9baa 100644 --- a/include/sst/jucegui/components/BaseStyles.h +++ b/include/sst/jucegui/components/BaseStyles.h @@ -50,7 +50,13 @@ struct Base { SCLASS(base); PROP(background); - static void initialize() { style::StyleSheet::addClass(styleClass).withProperty(background); } + PROP(background_hover); + static void initialize() + { + style::StyleSheet::addClass(styleClass) + .withProperty(background) + .withProperty(background_hover); + } }; struct SelectableRegion diff --git a/include/sst/jucegui/components/ButtonPainter.h b/include/sst/jucegui/components/ButtonPainter.h index edde19d..0657c7e 100644 --- a/include/sst/jucegui/components/ButtonPainter.h +++ b/include/sst/jucegui/components/ButtonPainter.h @@ -24,7 +24,7 @@ namespace sst::jucegui::components { template void paintButtonBG(T *that, juce::Graphics &g) { - float rectCorner = 1.5; + float rectCorner = 1; auto b = that->getLocalBounds().reduced(1).toFloat(); @@ -61,7 +61,7 @@ template void paintButtonBG(T *that, juce::Graphics &g) // Only call this in the 'on' state template void paintButtonOnValueBG(T *that, juce::Graphics &g) { - float rectCorner = 1.5; + float rectCorner = 1; auto b = that->getLocalBounds().reduced(1).toFloat(); auto bg = that->getColour(T::Styles::fill); diff --git a/include/sst/jucegui/components/ToggleButton.h b/include/sst/jucegui/components/ToggleButton.h index b5d02dd..2900092 100644 --- a/include/sst/jucegui/components/ToggleButton.h +++ b/include/sst/jucegui/components/ToggleButton.h @@ -40,12 +40,16 @@ struct ToggleButton : DiscreteParamEditor, ToggleButton(); ~ToggleButton(); - struct Styles : base_styles::PushButton, base_styles::BaseLabel, base_styles::ValueBearing + struct Styles : base_styles::Base, + base_styles::PushButton, + base_styles::BaseLabel, + base_styles::ValueBearing { SCLASS(togglebutton); static void initialize() { style::StyleSheet::addClass(styleClass) + .withBaseClass(base_styles::Base::styleClass) .withBaseClass(base_styles::PushButton::styleClass) .withBaseClass(base_styles::BaseLabel::styleClass) .withBaseClass(base_styles::ValueBearing::styleClass); diff --git a/src/sst/jucegui/components/ToggleButton.cpp b/src/sst/jucegui/components/ToggleButton.cpp index 3ab8300..fe19dd6 100644 --- a/src/sst/jucegui/components/ToggleButton.cpp +++ b/src/sst/jucegui/components/ToggleButton.cpp @@ -34,7 +34,8 @@ void ToggleButton::paint(juce::Graphics &g) { bool v = data ? data->getValue() : false; - if (drawMode != DrawMode::GLYPH && drawMode != DrawMode::DUAL_GLYPH) + if (drawMode != DrawMode::GLYPH && drawMode != DrawMode::DUAL_GLYPH && + drawMode != DrawMode::FILLED) { v = v && (drawMode != DrawMode::LABELED_BY_DATA); @@ -48,6 +49,31 @@ void ToggleButton::paint(juce::Graphics &g) } } + if (drawMode == DrawMode::FILLED) + { + if (isHovered) + { + if (v) + g.setColour(getColour(Styles::labelcolor_hover)); + else + g.setColour(getColour(Styles::background_hover)); + } + else + { + if (v) + g.setColour(getColour(Styles::labelcolor)); + else + g.setColour(getColour(Styles::background)); + } + + auto b = getLocalBounds().reduced(2).toFloat(); + g.fillRoundedRectangle(b, 1.f); // corner size should match those in ButtonPainter.h + + // Draw outline + g.setColour(getColour(Styles::brightoutline)); + g.drawRoundedRectangle(b, 1.f, 1.f); + } + if (isHovered) { if (v)