Embedding widget into another one

stalker87

28-09-2008 02:42:52

Hi... another question sorry.

How i can insert a Widget into another one ?
For example i create a Button and then a Window. So i want to embedding Button into that Window.

Something similar to this:

Button *b = //create widget

Window *win = //create window

win->embed(b);


I know Widget::createWidget method but i need to embedding precreated widget.

Have you any idea ?

my.name

28-09-2008 08:28:13

To create an exact copy, and old to remove.

stalker87

28-09-2008 12:35:18

Mmmh... i think is a bad solution for my problem cause i have a cascading embedded widget...


//Initial layout
Window1
Window2
Button1
Button2
Button3
//Another Layout
Window3
Button4
Button5


So if i want to detach Window2 and attach Window3 i need to recreate all widgets.

Altren

28-09-2008 12:43:36

Hmm, can you explain for what do you need such embedding. Currently there's no easy way.
Only solution I can give you at the moment is save everything to layout file and then load into widget...

stalker87

28-09-2008 13:36:06

Hmm, can you explain for what do you need such embedding.

Cause i need to have my widgets in parent's relative position with the Window1. I need it cause i use a .layout file to create my Window2 and Window3 (with the respective button as childs) so i have a data driven system that help me to modify my code without recompile it.

ppClarity

28-09-2008 18:20:09

Hmm, can you explain for what do you need such embedding. Currently there's no easy way.
Only solution I can give you at the moment is save everything to layout file and then load into widget...

:shock: :(

Ugh. Static definition via a toolkit specific file doesn't work for me either. I have my own toolkit agnostic API and wrapper for describing UI elements in my engine.

Since this can be done via the layout files, I assume that it shouldn't be a big deal to expose an interface to do this programatically.

Altren

28-09-2008 18:33:38

2 stalker87 I don't understand why you can't create this widgets in window. Why you need to create it somewhere else and then embed it? How you create those widgets that you need to embed. Do you create and embed them just after creating?
2 ppClarity You can create child widget. Explain why you need to create non-child widget and then embed it.
In layout we creating new widgets, not copying any.

stalker87

28-09-2008 19:31:33

I don't understand why you can't create this widgets in window.

Window2.layout
Window1.layout

This layouts are very complicated and create them via code is a bad bad thing. So i create two separate layout and i load them when i need them. After that i would attach this parent window ( Window2 or Window1 ) to the root widget Window0.
Clear now ? sorry for bad english :\

Altren

28-09-2008 19:59:04

Clear. You can load layout inside Window0.
MyGUI::LayoutManager::getInstance().loadLayout("Window1.layout ", "", pointerToWindow0)

ppClarity

28-09-2008 21:53:34

2 ppClarity You can create child widget. Explain why you need to create non-child widget and then embed it.
In layout we creating new widgets, not copying any.

Ah, I misunderstood what the original poster was asking for. Child widgets are pefect, thanks :)

mrmclovin

27-12-2008 23:45:20

I bring up this old thread coz I have a similar/same problem. I want to dynamically modify a widgets child/parent. The functionality is similar to Ogre's scenenode child tree.

// might be pseudo!
scenenode1->removeChild(childScenenode);
scenenode2->addChild(childSceneNode);


So let's say I have a MyGUI::Window and want to attach a button to its local offset position area.

rootWidget->removeChild(ButtonPtr);
windowWidget->addChild(ButtonPtr);
// (windowWidget is a child of rootWidget)

Can this be done or is it already possible? (without to copy and re-create widgets) I couldn't understand from this thread if it was or not...

PS. How to copy a widget (with its child(s)) effectively? There seem to be no copy constructor?

Altren

28-12-2008 03:59:44

There's no such functionality at the moment, but we are working on it.

mrmclovin

28-12-2008 18:36:29

Okey, sounds good! Let me/us know when you're done :)

But how do I _best_ copy a widget? If I copy a widget, will that widgets children be copied as well?

mrmclovin

22-01-2009 22:12:19

There's no such functionality at the moment, but we are working on it.

Any update yet? Or a time plan for this?
//thanks

my.name

23-01-2009 02:00:38

update from svn =)

mrmclovin

23-01-2009 19:28:23

you're the best! :D

Where do I find it? is it the void MyGUI::IWidgetCreator::_linkChildWidget() ?

Altren

23-01-2009 21:32:45

Where do I find it? is it the void MyGUI::IWidgetCreator::_linkChildWidget() ?
Not so deep :)
Widget::detachFromWidget();
Widget::attachToWidget(WidgetPtr _widget);

mrmclovin

23-01-2009 23:42:43

Where do I find it? is it the void MyGUI::IWidgetCreator::_linkChildWidget() ?
Not so deep :)
Widget::detachFromWidget();
Widget::attachToWidget(WidgetPtr _widget);


Sweet! Big hug from me!

mrmclovin

28-02-2009 18:35:07

Im having some problem with this.
I've set up a Tab. Then I created a TabItem. If I do tabItem->createWidget() I will get a corresponding sheet. But if I try to attach a pre-created widget to the tabItem, the widget position is not relative to the tabItem ot the Tab. The position should be relative to the tabItems upper-left corner of the "tab content", if you know what I mean. Just like if you create a Widget via tabItem->createWidget(). Maybe this attachToWidget() is'nt fully implemented yet?

I don't want to sound unthankful :oops: , but perhaps it's better to have the methods like widget->attachWidget(button) and widget->detachWidget(button) and widget->detachFromParent(). Like in Ogre. Just my opinion! :twisted: