Have done some searching and can't seem to figure this out. Essentially I want a hierarchy of windows (Root/subset/1, Root/subset/2, Root/subset...) to be show()/hide() when the base window (Root/subset) is either shown or hidden
At first I hoped a show/hide call propagated that to children, unsurprisingly it does not seem to (nor can I find an option that will cause it to?)
Next I figured I'd just iterate through d_children myself and set the state.. except its protected. Its not clear to me that I'm supposed to inherit from the window class, since that would mean intimate involvement with construction, which seems wrong.
I could just brute-force it and maintain a list which I selectively batch-on batch-off but that's a maintenance nightmare which should not involve recompiling the client when a designer adds a dialog which may be entirely serviced with scripts.
Perhaps my OO-foo is simply weak, how am I supposed to do this?
-Curt
*fixed* Newb question? how to iterate child windows?
Moderators: CEGUI MVP, CEGUI Team
*fixed* Newb question? how to iterate child windows?
Last edited by Curtaoa on Thu Sep 01, 2011 15:47, edited 1 time in total.
Re: Newb question? how to iterate child windows?
Definitely not an advanced question.
First of all I *think* you are "doing it wrong". You can just create a wrapper default window and hide/show that which will hide and show all of its children (if parent isn't visible, its children aren't visible as well).
However to iterate through children you can use:
To iterate depth first you would have to devise a recursive algorithm for it. Maybe we could introduce some better children traversal in 0.8, if someone makes a good suggestion with use cases.
PS: Read the guidelines! I won't downvote you since this is your first post. However we REQUIRE CEGUI.log or at least version info in each support post.
First of all I *think* you are "doing it wrong". You can just create a wrapper default window and hide/show that which will hide and show all of its children (if parent isn't visible, its children aren't visible as well).
However to iterate through children you can use:
Code: Select all
size_t index = 0;
while (index < wnd->getChildCount())
{
CEGUI::Window* child = wnd->getChildAtIdx(index);
// do stuff
++index;
}
To iterate depth first you would have to devise a recursive algorithm for it. Maybe we could introduce some better children traversal in 0.8, if someone makes a good suggestion with use cases.
PS: Read the guidelines! I won't downvote you since this is your first post. However we REQUIRE CEGUI.log or at least version info in each support post.
Re: Newb question? how to iterate child windows?
Thank you for your reply.
It may be that hiding the parent window causes CEGUI to not render children but they are still marked as 'visible' so the dynamic content rendered by the handler doesn't know to stop rendering. Is there some flag I can check to see if CEGUI thinks a window is completely clipped?
edit: I see isClippedByParent() which may ore may not work on a child-of-child. Since setting the children to "not visible" feels fast-fail and more optimal to me I'll just go with iterating all the children and setting their state.
If not then your iteration loop is certainly sufficient for what I need.
2nd edit: nope. unfortunately by iterating through all children it turns on windows that are supposed to be hidden (notably the title bar of my login dialog) so it looks like I'm going to explore the "am I completely clipped by an inactive parent" check every frame. I imagine issues regarding child-of-child cases. Perhaps CEGUI maintains some other "render me or not" state I can hook into, I will explore the API further. Again thank you for your assistance.
3rd edi *FIXED*: eureka! isVisible() takes a parameter to ask about ancestors as well, this is exactly what I'm looking for. Of course it defaults to 'false' which is what I want to set it to, so I wonder why it didn't just work the first time. In any case thanks for your direction.
It may be that hiding the parent window causes CEGUI to not render children but they are still marked as 'visible' so the dynamic content rendered by the handler doesn't know to stop rendering. Is there some flag I can check to see if CEGUI thinks a window is completely clipped?
edit: I see isClippedByParent() which may ore may not work on a child-of-child. Since setting the children to "not visible" feels fast-fail and more optimal to me I'll just go with iterating all the children and setting their state.
If not then your iteration loop is certainly sufficient for what I need.
2nd edit: nope. unfortunately by iterating through all children it turns on windows that are supposed to be hidden (notably the title bar of my login dialog) so it looks like I'm going to explore the "am I completely clipped by an inactive parent" check every frame. I imagine issues regarding child-of-child cases. Perhaps CEGUI maintains some other "render me or not" state I can hook into, I will explore the API further. Again thank you for your assistance.
3rd edi *FIXED*: eureka! isVisible() takes a parameter to ask about ancestors as well, this is exactly what I'm looking for. Of course it defaults to 'false' which is what I want to set it to, so I wonder why it didn't just work the first time. In any case thanks for your direction.
Who is online
Users browsing this forum: No registered users and 13 guests