[solved]VerticalLayoutContainer:getUnclippedOuterRect()

For help with anything that CEGUI doesn't offer straight out-of-the-box, e.g.:
- Implementation of new features, such as new Core classes, widgets, WindowRenderers, etc. ...
- Modification of any existing features for specific purposes
- Integration of CEGUI in new engines or frameworks and writing of new plugins (Renderer, Parser, ...) or modules

Moderators: CEGUI MVP, CEGUI Team

User avatar
spracle
Not too shy to talk
Not too shy to talk
Posts: 34
Joined: Tue Aug 24, 2010 07:29

[solved]VerticalLayoutContainer:getUnclippedOuterRect()

Postby spracle » Wed Jan 12, 2011 11:33

For VerticalLayoutContainer,if you do something like this:

Code: Select all

(VerticalLayoutContainer *)vcPtr->removeChildAtPosition(2);
rect = vcPtr->getUnclippedOuterRect();

you'll get wrong answer.The size of rect is previous,before removeChildWindow.

Later,I did something like this:

Code: Select all

(vcPtr->setPosition(pos);
rect = vcPtr->getUnclippedOuterRect();

then,the rect is right;

Problem's that i need to get the right 'rect' to locate the right position for itself.

Anyone could help? Thanks first :)
Last edited by spracle on Fri Jan 14, 2011 07:12, edited 1 time in total.

User avatar
spracle
Not too shy to talk
Not too shy to talk
Posts: 34
Joined: Tue Aug 24, 2010 07:29

Re: VerticalLayoutContainer:getUnclippedOuterRect(), a bug?

Postby spracle » Wed Jan 12, 2011 11:40

By the way , i called the function "layout()" between "romove(or add)ChildWindow" and "getUnclippedOuterRect()",and it 's not working all the same.

User avatar
Kulik
CEGUI Team
Posts: 1382
Joined: Mon Jul 26, 2010 18:47
Location: Czech Republic
Contact:

Re: VerticalLayoutContainer:getUnclippedOuterRect(), a bug?

Postby Kulik » Wed Jan 12, 2011 12:31

What are you expecting as the "right" rect? IIRC layout containers return their parent's clip rectangles.

User avatar
spracle
Not too shy to talk
Not too shy to talk
Posts: 34
Joined: Tue Aug 24, 2010 07:29

Re: VerticalLayoutContainer:getUnclippedOuterRect(), a bug?

Postby spracle » Thu Jan 13, 2011 01:46

layoutContainer:
A ----------- B
| (child_1) |
C----------- D
| (child_2) |
--------------
| (child_3) |
E------------F

When getUnclippedOuterRect(),the result should be ABEF;
when removeChildWindow(child_1),then result should be CDEF;

Hope I figured it out clearly

User avatar
Kulik
CEGUI Team
Posts: 1382
Joined: Mon Jul 26, 2010 18:47
Location: Czech Republic
Contact:

Re: VerticalLayoutContainer:getUnclippedOuterRect(), a bug?

Postby Kulik » Thu Jan 13, 2011 13:26

Layout containers only delegate inner rect to their parent, so I don't know why outer rect is broken. I will redo layout containers (hopefully) for 0.8 so I will look into this later.

For now I would go with getPosition and getPixelSize. The size is updated every time layout() is called. And layout() is called as late as possible for performance reasons, so after you remove a child, call layout() manually and then construct the rect from getPosition() (convert it to absolute via CoordConverter if necessary) and getSize()

User avatar
spracle
Not too shy to talk
Not too shy to talk
Posts: 34
Joined: Tue Aug 24, 2010 07:29

Re: VerticalLayoutContainer:getUnclippedOuterRect(), a bug?

Postby spracle » Fri Jan 14, 2011 02:34

By the way , i called the function "layout()" between "romove(or add)ChildWindow" and "getUnclippedOuterRect()",and it 's not working all the same.

--Sorry about this,it works, so outer rect isn't broken

My Problem was that VerticalLayoutContainer had one chlid whose type is VerticalLayoutContainer with some children attached on it.For this child, I removed its children, but called it's parent's layout()! sigh~

The correct behaviour is to call itself layout(),and then call its parent's layout(), and then getUnclippedOuterRect();

So,now the forcus is when layout() is called. I don't think that after removing child ,just markNeedtoLayout(),and when update(),the layout() is called automaticly is a good idea.
Obviously,if you don't call layout() manually between "removeChild"and "getUnclippedOuterRect", you'll get the wrong Rect.
If you call layout() manually ,next time update() is called, the layout() will be automatic called again,which is not necessary.

User avatar
Kulik
CEGUI Team
Posts: 1382
Joined: Mon Jul 26, 2010 18:47
Location: Czech Republic
Contact:

Re: VerticalLayoutContainer:getUnclippedOuterRect(), a bug?

Postby Kulik » Fri Jan 14, 2011 02:48

Imagine you would remove 10 children at once, if it was implemented as you suggest, layout() would be called 10 times. If you want the rect up to date quicker, just call layoutIfNecessary, it will mark that the layouting has been done and no mroe layouting will happen in update()

User avatar
spracle
Not too shy to talk
Not too shy to talk
Posts: 34
Joined: Tue Aug 24, 2010 07:29

Re: VerticalLayoutContainer:getUnclippedOuterRect(), a bug?

Postby spracle » Fri Jan 14, 2011 06:52

layoutIfNecessary instead of layout is pretty cool .
My point is that ,if you don't call the function layoutIfNecessary() manually between removeChild() and getUnclippedOuterRect(),you will not get the right rect ten to one
kind of weird..

Anyway,thanks kulik,you are very helpful~


Return to “Modifications / Integrations / Customisations”

Who is online

Users browsing this forum: Google [Bot] and 2 guests