How to add an empty GUI element?
-
- Posts: 51
- Joined: Thu Sep 11, 2008 2:24 pm
- Location: Hong Kong
- Contact:
How to add an empty GUI element?
I have several systems in my game, each of them has their own scene nodes and GUI elements.
To better organize them, for each system, I want to add an empty scene node and empty GUI element,
so that I can use them as a parent for other scene nodes and GUI elements,
and remove all the things easily by calling rootNode->remove() and rootElement->remove()
I can use smgr->addEmptySceneNode() to create an empty node
but I cannot find any function for creating an empty GUI element.
Does anyone know how to do it?
To better organize them, for each system, I want to add an empty scene node and empty GUI element,
so that I can use them as a parent for other scene nodes and GUI elements,
and remove all the things easily by calling rootNode->remove() and rootElement->remove()
I can use smgr->addEmptySceneNode() to create an empty node
but I cannot find any function for creating an empty GUI element.
Does anyone know how to do it?
Re: How to add an empty GUI element?
IGUITabcomicsteam wrote:I have several systems in my game, each of them has their own scene nodes and GUI elements.
To better organize them, for each system, I want to add an empty scene node and empty GUI element,
so that I can use them as a parent for other scene nodes and GUI elements,
and remove all the things easily by calling rootNode->remove() and rootElement->remove()
I can use smgr->addEmptySceneNode() to create an empty node
but I cannot find any function for creating an empty GUI element.
Does anyone know how to do it?
-
- Posts: 51
- Joined: Thu Sep 11, 2008 2:24 pm
- Location: Hong Kong
- Contact:
Re: How to add an empty GUI element?
Thanks~ you replied so fastLambda wrote:IGUITab
Should I add it in this way?
env->addTab(core::rect<s32>(0,0,0,0));
I use a custom gui element for this which looks as follows:
I think if you also need serialization you will have to add it by your own GUIElementFactory, otherwise you can just use it by creating it with new.
edit: It's not perfect btw. as it is not possible to control the clipping of childs. So the window-sizes can matter. But I see currently no way to get around that, so I just make the empty element really large.
Code: Select all
#ifndef _GUI_EMPTY_H
#define _GUI_EMPTY_H
#include <irrlicht.h>
// Empty elements which don't do much themself are useful as parent elements to build hierarchies
class CGUIEmptyElement : public irr::gui::IGUIElement
{
public:
CGUIEmptyElement(irr::gui::IGUIEnvironment* environment, irr::gui::IGUIElement* parent)
: irr::gui::IGUIElement((irr::gui::EGUI_ELEMENT_TYPE)(irr::gui::EGUIET_ELEMENT + 1), environment, parent, -1, irr::core::rect<irr::s32>(0,0,100,100)) {}
irr::gui::IGUIEnvironment* GetEnvironment() { return Environment; }
virtual const irr::c8* getTypeName() const { return "empty"; }
virtual bool isPointInside(const irr::core::position2d<irr::s32>& point) const
{
return false;
}
virtual bool bringToFront(IGUIElement* element)
{
bool result = IGUIElement::bringToFront(element);
// pass that on
if ( Parent )
{
Parent->bringToFront(this);
}
return result;
}
};
#endif // _GUI_EMPTY_H
edit: It's not perfect btw. as it is not possible to control the clipping of childs. So the window-sizes can matter. But I see currently no way to get around that, so I just make the empty element really large.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
-
- Posts: 51
- Joined: Thu Sep 11, 2008 2:24 pm
- Location: Hong Kong
- Contact:
Thanks, CuteAlienCuteAlien wrote:I use a custom gui element for this which looks as follows:
. . . .
I think if you also need serialization you will have to add it by your own GUIElementFactory, otherwise you can just use it by creating it with new.
edit: It's not perfect btw. as it is not possible to control the clipping of childs. So the window-sizes can matter. But I see currently no way to get around that, so I just make the empty element really large.
Actually I don't want to have any clipping of its childern.
If I create this empty element with 0 size, can its childern still be visible?
If the size is very large, will it block the elements of other systems?
Yeah, that's the problem I mentioned - it's not possible to control the clipping behaviour of children - it works the other way round and children decide if they want to clip against their parent. So either you make sure all children will always disable clipping or you make the empty element large enough that it never clips. I use the second solution and just set it to values like 2000x2000.comicsteam wrote: Actually I don't want to have any clipping of its childern.
If I create this empty element with 0 size, can its childern still be visible?
If the size is very large, will it block the elements of other systems?
And yes, that would usually lead to a problem that it would block other elements, which is never what it should do - that's why I overwrote those two functions (isPointInside and bringToFront). So it never is focused (isPointInside is checked for that) and it never is activated itself. Basically that was exactly the reason I couldn't use one of the available guielements for this task but had to write CGUIEmptyElement.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Re: How to add an empty GUI element?
Hello, sorry about the necro!
Was there any development on rooting GUI elements since 2006?
When using the above snippet, only the last created CGUIEmptyElement has mouse-accessible elements. I tried bringToFront and setVisible/setEnabled but they did not allow other gui elements to be mouse picked (the last root created this way behaves properly though.)
Thanks!
Was there any development on rooting GUI elements since 2006?
When using the above snippet, only the last created CGUIEmptyElement has mouse-accessible elements. I tried bringToFront and setVisible/setEnabled but they did not allow other gui elements to be mouse picked (the last root created this way behaves properly though.)
Thanks!
Re: How to add an empty GUI element?
Yeah, I avoid bringToFront in the code above (passing it on). But not quite sure right now why I did that (been long time since I wrote this... probably was something I needed in my case). Just remove that part.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Re: How to add an empty GUI element?
I'm looking for the pathway in which a EGET_ELEMENT_HOVERED will be emitted (to use QT talk).
Maybe there's a hacky way I can get the gui environment to only look down one 'root node' for all signals?
Maybe there's a hacky way I can get the gui environment to only look down one 'root node' for all signals?
Re: How to add an empty GUI element?
Sorry, not sure what you try to do. That code above worked for all my cases so far... so obviously you try doing something different from me. But can't help without knowing the exact context of what's going on and what you are trying.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Re: How to add an empty GUI element?
I solved this issue. If the current event receiver returns true, you will not have the ability to use the hard coded mouse interaction.
I assume this is done so that you can implement your own behaviors.
It would be great to add this to the source comments, as it is not obvious what
means in terms of windows with mouse functionality.
I assume this is done so that you can implement your own behaviors.
It would be great to add this to the source comments, as it is not obvious what
Code: Select all
"Please take care that you should only return 'true' when you want to _prevent_ Irrlicht from processing the event any further."
Re: How to add an empty GUI element?
Good it works now. Documentation could maybe be improved in some way, don't know. If it starts getting too long and detailed then people will probably start skipping over the text.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm