Add getActiveColor functions to IGUIStaticText and IGUIButton

Returns currently used color - depending on state and if override color is set.
Note: Not adding this to editbox for now as it's a bit more tricky there (selection changing color, so it has no single color).


git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6165 dfc29bdd-3216-0410-991c-e03cc46cb475
This commit is contained in:
cutealien 2020-12-10 14:45:30 +00:00
parent bd2b44aa1c
commit c90238e87f
7 changed files with 39 additions and 4 deletions

@ -1,5 +1,6 @@
-------------------------- --------------------------
Changes in 1.9 (not yet released) Changes in 1.9 (not yet released)
- Add getActiveColor functions to IGUIStaticText and IGUIButton (get currently used color).
- Add IGUIEnvironment::addToDeletionQueue to allow save removal of gui elements while iterating over them (like the same named function in ISceneManager). - Add IGUIEnvironment::addToDeletionQueue to allow save removal of gui elements while iterating over them (like the same named function in ISceneManager).
- IGUIEnvironment::drawAll has now a parameter to allow disabling automatic resize to screensize. Makes it easier to use partial screens with full alignment support. - IGUIEnvironment::drawAll has now a parameter to allow disabling automatic resize to screensize. Makes it easier to use partial screens with full alignment support.
- No longer try to set WM_QUIT when using an external Window on Win32. - No longer try to set WM_QUIT when using an external Window on Win32.

@ -139,6 +139,10 @@ namespace gui
/** \return: The override color */ /** \return: The override color */
virtual video::SColor getOverrideColor(void) const = 0; virtual video::SColor getOverrideColor(void) const = 0;
//! Gets the currently used text color
/** Either a skin-color for the current state or the override color */
virtual video::SColor getActiveColor() const = 0;
//! Sets if the button text should use the override color or the color in the gui skin. //! 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 /** \param enable: If set to true, the override color, which can be set
with IGUIStaticText::setOverrideColor is used, otherwise the with IGUIStaticText::setOverrideColor is used, otherwise the

@ -51,6 +51,10 @@ namespace gui
/** \return: The override color */ /** \return: The override color */
virtual video::SColor getOverrideColor(void) const = 0; virtual video::SColor getOverrideColor(void) const = 0;
//! Gets the currently used text color
/** Either a skin-color for the current state or the override color */
virtual video::SColor getActiveColor() const = 0;
//! Sets if the static text should use the override color or the color in the gui skin. //! Sets if the static 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 /** \param enable: If set to true, the override color, which can be set
with IGUIStaticText::setOverrideColor is used, otherwise the with IGUIStaticText::setOverrideColor is used, otherwise the

@ -327,7 +327,7 @@ void CGUIButton::draw()
if (font) if (font)
font->draw(Text.c_str(), rect, font->draw(Text.c_str(), rect,
OverrideColorEnabled ? OverrideColor : skin->getColor(isEnabled() ? EGDC_BUTTON_TEXT : EGDC_GRAY_TEXT), getActiveColor(),
true, true, &AbsoluteClippingRect); true, true, &AbsoluteClippingRect);
} }
@ -466,6 +466,16 @@ video::SColor CGUIButton::getOverrideColor() const
return OverrideColor; return OverrideColor;
} }
irr::video::SColor CGUIButton::getActiveColor() const
{
if ( OverrideColorEnabled )
return OverrideColor;
IGUISkin* skin = Environment->getSkin();
if (skin)
return OverrideColorEnabled ? OverrideColor : skin->getColor(isEnabled() ? EGDC_BUTTON_TEXT : EGDC_GRAY_TEXT);
return OverrideColor;
}
void CGUIButton::enableOverrideColor(bool enable) void CGUIButton::enableOverrideColor(bool enable)
{ {
OverrideColorEnabled = enable; OverrideColorEnabled = enable;

@ -50,6 +50,9 @@ namespace gui
//! Gets the override color //! Gets the override color
virtual video::SColor getOverrideColor(void) const _IRR_OVERRIDE_; virtual video::SColor getOverrideColor(void) const _IRR_OVERRIDE_;
//! Gets the currently used text color
virtual video::SColor getActiveColor() const _IRR_OVERRIDE_;
//! Sets if the button text should use the override color or the color in the gui skin. //! Sets if the button text should use the override color or the color in the gui skin.
virtual void enableOverrideColor(bool enable) _IRR_OVERRIDE_; virtual void enableOverrideColor(bool enable) _IRR_OVERRIDE_;

@ -100,7 +100,7 @@ void CGUIStaticText::draw()
} }
font->draw(Text.c_str(), frameRect, font->draw(Text.c_str(), frameRect,
OverrideColorEnabled ? OverrideColor : skin->getColor(isEnabled() ? EGDC_BUTTON_TEXT : EGDC_GRAY_TEXT), getActiveColor(),
HAlign == EGUIA_CENTER, VAlign == EGUIA_CENTER, (RestrainTextInside ? &AbsoluteClippingRect : NULL)); HAlign == EGUIA_CENTER, VAlign == EGUIA_CENTER, (RestrainTextInside ? &AbsoluteClippingRect : NULL));
} }
else else
@ -129,7 +129,7 @@ void CGUIStaticText::draw()
} }
font->draw(BrokenText[i].c_str(), r, font->draw(BrokenText[i].c_str(), r,
OverrideColorEnabled ? OverrideColor : skin->getColor(isEnabled() ? EGDC_BUTTON_TEXT : EGDC_GRAY_TEXT), getActiveColor(),
HAlign == EGUIA_CENTER, false, (RestrainTextInside ? &AbsoluteClippingRect : NULL)); HAlign == EGUIA_CENTER, false, (RestrainTextInside ? &AbsoluteClippingRect : NULL));
r.LowerRightCorner.Y += height; r.LowerRightCorner.Y += height;
@ -254,6 +254,16 @@ video::SColor CGUIStaticText::getOverrideColor() const
} }
irr::video::SColor CGUIStaticText::getActiveColor() const
{
if ( OverrideColorEnabled )
return OverrideColor;
IGUISkin* skin = Environment->getSkin();
if (skin)
return OverrideColorEnabled ? OverrideColor : skin->getColor(isEnabled() ? EGDC_BUTTON_TEXT : EGDC_GRAY_TEXT);
return OverrideColor;
}
//! Sets if the static text should use the override color or the //! Sets if the static text should use the override color or the
//! color in the gui skin. //! color in the gui skin.
void CGUIStaticText::enableOverrideColor(bool enable) void CGUIStaticText::enableOverrideColor(bool enable)

@ -66,6 +66,9 @@ namespace gui
//! Gets the override color //! Gets the override color
virtual video::SColor getOverrideColor() const _IRR_OVERRIDE_; virtual video::SColor getOverrideColor() const _IRR_OVERRIDE_;
//! Gets the currently used text color
virtual video::SColor getActiveColor() const _IRR_OVERRIDE_;
//! Sets if the static text should use the override color or the //! Sets if the static text should use the override color or the
//! color in the gui skin. //! color in the gui skin.
virtual void enableOverrideColor(bool enable) _IRR_OVERRIDE_; virtual void enableOverrideColor(bool enable) _IRR_OVERRIDE_;