Redid cores to conform to the new API changes
This commit is contained in:
parent
b08cbea320
commit
a34e8768ab
@ -1,4 +1,4 @@
|
|||||||
package element
|
package elements
|
||||||
|
|
||||||
import "git.tebibyte.media/sashakoshka/tomo/input"
|
import "git.tebibyte.media/sashakoshka/tomo/input"
|
||||||
|
|
||||||
|
|||||||
@ -3,31 +3,38 @@ package core
|
|||||||
import "image"
|
import "image"
|
||||||
import "image/color"
|
import "image/color"
|
||||||
import "git.tebibyte.media/sashakoshka/tomo/canvas"
|
import "git.tebibyte.media/sashakoshka/tomo/canvas"
|
||||||
|
import "git.tebibyte.media/sashakoshka/tomo/elements"
|
||||||
|
|
||||||
// Core is a struct that implements some core functionality common to most
|
// Core is a struct that implements some core functionality common to most
|
||||||
// widgets. It is meant to be embedded directly into a struct.
|
// widgets. It is meant to be embedded directly into a struct.
|
||||||
type Core struct {
|
type Core struct {
|
||||||
canvas canvas.Canvas
|
canvas canvas.Canvas
|
||||||
bounds image.Rectangle
|
bounds image.Rectangle
|
||||||
|
parent elements.Parent
|
||||||
|
outer elements.Element
|
||||||
|
|
||||||
metrics struct {
|
metrics struct {
|
||||||
minimumWidth int
|
minimumWidth int
|
||||||
minimumHeight int
|
minimumHeight int
|
||||||
}
|
}
|
||||||
|
|
||||||
drawSizeChange func ()
|
drawSizeChange func ()
|
||||||
onMinimumSizeChange func ()
|
onDamage func (region image.Rectangle)
|
||||||
onDamage func (region canvas.Canvas)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewCore creates a new element core and its corresponding control.
|
// NewCore creates a new element core and its corresponding control given the
|
||||||
|
// element that it will be a part of. If outer is nil, this function will return
|
||||||
|
// nil.
|
||||||
func NewCore (
|
func NewCore (
|
||||||
|
outer elements.Element,
|
||||||
drawSizeChange func (),
|
drawSizeChange func (),
|
||||||
) (
|
) (
|
||||||
core *Core,
|
core *Core,
|
||||||
control CoreControl,
|
control CoreControl,
|
||||||
) {
|
) {
|
||||||
|
if outer == nil { return }
|
||||||
core = &Core {
|
core = &Core {
|
||||||
|
outer: outer,
|
||||||
drawSizeChange: drawSizeChange,
|
drawSizeChange: drawSizeChange,
|
||||||
}
|
}
|
||||||
control = CoreControl { core: core }
|
control = CoreControl { core: core }
|
||||||