diff --git a/changes.txt b/changes.txt index 452ef8fb..12a0a857 100644 --- a/changes.txt +++ b/changes.txt @@ -1,5 +1,6 @@ -------------------------- Changes in 1.9 (not yet released) +- Add blinkMode parameter to IGUIEnvironment::addModalScreen, so blinking can be suppressed - Speedup: Avoid string copy in CXMLReaderImpl::getAttributeByName - Fix bug in rect::clipAgainst that had caused rects completely outside to the left-top of the rect to be clipped against ending up with both corners outside. It still worked for UI in most cases as the resulting rectangle still had an area of 0. diff --git a/include/IGUIEnvironment.h b/include/IGUIEnvironment.h index 4bd3db87..e631b1dc 100644 --- a/include/IGUIEnvironment.h +++ b/include/IGUIEnvironment.h @@ -260,10 +260,14 @@ public: Note that it usually works badly to pass the modal screen already as parent when creating a new element. It's better to add that new element later to the modal screen with addChild. \param parent Parent gui element of the modal. + \param blinkMode Bitset of when to blink (can be combined) + 0 = never + 1 = focus changes + 2 = Left mouse button pressed down \return Pointer to the created modal. Returns 0 if an error occurred. This pointer should not be dropped. See IReferenceCounted::drop() for more information. */ - virtual IGUIElement* addModalScreen(IGUIElement* parent) = 0; + virtual IGUIElement* addModalScreen(IGUIElement* parent, int blinkMode = 3) = 0; //! Adds a message box. /** \param caption Text to be displayed the title of the message box. diff --git a/source/Irrlicht/CGUIEnvironment.cpp b/source/Irrlicht/CGUIEnvironment.cpp index e970d640..465a20d4 100644 --- a/source/Irrlicht/CGUIEnvironment.cpp +++ b/source/Irrlicht/CGUIEnvironment.cpp @@ -1073,11 +1073,12 @@ IGUIWindow* CGUIEnvironment::addWindow(const core::rect& rectangle, bool mo //! adds a modal screen. The returned pointer must not be dropped. -IGUIElement* CGUIEnvironment::addModalScreen(IGUIElement* parent) +IGUIElement* CGUIEnvironment::addModalScreen(IGUIElement* parent, int blinkMode) { parent = parent ? parent : this; - IGUIElement *win = new CGUIModalScreen(this, parent, -1); + CGUIModalScreen *win = new CGUIModalScreen(this, parent, -1); + win->setBlinkMode(blinkMode); win->drop(); return win; diff --git a/source/Irrlicht/CGUIEnvironment.h b/source/Irrlicht/CGUIEnvironment.h index e87e236f..6730e6d6 100644 --- a/source/Irrlicht/CGUIEnvironment.h +++ b/source/Irrlicht/CGUIEnvironment.h @@ -97,7 +97,7 @@ public: const wchar_t* text=0, IGUIElement* parent=0, s32 id=-1) _IRR_OVERRIDE_; //! adds a modal screen. The returned pointer must not be dropped. - virtual IGUIElement* addModalScreen(IGUIElement* parent) _IRR_OVERRIDE_; + virtual IGUIElement* addModalScreen(IGUIElement* parent, int blinkMode) _IRR_OVERRIDE_; //! Adds a message box. virtual IGUIWindow* addMessageBox(const wchar_t* caption, const wchar_t* text=0, diff --git a/source/Irrlicht/CGUIModalScreen.cpp b/source/Irrlicht/CGUIModalScreen.cpp index 047fc716..1555cc26 100644 --- a/source/Irrlicht/CGUIModalScreen.cpp +++ b/source/Irrlicht/CGUIModalScreen.cpp @@ -18,6 +18,7 @@ namespace gui //! constructor CGUIModalScreen::CGUIModalScreen(IGUIEnvironment* environment, IGUIElement* parent, s32 id) : IGUIElement(EGUIET_MODAL_SCREEN, environment, parent, id, core::recti(0, 0, parent->getAbsolutePosition().getWidth(), parent->getAbsolutePosition().getHeight()) ), + BlinkMode(3), MouseDownTime(0) { #ifdef _DEBUG @@ -90,7 +91,8 @@ bool CGUIModalScreen::OnEvent(const SEvent& event) { Environment->removeFocus(0); // can't setFocus otherwise at it still has focus here Environment->setFocus(event.GUIEvent.Element); - MouseDownTime = os::Timer::getTime(); + if ( BlinkMode&1 ) + MouseDownTime = os::Timer::getTime(); return true; } if ( !canTakeFocus(event.GUIEvent.Caller)) @@ -112,7 +114,7 @@ bool CGUIModalScreen::OnEvent(const SEvent& event) else Environment->setFocus(this); } - else + else if ( BlinkMode&1 ) { MouseDownTime = os::Timer::getTime(); } @@ -130,7 +132,7 @@ bool CGUIModalScreen::OnEvent(const SEvent& event) } break; case EET_MOUSE_INPUT_EVENT: - if (event.MouseInput.Event == EMIE_LMOUSE_PRESSED_DOWN) + if (event.MouseInput.Event == EMIE_LMOUSE_PRESSED_DOWN && (BlinkMode & 2)) { MouseDownTime = os::Timer::getTime(); } @@ -153,7 +155,7 @@ void CGUIModalScreen::draw() return; u32 now = os::Timer::getTime(); - if (now - MouseDownTime < 300 && (now / 70)%2) + if (BlinkMode && now - MouseDownTime < 300 && (now / 70)%2) { core::list::Iterator it = Children.begin(); core::rect r; @@ -219,12 +221,16 @@ void CGUIModalScreen::updateAbsolutePosition() void CGUIModalScreen::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) const { IGUIElement::serializeAttributes(out,options); + + out->addInt("BlinkMode", BlinkMode ); } //! Reads attributes of the element void CGUIModalScreen::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0) { IGUIElement::deserializeAttributes(in, options); + + BlinkMode = in->getAttributeAsInt("BlinkMode", BlinkMode); } diff --git a/source/Irrlicht/CGUIModalScreen.h b/source/Irrlicht/CGUIModalScreen.h index 0fe761a2..c9ab8921 100644 --- a/source/Irrlicht/CGUIModalScreen.h +++ b/source/Irrlicht/CGUIModalScreen.h @@ -52,11 +52,27 @@ namespace gui //! Reads attributes of the element virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options) _IRR_OVERRIDE_; + //! Set when to blink. + //! Bitset of following values (can be combined) + //! 0 = never + //! 1 = focus changes + //! 2 = Left mouse button pressed down + void setBlinkMode(u32 blink) + { + BlinkMode = blink; + } + + u32 getBlinkMode() const + { + return BlinkMode; + } + protected: virtual bool canTakeFocus(IGUIElement* target) const; private: + u32 BlinkMode; u32 MouseDownTime; };