[SOLVED] Custom GUI Element (notified when adding child)

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
xterminhate
Posts: 206
Joined: Thu Sep 01, 2005 9:26 pm
Location: France

[SOLVED] Custom GUI Element (notified when adding child)

Post by xterminhate »

--edit
Found this very recent thrread about my problem : http://irrlicht.sourceforge.net/forum/v ... nd#p277529
I'm not considering this problem as a bug of Irrlicht. I'm just looking for a good solution to handle dynamic changes of GUI Element tree.
--edit


Hey,

I'm coding a custom GUI Element and I'm facing a little problem.

I cannot find a way for my new GUI Element to be notified when another GUI Element registers itself as a child.

It seems that there is no way to overload the member function that allows registering a GUI Element to a parent one.

IGUIElement.h
00817 // not virtual because needed in constructor
00818 void addChildToEnd(IGUIElement* child)

I would be please if someone could give me a tip. I can see no other way that scanning the list of children at every frame in order to detect new childs.

Bye,
X.
Last edited by xterminhate on Fri Mar 01, 2013 10:17 pm, edited 2 times in total.
Return to Irrlicht after years... I'm lovin it.
It's hard to be a Man !
Si vis pacem para belum
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Custom GUI Element (need to be notified when addin child

Post by CuteAlien »

You can overload addChild. It just won't work whenever you add childs using the constructor instead so you have to explicitely call addChild when adding them. I don't think there's a way around this. It's an unfortunate bug that this constructor even exists, I hope I can find time to work on this before 1.9 release.
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
xterminhate
Posts: 206
Joined: Thu Sep 01, 2005 9:26 pm
Location: France

Re: Custom GUI Element (need to be notified when addin child

Post by xterminhate »

Thank you very much for your quick reply, CuteAlien.

Well I have come to the same conclusion. My custom GUI element will not be as generic as I expected.

As long as the part of the GUI tree, where is located my custom GUI element, does not change often during execution (in-game), this is not a big problem.

I will post my GUI element in the code snippets section soon if I have got a good result.

Solved.
X.
Return to Irrlicht after years... I'm lovin it.
It's hard to be a Man !
Si vis pacem para belum
xterminhate
Posts: 206
Joined: Thu Sep 01, 2005 9:26 pm
Location: France

Re: [SOLVED] Custom GUI Element (notified when adding child)

Post by xterminhate »

---edit
That works, not too bad.
Follow : http://irrlicht.sourceforge.net/forum/v ... =9&t=48291
---edit

Hello,

This custom GUI element is called CGUIDynamicGrid.

In the following demo, I inserted one instance between the GUI Root Element and the instances of the GUI Windows. I did not change the Irrlicht 1.8 library. The algorithm of GUI Dynamic Grid has to be manually activated when adding a new child (eg. Window). The focused GUI child element of GUI Dynamic Grid automatically sticks to other GUI child element. Now, I'm looking for a way to dettach the windows. I will probably use a key (CTRL or SHIFT) to trigger the dettach algorithm.

http://www.youtube.com/watch?v=TlIWHTYHQxw

Let me know what you think. I will post the source code in a few days (I'm cleaning it, trying to conform Irrlicht conding rules).

X.

NB: I think there is a little bug with the focus and the GUI List Box of Irrlicht 1.8. I failed to drag the first GUI Windows on top of the List Box.
Return to Irrlicht after years... I'm lovin it.
It's hard to be a Man !
Si vis pacem para belum
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: [SOLVED] Custom GUI Element (notified when adding child)

Post by CuteAlien »

Looks pretty cool.
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
Post Reply