Skip to content

Commit

Permalink
(int)getStringWidth -> getStringWidthInt (#7804)
Browse files Browse the repository at this point in the history
Sigh.
  • Loading branch information
baconpaul committed Sep 28, 2024
1 parent 110e13d commit 952217b
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ sub findfiles
if (m/getStringWidth/)
{
print;
s/([^\s\{]+).getStringWidthFloat\(/juce::GlyphArrangement::getStringWidth\($1, /;
# s/([^\s\{]+).getStringWidthFloat\(/juce::GlyphArrangement::getStringWidth\($1, /;
s/\(int\)juce::GlyphArrangement::getStringWidth/juce::GlyphArrangement::getStringWidthInt/;
print;
#die;
}
Expand Down
6 changes: 3 additions & 3 deletions src/surge-xt/gui/SurgeJUCELookAndFeel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ void SurgeJUCELookAndFeel::drawLabel(Graphics &graphics, Label &label)
int SurgeJUCELookAndFeel::getTabButtonBestWidth(TabBarButton &b, int d)
{
auto f = skin->getFont(Fonts::Widgets::TabButtonFont);
auto r = (int)juce::GlyphArrangement::getStringWidth(f, b.getButtonText()) + 20;
auto r = juce::GlyphArrangement::getStringWidthInt(f, b.getButtonText()) + 20;
return r;
}

Expand Down Expand Up @@ -238,8 +238,8 @@ void SurgeJUCELookAndFeel::drawDocumentWindowTitleBar(DocumentWindow &window, Gr
fontVersion = fontSurge;
}

auto sw = (int)juce::GlyphArrangement::getStringWidth(fontSurge, surgeLabel);
auto vw = (int)juce::GlyphArrangement::getStringWidth(fontVersion, surgeVersion);
auto sw = juce::GlyphArrangement::getStringWidthInt(fontSurge, surgeLabel);
auto vw = juce::GlyphArrangement::getStringWidthInt(fontVersion, surgeVersion);

auto icon = associatedBitmapStore->getImage(IDB_SURGE_ICON);

Expand Down
4 changes: 2 additions & 2 deletions src/surge-xt/gui/overlays/AboutScreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ void AboutScreen::resized()
lb->setColour(juce::Label::textColourId, skin->getColor(Colors::AboutPage::Link));
lb->setText(std::get<1>(l), juce::NotificationType::dontSendNotification);

auto strw = (int)juce::GlyphArrangement::getStringWidth(font, std::get<1>(l)) + 8;
auto strw = juce::GlyphArrangement::getStringWidthInt(font, std::get<1>(l)) + 8;
lb->setBounds(margin + colW, h0, strw, lHeight);

addAndMakeVisible(*lb);
Expand Down Expand Up @@ -344,7 +344,7 @@ void AboutScreen::resized()
lb->setColour(juce::Label::textColourId, skin->getColor(Colors::AboutPage::Link));
lb->setText(std::get<1>(l), juce::NotificationType::dontSendNotification);

auto strw = (int)juce::GlyphArrangement::getStringWidth(font, std::get<1>(l)) + 8;
auto strw = juce::GlyphArrangement::getStringWidthInt(font, std::get<1>(l)) + 8;
lb->setBounds(rightSide + colW, h1, strw, lHeight);

addAndMakeVisible(*lb);
Expand Down
4 changes: 2 additions & 2 deletions src/surge-xt/gui/overlays/FilterAnalysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ void FilterAnalysis::paint(juce::Graphics &g)
const auto freqString =
juce::String(over1000 ? freq / 1000.f : freq) + (over1000 ? "k" : "");
const auto labelRect =
juce::Rectangle{(int)juce::GlyphArrangement::getStringWidth(font, freqString),
juce::Rectangle{juce::GlyphArrangement::getStringWidthInt(font, freqString),
labelHeight}
.withBottomY(height - 2)
.withRightX((int)xPos);
Expand Down Expand Up @@ -248,7 +248,7 @@ void FilterAnalysis::paint(juce::Graphics &g)

const auto dbString = juce::String(dB) + " dB";
const auto labelRect =
juce::Rectangle{(int)juce::GlyphArrangement::getStringWidth(font, dbString),
juce::Rectangle{juce::GlyphArrangement::getStringWidthInt(font, dbString),
labelHeight}
.withBottomY((int)yPos)
.withRightX(width - 2);
Expand Down
4 changes: 2 additions & 2 deletions src/surge-xt/gui/overlays/MSEGEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1553,8 +1553,8 @@ struct MSEGCanvas : public juce::Component, public Surge::GUI::SkinConsumingComp
std::string txt = fmt::format("X: {:.{}f}", pxt(cx), prec),
txt2 = fmt::format("Y: {:.{}f}", val, prec);

int sw1 = (int)juce::GlyphArrangement::getStringWidth(g.getCurrentFont(), txt),
sw2 = (int)juce::GlyphArrangement::getStringWidth(g.getCurrentFont(), txt2);
int sw1 = juce::GlyphArrangement::getStringWidthInt(g.getCurrentFont(), txt),
sw2 = juce::GlyphArrangement::getStringWidthInt(g.getCurrentFont(), txt2);

float dragX = r.getRight(), dragY = r.getBottom();
float dragW = 6 + std::max(sw1, sw2), dragH = 22;
Expand Down
6 changes: 3 additions & 3 deletions src/surge-xt/gui/overlays/Oscilloscope.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1499,7 +1499,7 @@ void Oscilloscope::Background::paintSpectrumBackground(juce::Graphics &g)
juce::String(over1000 ? freq / 1000.f : freq) + (over1000 ? "k" : "");
// Label will go past the end of the scopeRect.
const auto labelRect =
juce::Rectangle{(int)juce::GlyphArrangement::getStringWidth(font, freqString),
juce::Rectangle{juce::GlyphArrangement::getStringWidthInt(font, freqString),
labelHeight}
.withCentre(juce::Point<int>(xPos, height + 10));

Expand Down Expand Up @@ -1543,7 +1543,7 @@ void Oscilloscope::Background::paintSpectrumBackground(juce::Graphics &g)

// Label will go past the end of the scopeRect.
const auto labelRect =
juce::Rectangle{(int)juce::GlyphArrangement::getStringWidth(font, dbString),
juce::Rectangle{juce::GlyphArrangement::getStringWidthInt(font, dbString),
labelHeight}
.withBottomY((int)(yPos + (labelHeight / 2)) + 1)
.withRightX(width + 32);
Expand Down Expand Up @@ -1657,7 +1657,7 @@ void Oscilloscope::Background::paintWaveformBackground(juce::Graphics &g)
}

// Label will go past the end of the scopeRect.
auto labelWidth = (int)juce::GlyphArrangement::getStringWidth(font, timeString);
auto labelWidth = juce::GlyphArrangement::getStringWidthInt(font, timeString);
auto labelRect = juce::Rectangle{labelWidth, labelHeight}.withCentre(
juce::Point<int>(xPos, height + 10));
auto justify = juce::Justification::bottom;
Expand Down
2 changes: 1 addition & 1 deletion src/surge-xt/gui/widgets/LFOAndStepDisplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1390,7 +1390,7 @@ void LFOAndStepDisplay::paintStepSeq(juce::Graphics &g)

std::string txt = fmt::format("{:.{}f} %", ss->steps[draggedStep] * 100.f, prec);

int sw = (int)juce::GlyphArrangement::getStringWidth(g.getCurrentFont(), txt);
int sw = juce::GlyphArrangement::getStringWidthInt(g.getCurrentFont(), txt);

auto sr = steprect[draggedStep];

Expand Down
2 changes: 1 addition & 1 deletion src/surge-xt/gui/widgets/MenuCustomComponents.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ void MenuTitleHelpComponent::getIdealSize(int &idealWidth, int &idealHeight)

idealHeight =
standardMenuItemHeight > 0 ? standardMenuItemHeight : std::round(font.getHeight() * 1.3f);
idealWidth = (int)juce::GlyphArrangement::getStringWidth(font, label) + idealHeight * 2;
idealWidth = juce::GlyphArrangement::getStringWidthInt(font, label) + idealHeight * 2;
idealWidth += 20;
}

Expand Down
18 changes: 9 additions & 9 deletions src/surge-xt/gui/widgets/ParameterInfowindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,9 @@ void ParameterInfowindow::setBoundsToAccompany(const juce::Rectangle<int> &contr

if (name.empty())
{
auto sl1 = (int)juce::GlyphArrangement::getStringWidth(font, display);
auto sl2 = (int)juce::GlyphArrangement::getStringWidth(font, displayAlt);
auto pad = (int)juce::GlyphArrangement::getStringWidth(font, " ");
auto sl1 = juce::GlyphArrangement::getStringWidthInt(font, display);
auto sl2 = juce::GlyphArrangement::getStringWidthInt(font, displayAlt);
auto pad = juce::GlyphArrangement::getStringWidthInt(font, " ");
desiredWidth = std::max(sl1 + sl2 + pad, desiredWidth);
}
else
Expand All @@ -144,17 +144,17 @@ void ParameterInfowindow::setBoundsToAccompany(const juce::Rectangle<int> &contr
{
lheight = font.getHeight() * 3 + 11;
// row 2
auto r1l = (int)juce::GlyphArrangement::getStringWidth(font, name);
auto r2l = (int)juce::GlyphArrangement::getStringWidth(
auto r1l = juce::GlyphArrangement::getStringWidthInt(font, name);
auto r2l = juce::GlyphArrangement::getStringWidthInt(
font, mdiws.dvalminus + " " + mdiws.val + " " + mdiws.dvalplus);
auto r3l = (int)juce::GlyphArrangement::getStringWidth(font, mdiws.valminus + " " +
mdiws.valplus);
auto r3l = juce::GlyphArrangement::getStringWidthInt(font, mdiws.valminus + " " +
mdiws.valplus);
desiredWidth = std::max(std::max(std::max(r1l, r2l), r3l) + 8, desiredWidth);
}
else
{
auto sln = (int)juce::GlyphArrangement::getStringWidth(font, name);
auto sl1 = (int)juce::GlyphArrangement::getStringWidth(font, display);
auto sln = juce::GlyphArrangement::getStringWidthInt(font, name);
auto sl1 = juce::GlyphArrangement::getStringWidthInt(font, display);
desiredWidth = std::max(std::max(sln, sl1) + 8, desiredWidth);
lheight = font.getHeight() * 2 + 9;
}
Expand Down

0 comments on commit 952217b

Please sign in to comment.