Skip to content

Commit

Permalink
VUMeter gets notches to look less like a slider gutter (#119)
Browse files Browse the repository at this point in the history
  • Loading branch information
baconpaul authored Aug 30, 2024
1 parent 22a0715 commit 18e109b
Showing 1 changed file with 34 additions and 3 deletions.
37 changes: 34 additions & 3 deletions include/sst/jucegui/components/VUMeter.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ struct VUMeter : public juce::Component, public style::StyleConsumer, public sty
auto vl = getHeight() - scale(L) * getHeight();
auto vr = getHeight() - scale(R) * getHeight();

int gap{2};
int gap{0};
auto rLeft = getLocalBounds().withWidth(getWidth() / 2).withTrimmedRight(gap);
auto rRight = getLocalBounds().withTrimmedLeft(getWidth() / 2 + gap);

Expand All @@ -101,9 +101,29 @@ struct VUMeter : public juce::Component, public style::StyleConsumer, public sty
g.fillRect(rRight.withTrimmedTop(vr));
}

g.setColour(getColour(Styles::vu_gutter));

// Dont' draw the top line hence the offset
for (int i = getHeight() - 2; i > vl + 1; i -= 3)
{
g.drawHorizontalLine(i, rLeft.getX(), rLeft.getX() + rLeft.getWidth());
}
for (int i = getHeight() - 2; i > vr + 1; i -= 3)
{
g.drawHorizontalLine(i, rRight.getX(), rRight.getX() + rRight.getWidth());
}

g.setColour(getColour(Styles::outline));
g.drawRect(rLeft, 1);
g.drawRect(rRight, 1);
if (gap == 0)
{
g.drawRect(getLocalBounds(), 1);
g.drawVerticalLine(getWidth() / 2.f, 0, getHeight());
}
else
{
g.drawRect(rLeft, 1);
g.drawRect(rRight, 1);
}
}
else
{
Expand Down Expand Up @@ -142,6 +162,17 @@ struct VUMeter : public juce::Component, public style::StyleConsumer, public sty
g.fillRect(rRight.withWidth(vr).withTrimmedLeft(zerodb));
}

g.setColour(getColour(Styles::vu_gutter));

for (int i = 2; i < vl; i += 3)
{
g.drawVerticalLine(i, rLeft.getY(), rLeft.getY() + rLeft.getHeight());
}
for (int i = 2; i < vr; i += 3)
{
g.drawVerticalLine(i, rRight.getY(), rRight.getY() + rRight.getHeight());
}

g.setColour(getColour(Styles::outline));
g.drawRect(getLocalBounds(), 1);
}
Expand Down

0 comments on commit 18e109b

Please sign in to comment.