fredsa / forplay

Automatically exported from code.google.com/p/forplay
Apache License 2.0
12 stars 4 forks source link

Make it possible to get pointer events and paint callbacks directly on Layers #10

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Layers are a natural way to implement UI controls, because the compositor will 
take care of repaint automagically. However, it's currently more awkward than 
it should be, because you have to push paint() calls and pointer events 
manually down to the "controller" for each layer.

If each layer's controller could simply get callbacks for pointer events and 
painting, it would be trivially easy to implement buttons and other UI 
components without all this extra wiring.

For pointer events, I imagine adding an overload like 
pointer().setListener(Layer, Listener), so that the pointer-specific stuff 
remains where it belongs (the pointer implementation would now need to know 
about layers, though). Note that I'm *not* proposing adding keyboard events to 
the mix, because that would imply a full focus system, which seems like 
overkill (and I strongly suspect most games will want to handle the keyboard 
globally).

For paint callbacks, I believe it makes sense to propagate the alpha parameter 
as usual, but I don't believe there's any reason to add update(delta), because 
that should really be handled in the overall game logic.

Original issue reported on code.google.com by jgw@google.com on 13 May 2011 at 9:17