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

Added some more places where we can use the BorderSize from a Label's LookAndFeel

This commit is contained in:
Tom Poole 2018-09-04 12:47:30 +01:00
parent 0165e066b2
commit 02f8a125c4
3 changed files with 9 additions and 6 deletions

View file

@ -1218,7 +1218,7 @@ void LookAndFeel_V2::drawComboBoxTextWhenNothingSelected (Graphics& g, ComboBox&
g.setFont (font);
auto textArea = label.getBorderSize().subtractedFrom (label.getLocalBounds());
auto textArea = getLabelBorderSize (label).subtractedFrom (label.getLocalBounds());
g.drawFittedText (box.getTextWhenNothingSelected(), textArea, label.getJustificationType(),
jmax (1, (int) (textArea.getHeight() / font.getHeight())),

View file

@ -96,8 +96,9 @@ public:
{
if (getText().isEmpty() && ! isBeingEdited())
{
auto textArea = getBorderSize().subtractedFrom (getLocalBounds());
auto labelFont = owner.getLookAndFeel().getLabelFont (*this);
auto& lf = owner.getLookAndFeel();
auto textArea = lf.getLabelBorderSize (*this).subtractedFrom (getLocalBounds());
auto labelFont = lf.getLabelFont (*this);
g.setColour (owner.findColour (TextPropertyComponent::textColourId).withAlpha (alphaToUseForEmptyText));
g.setFont (labelFont);

View file

@ -155,19 +155,21 @@ void Label::attachToComponent (Component* owner, bool onLeft)
void Label::componentMovedOrResized (Component& component, bool /*wasMoved*/, bool /*wasResized*/)
{
auto f = getLookAndFeel().getLabelFont (*this);
auto& lf = getLookAndFeel();
auto f = lf.getLabelFont (*this);
auto border = lf.getLabelBorderSize (*this);
if (leftOfOwnerComp)
{
auto width = jmin (roundToInt (f.getStringWidthFloat (textValue.toString()) + 0.5f)
+ getBorderSize().getLeftAndRight(),
+ border.getLeftAndRight(),
component.getX());
setBounds (component.getX() - width, component.getY(), width, component.getHeight());
}
else
{
auto height = getBorderSize().getTopAndBottom() + 6 + roundToInt (f.getHeight() + 0.5f);
auto height = border.getTopAndBottom() + 6 + roundToInt (f.getHeight() + 0.5f);
setBounds (component.getX(), component.getY() - height, component.getWidth(), height);
}