Page 1 of 1

How to clip the child windows with given rect

Posted: Thu Jun 30, 2011 10:48
by zaexage
Hi, all
I'm making a UI control that kind of like the GridLayoutContainer, but it could make constraints on the width/height of some columns or rows.
When the size of the cell is determined by client's specified value, I wanna clip the child window inside the cell.
My question is how to clip the a child window with the area of the cell it resides in. Or in another word, how to clip children windows with a given Rect?

I don't quite want to change the size of the children windows, by which I will have to remember the original size of them in case of the re-layouting.

Thanks in advance.

Re: How to clip the child windows with given rect

Posted: Mon Jul 04, 2011 17:17
by Kulik
I don't think this is possible without custom a window renderer.

As a workaround you could put them into a fake window that would represent the rect and make them "ClippedByParent".

Re: How to clip the child windows with given rect

Posted: Wed Jul 06, 2011 02:21
by zaexage
I do have written a WindowRenderer (but it is just for rendering separator & frame anyway), how can i use it to clip the children windows?

I'm thinking about using GeometryBuffer::setClippingRegion for this task. Is it a viable method?

Re: How to clip the child windows with given rect

Posted: Wed Jul 06, 2011 14:08
by Kulik
This can be done (I think) but you have to have a special renderer for all children and that renderer will merge the clip rect with your rect. I think the easiest solution is to use a dummy wrapper default window that will clip children to itself.

Re: How to clip the child windows with given rect

Posted: Thu Jul 07, 2011 01:16
by zaexage
I tried SetClippingRegion and it does work, but the hitTest still failed, I think maybe this method needs a hack to add setUnclippedRect to CEGUI::Window...

Anyway, I think your method should be better. :)