backend/internal/system/canvasbox.go

38 lines
721 B
Go
Raw Normal View History

2024-06-01 14:39:14 -06:00
package system
import "git.tebibyte.media/tomo/tomo"
2024-06-02 11:23:03 -06:00
import "git.tebibyte.media/tomo/tomo/canvas"
type canvasBox struct {
*box
userDrawer canvas.Drawer
}
2024-06-01 14:39:14 -06:00
func (this *System) NewCanvasBox () tomo.CanvasBox {
2024-06-02 11:23:03 -06:00
box := &canvasBox { }
box.box = this.newBox(box)
box.drawer = box
return box
}
func (this *canvasBox) Box () tomo.Box {
return this
}
func (this *canvasBox) SetDrawer (drawer canvas.Drawer) {
this.userDrawer = drawer
this.invalidateDraw()
}
func (this *canvasBox) Invalidate () {
this.invalidateDraw()
}
2024-06-01 14:39:14 -06:00
2024-06-02 11:23:03 -06:00
func (this *canvasBox) Draw (can canvas.Canvas) {
this.box.Draw(can)
if this.userDrawer != nil {
this.userDrawer.Draw (
can.SubCanvas(this.padding.Apply(this.innerClippingBounds)))
}
2024-06-01 14:39:14 -06:00
}