factor out canvas backing logic for widgets
HeladoDeBrownie opened this issue · comments
create a new mixin called e.g. CanvasBacked
that performs the canvas drawing logic for a widget. unexpose Widget.get_canvas
, and instead expose:
- a
CanvasBacked.refresh
method, which will do effectively whatWidget.draw
now does; and - a
Widget.draw
method, which will draw a widget at specified coordinates on the screen or active canvas
note that there will be no CanvasBacked.get_canvas
. this is because with CanvasBacked
's implementation of draw
, there will be no need to leak the canvas. for that matter the mixin can be called something more centered on its extrinsic properties instead, such as Buffered
the idea here is that widgets can be designed to be buffered or not depending on their needs. like it's probably not necessary for a simple button widget to have its own canvas
resoloved by 7aabbd6