Moved element core to new package

This commit is contained in:
Sasha Koshka 2023-01-09 21:25:11 -05:00
parent bbdc5a0162
commit 34848f616b
5 changed files with 14 additions and 10 deletions

View File

@ -4,10 +4,11 @@ import "image"
import "git.tebibyte.media/sashakoshka/tomo"
import "git.tebibyte.media/sashakoshka/tomo/theme"
import "git.tebibyte.media/sashakoshka/tomo/artist"
import "git.tebibyte.media/sashakoshka/tomo/elements/core"
type Button struct {
*Core
core CoreControl
*core.Core
core core.CoreControl
pressed bool
enabled bool
@ -20,7 +21,7 @@ type Button struct {
func NewButton (text string) (element *Button) {
element = &Button { enabled: true }
element.Core, element.core = NewCore(element)
element.Core, element.core = core.NewCore(element)
element.drawer.SetFace(theme.FontFaceRegular())
element.SetText(text)
return

View File

@ -4,10 +4,11 @@ import "image"
import "git.tebibyte.media/sashakoshka/tomo"
import "git.tebibyte.media/sashakoshka/tomo/theme"
import "git.tebibyte.media/sashakoshka/tomo/artist"
import "git.tebibyte.media/sashakoshka/tomo/elements/core"
type Label struct {
*Core
core CoreControl
*core.Core
core core.CoreControl
text string
drawer artist.TextDrawer
@ -15,7 +16,7 @@ type Label struct {
func NewLabel (text string) (element *Label) {
element = &Label { }
element.Core, element.core = NewCore(element)
element.Core, element.core = core.NewCore(element)
face := theme.FontFaceRegular()
element.drawer.SetFace(face)
element.SetText(text)

View File

@ -4,17 +4,18 @@ import "image"
import "image/color"
import "git.tebibyte.media/sashakoshka/tomo"
import "git.tebibyte.media/sashakoshka/tomo/artist"
import "git.tebibyte.media/sashakoshka/tomo/elements/core"
// Test is a simple element that can be used as a placeholder.
type Test struct {
*Core
core CoreControl
*core.Core
core core.CoreControl
}
// NewTest creates a new test element.
func NewTest () (element *Test) {
element = &Test { }
element.Core, element.core = NewCore(element)
element.Core, element.core = core.NewCore(element)
element.core.SetMinimumSize(32, 32)
return
}

View File

@ -1,4 +1,4 @@
package basic
package core
import "image"
import "image/color"

View File

@ -2,6 +2,7 @@ package layouts
import "git.tebibyte.media/sashakoshka/tomo"
import "git.tebibyte.media/sashakoshka/tomo/artist"
import "git.tebibyte.media/sashakoshka/tomo/elements/core"
// Vertical lays its children out vertically. It can contain any number of
// children. When an child is added to the layout, it can either be set to