Skip to content

Commit

Permalink
NamedPanel vertical mode and Glyph_BG outlines also (#125)
Browse files Browse the repository at this point in the history
  • Loading branch information
baconpaul authored Sep 3, 2024
1 parent acd4dfc commit 9a4091a
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 12 deletions.
3 changes: 2 additions & 1 deletion include/sst/jucegui/components/NamedPanelDivider.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ struct NamedPanelDivider : public juce::Component,
}
};

NamedPanelDivider();
bool isHorizontal{true};
NamedPanelDivider(bool isHorizontal = true);
~NamedPanelDivider();

void paint(juce::Graphics &g) override;
Expand Down
33 changes: 23 additions & 10 deletions src/sst/jucegui/components/NamedPanelDivider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,34 @@
namespace sst::jucegui::components
{

NamedPanelDivider::NamedPanelDivider() : style::StyleConsumer(Styles::styleClass) {}
NamedPanelDivider::NamedPanelDivider(bool isH)
: isHorizontal(isH), style::StyleConsumer(Styles::styleClass)
{
}

NamedPanelDivider::~NamedPanelDivider() {}

void NamedPanelDivider::paint(juce::Graphics &g)
{
g.setColour(getColour(Styles::outline));

auto divH = 2;
auto margin = 10;
auto innerMargin = 5;
auto r = getLocalBounds().toFloat().withSizeKeepingCentre(getWidth() - 10, divH);
auto ls = r.withWidth(r.getWidth() / 2 - innerMargin / 2);
g.fillRoundedRectangle(ls, divH / 2);
ls = ls.translated(r.getWidth() / 2 + innerMargin / 2, 0);
g.fillRoundedRectangle(ls, divH / 2);

if (isHorizontal)
{
g.setColour(getColour(Styles::outline));

auto margin = 10;
auto innerMargin = 5;
auto r = getLocalBounds().toFloat().withSizeKeepingCentre(getWidth() - 10, divH);
auto ls = r.withWidth(r.getWidth() / 2 - innerMargin / 2);
g.fillRoundedRectangle(ls, divH / 2);
ls = ls.translated(r.getWidth() / 2 + innerMargin / 2, 0);
g.fillRoundedRectangle(ls, divH / 2);
}
else
{
g.setColour(getColour(Styles::outline));
auto d = getLocalBounds().withSizeKeepingCentre(divH, getHeight());
g.fillRoundedRectangle(d.toFloat(), divH / 2);
}
}
} // namespace sst::jucegui::components
11 changes: 10 additions & 1 deletion src/sst/jucegui/components/ToggleButton.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,16 @@ void ToggleButton::paint(juce::Graphics &g)
{
if (drawMode == DrawMode::GLYPH_WITH_BG)
{
paintButtonBG(this, g);
v = v && (drawMode != DrawMode::LABELED_BY_DATA);

if (v)
{
paintButtonOnValueBG(this, g);
}
else
{
paintButtonBG(this, g);
}
}

juce::Colour col = juce::Colours::red;
Expand Down

0 comments on commit 9a4091a

Please sign in to comment.