This repository has been archived on 2024-06-02. You can view files and clone it, but cannot push or open issues or pull requests.
x/canvasbox.go

36 lines
698 B
Go

package x
import "git.tebibyte.media/tomo/tomo"
import "git.tebibyte.media/tomo/tomo/canvas"
type canvasBox struct {
*box
userDrawer canvas.Drawer
}
func (backend *Backend) NewCanvasBox () tomo.CanvasBox {
this := &canvasBox { }
this.box = backend.newBox(this)
this.drawer = this
return this
}
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()
}
func (this *canvasBox) Draw (can canvas.Canvas) {
this.box.Draw(can)
this.userDrawer.Draw (
can.SubCanvas(this.padding.Apply(this.innerClippingBounds)))
}