Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a power-off button and clang-format #95

Merged
merged 1 commit into from
Jun 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion include/sst/jucegui/components/ButtonPainter.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ template <typename T> void paintButtonBG(T *that, juce::Graphics &g)
bg.withAlpha(0.f), that->getHeight() * 0.1);
g.setGradientFill(gr);
g.fillRoundedRectangle(b, rectCorner);

}

// Only call this in the 'on' state
Expand Down
2 changes: 2 additions & 0 deletions include/sst/jucegui/components/GlyphPainter.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ struct GlyphPainter : public juce::Component,

STEP_COUNT,
POWER_LIGHT,
POWER_LIGHT_OFF, // a special case of an off power light which isn't the
// grayed out filled power light

MUTE,

Expand Down
14 changes: 11 additions & 3 deletions src/sst/jucegui/components/GlyphPainter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -305,13 +305,20 @@ void paintStereoGlyph(juce::Graphics &g, const juce::Rectangle<int> &into)
}
}

void paintPowerLight(juce::Graphics &g, const juce::Rectangle<int> &into)
void paintPowerLight(juce::Graphics &g, const juce::Rectangle<int> &into, bool doFill)
{
auto rad = std::min(into.getWidth(), into.getHeight()) * 0.7 * 0.5;
auto bx = into.getCentreX();
auto by = into.getCentreY();

g.fillEllipse(bx - rad, by - rad, rad * 2, rad * 2);
if (doFill)
{
g.fillEllipse(bx - rad, by - rad, rad * 2, rad * 2);
}
else
{
g.drawEllipse(bx - rad, by - rad, rad * 2, rad * 2, 1);
}
}

void GlyphPainter::paint(juce::Graphics &g)
Expand Down Expand Up @@ -390,7 +397,8 @@ void GlyphPainter::paintGlyph(juce::Graphics &g, const juce::Rectangle<int> &int
return;

case POWER_LIGHT:
paintPowerLight(g, into);
case POWER_LIGHT_OFF:
paintPowerLight(g, into, glyph == POWER_LIGHT);
return;

default:
Expand Down
2 changes: 1 addition & 1 deletion src/sst/jucegui/components/HSlider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ void HSlider::paint(juce::Graphics &g)
if (r.getY() > newY)
r = r.withY(newY);
}

if (isHovered)
g.setColour(getColour(Styles::gutter_hover));
else
Expand Down
2 changes: 1 addition & 1 deletion src/sst/jucegui/components/JogUpDownButton.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ void JogUpDownButton::paint(juce::Graphics &g)

auto b = getLocalBounds().reduced(1).toFloat();

//auto ol = getColour(Styles::brightoutline);
// auto ol = getColour(Styles::brightoutline);
auto bg = getColour(Styles::fill);
auto tx = getColour(Styles::labelcolor);
auto ar = tx;
Expand Down
19 changes: 10 additions & 9 deletions src/sst/jucegui/components/MultiSwitch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,33 +85,34 @@ void MultiSwitch::paint(juce::Graphics &g)
// Selected option
g.setColour(getColour(Styles::valuebg));
g.fillRoundedRectangle(txtbg, rectCorner);

// Text
g.setColour(getColour(Styles::value));
}
else{
else
{
if (isH)
{
g.setColour(getColour(Styles::unselected_hover));
g.fillRoundedRectangle(txtbg, rectCorner);
g.setColour(getColour(Styles::labelcolor_hover));
}
else{
//g.setColour(getColour(Styles::background));
//g.fillRoundedRectangle(txtbg, rectCorner);
else
{
// g.setColour(getColour(Styles::background));
// g.fillRoundedRectangle(txtbg, rectCorner);
g.setColour(getColour(Styles::labelcolor));
}

}
g.setFont(getFont(Styles::labelfont));
g.drawText(data->getValueAsStringFor(i + data->getMin()), txt,
juce::Justification::centred);
juce::Justification::centred);
}

for (int i = 1; i < nItems; ++i)
{
break;

juce::Rectangle<float> rule;
if (direction == VERTICAL)
rule = b.toFloat().withY(h * i + 0.5).withHeight(1);
Expand All @@ -124,7 +125,7 @@ void MultiSwitch::paint(juce::Graphics &g)

// background outline
g.setColour(getColour(Styles::outline));
g.drawRoundedRectangle(bgb, rectCorner -1, 1);
g.drawRoundedRectangle(bgb, rectCorner - 1, 1);
}
}

Expand Down
7 changes: 6 additions & 1 deletion src/sst/jucegui/components/ToggleButton.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,12 @@ void ToggleButton::paint(juce::Graphics &g)
}
}

GlyphPainter::paintGlyph(g, getLocalBounds(), type, col);
auto paintType = type;
if (type == GlyphPainter::POWER_LIGHT && !v && !isHovered)
{
paintType = GlyphPainter::POWER_LIGHT_OFF;
}
GlyphPainter::paintGlyph(g, getLocalBounds(), paintType, col);
return;
}

Expand Down
Loading