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)
- 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).
- 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.

@ -139,6 +139,10 @@ namespace gui
/** \return: The override color */
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.
/** \param enable: If set to true, the override color, which can be set
with IGUIStaticText::setOverrideColor is used, otherwise the

@ -51,6 +51,10 @@ namespace gui
/** \return: The override color */
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.
/** \param enable: If set to true, the override color, which can be set
with IGUIStaticText::setOverrideColor is used, otherwise the

@ -327,7 +327,7 @@ void CGUIButton::draw()
if (font)
font->draw(Text.c_str(), rect,
OverrideColorEnabled ? OverrideColor : skin->getColor(isEnabled() ? EGDC_BUTTON_TEXT : EGDC_GRAY_TEXT),
getActiveColor(),
true, true, &AbsoluteClippingRect);
}
@ -466,6 +466,16 @@ video::SColor CGUIButton::getOverrideColor() const
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)
{
OverrideColorEnabled = enable;

@ -50,6 +50,9 @@ namespace gui
//! Gets the override color
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.
virtual void enableOverrideColor(bool enable) _IRR_OVERRIDE_;

@ -99,8 +99,8 @@ void CGUIStaticText::draw()
font->getDimension(Text.c_str()).Width;
}
font->draw(Text.c_str(), frameRect,
OverrideColorEnabled ? OverrideColor : skin->getColor(isEnabled() ? EGDC_BUTTON_TEXT : EGDC_GRAY_TEXT),
font->draw(Text.c_str(), frameRect,
getActiveColor(),
HAlign == EGUIA_CENTER, VAlign == EGUIA_CENTER, (RestrainTextInside ? &AbsoluteClippingRect : NULL));
}
else
@ -129,7 +129,7 @@ void CGUIStaticText::draw()
}
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));
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
//! color in the gui skin.
void CGUIStaticText::enableOverrideColor(bool enable)

@ -66,6 +66,9 @@ namespace gui
//! Gets the override color
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
//! color in the gui skin.
virtual void enableOverrideColor(bool enable) _IRR_OVERRIDE_;