fredsa / playn

Cross platform game library for N≥4 platforms
0 stars 1 forks source link

GroupLayer.Clipped does not clip child layers #200

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Create a GroupLayer.Clipped via graphics().createGroupLayer(float, float)
2. Add a child SurfaceLayer and draw an image onto said SurfaceLayer
3. position child in a way where it is sticking outside of its parent

What is the expected output? What do you see instead?
You see the entire child rendered rather than only the portion within the 
parent panel

What version of the product are you using? On what operating system?
PlayN 1.4 Windows 7 64 bit

Please provide any additional information below.

Original issue reported on code.google.com by heg...@gmail.com on 27 Jul 2012 at 2:56

GoogleCodeExporter commented 9 years ago
You're either doing something wrong, or using an out of date version of PlayN. 
I just tested placing a SurfaceLayer inside a clipped GroupLayer and it works 
fine. Try your code against the latest trunk.

Original comment by m...@samskivert.com on 28 Jul 2012 at 4:06

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Is it intended to not work when you have a Hierarchy such as:
GroupLayer---------->GroupLayer
|  SurfaceLayer         SurfaceLayer
|
|
V
GroupLayer-------->GroupLayer
  SurfaceLayer       SurfaceLayer

Original comment by heg...@gmail.com on 30 Jul 2012 at 6:26

GoogleCodeExporter commented 9 years ago
I don't understand your diagram. What's a child of what? And which GroupLayer 
is clipped?

Original comment by m...@samskivert.com on 30 Jul 2012 at 6:27

GoogleCodeExporter commented 9 years ago
My basic Widget is called a BPanel, all GUI elements descend from this and each 
contain by default a GroupLayer.Clipped, and a SurfaceLayer for drawing. Let's 
say I wanted to add a button onto my panel.

The hierarchy ends up like this
BPanel------------BButton
|_GroupLayer--------GroupLayer
  |_SurfaceLayer      SurfaceLayer

The BPanel's GroupLayer holds the following: 
BPanel's SurfaceLayer
BButton's GroupLayer

The BButton's GroupLayer only holds the BButton's SurfaceLayer.

Original comment by heg...@gmail.com on 30 Jul 2012 at 6:32

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
With that hierarchy, the BButton's surfacelayer ends up drawing outside the 
BPanel's GroupLayer. I figured it would be stopped by its own GroupLayer being 
clipped by the parent GroupLayer, but apparently not.

Original comment by heg...@gmail.com on 30 Jul 2012 at 6:33

GoogleCodeExporter commented 9 years ago
Clipping does not "nest". If you put a clipped group layer inside another 
clipped group layer, the nested group layer's clip will replace the outer group 
layer's clip, not intersect with it. Indeed, I doubt the outer group layer's 
clip would even be restored when the inner group finished rendering.

Clipped group layers are expensive (clipping is expensive). You should only use 
them when absolutely necessary. Baking them into the lowest level of your UI 
toolkit is a bad idea.

The vast majority of widgets in your toolkit should render inside their bounds. 
If they are all rendered to surface layers, then they will necessarily do so 
because they can't render outside the bounds of the surface. The only place 
where you need clipping is if you want a "scrolling panel" which allows many 
sub-components to be rendered in a virtual space which is clipped to the bounds 
of the scrolling panel. Only the scrolling panel would use a clipped group 
layer, and naturally you would never nest scrolling panels. That would be a 
user interface disaster in addition to simply not rendering properly.

Original comment by m...@samskivert.com on 30 Jul 2012 at 6:40