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

Improve TuningRadial label orientation #7169

Merged
merged 2 commits into from
Aug 10, 2023
Merged
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
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