Skip to content

Commit

Permalink
Improve TuningRadial label orientation (#7169)
Browse files Browse the repository at this point in the history
* Improve TuningRadial label orientation

Bottom half flips in aligned; left side flips in rotated. etc

Closes #7165

* - Avoid ellipse with label in fint shrink case
  • Loading branch information
baconpaul authored Aug 10, 2023
1 parent aad142f commit ae87a84
Showing 1 changed file with 47 additions and 4 deletions.
51 changes: 47 additions & 4 deletions src/surge-xt/gui/overlays/TuningOverlays.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -943,14 +943,27 @@ void RadialScaleGraph::paint(juce::Graphics &g)

g.addTransform(t);
g.setColour(juce::Colours::white);
g.setFont(skin->fontManager->getLatoAtSize(0.1));
g.setFont(skin->fontManager->getLatoAtSize(0.1 * irsf));

auto msg = fmt::format("{:.2f}", intervals[i]);
auto tr =
juce::Rectangle<float>(0.f * irsf, -0.1f * irsf, 0.6f * irsf, 0.2f * irsf);

auto al = juce::Justification::centredLeft;
if (frac + hfrac > 0.5)
{
// left side rotated flip
g.addTransform(juce::AffineTransform()
.rotated(juce::MathConstants<double>::pi)
.translated(tr.getWidth(), 0));
al = juce::Justification::centredRight;
}
g.setColour(juce::Colours::white);
g.drawText(msg, tr, juce::Justification::centredLeft);
g.drawText(msg, tr, al);

// g.setColour(juce::Colours::red);
// g.drawRect(tr, 0.01 * irsf);
// g.setColour(juce::Colours::white);
}
else
{
Expand All @@ -972,6 +985,14 @@ void RadialScaleGraph::paint(juce::Graphics &g)
auto tr = juce::Rectangle<float>(-0.3f * irsf, -0.2f * irsf, 0.6f * irsf,
0.2f * irsf);

if (frac + hfrac >= 0.25 && frac + hfrac <= 0.75)
{
// underneath rotated flip
g.addTransform(juce::AffineTransform()
.rotated(juce::MathConstants<double>::pi)
.translated(0, -tr.getHeight()));
}

g.setColour(juce::Colours::white);
g.drawText(msg, tr, juce::Justification::centred);

Expand Down Expand Up @@ -1164,10 +1185,17 @@ void RadialScaleGraph::paint(juce::Graphics &g)
g.addTransform(t);
g.setColour(juce::Colours::white);
auto fs = 0.1 * irsf;
auto pushFac = 1.0;
if (fabs(dAngle) < 0.02)
{
pushFac = 1.03;
fs *= 0.75;
}
if (fabs(dAngle) < 0.012)
{
pushFac = 1.07;
fs *= 0.8;
}
// and that's as far as we go
g.setFont(skin->fontManager->getLatoAtSize(fs));

Expand All @@ -1178,9 +1206,24 @@ void RadialScaleGraph::paint(juce::Graphics &g)
tr = juce::Rectangle<float>(0.02f * irsf, -0.1f * irsf, 0.6f * irsf,
0.2f * irsf);

auto al = rot ? juce::Justification::centredLeft : juce::Justification::centred;
if (rot && ca > 0.5)
{
// left side rotated flip
g.addTransform(juce::AffineTransform()
.rotated(juce::MathConstants<double>::pi)
.translated(tr.getWidth() * pushFac, 0));
al = juce::Justification::centredRight;
}
if (!rot && ca > 0.25 && ca < 0.75)
{
// underneat rotated flip
g.addTransform(juce::AffineTransform()
.rotated(juce::MathConstants<double>::pi)
.translated(0, -tr.getHeight()));
}
g.setColour(juce::Colours::white);
g.drawText(msg, tr,
rot ? juce::Justification::centredLeft : juce::Justification::centred);
g.drawText(msg, tr, al);
// Useful to debug text layout
// g.setColour(rot ? juce::Colours::blue : juce::Colours::red);
// g.drawRect(tr, 0.01 * irsf);
Expand Down

0 comments on commit ae87a84

Please sign in to comment.