Page 1 of 1
Using templates as a way to duplicate
Posted: Tue Jan 13, 2009 15:06
by arn
There is a way to use templates in CEGUI? . I mean, load several windows from a .layout file, and duplicate these windows for several purposes.
For example, I want to reutilize a ok-cancel dialog (with two buttons on it), But I would like to have several dialogs, each one with it's own purpose and linked also to different events in my application.
Posted: Tue Jan 13, 2009 16:53
by Jamarr
Sounds like you want to copy a CEGUI window? Try this thread:
http://www.cegui.org.uk/phpBB2/viewtopic.php?t=3584
Re: Using templates as a way to duplicate
Posted: Tue Jan 13, 2009 17:56
by dmail
arn wrote:For example, I want to reutilize a ok-cancel dialog (with two buttons on it), But I would like to have several dialogs, each one with it's own purpose and linked also to different events in my application.
Yes this is something I do with these sort of dialog boxes.
The layout just has the ok/cancel button and a text box attached to a window and the class which wraps it:
The constructor
-loads the layout
-attaches two functors, one for ok and one for cancel.(these are not CEGUI event functors yet a functor to another class instance)
-sets the window message text
-registers the events
-attaches the window to the root
The destructor.
-detaches the window from the root
-de-registers the events
-unloads the layout
As there is ever only one instance of the window there is no problems with window duplicate names and this window is ok to load and unload as it is never shown in time critical situations (it is in essence a blocking operation)
Posted: Tue Jan 13, 2009 18:34
by arn
Yes, I want to copy a whole tree, Unfortunately I have to deal also with the naming issue, because I want several copies working at the same time. I think it is not so difficult to do an appropiate algorithm for it.
While that kind of copying is not part of CEGUI itself, I have to code by myself.
Thanks anyway
Posted: Tue Jan 13, 2009 23:00
by earthsruler
Window* loadWindowLayout(const String& filename, bool generateRandomPrefix);
You can use that function of the window manager to load the same layout with different prefixes. The only problem is that you then cant rely on the names defined within the layout file cause they could now have a random prefix.
ER.
Posted: Wed Jan 14, 2009 02:27
by arn
If I used that method, I wouldn't identify the windows inside.
Can I rely on the order that the windows exist inside the layout?
In any case, which class loadWindowLayout method belongs to?
Posted: Wed Jan 14, 2009 08:11
by scriptkid
Hi,
you might want to check this post:
http://www.cegui.org.uk/phpBB2/viewtopi ... =deep+copy
It explains a little about deep copying of widget trees.
In any case, which class loadWindowLayout method belongs to?
Thas would be the WindowManager.
HTH.