Skip to content
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
3 changes: 3 additions & 0 deletions include/sst/jucegui/components/GlyphPainter.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,13 +117,16 @@ struct GlyphPainter : public juce::Component,
PORTAMENTO,
CURVE,
POLYPHONY,
DICE,

FREEZE,
NOTE_PRIORITY,

MONO,
STEREO,

HAMBURGER,

SURGE_LOGO,
SHORTCIRCUIT_LOGO
// the order doesn't matter but we iterate in the demo so
Expand Down
9 changes: 9 additions & 0 deletions include/sst/jucegui/components/JogUpDownButton.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,17 @@ struct JogUpDownButton : DiscreteParamEditor,
}
};

enum ArrowPosition
{
LEFT_AND_RIGHT,
RIGHT_SIDE
} arrowPosition{LEFT_AND_RIGHT};

std::function<void()> onPopupMenu{nullptr};

juce::Rectangle<int> leftButtonBound() const, rightButtonBound() const;
virtual bool isOverControl(const juce::Point<int> &) const;

void mouseDown(const juce::MouseEvent &e) override;
void mouseUp(const juce::MouseEvent &e) override;

Expand Down
7 changes: 7 additions & 0 deletions include/sst/jucegui/components/NamedPanel.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,13 @@ struct NamedPanel : public juce::Component,
repaint();
}

enum LabelPosition
{
IN_RULE,
IN_BORDER // As of this writing, ths is only testred if you have no adornments (power
// switch, hamburger, etc)
} labelPosition{IN_RULE};

