mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-09 23:34:20 +00:00
LookAndFeel: Allow specifying a default typeface metrics kind to use
This commit is contained in:
parent
fa81badb30
commit
4533077b75
26 changed files with 82 additions and 60 deletions
|
|
@ -97,7 +97,7 @@ public:
|
|||
g.setColour (isBlacklisted ? Colours::red
|
||||
: columnId == nameCol ? defaultTextColour
|
||||
: defaultTextColour.interpolatedWith (Colours::transparentBlack, 0.3f));
|
||||
g.setFont (FontOptions ((float) height * 0.7f, Font::bold));
|
||||
g.setFont (owner.withDefaultMetrics (FontOptions ((float) height * 0.7f, Font::bold)));
|
||||
g.drawFittedText (text, 4, 0, width - 6, height, Justification::centredLeft, 1, 0.9f);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -82,7 +82,7 @@ static void drawTextLayout (Graphics& g, Component& owner, StringRef text, const
|
|||
|
||||
AttributedString attributedString { text };
|
||||
attributedString.setColour (textColour);
|
||||
attributedString.setFont (FontOptions { (float) textBounds.getHeight() * 0.6f });
|
||||
attributedString.setFont (owner.withDefaultMetrics (FontOptions { (float) textBounds.getHeight() * 0.6f }));
|
||||
attributedString.setJustification (Justification::centredLeft);
|
||||
attributedString.setWordWrap (AttributedString::WordWrap::none);
|
||||
|
||||
|
|
|
|||
|
|
@ -109,7 +109,7 @@ void MPEKeyboardComponent::drawWhiteKey (int midiNoteNumber, Graphics& g, Rectan
|
|||
auto text = MidiMessage::getMidiNoteName (midiNoteNumber, true, true, getOctaveForMiddleC());
|
||||
|
||||
g.setColour (findColour (textLabelColourId));
|
||||
g.setFont (Font (FontOptions { fontHeight }).withHorizontalScale (0.8f));
|
||||
g.setFont (withDefaultMetrics (FontOptions { fontHeight }).withHorizontalScale (0.8f));
|
||||
|
||||
switch (getOrientation())
|
||||
{
|
||||
|
|
|
|||
|
|
@ -379,7 +379,7 @@ void MidiKeyboardComponent::drawWhiteNote (int midiNoteNumber, Graphics& g, Rect
|
|||
auto fontHeight = jmin (12.0f, getKeyWidth() * 0.9f);
|
||||
|
||||
g.setColour (textColour);
|
||||
g.setFont (Font (FontOptions { fontHeight }).withHorizontalScale (0.8f));
|
||||
g.setFont (withDefaultMetrics (FontOptions { fontHeight }).withHorizontalScale (0.8f));
|
||||
|
||||
switch (currentOrientation)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -130,7 +130,7 @@ void Graphics::resetToDefaultState()
|
|||
{
|
||||
saveStateIfPending();
|
||||
context.setFill (FillType());
|
||||
context.setFont (FontOptions{});
|
||||
context.setFont (FontOptions{}.withMetricsKind (TypefaceMetricsKind::legacy));
|
||||
context.setInterpolationQuality (Graphics::mediumResamplingQuality);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ HyperlinkButton::HyperlinkButton (const String& linkText,
|
|||
const URL& linkURL)
|
||||
: Button (linkText),
|
||||
url (linkURL),
|
||||
font (FontOptions { 14.0f, Font::underlined }),
|
||||
font (withDefaultMetrics (FontOptions { 14.0f, Font::underlined })),
|
||||
resizeFont (true),
|
||||
justification (Justification::centred)
|
||||
{
|
||||
|
|
@ -49,7 +49,7 @@ HyperlinkButton::HyperlinkButton (const String& linkText,
|
|||
|
||||
HyperlinkButton::HyperlinkButton()
|
||||
: Button (String()),
|
||||
font (FontOptions { 14.0f, Font::underlined }),
|
||||
font (withDefaultMetrics (FontOptions { 14.0f, Font::underlined })),
|
||||
resizeFont (true),
|
||||
justification (Justification::centred)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1856,6 +1856,11 @@ void Component::setLookAndFeel (LookAndFeel* newLookAndFeel)
|
|||
}
|
||||
}
|
||||
|
||||
FontOptions Component::withDefaultMetrics (FontOptions opt) const
|
||||
{
|
||||
return getLookAndFeel().withDefaultMetrics (std::move (opt));
|
||||
}
|
||||
|
||||
void Component::lookAndFeelChanged() {}
|
||||
void Component::colourChanged() {}
|
||||
|
||||
|
|
|
|||
|
|
@ -1181,6 +1181,9 @@ public:
|
|||
*/
|
||||
void setLookAndFeel (LookAndFeel* newLookAndFeel);
|
||||
|
||||
/** Returns a copy of the FontOptions with the default metrics kind from the component's LookAndFeel. */
|
||||
FontOptions withDefaultMetrics (FontOptions opt) const;
|
||||
|
||||
/** Called to let the component react to a change in the look-and-feel setting.
|
||||
|
||||
When the look-and-feel is changed for a component, this method, repaint(), and
|
||||
|
|
|
|||
|
|
@ -53,14 +53,14 @@ struct LookAndFeelHelpers
|
|||
return baseColour;
|
||||
}
|
||||
|
||||
static TextLayout layoutTooltipText (const String& text, Colour colour) noexcept
|
||||
static TextLayout layoutTooltipText (TypefaceMetricsKind metrics, const String& text, Colour colour) noexcept
|
||||
{
|
||||
const float tooltipFontSize = 13.0f;
|
||||
const int maxToolTipWidth = 400;
|
||||
|
||||
AttributedString s;
|
||||
s.setJustification (Justification::centred);
|
||||
s.append (text, FontOptions (tooltipFontSize, Font::bold), colour);
|
||||
s.append (text, FontOptions (tooltipFontSize, Font::bold).withMetricsKind (metrics), colour);
|
||||
|
||||
TextLayout tl;
|
||||
tl.createLayoutWithBalancedLineLengths (s, (float) maxToolTipWidth);
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ DrawableText::DrawableText()
|
|||
justification (Justification::centredLeft)
|
||||
{
|
||||
setBoundingBox (Parallelogram<float> ({ 0.0f, 0.0f, 50.0f, 20.0f }));
|
||||
setFont (FontOptions (15.0f), true);
|
||||
setFont (withDefaultMetrics (FontOptions (15.0f)), true);
|
||||
}
|
||||
|
||||
DrawableText::DrawableText (const DrawableText& other)
|
||||
|
|
|
|||
|
|
@ -114,7 +114,7 @@ private:
|
|||
//==============================================================================
|
||||
Parallelogram<float> bounds;
|
||||
float fontHeight, fontHScale;
|
||||
Font font { FontOptions{} }, scaledFont { FontOptions{} };
|
||||
Font font { withDefaultMetrics (FontOptions{}) }, scaledFont { withDefaultMetrics (FontOptions{}) };
|
||||
String text;
|
||||
Colour colour;
|
||||
Justification justification;
|
||||
|
|
|
|||
|
|
@ -134,7 +134,7 @@ void FileSearchPathListComponent::paintListBoxItem (int rowNumber, Graphics& g,
|
|||
g.fillAll (findColour (TextEditor::highlightColourId));
|
||||
|
||||
g.setColour (findColour (ListBox::textColourId));
|
||||
Font f (FontOptions { (float) height * 0.7f });
|
||||
Font f (withDefaultMetrics (FontOptions { (float) height * 0.7f }));
|
||||
f.setHorizontalScale (0.9f);
|
||||
g.setFont (f);
|
||||
|
||||
|
|
|
|||
|
|
@ -184,6 +184,19 @@ public:
|
|||
*/
|
||||
virtual Typeface::Ptr getTypefaceForFont (const Font&);
|
||||
|
||||
/** Widgets can call this to find out the kind of metrics they should use when creating their
|
||||
own fonts.
|
||||
|
||||
The default implementation returns the legacy metrics kind, but you can override this if
|
||||
you want to use the portable metrics kind instead. Using portable metrics may cause text
|
||||
to render at a different size, so you should check that text in your app still renders at an
|
||||
appropriate size, and potentially adjust font sizes where necessary after overriding this.
|
||||
*/
|
||||
virtual TypefaceMetricsKind getDefaultMetricsKind() const { return TypefaceMetricsKind::legacy; }
|
||||
|
||||
/** Returns a copy of the FontOptions with the LookAndFeel's default metrics kind set. */
|
||||
FontOptions withDefaultMetrics (FontOptions opt) const { return opt.withMetricsKind (getDefaultMetricsKind()); }
|
||||
|
||||
/** Allows you to supply a default typeface that will be returned as the default
|
||||
sans-serif font.
|
||||
|
||||
|
|
|
|||
|
|
@ -371,7 +371,7 @@ void LookAndFeel_V1::drawComboBox (Graphics& g, int width, int height,
|
|||
|
||||
Font LookAndFeel_V1::getComboBoxFont (ComboBox& box)
|
||||
{
|
||||
Font f (FontOptions { jmin (15.0f, (float) box.getHeight() * 0.85f) });
|
||||
Font f (withDefaultMetrics (FontOptions { jmin (15.0f, (float) box.getHeight() * 0.85f) }));
|
||||
f.setHorizontalScale (0.9f);
|
||||
return f;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -260,7 +260,7 @@ void LookAndFeel_V2::drawButtonBackground (Graphics& g,
|
|||
|
||||
Font LookAndFeel_V2::getTextButtonFont (TextButton&, int buttonHeight)
|
||||
{
|
||||
return FontOptions (jmin (15.0f, (float) buttonHeight * 0.6f));
|
||||
return withDefaultMetrics (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 (FontOptions { fontSize });
|
||||
Font font (withDefaultMetrics (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 (FontOptions ((float) iconRect.getHeight() * 0.9f, Font::bold),
|
||||
ga.addFittedText (withDefaultMetrics (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 FontOptions (15.0f);
|
||||
return withDefaultMetrics (FontOptions (15.0f));
|
||||
}
|
||||
|
||||
Font LookAndFeel_V2::getAlertWindowFont()
|
||||
{
|
||||
return FontOptions (12.0f);
|
||||
return withDefaultMetrics (FontOptions (12.0f));
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
|
|
@ -864,7 +864,7 @@ void LookAndFeel_V2::setComponentEffectForBubbleComponent (BubbleComponent& bubb
|
|||
//==============================================================================
|
||||
Font LookAndFeel_V2::getPopupMenuFont()
|
||||
{
|
||||
return FontOptions (17.0f);
|
||||
return withDefaultMetrics (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 FontOptions ((float) menuBar.getHeight() * 0.7f);
|
||||
return withDefaultMetrics (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 FontOptions (jmin (15.0f, (float) box.getHeight() * 0.85f));
|
||||
return withDefaultMetrics (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 FontOptions (15.0f, Font::bold);
|
||||
return withDefaultMetrics (FontOptions (15.0f, Font::bold));
|
||||
}
|
||||
|
||||
int LookAndFeel_V2::getSliderPopupPlacement (Slider&)
|
||||
|
|
@ -1728,7 +1728,7 @@ Slider::SliderLayout LookAndFeel_V2::getSliderLayout (Slider& slider)
|
|||
//==============================================================================
|
||||
Rectangle<int> LookAndFeel_V2::getTooltipBounds (const String& tipText, Point<int> screenPos, Rectangle<int> parentArea)
|
||||
{
|
||||
const TextLayout tl (detail::LookAndFeelHelpers::layoutTooltipText (tipText, Colours::black));
|
||||
const TextLayout tl (detail::LookAndFeelHelpers::layoutTooltipText (getDefaultMetricsKind(), tipText, Colours::black));
|
||||
|
||||
auto w = (int) (tl.getWidth() + 14.0f);
|
||||
auto h = (int) (tl.getHeight() + 6.0f);
|
||||
|
|
@ -1748,7 +1748,7 @@ void LookAndFeel_V2::drawTooltip (Graphics& g, const String& text, int width, in
|
|||
g.drawRect (0, 0, width, height, 1);
|
||||
#endif
|
||||
|
||||
detail::LookAndFeelHelpers::layoutTooltipText (text, findColour (TooltipWindow::textColourId))
|
||||
detail::LookAndFeelHelpers::layoutTooltipText (getDefaultMetricsKind(), text, findColour (TooltipWindow::textColourId))
|
||||
.draw (g, Rectangle<float> ((float) width, (float) height));
|
||||
}
|
||||
|
||||
|
|
@ -1784,7 +1784,7 @@ void LookAndFeel_V2::drawConcertinaPanelHeader (Graphics& g, const Rectangle<int
|
|||
g.drawRect (area);
|
||||
|
||||
g.setColour (Colours::white);
|
||||
g.setFont (Font (FontOptions { (float) area.getHeight() * 0.7f }).boldened());
|
||||
g.setFont (Font (withDefaultMetrics (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 (FontOptions { (float) h * 0.65f, Font::bold });
|
||||
Font font (withDefaultMetrics (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 (FontOptions { textH });
|
||||
Font f (withDefaultMetrics (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 (FontOptions { (float) tabDepth * 0.6f }).getStringWidth (button.getButtonText().trim())
|
||||
int width = Font (withDefaultMetrics (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 FontOptions { height * 0.6f };
|
||||
return withDefaultMetrics (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 (FontOptions ((float) height * 0.5f, Font::bold));
|
||||
g.setFont (withDefaultMetrics (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 (FontOptions ((float) height * 0.7f, Font::bold));
|
||||
g.setFont (withDefaultMetrics (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", FontOptions (17.0f, Font::bold), colour);
|
||||
s.append (instructions, FontOptions (14.0f), colour);
|
||||
s.append (title + "\n\n", withDefaultMetrics (FontOptions (17.0f, Font::bold)), colour);
|
||||
s.append (instructions, withDefaultMetrics (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 FontOptions (18.0f);
|
||||
return withDefaultMetrics (FontOptions (18.0f));
|
||||
}
|
||||
|
||||
Justification LookAndFeel_V2::getSidePanelTitleJustification (SidePanel& panel)
|
||||
|
|
|
|||
|
|
@ -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 (FontOptions { (float) area.getHeight() * 0.6f }).boldened());
|
||||
g.setFont (Font (withDefaultMetrics (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 (FontOptions { depth * 0.5f });
|
||||
Font font (button.withDefaultMetrics (FontOptions { depth * 0.5f }));
|
||||
font.setUnderline (button.hasKeyboardFocus (false));
|
||||
|
||||
AttributedString s;
|
||||
|
|
|
|||
|
|
@ -244,7 +244,7 @@ void LookAndFeel_V4::drawDocumentWindowTitleBar (DocumentWindow& window, Graphic
|
|||
g.setColour (getCurrentColourScheme().getUIColour (ColourScheme::widgetBackground));
|
||||
g.fillAll();
|
||||
|
||||
Font font (FontOptions { (float) h * 0.65f, Font::plain });
|
||||
Font font (withDefaultMetrics (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 FontOptions { jmin (16.0f, (float) buttonHeight * 0.6f) };
|
||||
return withDefaultMetrics (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 (FontOptions { fontSize });
|
||||
Font font (withDefaultMetrics (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 (FontOptions { (float) iconRect.getHeight() * 0.9f, Font::bold },
|
||||
ga.addFittedText (withDefaultMetrics (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 FontOptions { 18.0f, Font::bold }; }
|
||||
Font LookAndFeel_V4::getAlertWindowMessageFont() { return FontOptions { 16.0f }; }
|
||||
Font LookAndFeel_V4::getAlertWindowFont() { return FontOptions { 14.0f }; }
|
||||
Font LookAndFeel_V4::getAlertWindowTitleFont() { return withDefaultMetrics (FontOptions { 18.0f, Font::bold }); }
|
||||
Font LookAndFeel_V4::getAlertWindowMessageFont() { return withDefaultMetrics (FontOptions { 16.0f }); }
|
||||
Font LookAndFeel_V4::getAlertWindowFont() { return withDefaultMetrics (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 (FontOptions { 12.0f, Font::italic });
|
||||
g.setFont (progressBar.withDefaultMetrics (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 FontOptions { jmin (16.0f, (float) box.getHeight() * 0.85f) };
|
||||
return withDefaultMetrics (FontOptions { jmin (16.0f, (float) box.getHeight() * 0.85f) });
|
||||
}
|
||||
|
||||
void LookAndFeel_V4::positionComboBoxText (ComboBox& box, Label& label)
|
||||
|
|
@ -1162,7 +1162,7 @@ void LookAndFeel_V4::drawTooltip (Graphics& g, const String& text, int width, in
|
|||
g.setColour (findColour (TooltipWindow::outlineColourId));
|
||||
g.drawRoundedRectangle (bounds.toFloat().reduced (0.5f, 0.5f), cornerSize, 1.0f);
|
||||
|
||||
detail::LookAndFeelHelpers::layoutTooltipText (text, findColour (TooltipWindow::textColourId))
|
||||
detail::LookAndFeelHelpers::layoutTooltipText (getDefaultMetricsKind(), text, findColour (TooltipWindow::textColourId))
|
||||
.draw (g, { static_cast<float> (width), static_cast<float> (height) });
|
||||
}
|
||||
|
||||
|
|
@ -1268,7 +1268,7 @@ void LookAndFeel_V4::drawPropertyPanelSectionHeader (Graphics& g, const String&
|
|||
|
||||
g.setColour (findColour (PropertyComponent::labelTextColourId));
|
||||
|
||||
g.setFont (FontOptions { (float) height * 0.7f, Font::bold });
|
||||
g.setFont (withDefaultMetrics (FontOptions { (float) height * 0.7f, Font::bold }));
|
||||
g.drawText (name, textX, 0, width - textX - 4, height, Justification::centredLeft, true);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -355,7 +355,7 @@ private:
|
|||
//==============================================================================
|
||||
Value textValue;
|
||||
String lastTextValue;
|
||||
Font font { FontOptions { 15.0f } };
|
||||
Font font { withDefaultMetrics (FontOptions { 15.0f }) };
|
||||
Justification justification = Justification::centredLeft;
|
||||
std::unique_ptr<TextEditor> editor;
|
||||
ListenerList<Listener> listeners;
|
||||
|
|
|
|||
|
|
@ -825,7 +825,7 @@ private:
|
|||
Range<int> selection;
|
||||
int leftIndent = 4, topIndent = 4;
|
||||
unsigned int lastTransactionTime = 0;
|
||||
Font currentFont { FontOptions { 14.0f } };
|
||||
Font currentFont { withDefaultMetrics (FontOptions { 14.0f }) };
|
||||
mutable int totalNumChars = 0;
|
||||
int caretPosition = 0;
|
||||
OwnedArray<UniformTextSection> sections;
|
||||
|
|
|
|||
|
|
@ -770,7 +770,7 @@ private:
|
|||
}
|
||||
|
||||
addAndMakeVisible (instructions);
|
||||
instructions.setFont (FontOptions (13.0f));
|
||||
instructions.setFont (withDefaultMetrics (FontOptions (13.0f)));
|
||||
|
||||
setSize (500, 300);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -467,7 +467,7 @@ CodeEditorComponent::CodeEditorComponent (CodeDocument& doc, CodeTokeniser* cons
|
|||
addAndMakeVisible (horizontalScrollBar);
|
||||
horizontalScrollBar.setSingleStepSize (1.0);
|
||||
|
||||
Font f (FontOptions { 12.0f });
|
||||
Font f (withDefaultMetrics (FontOptions { 12.0f }));
|
||||
f.setTypefaceName (Font::getDefaultMonospacedFontName());
|
||||
setFont (f);
|
||||
|
||||
|
|
|
|||
|
|
@ -416,7 +416,7 @@ private:
|
|||
//==============================================================================
|
||||
CodeDocument& document;
|
||||
|
||||
Font font { FontOptions{} };
|
||||
Font font { withDefaultMetrics (FontOptions{}) };
|
||||
int firstLineOnScreen = 0, spacesPerTab = 4;
|
||||
float charWidth = 0;
|
||||
int lineHeight = 0, linesOnScreen = 0, columnsOnScreen = 0;
|
||||
|
|
|
|||
|
|
@ -382,7 +382,7 @@ private:
|
|||
ColourSelector& owner;
|
||||
|
||||
Colour currentColour;
|
||||
Font labelFont { FontOptions { 14.0f, Font::bold } };
|
||||
Font labelFont { withDefaultMetrics (FontOptions { 14.0f, Font::bold }) };
|
||||
int labelWidth = 0;
|
||||
Label colourLabel;
|
||||
|
||||
|
|
|
|||
|
|
@ -97,7 +97,7 @@ public:
|
|||
if (keyNum < 0)
|
||||
setSize (h, h);
|
||||
else
|
||||
setSize (jlimit (h * 4, h * 8, 6 + Font (FontOptions { (float) h * 0.6f }).getStringWidth (getName())), h);
|
||||
setSize (jlimit (h * 4, h * 8, 6 + Font (withDefaultMetrics (FontOptions { (float) h * 0.6f })).getStringWidth (getName())), h);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
|
|
@ -321,7 +321,7 @@ public:
|
|||
|
||||
void paintItem (Graphics& g, int width, int height) override
|
||||
{
|
||||
g.setFont (FontOptions ((float) height * 0.7f, Font::bold));
|
||||
g.setFont (owner.withDefaultMetrics (FontOptions ((float) height * 0.7f, Font::bold)));
|
||||
g.setColour (owner.findColour (KeyMappingEditorComponent::textColourId));
|
||||
|
||||
g.drawText (TRANS (categoryName), 2, 0, width - 2, height, Justification::centredLeft, true);
|
||||
|
|
|
|||
|
|
@ -144,7 +144,7 @@ LivePropertyEditorBase::LivePropertyEditorBase (LiveValueBase& v, CodeDocument&
|
|||
findOriginalValueInCode();
|
||||
selectOriginalValue();
|
||||
|
||||
name.setFont (FontOptions { 13.0f });
|
||||
name.setFont (withDefaultMetrics (FontOptions { 13.0f }));
|
||||
name.setText (v.name, dontSendNotification);
|
||||
valueEditor.setMultiLine (v.isString());
|
||||
valueEditor.setReturnKeyStartsNewLine (v.isString());
|
||||
|
|
|
|||
|
|
@ -250,9 +250,10 @@ void OnlineUnlockForm::resized()
|
|||
r.removeFromBottom (20);
|
||||
|
||||
// (force use of a default system font to make sure it has the password blob character)
|
||||
Font font (FontOptions { Font::getDefaultTypefaceForFont (FontOptions (Font::getDefaultSansSerifFontName(),
|
||||
Font::getDefaultStyle(),
|
||||
5.0f)) });
|
||||
const auto typeface = Font::getDefaultTypefaceForFont (FontOptions (Font::getDefaultSansSerifFontName(),
|
||||
Font::getDefaultStyle(),
|
||||
5.0f));
|
||||
Font font (withDefaultMetrics (FontOptions { typeface }));
|
||||
|
||||
const int boxHeight = 24;
|
||||
passwordBox.setBounds (r.removeFromBottom (boxHeight));
|
||||
|
|
@ -286,7 +287,7 @@ void OnlineUnlockForm::showBubbleMessage (const String& text, Component& target)
|
|||
addChildComponent (bubble.get());
|
||||
|
||||
AttributedString attString;
|
||||
attString.append (text, FontOptions (16.0f));
|
||||
attString.append (text, withDefaultMetrics (FontOptions (16.0f)));
|
||||
|
||||
bubble->showAt (getLocalArea (&target, target.getLocalBounds()),
|
||||
attString, 500, // numMillisecondsBeforeRemoving
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue