Browse Source

Added a LookAndFeel method to modify Label borders

tags/2021-05-28
Tom Poole 7 years ago
parent
commit
0165e066b2
4 changed files with 11 additions and 4 deletions
  1. +3
    -3
      modules/juce_graphics/geometry/juce_BorderSize.h
  2. +6
    -1
      modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V2.cpp
  3. +1
    -0
      modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V2.h
  4. +1
    -0
      modules/juce_gui_basics/widgets/juce_Label.h

+ 3
- 3
modules/juce_graphics/geometry/juce_BorderSize.h View File

@@ -67,13 +67,13 @@ public:
/** 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. */


+ 6
- 1
modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V2.cpp View File

@@ -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())),
@@ -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*/,


+ 1
- 0
modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V2.h View File

@@ -203,6 +203,7 @@ public:
//==============================================================================
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,


+ 1
- 0
modules/juce_gui_basics/widgets/juce_Label.h View File

@@ -280,6 +280,7 @@ public:
virtual void drawLabel (Graphics&, Label&) = 0;
virtual Font getLabelFont (Label&) = 0;
virtual BorderSize<int> getLabelBorderSize (Label&) = 0;
};
protected:


Loading…
Cancel
Save