Actually widgets extends TransformGroup, which is a bad thing, because a widget isn't a sort of TransformGroup. Instead it uses a TransformGroup to be displayed.
So instead of :
1
| WidgetBase extends TransformGroup |
we should have :
1 2 3 4 5
| WidgetBase { TransformGroup tg
public void addChild(Node node) {
|
Wouldn't this stand for doing things like group.addChild(hud.getGroup()). Which is a bad thing one will have to fight with like in the SceneBase class. So I don't see the advantage. WidgetBase should at least extend Group or BranchGroup.
Which would permit us to add an invisible yet rendered plane (TransparencyAttributes, alpha test function = NEVER) used only for stencil test (stencil function = ALWAYS) and when adding child to a component, setting the stencil function of all children to EQUALS.
I'm afraid I am not clear at all but I think it would permit to clip widgets so they display only in their allocated zone.
(See the StencilTest to see what I'm talking about).
If there's no objection I'm gonna implement that. But I didn't used Stencil Buffer before and maybe some of you can point out possible issues with this technique, or simpler methods to do clipping.
Yes, I have already thought of this. That's why I introduced the WidgetContainer interface. But I didn't know a way to do clipping. But when I saw the StencilTest during my code cleaning/-streamlining of the test package the last days I thought of doing this, too. So great idea, Amos. Feel free to implement it.
But we should talk about this TransformGroup extension thing. You are right, that a Widget is not a TransformGroup, but it is a Group or BranchGroup.