mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
Moved DrawableButton painting into a new method LookAndFeel::drawDrawableButton()
This commit is contained in:
parent
74390295ad
commit
cfe45720cc
4 changed files with 42 additions and 29 deletions
|
|
@ -175,37 +175,15 @@ void DrawableButton::paintButton (Graphics& g,
|
|||
const bool isMouseOverButton,
|
||||
const bool isButtonDown)
|
||||
{
|
||||
LookAndFeel& lf = getLookAndFeel();
|
||||
|
||||
if (style == ImageOnButtonBackground)
|
||||
{
|
||||
getLookAndFeel().drawButtonBackground (g, *this,
|
||||
findColour (getToggleState() ? TextButton::buttonOnColourId
|
||||
: TextButton::buttonColourId),
|
||||
isMouseOverButton,
|
||||
isButtonDown);
|
||||
}
|
||||
lf.drawButtonBackground (g, *this,
|
||||
findColour (getToggleState() ? TextButton::buttonOnColourId
|
||||
: TextButton::buttonColourId),
|
||||
isMouseOverButton, isButtonDown);
|
||||
else
|
||||
{
|
||||
g.fillAll (findColour (getToggleState() ? backgroundOnColourId
|
||||
: backgroundColourId));
|
||||
|
||||
const int textH = (style == ImageAboveTextLabel)
|
||||
? jmin (16, proportionOfHeight (0.25f))
|
||||
: 0;
|
||||
|
||||
if (textH > 0)
|
||||
{
|
||||
g.setFont ((float) textH);
|
||||
|
||||
g.setColour (findColour (getToggleState() ? DrawableButton::textColourOnId
|
||||
: DrawableButton::textColourId)
|
||||
.withMultipliedAlpha (isEnabled() ? 1.0f : 0.4f));
|
||||
|
||||
g.drawFittedText (getButtonText(),
|
||||
2, getHeight() - textH - 1,
|
||||
getWidth() - 4, textH,
|
||||
Justification::centred, 1);
|
||||
}
|
||||
}
|
||||
lf.drawDrawableButton (g, *this, isMouseOverButton, isButtonDown);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
|
|
|
|||
|
|
@ -115,6 +115,9 @@ public:
|
|||
*/
|
||||
void setButtonStyle (ButtonStyle newStyle);
|
||||
|
||||
/** Returns the current style. */
|
||||
ButtonStyle getStyle() const noexcept { return style; }
|
||||
|
||||
//==============================================================================
|
||||
/** Gives the button an optional amount of space around the edge of the drawable.
|
||||
By default there's a gap of about 3 pixels.
|
||||
|
|
|
|||
|
|
@ -447,6 +447,33 @@ void LookAndFeel::changeToggleButtonWidthToFitText (ToggleButton& button)
|
|||
button.getHeight());
|
||||
}
|
||||
|
||||
void LookAndFeel::drawDrawableButton (Graphics& g, DrawableButton& button,
|
||||
bool /*isMouseOverButton*/, bool /*isButtonDown*/)
|
||||
{
|
||||
bool toggleState = button.getToggleState();
|
||||
|
||||
g.fillAll (button.findColour (toggleState ? DrawableButton::backgroundOnColourId
|
||||
: DrawableButton::backgroundColourId));
|
||||
|
||||
const int textH = (button.getStyle() == DrawableButton::ImageAboveTextLabel)
|
||||
? jmin (16, button.proportionOfHeight (0.25f))
|
||||
: 0;
|
||||
|
||||
if (textH > 0)
|
||||
{
|
||||
g.setFont ((float) textH);
|
||||
|
||||
g.setColour (button.findColour (toggleState ? DrawableButton::textColourOnId
|
||||
: DrawableButton::textColourId)
|
||||
.withMultipliedAlpha (button.isEnabled() ? 1.0f : 0.4f));
|
||||
|
||||
g.drawFittedText (button.getButtonText(),
|
||||
2, button.getHeight() - textH - 1,
|
||||
button.getWidth() - 4, textH,
|
||||
Justification::centred, 1);
|
||||
}
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
AlertWindow* LookAndFeel::createAlertWindow (const String& title,
|
||||
const String& message,
|
||||
|
|
|
|||
|
|
@ -182,6 +182,11 @@ public:
|
|||
bool isMouseOverButton,
|
||||
bool isButtonDown);
|
||||
|
||||
virtual void drawDrawableButton (Graphics& g,
|
||||
DrawableButton& button,
|
||||
bool isMouseOverButton,
|
||||
bool isButtonDown);
|
||||
|
||||
//==============================================================================
|
||||
// AlertWindow handling..
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue