Skip to content

Commit

Permalink
Some six sines discorvered improvlements (#146)
Browse files Browse the repository at this point in the history
1. Jog up down button has consistent not-enabled state.
baconpaul/six-sines#110
  • Loading branch information
baconpaul authored Jan 14, 2025
1 parent 8211137 commit 311eed9
Showing 1 changed file with 8 additions and 19 deletions.
27 changes: 8 additions & 19 deletions src/sst/jucegui/components/JogUpDownButton.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,32 +50,21 @@ void JogUpDownButton::paint(juce::Graphics &g)
har = getColour(Styles::jogbutton_hover);
}

if (!isEnabled())
{
g.setColour(bg.withAlpha(0.5f));
g.drawRoundedRectangle(b, rectCorner, 1);

auto col = har.withAlpha(0.5f);
auto bl = b.withWidth(b.getHeight()).toNearestInt();
GlyphPainter::paintGlyph(g, bl, GlyphPainter::GlyphType::JOG_LEFT, col);

bl = b.withLeft(b.getRight() - b.getHeight()).toNearestInt();
GlyphPainter::paintGlyph(g, bl, GlyphPainter::GlyphType::JOG_RIGHT, col);
return;
}
float alpha = isEnabled() ? 1.f : 0.5f;

g.setColour(bg);
g.setColour(bg.withAlpha(alpha));
g.fillRoundedRectangle(b, rectCorner);

if (!data)
return;

g.setFont(getFont(Styles::labelfont));
g.setColour(tx);
g.setColour(tx.withAlpha(alpha));
g.drawText(data->getValueAsString(), b, juce::Justification::centred);

auto jwa = data->jogWrapsAtEnd;
auto col = hoverX < b.getHeight() ? har : ar;
col = col.withAlpha(alpha);
if (!jwa && data->getValue() == data->getMin())
{
col = ar.withAlpha(0.5f);
Expand All @@ -84,6 +73,7 @@ void JogUpDownButton::paint(juce::Graphics &g)
GlyphPainter::paintGlyph(g, bl, GlyphPainter::GlyphType::JOG_LEFT, col);

col = hoverX > b.getRight() - b.getHeight() ? har : ar;
col = col.withAlpha(alpha);
if (!jwa && data->getValue() == data->getMax())
{
col = ar.withAlpha(0.5f);
Expand All @@ -94,9 +84,8 @@ void JogUpDownButton::paint(juce::Graphics &g)

void JogUpDownButton::mouseDown(const juce::MouseEvent &e)
{
if (isEnabled() && data &&
(e.mods.isPopupMenu() ||
(e.position.x > getHeight() && e.position.x < (getWidth() - getHeight()))))
if (data && (e.mods.isPopupMenu() ||
(e.position.x > getHeight() && e.position.x < (getWidth() - getHeight()))))
{
showPopup(e.mods);
return;
Expand Down Expand Up @@ -134,7 +123,7 @@ void JogUpDownButton::mouseUp(const juce::MouseEvent &e)
if (e.position.x > getWidth() - getHeight())
jog = 1;

if (data && isEnabled() && jog != 0)
if (data && jog != 0)
{
if (popupMenuBuilder)
{
Expand Down

0 comments on commit 311eed9

Please sign in to comment.