Made interfacial changes that will allow for elements to be clipped
This commit is contained in:
parent
5afbc0e713
commit
3d28ebe4cf
@ -8,6 +8,7 @@ import "git.tebibyte.media/sashakoshka/tomo/canvas"
|
||||
// widgets. It is meant to be embedded directly into a struct.
|
||||
type Core struct {
|
||||
canvas canvas.Canvas
|
||||
bounds image.Rectangle
|
||||
|
||||
metrics struct {
|
||||
minimumWidth int
|
||||
@ -37,7 +38,7 @@ func NewCore (
|
||||
// overridden.
|
||||
func (core *Core) Bounds () (bounds image.Rectangle) {
|
||||
if core.canvas == nil { return }
|
||||
return core.canvas.Bounds()
|
||||
return core.bounds
|
||||
}
|
||||
|
||||
// MinimumSize fulfils the tomo.Element interface. This should not need to be
|
||||
@ -48,8 +49,9 @@ func (core *Core) MinimumSize () (width, height int) {
|
||||
|
||||
// DrawTo fulfills the tomo.Element interface. This should not need to be
|
||||
// overridden.
|
||||
func (core *Core) DrawTo (canvas canvas.Canvas) {
|
||||
func (core *Core) DrawTo (canvas canvas.Canvas, bounds image.Rectangle) {
|
||||
core.canvas = canvas
|
||||
core.bounds = bounds
|
||||
if core.drawSizeChange != nil && core.canvas != nil {
|
||||
core.drawSizeChange()
|
||||
}
|
||||
|
@ -9,13 +9,14 @@ import "git.tebibyte.media/sashakoshka/tomo/config"
|
||||
// Element represents a basic on-screen object.
|
||||
type Element interface {
|
||||
// Bounds reports the element's bounding box. This must reflect the
|
||||
// bounding box of the last canvas given to the element by DrawTo.
|
||||
// bounding last given to the element by DrawTo.
|
||||
Bounds () (bounds image.Rectangle)
|
||||
|
||||
// DrawTo sets this element's canvas. This should only be called by the
|
||||
// parent element. This is typically a region of the parent element's
|
||||
// canvas.
|
||||
DrawTo (canvas canvas.Canvas)
|
||||
// DrawTo gives the element a canvas to draw on, along with a bounding
|
||||
// box to be used for laying out the element. This should only be called
|
||||
// by the parent element. This is typically a region of the parent
|
||||
// element's canvas.
|
||||
DrawTo (canvas canvas.Canvas, bounds image.Rectangle)
|
||||
|
||||
// OnDamage sets a function to be called when an area of the element is
|
||||
// drawn on and should be pushed to the screen.
|
||||
|
Reference in New Issue
Block a user