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 what Widget.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
create a new mixin called e.g.
CanvasBacked
that performs the canvas drawing logic for a widget. unexposeWidget.get_canvas
, and instead expose:CanvasBacked.refresh
method, which will do effectively whatWidget.draw
now does; andWidget.draw
method, which will draw a widget at specified coordinates on the screen or active canvasnote that there will be no
CanvasBacked.get_canvas
. this is because withCanvasBacked
's implementation ofdraw
, 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 asBuffered
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