Commit 9b3c67fe authored by bitplane's avatar bitplane

changed behaviour of IGUIElement::OnEvent so it doesn't always absorb events,...

changed behaviour of IGUIElement::OnEvent so it doesn't always absorb events, and added getAbsoluteClippingRect.
fixed tooltip text on file open dialog's close button.
added some managed marshalling bugfix things where I missed them earlier.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@751 dfc29bdd-3216-0410-991c-e03cc46cb475
parent 4b370145
...@@ -5,20 +5,6 @@ Changes in version 1.4 (... 2007) ...@@ -5,20 +5,6 @@ Changes in version 1.4 (... 2007)
- Fixed a bug in CBillboardTextSceneNode::setText where the old text was not cleared. - Fixed a bug in CBillboardTextSceneNode::setText where the old text was not cleared.
- IGUIElement now calls getter and setter functions when serializing,
in case people override them.
- Added setDrawBorder and setTextAlignment to IGUIStaticText.
- IGUIEditBox new methods:
setWordWrap/isWordWrapEnabled, to split words on to the next line.
setMultiLine and isMultiLineEnabled, inserts a newline instead of sending
EGET_EDITBOX_ENTER events.
setTextAlignment, to align the text to left, right, top, bottom and centers
setAutoScroll, to enable and disable automatic scrolling with the cursor
- Added IGUISpinBox, by Michael Zeilfelder (CuteAlien).
- Changed irrArray::linear_search to use the == operator rather than < - Changed irrArray::linear_search to use the == operator rather than <
This may be slower in some cases, but it no longer returns false positives This may be slower in some cases, but it no longer returns false positives
when searching arrays of classes that override the < operator but when searching arrays of classes that override the < operator but
...@@ -42,6 +28,26 @@ Changes in version 1.4 (... 2007) ...@@ -42,6 +28,26 @@ Changes in version 1.4 (... 2007)
- Fixed a typo to do with 2nd light vectors in opengl parallax and normal map - Fixed a typo to do with 2nd light vectors in opengl parallax and normal map
renderers. renderers.
GUI:
- IGUIElement changes:
OnEvent no longer absorbs events by default.
Serialize/deserialize now call getter and setter functions, in case people
override these and don't use the internal protected variables.
added getAbsoluteClippingRect, returns the visible area of an element.
- Added IGUISpinBox, by Michael Zeilfelder (CuteAlien).
- IGUIEditBox new methods:
setWordWrap/isWordWrapEnabled, to split words on to the next line.
setMultiLine and isMultiLineEnabled, inserts a newline instead of sending
EGET_EDITBOX_ENTER events.
setTextAlignment, to align the text to left, right, top, bottom and centers
setAutoScroll, to enable and disable automatic scrolling with the cursor
- IGUIStaticText new methods setDrawBorder and setTextAlignment.
Changes in version 1.3.1 (20 Jun 2007) Changes in version 1.3.1 (20 Jun 2007)
- Fixed a bug with negative exponents in fast_atof, posted by RVL - Fixed a bug with negative exponents in fast_atof, posted by RVL
......
...@@ -147,6 +147,12 @@ public: ...@@ -147,6 +147,12 @@ public:
return AbsoluteRect; return AbsoluteRect;
} }
//! Returns the visible area of the element.
core::rect<s32> getAbsoluteClippingRect() const
{
return AbsoluteClippingRect;
}
//! Sets whether the element will ignore its parent's clipping rectangle //! Sets whether the element will ignore its parent's clipping rectangle
void setNotClipped(bool noClip) void setNotClipped(bool noClip)
{ {
...@@ -516,10 +522,7 @@ public: ...@@ -516,10 +522,7 @@ public:
//! Called if an event happened. //! Called if an event happened.
virtual bool OnEvent(SEvent event) virtual bool OnEvent(SEvent event)
{ {
if (Parent) return Parent ? Parent->OnEvent(event) : false;
Parent->OnEvent(event);
return true;
} }
......
...@@ -114,6 +114,7 @@ void CGUIEditBox::updateAbsolutePosition() ...@@ -114,6 +114,7 @@ void CGUIEditBox::updateAbsolutePosition()
//! Checks if word wrap is enabled //! Checks if word wrap is enabled
bool CGUIEditBox::isWordWrapEnabled() bool CGUIEditBox::isWordWrapEnabled()
{ {
_IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX;
return WordWrap; return WordWrap;
} }
...@@ -126,6 +127,7 @@ void CGUIEditBox::setMultiLine(bool enable) ...@@ -126,6 +127,7 @@ void CGUIEditBox::setMultiLine(bool enable)
//! Checks if multi line editing is enabled //! Checks if multi line editing is enabled
bool CGUIEditBox::isMultiLineEnabled() bool CGUIEditBox::isMultiLineEnabled()
{ {
_IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX;
return MultiLine; return MultiLine;
} }
...@@ -779,6 +781,7 @@ void CGUIEditBox::setAutoScroll(bool enable) ...@@ -779,6 +781,7 @@ void CGUIEditBox::setAutoScroll(bool enable)
//! \return true if automatic scrolling is enabled, false if not //! \return true if automatic scrolling is enabled, false if not
bool CGUIEditBox::isAutoScrollEnabled() bool CGUIEditBox::isAutoScrollEnabled()
{ {
_IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX;
return AutoScroll; return AutoScroll;
} }
...@@ -871,17 +874,19 @@ bool CGUIEditBox::processMouse(const SEvent& event) ...@@ -871,17 +874,19 @@ bool CGUIEditBox::processMouse(const SEvent& event)
Environment->removeFocus(this); Environment->removeFocus(this);
return false; return false;
} }
else
{
// move cursor
CursorPos = getCursorPos(event.MouseInput.X, event.MouseInput.Y);
// move cursor if (!MouseMarking)
CursorPos = getCursorPos(event.MouseInput.X, event.MouseInput.Y); MarkBegin = CursorPos;
if (!MouseMarking)
MarkBegin = CursorPos;
MouseMarking = true; MouseMarking = true;
MarkEnd = CursorPos; MarkEnd = CursorPos;
calculateScrollPos(); calculateScrollPos();
return true; return true;
}
} }
} }
......
...@@ -299,7 +299,7 @@ void CGUIEnvironment::clear() ...@@ -299,7 +299,7 @@ void CGUIEnvironment::clear()
//! called by ui if an event happened. //! called by ui if an event happened.
bool CGUIEnvironment::OnEvent(SEvent event) bool CGUIEnvironment::OnEvent(SEvent event)
{ {
if (UserReceiver && event.GUIEvent.Caller != this) if (UserReceiver && (event.EventType != EET_GUI_EVENT || event.GUIEvent.Caller != this))
return UserReceiver->OnEvent(event); return UserReceiver->OnEvent(event);
return false; return false;
......
...@@ -50,7 +50,7 @@ CGUIFileOpenDialog::CGUIFileOpenDialog(const wchar_t* title, IGUIEnvironment* en ...@@ -50,7 +50,7 @@ CGUIFileOpenDialog::CGUIFileOpenDialog(const wchar_t* title, IGUIEnvironment* en
s32 posx = RelativeRect.getWidth() - buttonw - 4; s32 posx = RelativeRect.getWidth() - buttonw - 4;
CloseButton = Environment->addButton(core::rect<s32>(posx, 3, posx + buttonw, 3 + buttonw), this, -1, CloseButton = Environment->addButton(core::rect<s32>(posx, 3, posx + buttonw, 3 + buttonw), this, -1,
L"", skin ? skin->getDefaultText(EGDT_MSG_BOX_OK) : L"Close"); L"", skin ? skin->getDefaultText(EGDT_WINDOW_CLOSE) : L"Close");
CloseButton->setSubElement(true); CloseButton->setSubElement(true);
if (sprites) if (sprites)
{ {
......
...@@ -44,7 +44,7 @@ bool CGUIModalScreen::OnEvent(SEvent event) ...@@ -44,7 +44,7 @@ bool CGUIModalScreen::OnEvent(SEvent event)
} }
} }
return IGUIElement::OnEvent(event); return true;
} }
......
...@@ -93,9 +93,8 @@ bool CGUIScrollBar::OnEvent(SEvent event) ...@@ -93,9 +93,8 @@ bool CGUIScrollBar::OnEvent(SEvent event)
break; break;
case EMIE_LMOUSE_PRESSED_DOWN: case EMIE_LMOUSE_PRESSED_DOWN:
{ {
IGUIElement *el = Environment->getRootGUIElement()->getElementFromPoint(
core::position2di(event.MouseInput.X, event.MouseInput.Y)); if (AbsoluteClippingRect.isPointInside(core::position2di(event.MouseInput.X, event.MouseInput.Y)))
if (el == this )
{ {
Dragging = true; Dragging = true;
Environment->setFocus(this); Environment->setFocus(this);
...@@ -103,11 +102,7 @@ bool CGUIScrollBar::OnEvent(SEvent event) ...@@ -103,11 +102,7 @@ bool CGUIScrollBar::OnEvent(SEvent event)
} }
else else
{ {
if (Environment->getFocus() == this) Environment->removeFocus(this);
{
Environment->setFocus(el);
return el->OnEvent(event);
}
} }
break; break;
} }
......
...@@ -208,6 +208,7 @@ void CGUIStaticText::enableOverrideColor(bool enable) ...@@ -208,6 +208,7 @@ void CGUIStaticText::enableOverrideColor(bool enable)
bool CGUIStaticText::isOverrideColorEnabled() bool CGUIStaticText::isOverrideColorEnabled()
{ {
_IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX;
return OverrideColorEnabled; return OverrideColorEnabled;
} }
...@@ -222,6 +223,7 @@ void CGUIStaticText::setWordWrap(bool enable) ...@@ -222,6 +223,7 @@ void CGUIStaticText::setWordWrap(bool enable)
bool CGUIStaticText::isWordWrapEnabled() bool CGUIStaticText::isWordWrapEnabled()
{ {
_IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX;
return WordWrap; return WordWrap;
} }
......
...@@ -68,7 +68,18 @@ CGUIToolBar::~CGUIToolBar() ...@@ -68,7 +68,18 @@ CGUIToolBar::~CGUIToolBar()
{ {
} }
//! called if an event happened.
bool CGUIToolBar::OnEvent(SEvent event)
{
if (event.EventType == EET_MOUSE_INPUT_EVENT &&
event.MouseInput.Event == EMIE_LMOUSE_PRESSED_DOWN)
{
if (AbsoluteClippingRect.isPointInside(core::position2di(event.MouseInput.X, event.MouseInput.Y)))
return true;
}
return Parent ? Parent->OnEvent(event) : false;
}
//! draws the element and its children //! draws the element and its children
void CGUIToolBar::draw() void CGUIToolBar::draw()
......
...@@ -23,6 +23,9 @@ namespace gui ...@@ -23,6 +23,9 @@ namespace gui
//! destructor //! destructor
~CGUIToolBar(); ~CGUIToolBar();
//! called if an event happened.
virtual bool OnEvent(SEvent event);
//! draws the element and its children //! draws the element and its children
virtual void draw(); virtual void draw();
......
...@@ -107,8 +107,10 @@ bool CGUIWindow::OnEvent(SEvent event) ...@@ -107,8 +107,10 @@ bool CGUIWindow::OnEvent(SEvent event)
if (event.GUIEvent.EventType == EGET_ELEMENT_FOCUS_LOST) if (event.GUIEvent.EventType == EGET_ELEMENT_FOCUS_LOST)
{ {
if (event.GUIEvent.Caller == (IGUIElement*)this) if (event.GUIEvent.Caller == (IGUIElement*)this)
{
Dragging = false; Dragging = false;
return true; return true;
}
} }
else else
if (event.GUIEvent.EventType == EGET_BUTTON_CLICKED) if (event.GUIEvent.EventType == EGET_BUTTON_CLICKED)
......
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