mirror of
https://github.com/minetest/irrlicht.git
synced 2025-06-28 06:20:21 +02:00
Add blinkMode parameter to IGUIEnvironment::addModalScreen, so blinking can be suppressed
git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6212 dfc29bdd-3216-0410-991c-e03cc46cb475
This commit is contained in:
@ -1073,11 +1073,12 @@ IGUIWindow* CGUIEnvironment::addWindow(const core::rect<s32>& 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;
|
||||
|
@ -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,
|
||||
|
@ -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<IGUIElement*>::Iterator it = Children.begin();
|
||||
core::rect<s32> 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);
|
||||
}
|
||||
|
||||
|
||||
|
@ -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;
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user