1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

Font: Deprecate old Font constructors

This commit is contained in:
reuk 2024-03-19 20:32:19 +00:00
parent 2ed9b84070
commit 4f2c287f9b
No known key found for this signature in database
GPG key ID: FCB43929F012EE5C
95 changed files with 428 additions and 209 deletions

View file

@ -371,7 +371,7 @@ void LookAndFeel_V1::drawComboBox (Graphics& g, int width, int height,
Font LookAndFeel_V1::getComboBoxFont (ComboBox& box)
{
Font f (jmin (15.0f, (float) box.getHeight() * 0.85f));
Font f (FontOptions { jmin (15.0f, (float) box.getHeight() * 0.85f) });
f.setHorizontalScale (0.9f);
return f;
}

View file

@ -260,7 +260,7 @@ void LookAndFeel_V2::drawButtonBackground (Graphics& g,
Font LookAndFeel_V2::getTextButtonFont (TextButton&, int buttonHeight)
{
return Font (jmin (15.0f, (float) buttonHeight * 0.6f));
return FontOptions (jmin (15.0f, (float) buttonHeight * 0.6f));
}
int LookAndFeel_V2::getTextButtonWidthToFitText (TextButton& b, int buttonHeight)
@ -359,7 +359,7 @@ void LookAndFeel_V2::changeToggleButtonWidthToFitText (ToggleButton& button)
auto fontSize = jmin (15.0f, (float) button.getHeight() * 0.75f);
auto tickWidth = fontSize * 1.1f;
Font font (fontSize);
Font font (FontOptions { fontSize });
button.setSize (font.getStringWidth (button.getButtonText()) + roundToInt (tickWidth) + 9,
button.getHeight());
@ -471,7 +471,7 @@ void LookAndFeel_V2::drawAlertBox (Graphics& g, AlertWindow& alert,
}
GlyphArrangement ga;
ga.addFittedText (Font ((float) iconRect.getHeight() * 0.9f, Font::bold),
ga.addFittedText (FontOptions ((float) iconRect.getHeight() * 0.9f, Font::bold),
String::charToString ((juce_wchar) (uint8) character),
(float) iconRect.getX(), (float) iconRect.getY(),
(float) iconRect.getWidth(), (float) iconRect.getHeight(),
@ -528,12 +528,12 @@ Font LookAndFeel_V2::getAlertWindowTitleFont()
Font LookAndFeel_V2::getAlertWindowMessageFont()
{
return Font (15.0f);
return FontOptions (15.0f);
}
Font LookAndFeel_V2::getAlertWindowFont()
{
return Font (12.0f);
return FontOptions (12.0f);
}
//==============================================================================
@ -864,7 +864,7 @@ void LookAndFeel_V2::setComponentEffectForBubbleComponent (BubbleComponent& bubb
//==============================================================================
Font LookAndFeel_V2::getPopupMenuFont()
{
return Font (17.0f);
return FontOptions (17.0f);
}
void LookAndFeel_V2::getIdealPopupMenuItemSize (const String& text, const bool isSeparator,
@ -1112,7 +1112,7 @@ void LookAndFeel_V2::drawMenuBarBackground (Graphics& g, int width, int height,
Font LookAndFeel_V2::getMenuBarFont (MenuBarComponent& menuBar, int /*itemIndex*/, const String& /*itemText*/)
{
return Font ((float) menuBar.getHeight() * 0.7f);
return FontOptions ((float) menuBar.getHeight() * 0.7f);
}
int LookAndFeel_V2::getMenuBarItemWidth (MenuBarComponent& menuBar, int itemIndex, const String& itemText)
@ -1264,7 +1264,7 @@ void LookAndFeel_V2::drawComboBox (Graphics& g, int width, int height, const boo
Font LookAndFeel_V2::getComboBoxFont (ComboBox& box)
{
return Font (jmin (15.0f, (float) box.getHeight() * 0.85f));
return FontOptions (jmin (15.0f, (float) box.getHeight() * 0.85f));
}
Label* LookAndFeel_V2::createComboBoxTextBox (ComboBox&)
@ -1645,7 +1645,7 @@ ImageEffectFilter* LookAndFeel_V2::getSliderEffect (Slider&)
Font LookAndFeel_V2::getSliderPopupFont (Slider&)
{
return Font (15.0f, Font::bold);
return FontOptions (15.0f, Font::bold);
}
int LookAndFeel_V2::getSliderPopupPlacement (Slider&)
@ -1784,7 +1784,7 @@ void LookAndFeel_V2::drawConcertinaPanelHeader (Graphics& g, const Rectangle<int
g.drawRect (area);
g.setColour (Colours::white);
g.setFont (Font ((float) area.getHeight() * 0.7f).boldened());
g.setFont (Font (FontOptions { (float) area.getHeight() * 0.7f }).boldened());
g.drawFittedText (panel.getName(), 4, 0, area.getWidth() - 6, area.getHeight(), Justification::centredLeft, 1);
}
@ -1884,7 +1884,7 @@ void LookAndFeel_V2::drawDocumentWindowTitleBar (DocumentWindow& window, Graphic
window.getBackgroundColour().contrasting (isActive ? 0.15f : 0.05f), (float) h));
g.fillAll();
Font font ((float) h * 0.65f, Font::bold);
Font font (FontOptions { (float) h * 0.65f, Font::bold });
g.setFont (font);
int textW = font.getStringWidth (window.getName());
@ -2124,7 +2124,7 @@ void LookAndFeel_V2::drawGroupComponentOutline (Graphics& g, int width, int heig
const float textEdgeGap = 4.0f;
auto cs = 5.0f;
Font f (textH);
Font f (FontOptions { textH });
Path p;
auto x = indent;
@ -2190,7 +2190,7 @@ int LookAndFeel_V2::getTabButtonSpaceAroundImage()
int LookAndFeel_V2::getTabButtonBestWidth (TabBarButton& button, int tabDepth)
{
int width = Font ((float) tabDepth * 0.6f).getStringWidth (button.getButtonText().trim())
int width = Font (FontOptions { (float) tabDepth * 0.6f }).getStringWidth (button.getButtonText().trim())
+ getTabButtonOverlap (tabDepth) * 2;
if (auto* extraComponent = button.getExtraComponent())
@ -2312,7 +2312,7 @@ void LookAndFeel_V2::fillTabButtonShape (TabBarButton& button, Graphics& g, cons
Font LookAndFeel_V2::getTabButtonFont (TabBarButton&, float height)
{
return { height * 0.6f };
return FontOptions { height * 0.6f };
}
void LookAndFeel_V2::drawTabButtonText (TabBarButton& button, Graphics& g, bool isMouseOver, bool isMouseDown)
@ -2515,7 +2515,7 @@ void LookAndFeel_V2::drawTableHeaderColumn (Graphics& g, TableHeaderComponent& h
}
g.setColour (header.findColour (TableHeaderComponent::textColourId));
g.setFont (Font ((float) height * 0.5f, Font::bold));
g.setFont (FontOptions ((float) height * 0.5f, Font::bold));
g.drawFittedText (columnName, area, Justification::centredLeft, 1);
}
@ -2585,7 +2585,7 @@ void LookAndFeel_V2::drawPropertyPanelSectionHeader (Graphics& g, const String&
auto textX = (int) (buttonIndent * 2.0f + buttonSize + 2.0f);
g.setColour (Colours::black);
g.setFont (Font ((float) height * 0.7f, Font::bold));
g.setFont (FontOptions ((float) height * 0.7f, Font::bold));
g.drawText (name, textX, 0, width - textX - 4, height, Justification::centredLeft, true);
}
@ -2660,8 +2660,8 @@ AttributedString LookAndFeel_V2::createFileChooserHeaderText (const String& titl
s.setJustification (Justification::centred);
auto colour = findColour (FileChooserDialogBox::titleTextColourId);
s.append (title + "\n\n", Font (17.0f, Font::bold), colour);
s.append (instructions, Font (14.0f), colour);
s.append (title + "\n\n", FontOptions (17.0f, Font::bold), colour);
s.append (instructions, FontOptions (14.0f), colour);
return s;
}
@ -2950,7 +2950,7 @@ void LookAndFeel_V2::drawKeymapChangeButton (Graphics& g, int width, int height,
//==============================================================================
Font LookAndFeel_V2::getSidePanelTitleFont (SidePanel&)
{
return Font (18.0f);
return FontOptions (18.0f);
}
Justification LookAndFeel_V2::getSidePanelTitleJustification (SidePanel& panel)

View file

@ -111,7 +111,7 @@ void LookAndFeel_V3::drawConcertinaPanelHeader (Graphics& g, const Rectangle<int
g.fillRect (area.withTop (area.getBottom() - 1));
g.setColour (bkg.contrasting());
g.setFont (Font ((float) area.getHeight() * 0.6f).boldened());
g.setFont (Font (FontOptions { (float) area.getHeight() * 0.6f }).boldened());
g.drawFittedText (panel.getName(), 4, 0, area.getWidth() - 6, area.getHeight(), Justification::centredLeft, 1);
}
@ -187,7 +187,7 @@ int LookAndFeel_V3::getTabButtonSpaceAroundImage() { return 0
void LookAndFeel_V3::createTabTextLayout (const TabBarButton& button, float length, float depth,
Colour colour, TextLayout& textLayout)
{
Font font (depth * 0.5f);
Font font (FontOptions { depth * 0.5f });
font.setUnderline (button.hasKeyboardFocus (false));
AttributedString s;

View file

@ -244,7 +244,7 @@ void LookAndFeel_V4::drawDocumentWindowTitleBar (DocumentWindow& window, Graphic
g.setColour (getCurrentColourScheme().getUIColour (ColourScheme::widgetBackground));
g.fillAll();
Font font ((float) h * 0.65f, Font::plain);
Font font (FontOptions { (float) h * 0.65f, Font::plain });
g.setFont (font);
auto textW = font.getStringWidth (window.getName());
@ -284,7 +284,7 @@ void LookAndFeel_V4::drawDocumentWindowTitleBar (DocumentWindow& window, Graphic
//==============================================================================
Font LookAndFeel_V4::getTextButtonFont (TextButton&, int buttonHeight)
{
return { jmin (16.0f, (float) buttonHeight * 0.6f) };
return FontOptions { jmin (16.0f, (float) buttonHeight * 0.6f) };
}
void LookAndFeel_V4::drawButtonBackground (Graphics& g,
@ -384,7 +384,7 @@ void LookAndFeel_V4::changeToggleButtonWidthToFitText (ToggleButton& button)
auto fontSize = jmin (15.0f, (float) button.getHeight() * 0.75f);
auto tickWidth = fontSize * 1.1f;
Font font (fontSize);
Font font (FontOptions { fontSize });
button.setSize (font.getStringWidth (button.getButtonText()) + roundToInt (tickWidth) + 14, button.getHeight());
}
@ -462,7 +462,7 @@ void LookAndFeel_V4::drawAlertBox (Graphics& g, AlertWindow& alert,
}
GlyphArrangement ga;
ga.addFittedText ({ (float) iconRect.getHeight() * 0.9f, Font::bold },
ga.addFittedText (FontOptions { (float) iconRect.getHeight() * 0.9f, Font::bold },
String::charToString ((juce_wchar) (uint8) character),
static_cast<float> (iconRect.getX()), static_cast<float> (iconRect.getY()),
static_cast<float> (iconRect.getWidth()), static_cast<float> (iconRect.getHeight()),
@ -485,9 +485,9 @@ void LookAndFeel_V4::drawAlertBox (Graphics& g, AlertWindow& alert,
}
int LookAndFeel_V4::getAlertWindowButtonHeight() { return 40; }
Font LookAndFeel_V4::getAlertWindowTitleFont() { return { 18.0f, Font::bold }; }
Font LookAndFeel_V4::getAlertWindowMessageFont() { return { 16.0f }; }
Font LookAndFeel_V4::getAlertWindowFont() { return { 14.0f }; }
Font LookAndFeel_V4::getAlertWindowTitleFont() { return FontOptions { 18.0f, Font::bold }; }
Font LookAndFeel_V4::getAlertWindowMessageFont() { return FontOptions { 16.0f }; }
Font LookAndFeel_V4::getAlertWindowFont() { return FontOptions { 14.0f }; }
//==============================================================================
void LookAndFeel_V4::drawProgressBar (Graphics& g, ProgressBar& progressBar,
@ -629,7 +629,7 @@ void LookAndFeel_V4::drawCircularProgressBar (Graphics& g, const ProgressBar& pr
if (textToShow.isNotEmpty())
{
g.setColour (progressBar.findColour (TextButton::textColourOffId));
g.setFont ({ 12.0f, Font::italic });
g.setFont (FontOptions { 12.0f, Font::italic });
g.drawText (textToShow, barBounds, Justification::centred, false);
}
}
@ -950,7 +950,7 @@ void LookAndFeel_V4::drawComboBox (Graphics& g, int width, int height, bool,
Font LookAndFeel_V4::getComboBoxFont (ComboBox& box)
{
return { jmin (16.0f, (float) box.getHeight() * 0.85f) };
return FontOptions { jmin (16.0f, (float) box.getHeight() * 0.85f) };
}
void LookAndFeel_V4::positionComboBoxText (ComboBox& box, Label& label)
@ -1268,7 +1268,7 @@ void LookAndFeel_V4::drawPropertyPanelSectionHeader (Graphics& g, const String&
g.setColour (findColour (PropertyComponent::labelTextColourId));
g.setFont ({ (float) height * 0.7f, Font::bold });
g.setFont (FontOptions { (float) height * 0.7f, Font::bold });
g.drawText (name, textX, 0, width - textX - 4, height, Justification::centredLeft, true);
}