1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-26 02:14:22 +00:00
This commit is contained in:
jules 2007-10-04 10:56:58 +00:00
parent 05e4c79c7c
commit 697ca8615a
5 changed files with 211 additions and 86 deletions

View file

@ -59,22 +59,9 @@ void TextButton::paintButton (Graphics& g,
isMouseOverButton,
isButtonDown);
const int yIndent = jmin (4, proportionOfHeight (0.3f));
const int cornerSize = jmin (getHeight(), getWidth()) / 2;
g.setFont (getFont());
g.setColour (findColour (textColourId).withMultipliedAlpha (isEnabled() ? 1.0f : 0.5f));
const int fontHeight = roundFloatToInt (g.getCurrentFont().getHeight() * 0.6f);
const int leftIndent = jmin (fontHeight, 2 + cornerSize / (isConnectedOnLeft() ? 4 : 2));
const int rightIndent = jmin (fontHeight, 2 + cornerSize / (isConnectedOnRight() ? 4 : 2));
g.drawFittedText (getButtonText(),
leftIndent,
yIndent,
getWidth() - leftIndent - rightIndent,
getHeight() - yIndent * 2,
Justification::centred, 2);
getLookAndFeel().drawButtonText (g, *this,
isMouseOverButton,
isButtonDown);
}
void TextButton::colourChanged()

View file

@ -308,6 +308,28 @@ void LookAndFeel::drawButtonBackground (Graphics& g,
button.isConnectedOnBottom());
}
void LookAndFeel::drawButtonText (Graphics& g, TextButton& button,
bool /*isMouseOverButton*/, bool /*isButtonDown*/)
{
g.setFont (button.getFont());
g.setColour (button.findColour (TextButton::textColourId)
.withMultipliedAlpha (button.isEnabled() ? 1.0f : 0.5f));
const int yIndent = jmin (4, button.proportionOfHeight (0.3f));
const int cornerSize = jmin (button.getHeight(), button.getWidth()) / 2;
const int fontHeight = roundFloatToInt (g.getCurrentFont().getHeight() * 0.6f);
const int leftIndent = jmin (fontHeight, 2 + cornerSize / (button.isConnectedOnLeft() ? 4 : 2));
const int rightIndent = jmin (fontHeight, 2 + cornerSize / (button.isConnectedOnRight() ? 4 : 2));
g.drawFittedText (button.getButtonText(),
leftIndent,
yIndent,
button.getWidth() - leftIndent - rightIndent,
button.getHeight() - yIndent * 2,
Justification::centred, 2);
}
void LookAndFeel::drawTickBox (Graphics& g,
Component& component,
int x, int y, int w, int h,

View file

@ -38,6 +38,7 @@
#include "../layout/juce_TabbedComponent.h"
class ToggleButton;
class TextButton;
class AlertWindow;
class TextLayout;
class ScrollBar;
@ -130,6 +131,11 @@ public:
bool isMouseOverButton,
bool isButtonDown);
/** Draws the text for a TextButton. */
virtual void drawButtonText (Graphics& g,
TextButton& button,
bool isMouseOverButton,
bool isButtonDown);
/** Draws the contents of a standard ToggleButton. */
virtual void drawToggleButton (Graphics& g,

View file

@ -137,8 +137,13 @@ void PropertySet::setValue (const String& keyName,
{
const ScopedLock sl (lock);
properties.set (keyName, value);
propertyChanged();
const int index = properties.getAllKeys().indexOf (keyName, ignoreCaseOfKeys);
if (index < 0 || properties.getAllValues() [index] != value)
{
properties.set (keyName, value);
propertyChanged();
}
}
}