Commit 3897efe3 authored by cutealien's avatar cutealien

- Add new skin-colors: EGDC_GRAY_WINDOW_SYMBOL, EGDC_EDITABLE,...

- Add new skin-colors: EGDC_GRAY_WINDOW_SYMBOL, EGDC_EDITABLE, EGDC_GRAY_EDITABLE, EGDC_FOCUSED_EDITABLE
- Make sure disabled state is extended to sub-elements.
- Fix that icons in tabcontrol get also affected immediately by skin-changes
- Make disabled state for several elements more visible


git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@3433 dfc29bdd-3216-0410-991c-e03cc46cb475
parent 61d23229
...@@ -454,9 +454,16 @@ public: ...@@ -454,9 +454,16 @@ public:
} }
//! Returns true if element is enabled. //! Returns true if element is enabled
/** Currently elements do _not_ care about parent-states.
So if you want to affect childs you have to enable/disable them all.
The only exception to this are sub-elements which also check their parent.
*/
virtual bool isEnabled() const virtual bool isEnabled() const
{ {
if ( isSubElement() && IsEnabled && getParent() )
return getParent()->isEnabled();
_IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX;
return IsEnabled; return IsEnabled;
} }
......
...@@ -99,6 +99,15 @@ namespace gui ...@@ -99,6 +99,15 @@ namespace gui
EGDC_ICON, EGDC_ICON,
//! Selected icons in a list or tree //! Selected icons in a list or tree
EGDC_ICON_HIGH_LIGHT, EGDC_ICON_HIGH_LIGHT,
//! Grayed (disabled) window symbols like on close buttons, scroll bars and check boxes
EGDC_GRAY_WINDOW_SYMBOL,
//! Window background for editable field (editbox, checkbox-field)
EGDC_EDITABLE,
//! Grayed (disabled) window background for editable field (editbox, checkbox-field)
EGDC_GRAY_EDITABLE,
//! Show focus of window background for editable field (editbox or when checkbox-field is pressed)
EGDC_FOCUSED_EDITABLE,
//! this value is not used, it only specifies the amount of default colors //! this value is not used, it only specifies the amount of default colors
//! available. //! available.
EGDC_COUNT EGDC_COUNT
...@@ -128,6 +137,10 @@ namespace gui ...@@ -128,6 +137,10 @@ namespace gui
"WindowSymbol", "WindowSymbol",
"Icon", "Icon",
"IconHighlight", "IconHighlight",
"GrayWindowSymbol",
"Editable",
"GrayEditable",
"FocusedEditable",
0, 0,
}; };
......
...@@ -108,7 +108,7 @@ void CGUIButton::setSprite(EGUI_BUTTON_STATE state, s32 index, video::SColor col ...@@ -108,7 +108,7 @@ void CGUIButton::setSprite(EGUI_BUTTON_STATE state, s32 index, video::SColor col
//! called if an event happened. //! called if an event happened.
bool CGUIButton::OnEvent(const SEvent& event) bool CGUIButton::OnEvent(const SEvent& event)
{ {
if (!IsEnabled) if (!isEnabled())
return IGUIElement::OnEvent(event); return IGUIElement::OnEvent(event);
switch(event.EventType) switch(event.EventType)
...@@ -297,7 +297,7 @@ void CGUIButton::draw() ...@@ -297,7 +297,7 @@ void CGUIButton::draw()
if (font) if (font)
font->draw(Text.c_str(), rect, font->draw(Text.c_str(), rect,
skin->getColor(IsEnabled ? EGDC_BUTTON_TEXT : EGDC_GRAY_TEXT), skin->getColor(isEnabled() ? EGDC_BUTTON_TEXT : EGDC_GRAY_TEXT),
true, true, &AbsoluteClippingRect); true, true, &AbsoluteClippingRect);
} }
......
...@@ -34,7 +34,7 @@ CGUICheckBox::CGUICheckBox(bool checked, IGUIEnvironment* environment, IGUIEleme ...@@ -34,7 +34,7 @@ CGUICheckBox::CGUICheckBox(bool checked, IGUIEnvironment* environment, IGUIEleme
//! called if an event happened. //! called if an event happened.
bool CGUICheckBox::OnEvent(const SEvent& event) bool CGUICheckBox::OnEvent(const SEvent& event)
{ {
if (IsEnabled) if (isEnabled())
{ {
switch(event.EventType) switch(event.EventType)
{ {
...@@ -139,7 +139,10 @@ void CGUICheckBox::draw() ...@@ -139,7 +139,10 @@ void CGUICheckBox::draw()
checkRect.LowerRightCorner.X = checkRect.UpperLeftCorner.X + height; checkRect.LowerRightCorner.X = checkRect.UpperLeftCorner.X + height;
checkRect.LowerRightCorner.Y = checkRect.UpperLeftCorner.Y + height; checkRect.LowerRightCorner.Y = checkRect.UpperLeftCorner.Y + height;
skin->draw3DSunkenPane(this, skin->getColor(Pressed || !IsEnabled ? EGDC_3D_FACE : EGDC_ACTIVE_CAPTION), EGUI_DEFAULT_COLOR col = EGDC_GRAY_EDITABLE;
if ( isEnabled() )
col = Pressed ? EGDC_FOCUSED_EDITABLE : EGDC_EDITABLE;
skin->draw3DSunkenPane(this, skin->getColor(col),
false, true, checkRect, &AbsoluteClippingRect); false, true, checkRect, &AbsoluteClippingRect);
if (Checked && Environment->getSkin()) if (Checked && Environment->getSkin())
...@@ -154,7 +157,7 @@ void CGUICheckBox::draw() ...@@ -154,7 +157,7 @@ void CGUICheckBox::draw()
IGUIFont* font = skin->getFont(); IGUIFont* font = skin->getFont();
if (font) if (font)
font->draw(Text.c_str(), checkRect, font->draw(Text.c_str(), checkRect,
skin->getColor(IsEnabled ? EGDC_BUTTON_TEXT : EGDC_GRAY_TEXT), false, true, &AbsoluteClippingRect); skin->getColor(isEnabled() ? EGDC_BUTTON_TEXT : EGDC_GRAY_TEXT), false, true, &AbsoluteClippingRect);
} }
IGUIElement::draw(); IGUIElement::draw();
......
...@@ -273,7 +273,7 @@ void CGUIColorSelectDialog::buildColorRing( const core::dimension2d<u32> & dim, ...@@ -273,7 +273,7 @@ void CGUIColorSelectDialog::buildColorRing( const core::dimension2d<u32> & dim,
{ {
const u32 alpha = (u32) ( (rTest - 0.5f ) * ( 255.f / 0.05f ) ); const u32 alpha = (u32) ( (rTest - 0.5f ) * ( 255.f / 0.05f ) );
rgb.setAlpha(alpha); rgb.setAlpha(alpha);
} }
else if ( rTest >= 0.95f ) else if ( rTest >= 0.95f )
{ {
const u32 alpha = (u32) ( (rTest - 0.95f ) * ( 255.f / 0.05f ) ); const u32 alpha = (u32) ( (rTest - 0.95f ) * ( 255.f / 0.05f ) );
...@@ -312,7 +312,7 @@ void CGUIColorSelectDialog::buildColorRing( const core::dimension2d<u32> & dim, ...@@ -312,7 +312,7 @@ void CGUIColorSelectDialog::buildColorRing( const core::dimension2d<u32> & dim,
//! called if an event happened. //! called if an event happened.
bool CGUIColorSelectDialog::OnEvent(const SEvent& event) bool CGUIColorSelectDialog::OnEvent(const SEvent& event)
{ {
if (IsEnabled) if (isEnabled())
{ {
switch(event.EventType) switch(event.EventType)
{ {
......
...@@ -182,7 +182,7 @@ void CGUIComboBox::setSelected(s32 idx) ...@@ -182,7 +182,7 @@ void CGUIComboBox::setSelected(s32 idx)
//! called if an event happened. //! called if an event happened.
bool CGUIComboBox::OnEvent(const SEvent& event) bool CGUIComboBox::OnEvent(const SEvent& event)
{ {
if (IsEnabled) if (isEnabled())
{ {
switch(event.EventType) switch(event.EventType)
{ {
...@@ -377,8 +377,8 @@ void CGUIComboBox::draw() ...@@ -377,8 +377,8 @@ void CGUIComboBox::draw()
SelectedText->setDrawBackground(false); SelectedText->setDrawBackground(false);
SelectedText->setOverrideColor(skin->getColor(EGDC_GRAY_TEXT)); SelectedText->setOverrideColor(skin->getColor(EGDC_GRAY_TEXT));
} }
ListButton->setSprite(EGBS_BUTTON_UP, skin->getIcon(EGDI_CURSOR_DOWN), skin->getColor(EGDC_WINDOW_SYMBOL)); ListButton->setSprite(EGBS_BUTTON_UP, skin->getIcon(EGDI_CURSOR_DOWN), skin->getColor(isEnabled() ? EGDC_WINDOW_SYMBOL : EGDC_GRAY_WINDOW_SYMBOL));
ListButton->setSprite(EGBS_BUTTON_DOWN, skin->getIcon(EGDI_CURSOR_DOWN), skin->getColor(EGDC_WINDOW_SYMBOL)); ListButton->setSprite(EGBS_BUTTON_DOWN, skin->getIcon(EGDI_CURSOR_DOWN), skin->getColor(isEnabled() ? EGDC_WINDOW_SYMBOL : EGDC_GRAY_WINDOW_SYMBOL));
core::rect<s32> frameRect(AbsoluteRect); core::rect<s32> frameRect(AbsoluteRect);
......
...@@ -276,7 +276,7 @@ void CGUIContextMenu::removeAllItems() ...@@ -276,7 +276,7 @@ void CGUIContextMenu::removeAllItems()
//! called if an event happened. //! called if an event happened.
bool CGUIContextMenu::OnEvent(const SEvent& event) bool CGUIContextMenu::OnEvent(const SEvent& event)
{ {
if (IsEnabled) if (isEnabled())
{ {
switch(event.EventType) switch(event.EventType)
......
...@@ -207,7 +207,7 @@ void CGUIEditBox::setTextAlignment(EGUI_ALIGNMENT horizontal, EGUI_ALIGNMENT ver ...@@ -207,7 +207,7 @@ void CGUIEditBox::setTextAlignment(EGUI_ALIGNMENT horizontal, EGUI_ALIGNMENT ver
//! called if an event happened. //! called if an event happened.
bool CGUIEditBox::OnEvent(const SEvent& event) bool CGUIEditBox::OnEvent(const SEvent& event)
{ {
if (IsEnabled) if (isEnabled())
{ {
switch(event.EventType) switch(event.EventType)
...@@ -290,7 +290,7 @@ bool CGUIEditBox::processKey(const SEvent& event) ...@@ -290,7 +290,7 @@ bool CGUIEditBox::processKey(const SEvent& event)
sc = Text.subString(realmbgn, realmend - realmbgn).c_str(); sc = Text.subString(realmbgn, realmend - realmbgn).c_str();
Operator->copyToClipboard(sc.c_str()); Operator->copyToClipboard(sc.c_str());
if (IsEnabled) if (isEnabled())
{ {
// delete // delete
core::stringw s; core::stringw s;
...@@ -306,7 +306,7 @@ bool CGUIEditBox::processKey(const SEvent& event) ...@@ -306,7 +306,7 @@ bool CGUIEditBox::processKey(const SEvent& event)
} }
break; break;
case KEY_KEY_V: case KEY_KEY_V:
if ( !IsEnabled ) if ( !isEnabled() )
break; break;
// paste from the clipboard // paste from the clipboard
...@@ -562,7 +562,7 @@ bool CGUIEditBox::processKey(const SEvent& event) ...@@ -562,7 +562,7 @@ bool CGUIEditBox::processKey(const SEvent& event)
break; break;
case KEY_BACK: case KEY_BACK:
if ( !this->IsEnabled ) if ( !isEnabled() )
break; break;
if (Text.size()) if (Text.size())
...@@ -602,7 +602,7 @@ bool CGUIEditBox::processKey(const SEvent& event) ...@@ -602,7 +602,7 @@ bool CGUIEditBox::processKey(const SEvent& event)
} }
break; break;
case KEY_DELETE: case KEY_DELETE:
if ( !this->IsEnabled ) if ( !isEnabled() )
break; break;
if (Text.size() != 0) if (Text.size() != 0)
...@@ -708,7 +708,10 @@ void CGUIEditBox::draw() ...@@ -708,7 +708,10 @@ void CGUIEditBox::draw()
if (Border) if (Border)
{ {
skin->draw3DSunkenPane(this, skin->getColor(EGDC_WINDOW), EGUI_DEFAULT_COLOR col = EGDC_GRAY_EDITABLE;
if ( isEnabled() )
col = focus ? EGDC_FOCUSED_EDITABLE : EGDC_EDITABLE;
skin->draw3DSunkenPane(this, skin->getColor(col),
false, true, FrameRect, &AbsoluteClippingRect); false, true, FrameRect, &AbsoluteClippingRect);
FrameRect.UpperLeftCorner.X += skin->getSize(EGDS_TEXT_DISTANCE_X)+1; FrameRect.UpperLeftCorner.X += skin->getSize(EGDS_TEXT_DISTANCE_X)+1;
...@@ -757,7 +760,7 @@ void CGUIEditBox::draw() ...@@ -757,7 +760,7 @@ void CGUIEditBox::draw()
if (Text.size()) if (Text.size())
{ {
if (!IsEnabled && !OverrideColorEnabled) if (!isEnabled() && !OverrideColorEnabled)
{ {
OverrideColorEnabled = true; OverrideColorEnabled = true;
OverrideColor = skin->getColor(EGDC_GRAY_TEXT); OverrideColor = skin->getColor(EGDC_GRAY_TEXT);
...@@ -1270,7 +1273,7 @@ s32 CGUIEditBox::getLineFromPos(s32 pos) ...@@ -1270,7 +1273,7 @@ s32 CGUIEditBox::getLineFromPos(s32 pos)
void CGUIEditBox::inputChar(wchar_t c) void CGUIEditBox::inputChar(wchar_t c)
{ {
if (!IsEnabled) if (!isEnabled())
return; return;
if (c != 0) if (c != 0)
......
...@@ -145,7 +145,7 @@ const io::path& CGUIFileOpenDialog::getDirectoryName() ...@@ -145,7 +145,7 @@ const io::path& CGUIFileOpenDialog::getDirectoryName()
//! called if an event happened. //! called if an event happened.
bool CGUIFileOpenDialog::OnEvent(const SEvent& event) bool CGUIFileOpenDialog::OnEvent(const SEvent& event)
{ {
if (IsEnabled) if (isEnabled())
{ {
switch(event.EventType) switch(event.EventType)
{ {
......
...@@ -213,7 +213,7 @@ void CGUIListBox::setSelected(const wchar_t *item) ...@@ -213,7 +213,7 @@ void CGUIListBox::setSelected(const wchar_t *item)
//! called if an event happened. //! called if an event happened.
bool CGUIListBox::OnEvent(const SEvent& event) bool CGUIListBox::OnEvent(const SEvent& event)
{ {
if (IsEnabled) if (isEnabled())
{ {
switch(event.EventType) switch(event.EventType)
{ {
......
...@@ -100,7 +100,7 @@ void CGUIMenu::draw() ...@@ -100,7 +100,7 @@ void CGUIMenu::draw()
//! called if an event happened. //! called if an event happened.
bool CGUIMenu::OnEvent(const SEvent& event) bool CGUIMenu::OnEvent(const SEvent& event)
{ {
if (IsEnabled) if (isEnabled())
{ {
switch(event.EventType) switch(event.EventType)
......
...@@ -254,7 +254,7 @@ void CGUIMessageBox::refreshControls() ...@@ -254,7 +254,7 @@ void CGUIMessageBox::refreshControls()
//! called if an event happened. //! called if an event happened.
bool CGUIMessageBox::OnEvent(const SEvent& event) bool CGUIMessageBox::OnEvent(const SEvent& event)
{ {
if (IsEnabled) if (isEnabled())
{ {
SEvent outevent; SEvent outevent;
outevent.EventType = EET_GUI_EVENT; outevent.EventType = EET_GUI_EVENT;
......
...@@ -77,7 +77,7 @@ bool CGUIModalScreen::isPointInside(const core::position2d<s32>& point) const ...@@ -77,7 +77,7 @@ bool CGUIModalScreen::isPointInside(const core::position2d<s32>& point) const
//! called if an event happened. //! called if an event happened.
bool CGUIModalScreen::OnEvent(const SEvent& event) bool CGUIModalScreen::OnEvent(const SEvent& event)
{ {
if (!IsEnabled || !isVisible() ) if (!isEnabled() || !isVisible() )
return IGUIElement::OnEvent(event); return IGUIElement::OnEvent(event);
switch(event.EventType) switch(event.EventType)
......
...@@ -59,7 +59,7 @@ CGUIScrollBar::~CGUIScrollBar() ...@@ -59,7 +59,7 @@ CGUIScrollBar::~CGUIScrollBar()
//! called if an event happened. //! called if an event happened.
bool CGUIScrollBar::OnEvent(const SEvent& event) bool CGUIScrollBar::OnEvent(const SEvent& event)
{ {
if (IsEnabled) if (isEnabled())
{ {
switch(event.EventType) switch(event.EventType)
...@@ -280,7 +280,7 @@ void CGUIScrollBar::draw() ...@@ -280,7 +280,7 @@ void CGUIScrollBar::draw()
return; return;
video::SColor iconColor = skin->getColor(EGDC_WINDOW_SYMBOL); video::SColor iconColor = skin->getColor(isEnabled() ? EGDC_WINDOW_SYMBOL : EGDC_GRAY_WINDOW_SYMBOL);
if ( iconColor != CurrentIconColor ) if ( iconColor != CurrentIconColor )
{ {
refreshControls(); refreshControls();
...@@ -451,7 +451,7 @@ void CGUIScrollBar::refreshControls() ...@@ -451,7 +451,7 @@ void CGUIScrollBar::refreshControls()
if (skin) if (skin)
{ {
sprites = skin->getSpriteBank(); sprites = skin->getSpriteBank();
CurrentIconColor = skin->getColor(EGDC_WINDOW_SYMBOL); CurrentIconColor = skin->getColor(isEnabled() ? EGDC_WINDOW_SYMBOL : EGDC_GRAY_WINDOW_SYMBOL);
} }
if (Horizontal) if (Horizontal)
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include "IGUIFont.h" #include "IGUIFont.h"
#include "IGUISpriteBank.h" #include "IGUISpriteBank.h"
#include "IGUIElement.h"
#include "IVideoDriver.h" #include "IVideoDriver.h"
#include "IAttributes.h" #include "IAttributes.h"
...@@ -24,27 +25,32 @@ CGUISkin::CGUISkin(EGUI_SKIN_TYPE type, video::IVideoDriver* driver) ...@@ -24,27 +25,32 @@ CGUISkin::CGUISkin(EGUI_SKIN_TYPE type, video::IVideoDriver* driver)
if ((Type == EGST_WINDOWS_CLASSIC) || (Type == EGST_WINDOWS_METALLIC)) if ((Type == EGST_WINDOWS_CLASSIC) || (Type == EGST_WINDOWS_METALLIC))
{ {
Colors[EGDC_3D_DARK_SHADOW] = video::SColor(101,50,50,50); Colors[EGDC_3D_DARK_SHADOW] = video::SColor(101,50,50,50);
Colors[EGDC_3D_SHADOW] = video::SColor(101,130,130,130); Colors[EGDC_3D_SHADOW] = video::SColor(101,130,130,130);
Colors[EGDC_3D_FACE] = video::SColor(101,210,210,210); Colors[EGDC_3D_FACE] = video::SColor(101,210,210,210);
Colors[EGDC_3D_HIGH_LIGHT] = video::SColor(101,255,255,255); Colors[EGDC_3D_HIGH_LIGHT] = video::SColor(101,255,255,255);
Colors[EGDC_3D_LIGHT] = video::SColor(101,210,210,210); Colors[EGDC_3D_LIGHT] = video::SColor(101,210,210,210);
Colors[EGDC_ACTIVE_BORDER] = video::SColor(101,16,14,115); Colors[EGDC_ACTIVE_BORDER] = video::SColor(101,16,14,115);
Colors[EGDC_ACTIVE_CAPTION] = video::SColor(255,255,255,255); Colors[EGDC_ACTIVE_CAPTION] = video::SColor(255,255,255,255);
Colors[EGDC_APP_WORKSPACE] = video::SColor(101,100,100,100); Colors[EGDC_APP_WORKSPACE] = video::SColor(101,100,100,100);
Colors[EGDC_BUTTON_TEXT] = video::SColor(240,10,10,10); Colors[EGDC_BUTTON_TEXT] = video::SColor(240,10,10,10);
Colors[EGDC_GRAY_TEXT] = video::SColor(240,130,130,130); Colors[EGDC_GRAY_TEXT] = video::SColor(240,130,130,130);
Colors[EGDC_HIGH_LIGHT] = video::SColor(101,8,36,107); Colors[EGDC_HIGH_LIGHT] = video::SColor(101,8,36,107);
Colors[EGDC_HIGH_LIGHT_TEXT] = video::SColor(240,255,255,255); Colors[EGDC_HIGH_LIGHT_TEXT] = video::SColor(240,255,255,255);
Colors[EGDC_INACTIVE_BORDER] = video::SColor(101,165,165,165); Colors[EGDC_INACTIVE_BORDER] = video::SColor(101,165,165,165);
Colors[EGDC_INACTIVE_CAPTION] = video::SColor(255,30,30,30); Colors[EGDC_INACTIVE_CAPTION] = video::SColor(255,30,30,30);
Colors[EGDC_TOOLTIP] = video::SColor(200,0,0,0); Colors[EGDC_TOOLTIP] = video::SColor(200,0,0,0);
Colors[EGDC_TOOLTIP_BACKGROUND]= video::SColor(200,255,255,225); Colors[EGDC_TOOLTIP_BACKGROUND] = video::SColor(200,255,255,225);
Colors[EGDC_SCROLLBAR] = video::SColor(101,230,230,230); Colors[EGDC_SCROLLBAR] = video::SColor(101,230,230,230);
Colors[EGDC_WINDOW] = video::SColor(101,255,255,255); Colors[EGDC_WINDOW] = video::SColor(101,255,255,255);
Colors[EGDC_WINDOW_SYMBOL] = video::SColor(200,10,10,10); Colors[EGDC_WINDOW_SYMBOL] = video::SColor(200,10,10,10);
Colors[EGDC_ICON] = video::SColor(200,255,255,255); Colors[EGDC_ICON] = video::SColor(200,255,255,255);
Colors[EGDC_ICON_HIGH_LIGHT] = video::SColor(200,8,36,107); Colors[EGDC_ICON_HIGH_LIGHT] = video::SColor(200,8,36,107);
Colors[EGDC_GRAY_WINDOW_SYMBOL] = video::SColor(240,100,100,100);
Colors[EGDC_EDITABLE] = video::SColor(101,255,255,255);
Colors[EGDC_GRAY_EDITABLE] = video::SColor(101,200,200,200);
Colors[EGDC_FOCUSED_EDITABLE] = video::SColor(101,230,230,255);
Sizes[EGDS_SCROLLBAR_SIZE] = 14; Sizes[EGDS_SCROLLBAR_SIZE] = 14;
Sizes[EGDS_MENU_HEIGHT] = 30; Sizes[EGDS_MENU_HEIGHT] = 30;
...@@ -64,28 +70,32 @@ CGUISkin::CGUISkin(EGUI_SKIN_TYPE type, video::IVideoDriver* driver) ...@@ -64,28 +70,32 @@ CGUISkin::CGUISkin(EGUI_SKIN_TYPE type, video::IVideoDriver* driver)
else else
{ {
//0x80a6a8af //0x80a6a8af
Colors[EGDC_3D_DARK_SHADOW] = 0x60767982; Colors[EGDC_3D_DARK_SHADOW] = 0x60767982;
//Colors[EGDC_3D_FACE] = 0xc0c9ccd4; // tab background //Colors[EGDC_3D_FACE] = 0xc0c9ccd4; // tab background
Colors[EGDC_3D_FACE] = 0xc0cbd2d9; // tab background Colors[EGDC_3D_FACE] = 0xc0cbd2d9; // tab background
Colors[EGDC_3D_SHADOW] = 0x50e4e8f1; // tab background, and left-top highlight Colors[EGDC_3D_SHADOW] = 0x50e4e8f1; // tab background, and left-top highlight
Colors[EGDC_3D_HIGH_LIGHT] = 0x40c7ccdc; Colors[EGDC_3D_HIGH_LIGHT] = 0x40c7ccdc;
Colors[EGDC_3D_LIGHT] = 0x802e313a; Colors[EGDC_3D_LIGHT] = 0x802e313a;
Colors[EGDC_ACTIVE_BORDER] = 0x80404040; // window title Colors[EGDC_ACTIVE_BORDER] = 0x80404040; // window title
Colors[EGDC_ACTIVE_CAPTION] = 0xffd0d0d0; Colors[EGDC_ACTIVE_CAPTION] = 0xffd0d0d0;
Colors[EGDC_APP_WORKSPACE] = 0xc0646464; // unused Colors[EGDC_APP_WORKSPACE] = 0xc0646464; // unused
Colors[EGDC_BUTTON_TEXT] = 0xd0161616; Colors[EGDC_BUTTON_TEXT] = 0xd0161616;
Colors[EGDC_GRAY_TEXT] = 0x3c141414; Colors[EGDC_GRAY_TEXT] = 0x3c141414;
Colors[EGDC_HIGH_LIGHT] = 0x6c606060; Colors[EGDC_HIGH_LIGHT] = 0x6c606060;
Colors[EGDC_HIGH_LIGHT_TEXT]= 0xd0e0e0e0; Colors[EGDC_HIGH_LIGHT_TEXT] = 0xd0e0e0e0;
Colors[EGDC_INACTIVE_BORDER]= 0xf0a5a5a5; Colors[EGDC_INACTIVE_BORDER] = 0xf0a5a5a5;
Colors[EGDC_INACTIVE_CAPTION]= 0xffd2d2d2; Colors[EGDC_INACTIVE_CAPTION] = 0xffd2d2d2;
Colors[EGDC_TOOLTIP] = 0xf00f2033; Colors[EGDC_TOOLTIP] = 0xf00f2033;
Colors[EGDC_TOOLTIP_BACKGROUND]=0xc0cbd2d9; Colors[EGDC_TOOLTIP_BACKGROUND] = 0xc0cbd2d9;
Colors[EGDC_SCROLLBAR] = 0xf0e0e0e0; Colors[EGDC_SCROLLBAR] = 0xf0e0e0e0;
Colors[EGDC_WINDOW] = 0xf0f0f0f0; Colors[EGDC_WINDOW] = 0xf0f0f0f0;
Colors[EGDC_WINDOW_SYMBOL] = 0xd0161616; Colors[EGDC_WINDOW_SYMBOL] = 0xd0161616;
Colors[EGDC_ICON] = 0xd0161616; Colors[EGDC_ICON] = 0xd0161616;
Colors[EGDC_ICON_HIGH_LIGHT]= 0xd0606060; Colors[EGDC_ICON_HIGH_LIGHT] = 0xd0606060;
Colors[EGDC_GRAY_WINDOW_SYMBOL] = 0x3c101010;
Colors[EGDC_EDITABLE] = 0xf0ffffff;
Colors[EGDC_GRAY_EDITABLE] = 0xf0cccccc;
Colors[EGDC_FOCUSED_EDITABLE] = 0xf0fffff0;
Sizes[EGDS_SCROLLBAR_SIZE] = 14; Sizes[EGDS_SCROLLBAR_SIZE] = 14;
Sizes[EGDS_MENU_HEIGHT] = 48; Sizes[EGDS_MENU_HEIGHT] = 48;
...@@ -909,9 +919,9 @@ void CGUISkin::drawIcon(IGUIElement* element, EGUI_DEFAULT_ICON icon, ...@@ -909,9 +919,9 @@ void CGUISkin::drawIcon(IGUIElement* element, EGUI_DEFAULT_ICON icon,
if (!SpriteBank) if (!SpriteBank)
return; return;
// TODO: we need another state for disabled elements (can't add now because it's an interface change) bool gray = element && !element->isEnabled();
SpriteBank->draw2DSprite(Icons[icon], position, clip, SpriteBank->draw2DSprite(Icons[icon], position, clip,
Colors[EGDC_WINDOW_SYMBOL], starttime, currenttime, loop, true); Colors[gray? EGDC_GRAY_WINDOW_SYMBOL : EGDC_WINDOW_SYMBOL], starttime, currenttime, loop, true);
} }
......
...@@ -86,7 +86,7 @@ void CGUISpinBox::refreshSprites() ...@@ -86,7 +86,7 @@ void CGUISpinBox::refreshSprites()
if (sb) if (sb)
{ {
IGUISkin * skin = Environment->getSkin(); IGUISkin * skin = Environment->getSkin();
CurrentIconColor = skin->getColor(EGDC_WINDOW_SYMBOL); CurrentIconColor = skin->getColor(isEnabled() ? EGDC_WINDOW_SYMBOL : EGDC_GRAY_WINDOW_SYMBOL);
ButtonSpinDown->setSpriteBank(sb); ButtonSpinDown->setSpriteBank(sb);
ButtonSpinDown->setSprite(EGBS_BUTTON_UP, skin->getIcon(EGDI_SMALL_CURSOR_DOWN), CurrentIconColor); ButtonSpinDown->setSprite(EGBS_BUTTON_UP, skin->getIcon(EGDI_SMALL_CURSOR_DOWN), CurrentIconColor);
ButtonSpinDown->setSprite(EGBS_BUTTON_DOWN, skin->getIcon(EGDI_SMALL_CURSOR_DOWN), CurrentIconColor); ButtonSpinDown->setSprite(EGBS_BUTTON_DOWN, skin->getIcon(EGDI_SMALL_CURSOR_DOWN), CurrentIconColor);
...@@ -246,13 +246,26 @@ bool CGUISpinBox::OnEvent(const SEvent& event) ...@@ -246,13 +246,26 @@ bool CGUISpinBox::OnEvent(const SEvent& event)
} }
void CGUISpinBox::verifyValueRange() void CGUISpinBox::draw()
{ {
// TODO: This should be called in "draw" similar to the way it's done in CGUIWindow. if ( !isVisible() )
// But guess I can't in bugfix-release as overloading draw would break binary compitibility. return;
// So added here to allow users at least to manually force the element to having new skin-colors.
refreshSprites(); IGUISkin* skin = Environment->getSkin();
if (!skin)
return;
video::SColor iconColor = skin->getColor(isEnabled() ? EGDC_WINDOW_SYMBOL : EGDC_GRAY_WINDOW_SYMBOL);
if ( iconColor != CurrentIconColor )
{
refreshSprites();
}
IGUISpinBox::draw();
}
void CGUISpinBox::verifyValueRange()
{
f32 val = getValue(); f32 val = getValue();
if ( val+core::ROUNDING_ERROR_f32 < RangeMin ) if ( val+core::ROUNDING_ERROR_f32 < RangeMin )
val = RangeMin; val = RangeMin;
......
...@@ -62,6 +62,9 @@ namespace gui ...@@ -62,6 +62,9 @@ namespace gui
//! called if an event happened. //! called if an event happened.
virtual bool OnEvent(const SEvent& event); virtual bool OnEvent(const SEvent& event);
//! Draws the element and its children.
virtual void draw();
//! Sets the new caption of the element //! Sets the new caption of the element
virtual void setText(const wchar_t* text); virtual void setText(const wchar_t* text);
......
...@@ -101,7 +101,7 @@ void CGUIStaticText::draw() ...@@ -101,7 +101,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), OverrideColorEnabled ? OverrideColor : skin->getColor(isEnabled() ? EGDC_BUTTON_TEXT : EGDC_GRAY_TEXT),
HAlign == EGUIA_CENTER, VAlign == EGUIA_CENTER, &AbsoluteClippingRect); HAlign == EGUIA_CENTER, VAlign == EGUIA_CENTER, &AbsoluteClippingRect);
} }
else else
...@@ -130,7 +130,7 @@ void CGUIStaticText::draw() ...@@ -130,7 +130,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), OverrideColorEnabled ? OverrideColor : skin->getColor(isEnabled() ? EGDC_BUTTON_TEXT : EGDC_GRAY_TEXT),
HAlign == EGUIA_CENTER, false, &AbsoluteClippingRect); HAlign == EGUIA_CENTER, false, &AbsoluteClippingRect);
r.LowerRightCorner.Y += height; r.LowerRightCorner.Y += height;
......
...@@ -174,7 +174,6 @@ CGUITabControl::CGUITabControl(IGUIEnvironment* environment, ...@@ -174,7 +174,6 @@ CGUITabControl::CGUITabControl(IGUIEnvironment* environment,
setDebugName("CGUITabControl"); setDebugName("CGUITabControl");
#endif #endif
video::SColor color(255,255,255,255);
IGUISkin* skin = Environment->getSkin(); IGUISkin* skin = Environment->getSkin();
IGUISpriteBank* sprites = 0; IGUISpriteBank* sprites = 0;
...@@ -183,7 +182,6 @@ CGUITabControl::CGUITabControl(IGUIEnvironment* environment, ...@@ -183,7 +182,6 @@ CGUITabControl::CGUITabControl(IGUIEnvironment* environment,
if (skin) if (skin)
{ {
sprites = skin->getSpriteBank(); sprites = skin->getSpriteBank();
color = skin->getColor(EGDC_WINDOW_SYMBOL);
TabHeight = skin->getSize(gui::EGDS_BUTTON_HEIGHT) + 2; TabHeight = skin->getSize(gui::EGDS_BUTTON_HEIGHT) + 2;
} }
...@@ -192,8 +190,6 @@ CGUITabControl::CGUITabControl(IGUIEnvironment* environment, ...@@ -192,8 +190,6 @@ CGUITabControl::CGUITabControl(IGUIEnvironment* environment,
if (UpButton) if (UpButton)
{ {
UpButton->setSpriteBank(sprites); UpButton->setSpriteBank(sprites);
UpButton->setSprite(EGBS_BUTTON_UP, skin->getIcon(EGDI_CURSOR_LEFT), color);
UpButton->setSprite(EGBS_BUTTON_DOWN, skin->getIcon(EGDI_CURSOR_LEFT), color);
UpButton->setVisible(false); UpButton->setVisible(false);
UpButton->setSubElement(true); UpButton->setSubElement(true);
UpButton->setAlignment(EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT); UpButton->setAlignment(EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT);
...@@ -206,8 +202,6 @@ CGUITabControl::CGUITabControl(IGUIEnvironment* environment, ...@@ -206,8 +202,6 @@ CGUITabControl::CGUITabControl(IGUIEnvironment* environment,
if (DownButton) if (DownButton)
{ {
DownButton->setSpriteBank(sprites); DownButton->setSpriteBank(sprites);
DownButton->setSprite(EGBS_BUTTON_UP, skin->getIcon(EGDI_CURSOR_RIGHT), color);
DownButton->setSprite(EGBS_BUTTON_DOWN, skin->getIcon(EGDI_CURSOR_RIGHT), color);
DownButton->setVisible(false); DownButton->setVisible(false);
DownButton->setSubElement(true); DownButton->setSubElement(true);
DownButton->setAlignment(EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT); DownButton->setAlignment(EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT);
...@@ -216,9 +210,9 @@ CGUITabControl::CGUITabControl(IGUIEnvironment* environment, ...@@ -216,9 +210,9 @@ CGUITabControl::CGUITabControl(IGUIEnvironment* environment,
} }
setTabVerticalAlignment(EGUIA_UPPERLEFT); setTabVerticalAlignment(EGUIA_UPPERLEFT);
refreshSprites();
} }
//! destructor //! destructor
CGUITabControl::~CGUITabControl() CGUITabControl::~CGUITabControl()
{ {
...@@ -235,6 +229,27 @@ CGUITabControl::~CGUITabControl() ...@@ -235,6 +229,27 @@ CGUITabControl::~CGUITabControl()
DownButton->drop(); DownButton->drop();
} }
void CGUITabControl::refreshSprites()
{
video::SColor color(255,255,255,255);
IGUISkin* skin = Environment->getSkin();
if (skin)
{
color = skin->getColor(isEnabled() ? EGDC_WINDOW_SYMBOL : EGDC_GRAY_WINDOW_SYMBOL);
}
if (UpButton)
{
UpButton->setSprite(EGBS_BUTTON_UP, skin->getIcon(EGDI_CURSOR_LEFT), color);
UpButton->setSprite(EGBS_BUTTON_DOWN, skin->getIcon(EGDI_CURSOR_LEFT), color);
}
if (DownButton)
{
DownButton->setSprite(EGBS_BUTTON_UP, skin->getIcon(EGDI_CURSOR_RIGHT), color);
DownButton->setSprite(EGBS_BUTTON_DOWN, skin->getIcon(EGDI_CURSOR_RIGHT), color);
}
}
//! Adds a tab //! Adds a tab
IGUITab* CGUITabControl::addTab(const wchar_t* caption, s32 id) IGUITab* CGUITabControl::addTab(const wchar_t* caption, s32 id)
...@@ -339,7 +354,7 @@ IGUITab* CGUITabControl::getTab(s32 idx) const ...@@ -339,7 +354,7 @@ IGUITab* CGUITabControl::getTab(s32 idx) const
//! called if an event happened. //! called if an event happened.
bool CGUITabControl::OnEvent(const SEvent& event) bool CGUITabControl::OnEvent(const SEvent& event)
{ {
if (IsEnabled) if (isEnabled())
{ {
switch(event.EventType) switch(event.EventType)
...@@ -692,6 +707,7 @@ void CGUITabControl::draw() ...@@ -692,6 +707,7 @@ void CGUITabControl::draw()
UpButton->setEnabled(needLeftScroll); UpButton->setEnabled(needLeftScroll);
if ( DownButton ) if ( DownButton )
DownButton->setEnabled(needRightScroll); DownButton->setEnabled(needRightScroll);
refreshSprites();
IGUIElement::draw(); IGUIElement::draw();
} }
...@@ -770,7 +786,6 @@ void CGUITabControl::recalculateScrollBar() ...@@ -770,7 +786,6 @@ void CGUITabControl::recalculateScrollBar()
bringToFront( DownButton ); bringToFront( DownButton );
} }
//! Set the alignment of the tabs //! Set the alignment of the tabs
void CGUITabControl::setTabVerticalAlignment( EGUI_ALIGNMENT alignment ) void CGUITabControl::setTabVerticalAlignment( EGUI_ALIGNMENT alignment )
{ {
......
...@@ -164,6 +164,7 @@ namespace gui ...@@ -164,6 +164,7 @@ namespace gui
void recalculateScrollButtonPlacement(); void recalculateScrollButtonPlacement();
void recalculateScrollBar(); void recalculateScrollBar();
void refreshSprites();
core::array<CGUITab*> Tabs; core::array<CGUITab*> Tabs;
s32 ActiveTab; s32 ActiveTab;
......
...@@ -535,7 +535,7 @@ void CGUITable::refreshControls() ...@@ -535,7 +535,7 @@ void CGUITable::refreshControls()
//! called if an event happened. //! called if an event happened.
bool CGUITable::OnEvent(const SEvent &event) bool CGUITable::OnEvent(const SEvent &event)
{ {
if (IsEnabled) if (isEnabled())
{ {
switch(event.EventType) switch(event.EventType)
...@@ -567,7 +567,7 @@ bool CGUITable::OnEvent(const SEvent &event) ...@@ -567,7 +567,7 @@ bool CGUITable::OnEvent(const SEvent &event)
break; break;
case EET_MOUSE_INPUT_EVENT: case EET_MOUSE_INPUT_EVENT:
{ {
if ( !IsEnabled ) if ( !isEnabled() )
return false; return false;
core::position2d<s32> p(event.MouseInput.X, event.MouseInput.Y); core::position2d<s32> p(event.MouseInput.X, event.MouseInput.Y);
...@@ -945,13 +945,13 @@ void CGUITable::draw() ...@@ -945,13 +945,13 @@ void CGUITable::draw()
// draw item text // draw item text
if ((s32)i == Selected) if ((s32)i == Selected)
{ {
font->draw(Rows[i].Items[j].BrokenText.c_str(), textRect, skin->getColor(IsEnabled ? EGDC_HIGH_LIGHT_TEXT : EGDC_GRAY_TEXT), false, true, &clientClip); font->draw(Rows[i].Items[j].BrokenText.c_str(), textRect, skin->getColor(isEnabled() ? EGDC_HIGH_LIGHT_TEXT : EGDC_GRAY_TEXT), false, true, &clientClip);
} }
else else
{ {
if ( !Rows[i].Items[j].IsOverrideColor ) // skin-colors can change if ( !Rows[i].Items[j].IsOverrideColor ) // skin-colors can change
Rows[i].Items[j].Color = skin->getColor(EGDC_BUTTON_TEXT); Rows[i].Items[j].Color = skin->getColor(EGDC_BUTTON_TEXT);
font->draw(Rows[i].Items[j].BrokenText.c_str(), textRect, IsEnabled ? Rows[i].Items[j].Color : skin->getColor(EGDC_GRAY_TEXT), false, true, &clientClip); font->draw(Rows[i].Items[j].BrokenText.c_str(), textRect, isEnabled() ? Rows[i].Items[j].Color : skin->getColor(EGDC_GRAY_TEXT), false, true, &clientClip);
} }
pos += Columns[j].Width; pos += Columns[j].Width;
...@@ -987,7 +987,7 @@ void CGUITable::draw() ...@@ -987,7 +987,7 @@ void CGUITable::draw()
// draw header column text // draw header column text
columnrect.UpperLeftCorner.X += CellWidthPadding; columnrect.UpperLeftCorner.X += CellWidthPadding;
font->draw(text, columnrect, skin->getColor( IsEnabled ? EGDC_BUTTON_TEXT : EGDC_GRAY_TEXT), false, true, &tableRect); font->draw(text, columnrect, skin->getColor( isEnabled() ? EGDC_BUTTON_TEXT : EGDC_GRAY_TEXT), false, true, &tableRect);
// draw icon for active column tab // draw icon for active column tab
if ( (s32)i == ActiveTab ) if ( (s32)i == ActiveTab )
......
...@@ -67,7 +67,7 @@ CGUIToolBar::CGUIToolBar(IGUIEnvironment* environment, IGUIElement* parent, s32 ...@@ -67,7 +67,7 @@ CGUIToolBar::CGUIToolBar(IGUIEnvironment* environment, IGUIElement* parent, s32
//! called if an event happened. //! called if an event happened.
bool CGUIToolBar::OnEvent(const SEvent& event) bool CGUIToolBar::OnEvent(const SEvent& event)
{ {
if (IsEnabled) if (isEnabled())
{ {
if (event.EventType == EET_MOUSE_INPUT_EVENT && if (event.EventType == EET_MOUSE_INPUT_EVENT &&
event.MouseInput.Event == EMIE_LMOUSE_PRESSED_DOWN) event.MouseInput.Event == EMIE_LMOUSE_PRESSED_DOWN)
...@@ -128,11 +128,11 @@ IGUIButton* CGUIToolBar::addButton(s32 id, const wchar_t* text,const wchar_t* to ...@@ -128,11 +128,11 @@ IGUIButton* CGUIToolBar::addButton(s32 id, const wchar_t* text,const wchar_t* to
rectangle.LowerRightCorner.X = rectangle.UpperLeftCorner.X + size.Width + 8; rectangle.LowerRightCorner.X = rectangle.UpperLeftCorner.X + size.Width + 8;
rectangle.LowerRightCorner.Y = rectangle.UpperLeftCorner.Y + size.Height + 6; rectangle.LowerRightCorner.Y = rectangle.UpperLeftCorner.Y + size.Height + 6;
} }
if ( text ) if ( text )
{ {
IGUISkin* skin = Environment->getSkin(); IGUISkin* skin = Environment->getSkin();
IGUIFont * font = skin->getFont(EGDF_BUTTON); IGUIFont * font = skin->getFont(EGDF_BUTTON);
if ( font ) if ( font )
{ {
core::dimension2d<u32> dim = font->getDimension(text); core::dimension2d<u32> dim = font->getDimension(text);
......
...@@ -99,7 +99,7 @@ void CGUIWindow::refreshSprites() ...@@ -99,7 +99,7 @@ void CGUIWindow::refreshSprites()
if ( !sprites ) if ( !sprites )
return; return;
CurrentIconColor = skin->getColor(EGDC_WINDOW_SYMBOL); CurrentIconColor = skin->getColor(isEnabled() ? EGDC_WINDOW_SYMBOL : EGDC_GRAY_WINDOW_SYMBOL);
if (sprites) if (sprites)
{ {
...@@ -120,7 +120,7 @@ void CGUIWindow::refreshSprites() ...@@ -120,7 +120,7 @@ void CGUIWindow::refreshSprites()
//! called if an event happened. //! called if an event happened.
bool CGUIWindow::OnEvent(const SEvent& event) bool CGUIWindow::OnEvent(const SEvent& event)
{ {
if (IsEnabled) if (isEnabled())
{ {
switch(event.EventType) switch(event.EventType)
...@@ -236,7 +236,7 @@ void CGUIWindow::draw() ...@@ -236,7 +236,7 @@ void CGUIWindow::draw()
// update each time because the skin is allowed to change this always. // update each time because the skin is allowed to change this always.
updateClientRect(); updateClientRect();
if ( CurrentIconColor != skin->getColor(EGDC_WINDOW_SYMBOL) ) if ( CurrentIconColor != skin->getColor(isEnabled() ? EGDC_WINDOW_SYMBOL : EGDC_GRAY_WINDOW_SYMBOL) )
refreshSprites(); refreshSprites();
core::rect<s32> rect = AbsoluteRect; core::rect<s32> rect = AbsoluteRect;
......
...@@ -470,6 +470,7 @@ ...@@ -470,6 +470,7 @@
<Unit filename="../../include/IGUITabControl.h" /> <Unit filename="../../include/IGUITabControl.h" />
<Unit filename="../../include/IGUITable.h" /> <Unit filename="../../include/IGUITable.h" />
<Unit filename="../../include/IGUIToolbar.h" /> <Unit filename="../../include/IGUIToolbar.h" />
<Unit filename="../../include/IGUITreeView.h" />
<Unit filename="../../include/IGUIWindow.h" /> <Unit filename="../../include/IGUIWindow.h" />
<Unit filename="../../include/IGeometryCreator.h" /> <Unit filename="../../include/IGeometryCreator.h" />
<Unit filename="../../include/IImage.h" /> <Unit filename="../../include/IImage.h" />
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment