Add IGUIButton::setOverrideColor to allow overriding text-color (same function as statictexts and editboxes have).
git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@5546 dfc29bdd-3216-0410-991c-e03cc46cb475master
parent
4d59133e49
commit
92799fded9
|
@ -1,6 +1,7 @@
|
|||
--------------------------
|
||||
Changes in 1.9 (not yet released)
|
||||
|
||||
- Add IGUIButton::setOverrideColor to allow overriding text-color (same function as statictexts and editboxes have).
|
||||
- Add functions IGUIButton::getClickShiftState and IGUIButton::getClickControlState to get shift/ctrl key-state when a button was clicked. Thanks @StarSonata for patch.
|
||||
- Add function ISceneManager::clearAllRegisteredNodesForRendering.
|
||||
- Add function IVideoDriver::queryTextureFormat to allow checking if a driver supports textures with a specific color format.
|
||||
|
|
|
@ -128,6 +128,27 @@ namespace gui
|
|||
font of the active skin otherwise */
|
||||
virtual IGUIFont* getActiveFont() const = 0;
|
||||
|
||||
//! Sets another color for the button text.
|
||||
/** When set, this color is used instead of EGDC_BUTTON_TEXT/EGDC_GRAY_TEXT.
|
||||
You don't need to call enableOverrideColor(true), that's done by this function.
|
||||
If you want the the color of the skin back, call enableOverrideColor(false);
|
||||
\param color: New color of the text. */
|
||||
virtual void setOverrideColor(video::SColor color) = 0;
|
||||
|
||||
//! Gets the override color
|
||||
/** \return: The override color */
|
||||
virtual video::SColor getOverrideColor(void) const = 0;
|
||||
|
||||
//! Sets if the button text should use the override color or the color in the gui skin.
|
||||
/** \param enable: If set to true, the override color, which can be set
|
||||
with IGUIStaticText::setOverrideColor is used, otherwise the
|
||||
EGDC_BUTTON_TEXT or EGDC_GRAY_TEXT color of the skin. */
|
||||
virtual void enableOverrideColor(bool enable) = 0;
|
||||
|
||||
//! Checks if an override color is enabled
|
||||
/** \return true if the override color is enabled, false otherwise */
|
||||
virtual bool isOverrideColorEnabled(void) const = 0;
|
||||
|
||||
//! Sets an image which should be displayed on the button when it is in the given state.
|
||||
/** Only one image-state can be active at a time. Images are drawn below sprites.
|
||||
If a state is without image it will try to use images from other states as described
|
||||
|
|
|
@ -21,6 +21,7 @@ CGUIButton::CGUIButton(IGUIEnvironment* environment, IGUIElement* parent,
|
|||
s32 id, core::rect<s32> rectangle, bool noclip)
|
||||
: IGUIButton(environment, parent, id, rectangle),
|
||||
SpriteBank(0), OverrideFont(0),
|
||||
OverrideColorEnabled(false), OverrideColor(video::SColor(101,255,255,255)),
|
||||
ClickTime(0), HoverTime(0), FocusTime(0),
|
||||
ClickShiftState(false), ClickControlState(false),
|
||||
IsPushButton(false), Pressed(false),
|
||||
|
@ -327,7 +328,7 @@ void CGUIButton::draw()
|
|||
|
||||
if (font)
|
||||
font->draw(Text.c_str(), rect,
|
||||
skin->getColor(isEnabled() ? EGDC_BUTTON_TEXT : EGDC_GRAY_TEXT),
|
||||
OverrideColorEnabled ? OverrideColor : skin->getColor(isEnabled() ? EGDC_BUTTON_TEXT : EGDC_GRAY_TEXT),
|
||||
true, true, &AbsoluteClippingRect);
|
||||
}
|
||||
|
||||
|
@ -454,6 +455,28 @@ IGUIFont* CGUIButton::getActiveFont() const
|
|||
return 0;
|
||||
}
|
||||
|
||||
//! Sets another color for the text.
|
||||
void CGUIButton::setOverrideColor(video::SColor color)
|
||||
{
|
||||
OverrideColor = color;
|
||||
OverrideColorEnabled = true;
|
||||
}
|
||||
|
||||
video::SColor CGUIButton::getOverrideColor() const
|
||||
{
|
||||
return OverrideColor;
|
||||
}
|
||||
|
||||
void CGUIButton::enableOverrideColor(bool enable)
|
||||
{
|
||||
OverrideColorEnabled = enable;
|
||||
}
|
||||
|
||||
bool CGUIButton::isOverrideColorEnabled() const
|
||||
{
|
||||
return OverrideColorEnabled;
|
||||
}
|
||||
|
||||
void CGUIButton::setImage(EGUI_BUTTON_IMAGE_STATE state, video::ITexture* image, const core::rect<s32>& sourceRect)
|
||||
{
|
||||
if ( state >= EGBIS_COUNT )
|
||||
|
|
|
@ -44,6 +44,18 @@ namespace gui
|
|||
//! Get the font which is used right now for drawing
|
||||
virtual IGUIFont* getActiveFont() const _IRR_OVERRIDE_;
|
||||
|
||||
//! Sets another color for the button text.
|
||||
virtual void setOverrideColor(video::SColor color) _IRR_OVERRIDE_;
|
||||
|
||||
//! Gets the override color
|
||||
virtual video::SColor getOverrideColor(void) const _IRR_OVERRIDE_;
|
||||
|
||||
//! Sets if the button text should use the override color or the color in the gui skin.
|
||||
virtual void enableOverrideColor(bool enable) _IRR_OVERRIDE_;
|
||||
|
||||
//! Checks if an override color is enabled
|
||||
virtual bool isOverrideColorEnabled(void) const _IRR_OVERRIDE_;
|
||||
|
||||
//! Sets an image which should be displayed on the button when it is in the given state.
|
||||
virtual void setImage(EGUI_BUTTON_IMAGE_STATE state, video::ITexture* image=0, const core::rect<s32>& sourceRect=core::rect<s32>(0,0,0,0)) _IRR_OVERRIDE_;
|
||||
|
||||
|
@ -217,6 +229,9 @@ namespace gui
|
|||
|
||||
IGUIFont* OverrideFont;
|
||||
|
||||
bool OverrideColorEnabled;
|
||||
video::SColor OverrideColor;
|
||||
|
||||
u32 ClickTime, HoverTime, FocusTime;
|
||||
|
||||
bool ClickShiftState;
|
||||
|
|
Loading…
Reference in New Issue