mirror of
https://github.com/minetest/irrlicht.git
synced 2024-11-19 08:40:24 +01:00
Add IGUIEnvironment::addToDeletionQueue to allow save removal of gui elements while iterating over them
Basically same as ISceneManager::addToDeletionQueue. git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6164 dfc29bdd-3216-0410-991c-e03cc46cb475
This commit is contained in:
parent
0368c5b09d
commit
bd2b44aa1c
@ -1,5 +1,6 @@
|
|||||||
--------------------------
|
--------------------------
|
||||||
Changes in 1.9 (not yet released)
|
Changes in 1.9 (not yet released)
|
||||||
|
- Add IGUIEnvironment::addToDeletionQueue to allow save removal of gui elements while iterating over them (like the same named function in ISceneManager).
|
||||||
- IGUIEnvironment::drawAll has now a parameter to allow disabling automatic resize to screensize. Makes it easier to use partial screens with full alignment support.
|
- IGUIEnvironment::drawAll has now a parameter to allow disabling automatic resize to screensize. Makes it easier to use partial screens with full alignment support.
|
||||||
- No longer try to set WM_QUIT when using an external Window on Win32.
|
- No longer try to set WM_QUIT when using an external Window on Win32.
|
||||||
Thx @Marko Mahnic for the patch (https://sourceforge.net/p/irrlicht/bugs/449)
|
Thx @Marko Mahnic for the patch (https://sourceforge.net/p/irrlicht/bugs/449)
|
||||||
|
@ -623,10 +623,10 @@ public:
|
|||||||
virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0)=0;
|
virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0)=0;
|
||||||
|
|
||||||
//! writes an element
|
//! writes an element
|
||||||
virtual void writeGUIElement(io::IXMLWriter* writer, IGUIElement* node) =0;
|
virtual void writeGUIElement(io::IXMLWriter* writer, IGUIElement* element) =0;
|
||||||
|
|
||||||
//! reads an element
|
//! reads an element
|
||||||
virtual void readGUIElement(io::IXMLReader* reader, IGUIElement* node) =0;
|
virtual void readGUIElement(io::IXMLReader* reader, IGUIElement* element) =0;
|
||||||
|
|
||||||
//! Find the next element which would be selected when pressing the tab-key
|
//! Find the next element which would be selected when pressing the tab-key
|
||||||
/** If you set the focus for the result you can manually force focus-changes like they
|
/** If you set the focus for the result you can manually force focus-changes like they
|
||||||
@ -646,6 +646,17 @@ public:
|
|||||||
//! Get the way the gui does handle focus changes
|
//! Get the way the gui does handle focus changes
|
||||||
/** \returns A bitmask which is a combination of ::EFOCUS_FLAG flags.*/
|
/** \returns A bitmask which is a combination of ::EFOCUS_FLAG flags.*/
|
||||||
virtual u32 getFocusBehavior() const = 0;
|
virtual u32 getFocusBehavior() const = 0;
|
||||||
|
|
||||||
|
//! Adds a IGUIElement to deletion queue.
|
||||||
|
/** Queued elements will be removed at the end of each drawAll call.
|
||||||
|
Or latest in the destructor of the GUIEnvironment.
|
||||||
|
This can be used to allow an element removing itself safely in a function
|
||||||
|
iterating over gui elements, like an overloaded IGUIElement::draw or
|
||||||
|
IGUIElement::OnPostRender function.
|
||||||
|
Note that in general just calling IGUIElement::remove() is enough.
|
||||||
|
Unless you create your own GUI elements removing themselves you won't need it.
|
||||||
|
\param element: Element to remove */
|
||||||
|
virtual void addToDeletionQueue(IGUIElement* element) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -101,6 +101,8 @@ CGUIEnvironment::CGUIEnvironment(io::IFileSystem* fs, video::IVideoDriver* drive
|
|||||||
//! destructor
|
//! destructor
|
||||||
CGUIEnvironment::~CGUIEnvironment()
|
CGUIEnvironment::~CGUIEnvironment()
|
||||||
{
|
{
|
||||||
|
clearDeletionQueue();
|
||||||
|
|
||||||
if ( HoveredNoSubelement && HoveredNoSubelement != this )
|
if ( HoveredNoSubelement && HoveredNoSubelement != this )
|
||||||
{
|
{
|
||||||
HoveredNoSubelement->drop();
|
HoveredNoSubelement->drop();
|
||||||
@ -212,6 +214,8 @@ void CGUIEnvironment::drawAll(bool useScreenSize)
|
|||||||
|
|
||||||
draw();
|
draw();
|
||||||
OnPostRender ( os::Timer::getTime () );
|
OnPostRender ( os::Timer::getTime () );
|
||||||
|
|
||||||
|
clearDeletionQueue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -470,6 +474,28 @@ void CGUIEnvironment::OnPostRender( u32 time )
|
|||||||
IGUIElement::OnPostRender ( time );
|
IGUIElement::OnPostRender ( time );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CGUIEnvironment::addToDeletionQueue(IGUIElement* element)
|
||||||
|
{
|
||||||
|
if (!element)
|
||||||
|
return;
|
||||||
|
|
||||||
|
element->grab();
|
||||||
|
DeletionQueue.push_back(element);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CGUIEnvironment::clearDeletionQueue()
|
||||||
|
{
|
||||||
|
if (DeletionQueue.empty())
|
||||||
|
return;
|
||||||
|
|
||||||
|
for (u32 i=0; i<DeletionQueue.size(); ++i)
|
||||||
|
{
|
||||||
|
DeletionQueue[i]->remove();
|
||||||
|
DeletionQueue[i]->drop();
|
||||||
|
}
|
||||||
|
|
||||||
|
DeletionQueue.clear();
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
void CGUIEnvironment::updateHoveredElement(core::position2d<s32> mousePos)
|
void CGUIEnvironment::updateHoveredElement(core::position2d<s32> mousePos)
|
||||||
|
@ -269,8 +269,14 @@ public:
|
|||||||
//! Get the way the gui does handle focus changes
|
//! Get the way the gui does handle focus changes
|
||||||
virtual u32 getFocusBehavior() const _IRR_OVERRIDE_;
|
virtual u32 getFocusBehavior() const _IRR_OVERRIDE_;
|
||||||
|
|
||||||
|
//! Adds a IGUIElement to deletion queue.
|
||||||
|
virtual void addToDeletionQueue(IGUIElement* element) _IRR_OVERRIDE_;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
//! clears the deletion queue
|
||||||
|
void clearDeletionQueue();
|
||||||
|
|
||||||
void updateHoveredElement(core::position2d<s32> mousePos);
|
void updateHoveredElement(core::position2d<s32> mousePos);
|
||||||
|
|
||||||
void loadBuiltInFont();
|
void loadBuiltInFont();
|
||||||
@ -322,6 +328,8 @@ private:
|
|||||||
IEventReceiver* UserReceiver;
|
IEventReceiver* UserReceiver;
|
||||||
IOSOperator* Operator;
|
IOSOperator* Operator;
|
||||||
u32 FocusFlags;
|
u32 FocusFlags;
|
||||||
|
core::array<IGUIElement*> DeletionQueue;
|
||||||
|
|
||||||
static const io::path DefaultFontName;
|
static const io::path DefaultFontName;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user