From b2462192c43b70e42ddb47b2e6b25d3ddc604b9a Mon Sep 17 00:00:00 2001 From: Paul Walker Date: Mon, 2 Sep 2024 13:36:55 -0400 Subject: [PATCH] Add glyph with bg draw mode to toggle butotn --- include/sst/jucegui/components/ToggleButton.h | 4 +++- src/sst/jucegui/components/ToggleButton.cpp | 11 ++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/include/sst/jucegui/components/ToggleButton.h b/include/sst/jucegui/components/ToggleButton.h index 2900092..ab6498a 100644 --- a/include/sst/jucegui/components/ToggleButton.h +++ b/include/sst/jucegui/components/ToggleButton.h @@ -62,6 +62,7 @@ struct ToggleButton : DiscreteParamEditor, LABELED_BY_DATA, FILLED, GLYPH, + GLYPH_WITH_BG, DUAL_GLYPH, } drawMode{DrawMode::LABELED}; @@ -76,7 +77,8 @@ struct ToggleButton : DiscreteParamEditor, offType{GlyphPainter::SMALL_POWER_LIGHT_OFF}; void setGlyph(GlyphPainter::GlyphType gt) { - if (drawMode != DrawMode::GLYPH && drawMode != DrawMode::DUAL_GLYPH) + if (drawMode != DrawMode::GLYPH && drawMode != DrawMode::DUAL_GLYPH && + drawMode != DrawMode::GLYPH_WITH_BG) drawMode = DrawMode::GLYPH; type = gt; repaint(); diff --git a/src/sst/jucegui/components/ToggleButton.cpp b/src/sst/jucegui/components/ToggleButton.cpp index fe19dd6..e94bda7 100644 --- a/src/sst/jucegui/components/ToggleButton.cpp +++ b/src/sst/jucegui/components/ToggleButton.cpp @@ -34,8 +34,8 @@ void ToggleButton::paint(juce::Graphics &g) { bool v = data ? data->getValue() : false; - if (drawMode != DrawMode::GLYPH && drawMode != DrawMode::DUAL_GLYPH && - drawMode != DrawMode::FILLED) + if (drawMode != DrawMode::GLYPH && drawMode != DrawMode::GLYPH_WITH_BG && + drawMode != DrawMode::DUAL_GLYPH && drawMode != DrawMode::FILLED) { v = v && (drawMode != DrawMode::LABELED_BY_DATA); @@ -89,8 +89,13 @@ void ToggleButton::paint(juce::Graphics &g) g.setColour(getColour(Styles::labelcolor)); } - if (drawMode == DrawMode::GLYPH) + if (drawMode == DrawMode::GLYPH || drawMode == DrawMode::GLYPH_WITH_BG) { + if (drawMode == DrawMode::GLYPH_WITH_BG) + { + paintButtonBG(this, g); + } + juce::Colour col = juce::Colours::red; if (v) {