Commit 3d51b275 authored by bitplane's avatar bitplane

Checking for IsEnabled is now consistent across all GUI elements (bug 2003234 by CuteAlien)

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@1412 dfc29bdd-3216-0410-991c-e03cc46cb475
parent f7173847
...@@ -46,6 +46,7 @@ Changes in version 1.5 (... 2008) ...@@ -46,6 +46,7 @@ Changes in version 1.5 (... 2008)
Nodes are now solid or transparent. ( but still more states are needed ) Nodes are now solid or transparent. ( but still more states are needed )
- GUI: - GUI:
- Checking IsEnabled is now consistent across all GUI elements
- Disabling the BMP loader now compiles without the built-in font - Disabling the BMP loader now compiles without the built-in font
- Added setTextAlignment to IGUIComboBox - Added setTextAlignment to IGUIComboBox
- Fixed a bug in CGUISpriteBank which caused a crash when a non-looping animated sprite reached the end of its animation. - Fixed a bug in CGUISpriteBank which caused a crash when a non-looping animated sprite reached the end of its animation.
......
...@@ -93,7 +93,7 @@ void CGUIButton::setSprite(EGUI_BUTTON_STATE state, s32 index, video::SColor col ...@@ -93,7 +93,7 @@ void CGUIButton::setSprite(EGUI_BUTTON_STATE state, s32 index, video::SColor col
bool CGUIButton::OnEvent(const SEvent& event) bool CGUIButton::OnEvent(const SEvent& event)
{ {
if (!IsEnabled) if (!IsEnabled)
return Parent ? Parent->OnEvent(event) : false; return IGUIElement::OnEvent(event);
switch(event.EventType) switch(event.EventType)
{ {
......
...@@ -119,7 +119,7 @@ bool CGUICheckBox::OnEvent(const SEvent& event) ...@@ -119,7 +119,7 @@ bool CGUICheckBox::OnEvent(const SEvent& event)
} }
} }
return Parent ? Parent->OnEvent(event) : false; return IGUIElement::OnEvent(event);
} }
......
...@@ -339,7 +339,8 @@ void CGUIColorSelectDialog::buildColorRing( const core::dimension2d<s32> & dim, ...@@ -339,7 +339,8 @@ void CGUIColorSelectDialog::buildColorRing( const core::dimension2d<s32> & 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)
{
switch(event.EventType) switch(event.EventType)
{ {
case EET_GUI_EVENT: case EET_GUI_EVENT:
...@@ -423,8 +424,9 @@ bool CGUIColorSelectDialog::OnEvent(const SEvent& event) ...@@ -423,8 +424,9 @@ bool CGUIColorSelectDialog::OnEvent(const SEvent& event)
default: default:
break; break;
} }
}
return Parent ? Parent->OnEvent(event) : false; return IGUIElement::OnEvent(event);
} }
......
...@@ -161,6 +161,8 @@ void CGUIComboBox::setSelected(s32 idx) ...@@ -161,6 +161,8 @@ 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)
{
switch(event.EventType) switch(event.EventType)
{ {
...@@ -304,8 +306,9 @@ bool CGUIComboBox::OnEvent(const SEvent& event) ...@@ -304,8 +306,9 @@ bool CGUIComboBox::OnEvent(const SEvent& event)
default: default:
break; break;
} }
}
return Parent ? Parent->OnEvent(event) : false; return IGUIElement::OnEvent(event);
} }
......
...@@ -218,8 +218,8 @@ void CGUIContextMenu::removeAllItems() ...@@ -218,8 +218,8 @@ 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)
return Parent ? Parent->OnEvent(event) : false; {
switch(event.EventType) switch(event.EventType)
{ {
...@@ -271,8 +271,9 @@ bool CGUIContextMenu::OnEvent(const SEvent& event) ...@@ -271,8 +271,9 @@ bool CGUIContextMenu::OnEvent(const SEvent& event)
default: default:
break; break;
} }
}
return Parent ? Parent->OnEvent(event) : false; return IGUIElement::OnEvent(event);
} }
......
...@@ -187,6 +187,9 @@ void CGUIEditBox::setTextAlignment(EGUI_ALIGNMENT horizontal, EGUI_ALIGNMENT ver ...@@ -187,6 +187,9 @@ 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)
{
switch(event.EventType) switch(event.EventType)
{ {
case EET_GUI_EVENT: case EET_GUI_EVENT:
...@@ -211,8 +214,9 @@ bool CGUIEditBox::OnEvent(const SEvent& event) ...@@ -211,8 +214,9 @@ bool CGUIEditBox::OnEvent(const SEvent& event)
default: default:
break; break;
} }
}
return Parent ? Parent->OnEvent(event) : false; return IGUIElement::OnEvent(event);
} }
......
...@@ -136,6 +136,8 @@ const wchar_t* CGUIFileOpenDialog::getFileName() const ...@@ -136,6 +136,8 @@ const wchar_t* CGUIFileOpenDialog::getFileName() const
//! called if an event happened. //! called if an event happened.
bool CGUIFileOpenDialog::OnEvent(const SEvent& event) bool CGUIFileOpenDialog::OnEvent(const SEvent& event)
{ {
if (IsEnabled)
{
switch(event.EventType) switch(event.EventType)
{ {
case EET_GUI_EVENT: case EET_GUI_EVENT:
...@@ -235,8 +237,9 @@ bool CGUIFileOpenDialog::OnEvent(const SEvent& event) ...@@ -235,8 +237,9 @@ bool CGUIFileOpenDialog::OnEvent(const SEvent& event)
default: default:
break; break;
} }
}
return Parent ? Parent->OnEvent(event) : false; return IGUIElement::OnEvent(event);
} }
......
...@@ -195,6 +195,8 @@ void CGUIListBox::setSelected(s32 id) ...@@ -195,6 +195,8 @@ void CGUIListBox::setSelected(s32 id)
//! called if an event happened. //! called if an event happened.
bool CGUIListBox::OnEvent(const SEvent& event) bool CGUIListBox::OnEvent(const SEvent& event)
{ {
if (IsEnabled)
{
switch(event.EventType) switch(event.EventType)
{ {
case EET_KEY_INPUT_EVENT: case EET_KEY_INPUT_EVENT:
...@@ -405,8 +407,9 @@ bool CGUIListBox::OnEvent(const SEvent& event) ...@@ -405,8 +407,9 @@ bool CGUIListBox::OnEvent(const SEvent& event)
case EET_USER_EVENT: case EET_USER_EVENT:
break; break;
} }
}
return Parent ? Parent->OnEvent(event) : false; return IGUIElement::OnEvent(event);
} }
......
...@@ -99,8 +99,8 @@ void CGUIMenu::draw() ...@@ -99,8 +99,8 @@ 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)
return Parent ? Parent->OnEvent(event) : false; {
switch(event.EventType) switch(event.EventType)
{ {
...@@ -163,8 +163,9 @@ bool CGUIMenu::OnEvent(const SEvent& event) ...@@ -163,8 +163,9 @@ bool CGUIMenu::OnEvent(const SEvent& event)
default: default:
break; break;
} }
}
return Parent ? Parent->OnEvent(event) : false; return IGUIElement::OnEvent(event);
} }
......
...@@ -83,7 +83,7 @@ const video::SMaterial& CGUIMeshViewer::getMaterial() const ...@@ -83,7 +83,7 @@ const video::SMaterial& CGUIMeshViewer::getMaterial() const
//! called if an event happened. //! called if an event happened.
bool CGUIMeshViewer::OnEvent(const SEvent& event) bool CGUIMeshViewer::OnEvent(const SEvent& event)
{ {
return Parent ? Parent->OnEvent(event) : false; return IGUIElement::OnEvent(event);
} }
......
...@@ -254,6 +254,8 @@ void CGUIMessageBox::refreshControls() ...@@ -254,6 +254,8 @@ 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)
{
SEvent outevent; SEvent outevent;
outevent.EventType = EET_GUI_EVENT; outevent.EventType = EET_GUI_EVENT;
outevent.GUIEvent.Caller = this; outevent.GUIEvent.Caller = this;
...@@ -390,6 +392,7 @@ bool CGUIMessageBox::OnEvent(const SEvent& event) ...@@ -390,6 +392,7 @@ bool CGUIMessageBox::OnEvent(const SEvent& event)
default: default:
break; break;
} }
}
return CGUIWindow::OnEvent(event); return CGUIWindow::OnEvent(event);
} }
......
...@@ -59,6 +59,9 @@ CGUIScrollBar::~CGUIScrollBar() ...@@ -59,6 +59,9 @@ 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)
{
switch(event.EventType) switch(event.EventType)
{ {
case EET_KEY_INPUT_EVENT: case EET_KEY_INPUT_EVENT:
...@@ -211,6 +214,7 @@ bool CGUIScrollBar::OnEvent(const SEvent& event) ...@@ -211,6 +214,7 @@ bool CGUIScrollBar::OnEvent(const SEvent& event)
default: default:
break; break;
} }
}
return IGUIElement::OnEvent(event); return IGUIElement::OnEvent(event);
} }
......
...@@ -161,6 +161,8 @@ void CGUISpinBox::setDecimalPlaces(s32 places) ...@@ -161,6 +161,8 @@ void CGUISpinBox::setDecimalPlaces(s32 places)
bool CGUISpinBox::OnEvent(const SEvent& event) bool CGUISpinBox::OnEvent(const SEvent& event)
{ {
if (IsEnabled)
{
bool changeEvent = false; bool changeEvent = false;
switch(event.EventType) switch(event.EventType)
{ {
...@@ -207,6 +209,7 @@ bool CGUISpinBox::OnEvent(const SEvent& event) ...@@ -207,6 +209,7 @@ bool CGUISpinBox::OnEvent(const SEvent& event)
Parent->OnEvent(e); Parent->OnEvent(e);
return true; return true;
} }
}
return IGUIElement::OnEvent(event); return IGUIElement::OnEvent(event);
} }
......
...@@ -323,8 +323,8 @@ IGUITab* CGUITabControl::getTab(s32 idx) const ...@@ -323,8 +323,8 @@ 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)
return Parent ? Parent->OnEvent(event) : false; {
switch(event.EventType) switch(event.EventType)
{ {
...@@ -365,8 +365,9 @@ bool CGUITabControl::OnEvent(const SEvent& event) ...@@ -365,8 +365,9 @@ bool CGUITabControl::OnEvent(const SEvent& event)
default: default:
break; break;
} }
}
return Parent ? Parent->OnEvent(event) : false; return IGUIElement::OnEvent(event);
} }
void CGUITabControl::scrollLeft() void CGUITabControl::scrollLeft()
......
...@@ -502,6 +502,8 @@ void CGUITable::refreshControls() ...@@ -502,6 +502,8 @@ 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)
{
switch(event.EventType) switch(event.EventType)
{ {
...@@ -623,8 +625,9 @@ bool CGUITable::OnEvent(const SEvent &event) ...@@ -623,8 +625,9 @@ bool CGUITable::OnEvent(const SEvent &event)
default: default:
break; break;
} }
}
return Parent ? Parent->OnEvent(event) : false; return IGUIElement::OnEvent(event);
} }
......
...@@ -67,14 +67,17 @@ CGUIToolBar::CGUIToolBar(IGUIEnvironment* environment, IGUIElement* parent, s32 ...@@ -67,14 +67,17 @@ 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 (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)
{ {
if (AbsoluteClippingRect.isPointInside(core::position2di(event.MouseInput.X, event.MouseInput.Y))) if (AbsoluteClippingRect.isPointInside(core::position2di(event.MouseInput.X, event.MouseInput.Y)))
return true; return true;
} }
}
return Parent ? Parent->OnEvent(event) : false; return IGUIElement::OnEvent(event);
} }
......
...@@ -109,6 +109,9 @@ CGUIWindow::~CGUIWindow() ...@@ -109,6 +109,9 @@ CGUIWindow::~CGUIWindow()
//! called if an event happened. //! called if an event happened.
bool CGUIWindow::OnEvent(const SEvent& event) bool CGUIWindow::OnEvent(const SEvent& event)
{ {
if (IsEnabled)
{
switch(event.EventType) switch(event.EventType)
{ {
case EET_GUI_EVENT: case EET_GUI_EVENT:
...@@ -189,6 +192,7 @@ bool CGUIWindow::OnEvent(const SEvent& event) ...@@ -189,6 +192,7 @@ bool CGUIWindow::OnEvent(const SEvent& event)
default: default:
break; break;
} }
}
return IGUIElement::OnEvent(event); return IGUIElement::OnEvent(event);
} }
......
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