/*
* Named panels can have tab selections as their named
* bar.
Expand Down
25 changes: 24 additions & 1 deletion src/sst/jucegui/components/GlyphPainter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ static juce::Rectangle<float> centeredSquareIn(const juce::Rectangle<int> &into)
return into.withSizeKeepingCentre(sz, sz).toFloat();
}

static void paintHamburgerGlyph(juce::Graphics &g, const juce::Rectangle<int> &into)
static void paintHamburger(juce::Graphics &g, const juce::Rectangle<int> &into)
{
auto sq = centeredSquareIn(into).reduced(1, 1);
auto h = sq.getHeight();
Expand Down Expand Up @@ -134,6 +134,21 @@ void paintFromSvg(juce::Graphics &g, const juce::Rectangle<int> &into, const std
}
}

void paintDice(juce::Graphics &g, const juce::Rectangle<int> &into)
{
auto bx = into.reduced(3);
g.drawRoundedRectangle(bx.toFloat(), 2, 1);
auto sy = bx.getHeight() * 0.25;
auto cs = bx.getHeight() * 0.075;
juce::Graphics::ScopedSaveState ss(g);
g.addTransform(juce::AffineTransform().translated(bx.getX(), bx.getY()));
g.fillEllipse(sy - cs, sy - cs, cs * 2, cs * 2);
g.fillEllipse(3 * sy - cs, sy - cs, cs * 2, cs * 2);
g.fillEllipse(2 * sy - cs, 2 * sy - cs, cs * 2, cs * 2);
g.fillEllipse(sy - cs, 3 * sy - cs, cs * 2, cs * 2);
g.fillEllipse(3 * sy - cs, 3 * sy - cs, cs * 2, cs * 2);
}

void paintStereoGlyph(juce::Graphics &g, const juce::Rectangle<int> &into)
{
auto rad = std::min(into.getWidth(), into.getHeight()) * 0.8 * 0.5;
Expand Down Expand Up @@ -268,6 +283,14 @@ void GlyphPainter::paintGlyph(juce::Graphics &g, const juce::Rectangle<int> &int
paintPowerLight(g, into, glyph == SMALL_POWER_LIGHT);
return;

case HAMBURGER:
paintHamburger(g, into);
return;

case DICE:
paintDice(g, into);
return;

default:
{
auto w = std::min(into.getHeight(), into.getWidth());
Expand Down
44 changes: 34 additions & 10 deletions src/sst/jucegui/components/JogUpDownButton.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,26 @@ JogUpDownButton::~JogUpDownButton()
}
}

juce::Rectangle<int> JogUpDownButton::leftButtonBound() const
{
if (arrowPosition == ArrowPosition::LEFT_AND_RIGHT)
{
auto bx = getLocalBounds().reduced(1);
return bx.withWidth(bx.getHeight());
}
else
{
auto bx = getLocalBounds().reduced(1);
return bx.withTrimmedLeft(bx.getWidth() - 2 * bx.getHeight()).withWidth(bx.getHeight());
}
}

juce::Rectangle<int> JogUpDownButton::rightButtonBound() const
{
auto bx = getLocalBounds().reduced(1);
return bx.withTrimmedLeft(bx.getWidth() - bx.getHeight());
}

void JogUpDownButton::paint(juce::Graphics &g)
{
float rectCorner = 1.5;
Expand Down Expand Up @@ -63,29 +83,33 @@ void JogUpDownButton::paint(juce::Graphics &g)
g.drawText(data->getValueAsString(), b, juce::Justification::centred);

auto jwa = data->jogWrapsAtEnd;
auto col = hoverX < b.getHeight() ? har : ar;
auto lbb = leftButtonBound();
auto col = lbb.contains(hoverX, getHeight() / 2) ? har : ar;
col = col.withAlpha(alpha);
if (!jwa && data->getValue() == data->getMin())
{
col = ar.withAlpha(0.5f);
}
auto bl = b.withWidth(b.getHeight()).toNearestInt();
GlyphPainter::paintGlyph(g, bl, GlyphPainter::GlyphType::JOG_LEFT, col);
GlyphPainter::paintGlyph(g, lbb, GlyphPainter::GlyphType::JOG_LEFT, col);

col = hoverX > b.getRight() - b.getHeight() ? har : ar;
auto rbb = rightButtonBound();
col = rbb.contains(hoverX, getHeight() / 2) ? har : ar;
col = col.withAlpha(alpha);
if (!jwa && data->getValue() == data->getMax())
{
col = ar.withAlpha(0.5f);
}
bl = b.withLeft(b.getRight() - b.getHeight()).toNearestInt();
GlyphPainter::paintGlyph(g, bl, GlyphPainter::GlyphType::JOG_RIGHT, col);
GlyphPainter::paintGlyph(g, rbb, GlyphPainter::GlyphType::JOG_RIGHT, col);
}

bool JogUpDownButton::isOverControl(const juce::Point<int> &e) const
{
return leftButtonBound().contains(e) || rightButtonBound().contains(e);
}

void JogUpDownButton::mouseDown(const juce::MouseEvent &e)
{
if (data && (e.mods.isPopupMenu() ||
(e.position.x > getHeight() && e.position.x < (getWidth() - getHeight()))))
if (data && (e.mods.isPopupMenu() || !isOverControl(e.position.toInt())))
{
showPopup(e.mods);
return;
Expand Down Expand Up @@ -118,9 +142,9 @@ void JogUpDownButton::mouseUp(const juce::MouseEvent &e)
return;

auto jog = 0;
if (e.position.x < getHeight())
if (leftButtonBound().contains(e.position.toInt()))
jog = -1;
if (e.position.x > getWidth() - getHeight())
if (rightButtonBound().contains(e.position.toInt()))
jog = 1;

if (data && jog != 0)
Expand Down
33 changes: 28 additions & 5 deletions src/sst/jucegui/components/NamedPanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,26 +42,49 @@ void NamedPanel::paint(juce::Graphics &g)
return;
}
auto b = getLocalBounds().reduced(outerMargin);
if (labelPosition == IN_BORDER)
{
b = b.withTrimmedTop(headerHeight / 2);
}
juce::Colour bg{juce::Colours::red}, border{juce::Colours::red};
if (selectable && selected)
{
g.setColour(getColour(Styles::backgroundSelected));
bg = getColour(Styles::backgroundSelected);
}
else
{
g.setColour(getColour(Styles::background));
bg = getColour(Styles::background);
}
g.setColour(bg);

g.fillRoundedRectangle(b.toFloat(), cornerRadius);
if (isAccented)
{
g.setColour(getColour(Styles::accentedPanel));
border = getColour(Styles::accentedPanel);
}
else
{
g.setColour(getColour(Styles::brightoutline));
border = getColour(Styles::brightoutline);
}
g.setColour(border);
g.drawRoundedRectangle(b.toFloat(), cornerRadius, 1);

paintHeader(g);
if (labelPosition == IN_RULE)
paintHeader(g);
else
{
auto tb = getLocalBounds()
.reduced(outerMargin)
.withHeight(headerHeight)
.reduced(cornerRadius * 4, 0);
g.setFont(getFont(Styles::labelfont));
auto labelWidth = SST_STRING_WIDTH_INT(g.getCurrentFont(), name);
g.setColour(bg);
g.drawLine(b.getX() + 2 * cornerRadius, b.getY(), b.getX() + labelWidth + 6 * cornerRadius,
b.getY(), 1);
g.setColour(border);
g.drawText(name, tb, juce::Justification::centredLeft);
}
}

void NamedPanel::paintHeader(juce::Graphics &g)
Expand Down
2 changes: 1 addition & 1 deletion src/sst/jucegui/components/ToolTip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ void ToolTip::paint(juce::Graphics &g)
auto rowHeight = f.getHeight() + rowPad;

g.setColour(lbord);
g.drawLine(3, rowHeight + margin - rowPad / 2, getWidth() - 3, rowHeight + margin - rowPad / 2,
g.drawLine(3, rowHeight + margin + rowPad / 2, getWidth() - 3, rowHeight + margin + rowPad / 2,
1);

g.setColour(txtColour);
Expand Down