Skip to content

Commit

Permalink
Added a LookAndFeel method to modify Label borders
Browse files Browse the repository at this point in the history
  • Loading branch information
tpoole committed Sep 4, 2018
1 parent 27349ea commit 0165e06
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 4 deletions.
6 changes: 3 additions & 3 deletions modules/juce_graphics/geometry/juce_BorderSize.h
Expand Up @@ -67,13 +67,13 @@ class BorderSize
/** Returns the gap that should be left at the top of the region. */
ValueType getTop() const noexcept { return top; }

/** Returns the gap that should be left at the top of the region. */
/** Returns the gap that should be left at the left of the region. */
ValueType getLeft() const noexcept { return left; }

/** Returns the gap that should be left at the top of the region. */
/** Returns the gap that should be left at the bottom of the region. */
ValueType getBottom() const noexcept { return bottom; }

/** Returns the gap that should be left at the top of the region. */
/** Returns the gap that should be left at the right of the region. */
ValueType getRight() const noexcept { return right; }

/** Returns the sum of the top and bottom gaps. */
Expand Down
7 changes: 6 additions & 1 deletion modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V2.cpp
Expand Up @@ -1243,7 +1243,7 @@ void LookAndFeel_V2::drawLabel (Graphics& g, Label& label)
g.setColour (label.findColour (Label::textColourId).withMultipliedAlpha (alpha));
g.setFont (font);

auto textArea = label.getBorderSize().subtractedFrom (label.getLocalBounds());
auto textArea = getLabelBorderSize (label).subtractedFrom (label.getLocalBounds());

g.drawFittedText (label.getText(), textArea, label.getJustificationType(),
jmax (1, (int) (textArea.getHeight() / font.getHeight())),
Expand All @@ -1259,6 +1259,11 @@ void LookAndFeel_V2::drawLabel (Graphics& g, Label& label)
g.drawRect (label.getLocalBounds());
}

BorderSize<int> LookAndFeel_V2::getLabelBorderSize (Label& label)
{
return label.getBorderSize();
}

//==============================================================================
void LookAndFeel_V2::drawLinearSliderBackground (Graphics& g, int x, int y, int width, int height,
float /*sliderPos*/,
Expand Down
1 change: 1 addition & 0 deletions modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V2.h
Expand Up @@ -203,6 +203,7 @@ class JUCE_API LookAndFeel_V2 : public LookAndFeel
//==============================================================================
void drawLabel (Graphics&, Label&) override;
Font getLabelFont (Label&) override;
BorderSize<int> getLabelBorderSize (Label&) override;

//==============================================================================
void drawLinearSlider (Graphics&, int x, int y, int width, int height,
Expand Down
1 change: 1 addition & 0 deletions modules/juce_gui_basics/widgets/juce_Label.h
Expand Up @@ -280,6 +280,7 @@ class JUCE_API Label : public Component,

virtual void drawLabel (Graphics&, Label&) = 0;
virtual Font getLabelFont (Label&) = 0;
virtual BorderSize<int> getLabelBorderSize (Label&) = 0;
};

protected:
Expand Down

0 comments on commit 0165e06

Please sign in to comment.