Add gitignore
This commit is contained in:
parent
b84e444697
commit
69e73a7b84
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
/build
|
@ -2,9 +2,11 @@ package elements
|
|||||||
|
|
||||||
import "image"
|
import "image"
|
||||||
import "git.tebibyte.media/sashakoshka/tomo"
|
import "git.tebibyte.media/sashakoshka/tomo"
|
||||||
import "git.tebibyte.media/sashakoshka/tomo/canvas"
|
import "git.tebibyte.media/sashakoshka/tomo/artist"
|
||||||
import "git.tebibyte.media/sashakoshka/tomo/shatter"
|
import "git.tebibyte.media/sashakoshka/tomo/shatter"
|
||||||
import "git.tebibyte.media/sashakoshka/tomo/default/theme"
|
import "git.tebibyte.media/sashakoshka/tomo/ability"
|
||||||
|
|
||||||
|
var boxCase = tomo.C("tomo", "box")
|
||||||
|
|
||||||
// Space is a list of spacing configurations that can be passed to some
|
// Space is a list of spacing configurations that can be passed to some
|
||||||
// containers.
|
// containers.
|
||||||
@ -27,7 +29,6 @@ func (space Space) Includes (sub Space) bool {
|
|||||||
// complex layouts.
|
// complex layouts.
|
||||||
type Box struct {
|
type Box struct {
|
||||||
container
|
container
|
||||||
theme theme.Wrapped
|
|
||||||
padding bool
|
padding bool
|
||||||
margin bool
|
margin bool
|
||||||
vertical bool
|
vertical bool
|
||||||
@ -39,10 +40,9 @@ func NewHBox (space Space, children ...tomo.Element) (element *Box) {
|
|||||||
padding: space.Includes(SpacePadding),
|
padding: space.Includes(SpacePadding),
|
||||||
margin: space.Includes(SpaceMargin),
|
margin: space.Includes(SpaceMargin),
|
||||||
}
|
}
|
||||||
element.entity = tomo.NewEntity(element).(tomo.ContainerEntity)
|
element.entity = tomo.GetBackend().NewEntity(element)
|
||||||
element.minimumSize = element.updateMinimumSize
|
element.minimumSize = element.updateMinimumSize
|
||||||
element.init()
|
element.init()
|
||||||
element.theme.Case = tomo.C("tomo", "box")
|
|
||||||
element.Adopt(children...)
|
element.Adopt(children...)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -54,16 +54,15 @@ func NewVBox (space Space, children ...tomo.Element) (element *Box) {
|
|||||||
margin: space.Includes(SpaceMargin),
|
margin: space.Includes(SpaceMargin),
|
||||||
vertical: true,
|
vertical: true,
|
||||||
}
|
}
|
||||||
element.entity = tomo.NewEntity(element).(tomo.ContainerEntity)
|
element.entity = tomo.GetBackend().NewEntity(element)
|
||||||
element.minimumSize = element.updateMinimumSize
|
element.minimumSize = element.updateMinimumSize
|
||||||
element.init()
|
element.init()
|
||||||
element.theme.Case = tomo.C("tomo", "box")
|
|
||||||
element.Adopt(children...)
|
element.Adopt(children...)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw causes the element to draw to the specified destination canvas.
|
// Draw causes the element to draw to the specified destination canvas.
|
||||||
func (element *Box) Draw (destination canvas.Canvas) {
|
func (element *Box) Draw (destination artist.Canvas) {
|
||||||
rocks := make([]image.Rectangle, element.entity.CountChildren())
|
rocks := make([]image.Rectangle, element.entity.CountChildren())
|
||||||
for index := 0; index < element.entity.CountChildren(); index ++ {
|
for index := 0; index < element.entity.CountChildren(); index ++ {
|
||||||
rocks[index] = element.entity.Child(index).Entity().Bounds()
|
rocks[index] = element.entity.Child(index).Entity().Bounds()
|
||||||
@ -71,14 +70,14 @@ func (element *Box) Draw (destination canvas.Canvas) {
|
|||||||
|
|
||||||
tiles := shatter.Shatter(element.entity.Bounds(), rocks...)
|
tiles := shatter.Shatter(element.entity.Bounds(), rocks...)
|
||||||
for _, tile := range tiles {
|
for _, tile := range tiles {
|
||||||
element.entity.DrawBackground(canvas.Cut(destination, tile))
|
element.entity.DrawBackground(artist.Cut(destination, tile))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Layout causes this element to perform a layout operation.
|
// Layout causes this element to perform a layout operation.
|
||||||
func (element *Box) Layout () {
|
func (element *Box) Layout () {
|
||||||
margin := element.theme.Margin(tomo.PatternBackground)
|
margin := element.entity.Theme().Margin(tomo.PatternBackground, boxCase)
|
||||||
padding := element.theme.Padding(tomo.PatternBackground)
|
padding := element.entity.Theme().Padding(tomo.PatternBackground, boxCase)
|
||||||
bounds := element.entity.Bounds()
|
bounds := element.entity.Bounds()
|
||||||
if element.padding { bounds = padding.Apply(bounds) }
|
if element.padding { bounds = padding.Apply(bounds) }
|
||||||
|
|
||||||
@ -128,22 +127,19 @@ func (element *Box) AdoptExpand (children ...tomo.Element) {
|
|||||||
|
|
||||||
// DrawBackground draws this element's background pattern to the specified
|
// DrawBackground draws this element's background pattern to the specified
|
||||||
// destination canvas.
|
// destination canvas.
|
||||||
func (element *Box) DrawBackground (destination canvas.Canvas) {
|
func (element *Box) DrawBackground (destination artist.Canvas) {
|
||||||
element.entity.DrawBackground(destination)
|
element.entity.DrawBackground(destination)
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetTheme sets the element's theme.
|
func (element *Box) HandleThemeChange () {
|
||||||
func (element *Box) SetTheme (theme tomo.Theme) {
|
|
||||||
if theme == element.theme.Theme { return }
|
|
||||||
element.theme.Theme = theme
|
|
||||||
element.updateMinimumSize()
|
element.updateMinimumSize()
|
||||||
element.entity.Invalidate()
|
element.entity.Invalidate()
|
||||||
element.entity.InvalidateLayout()
|
element.entity.InvalidateLayout()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (element *Box) freeSpace () (space float64, nExpanding float64) {
|
func (element *Box) freeSpace () (space float64, nExpanding float64) {
|
||||||
margin := element.theme.Margin(tomo.PatternBackground)
|
margin := element.entity.Theme().Margin(tomo.PatternBackground, boxCase)
|
||||||
padding := element.theme.Padding(tomo.PatternBackground)
|
padding := element.entity.Theme().Padding(tomo.PatternBackground, boxCase)
|
||||||
|
|
||||||
var marginSize int; if element.vertical {
|
var marginSize int; if element.vertical {
|
||||||
marginSize = margin.Y
|
marginSize = margin.Y
|
||||||
@ -176,8 +172,8 @@ func (element *Box) freeSpace () (space float64, nExpanding float64) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (element *Box) updateMinimumSize () {
|
func (element *Box) updateMinimumSize () {
|
||||||
margin := element.theme.Margin(tomo.PatternBackground)
|
margin := element.entity.Theme().Margin(tomo.PatternBackground, boxCase)
|
||||||
padding := element.theme.Padding(tomo.PatternBackground)
|
padding := element.entity.Theme().Padding(tomo.PatternBackground, boxCase)
|
||||||
var breadth, size int
|
var breadth, size int
|
||||||
var marginSize int; if element.vertical {
|
var marginSize int; if element.vertical {
|
||||||
marginSize = margin.Y
|
marginSize = margin.Y
|
||||||
|
@ -3,22 +3,18 @@ package elements
|
|||||||
import "image"
|
import "image"
|
||||||
import "git.tebibyte.media/sashakoshka/tomo"
|
import "git.tebibyte.media/sashakoshka/tomo"
|
||||||
import "git.tebibyte.media/sashakoshka/tomo/input"
|
import "git.tebibyte.media/sashakoshka/tomo/input"
|
||||||
import "git.tebibyte.media/sashakoshka/tomo/canvas"
|
import "git.tebibyte.media/sashakoshka/tomo/artist"
|
||||||
import "git.tebibyte.media/sashakoshka/tomo/default/theme"
|
import "git.tebibyte.media/sashakoshka/tomo/ability"
|
||||||
import "git.tebibyte.media/sashakoshka/tomo/default/config"
|
|
||||||
import "git.tebibyte.media/sashakoshka/tomo/textdraw"
|
import "git.tebibyte.media/sashakoshka/tomo/textdraw"
|
||||||
|
|
||||||
// Button is a clickable button.
|
// Button is a clickable button.
|
||||||
type Button struct {
|
type Button struct {
|
||||||
entity tomo.FocusableEntity
|
entity tomo.Entity
|
||||||
drawer textdraw.Drawer
|
drawer textdraw.Drawer
|
||||||
|
|
||||||
enabled bool
|
enabled bool
|
||||||
pressed bool
|
pressed bool
|
||||||
text string
|
text string
|
||||||
|
|
||||||
config config.Wrapped
|
|
||||||
theme theme.Wrapped
|
|
||||||
|
|
||||||
showText bool
|
showText bool
|
||||||
hasIcon bool
|
hasIcon bool
|
||||||
@ -30,7 +26,7 @@ type Button struct {
|
|||||||
// NewButton creates a new button with the specified label text.
|
// NewButton creates a new button with the specified label text.
|
||||||
func NewButton (text string) (element *Button) {
|
func NewButton (text string) (element *Button) {
|
||||||
element = &Button { showText: true, enabled: true }
|
element = &Button { showText: true, enabled: true }
|
||||||
element.entity = tomo.NewEntity(element).(tomo.FocusableEntity)
|
element.entity = tomo.NewEntity(element).(buttonEntity)
|
||||||
element.theme.Case = tomo.C("tomo", "button")
|
element.theme.Case = tomo.C("tomo", "button")
|
||||||
element.drawer.SetFace (element.theme.FontFace (
|
element.drawer.SetFace (element.theme.FontFace (
|
||||||
tomo.FontStyleRegular,
|
tomo.FontStyleRegular,
|
||||||
@ -45,7 +41,7 @@ func (element *Button) Entity () tomo.Entity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Draw causes the element to draw to the specified destination canvas.
|
// Draw causes the element to draw to the specified destination canvas.
|
||||||
func (element *Button) Draw (destination canvas.Canvas) {
|
func (element *Button) Draw (destination artist.Canvas) {
|
||||||
state := element.state()
|
state := element.state()
|
||||||
bounds := element.entity.Bounds()
|
bounds := element.entity.Bounds()
|
||||||
pattern := element.theme.Pattern(tomo.PatternButton, state)
|
pattern := element.theme.Pattern(tomo.PatternButton, state)
|
||||||
|
@ -1,22 +1,16 @@
|
|||||||
package elements
|
package elements
|
||||||
|
|
||||||
import "git.tebibyte.media/sashakoshka/tomo"
|
import "git.tebibyte.media/sashakoshka/tomo"
|
||||||
import "git.tebibyte.media/sashakoshka/tomo/canvas"
|
|
||||||
import "git.tebibyte.media/sashakoshka/tomo/artist"
|
import "git.tebibyte.media/sashakoshka/tomo/artist"
|
||||||
import "git.tebibyte.media/sashakoshka/tomo/default/theme"
|
import "git.tebibyte.media/sashakoshka/tomo/ability"
|
||||||
|
|
||||||
type cellEntity interface {
|
|
||||||
tomo.ContainerEntity
|
|
||||||
tomo.SelectableEntity
|
|
||||||
}
|
|
||||||
|
|
||||||
// Cell is a single-element container that satisfies tomo.Selectable. It
|
// Cell is a single-element container that satisfies tomo.Selectable. It
|
||||||
// provides styling based on whether or not it is selected.
|
// provides styling based on whether or not it is selected.
|
||||||
type Cell struct {
|
type Cell struct {
|
||||||
entity cellEntity
|
entity tomo.Entity
|
||||||
child tomo.Element
|
child tomo.Element
|
||||||
enabled bool
|
enabled bool
|
||||||
theme theme.Wrapped
|
|
||||||
|
|
||||||
onSelectionChange func ()
|
onSelectionChange func ()
|
||||||
}
|
}
|
||||||
@ -38,7 +32,7 @@ func (element *Cell) Entity () tomo.Entity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Draw causes the element to draw to the specified destination canvas.
|
// Draw causes the element to draw to the specified destination canvas.
|
||||||
func (element *Cell) Draw (destination canvas.Canvas) {
|
func (element *Cell) Draw (destination artist.Canvas) {
|
||||||
bounds := element.entity.Bounds()
|
bounds := element.entity.Bounds()
|
||||||
pattern := element.theme.Pattern(tomo.PatternTableCell, element.state())
|
pattern := element.theme.Pattern(tomo.PatternTableCell, element.state())
|
||||||
if element.child == nil {
|
if element.child == nil {
|
||||||
@ -62,7 +56,7 @@ func (element *Cell) Layout () {
|
|||||||
|
|
||||||
// DrawBackground draws this element's background pattern to the specified
|
// DrawBackground draws this element's background pattern to the specified
|
||||||
// destination canvas.
|
// destination canvas.
|
||||||
func (element *Cell) DrawBackground (destination canvas.Canvas) {
|
func (element *Cell) DrawBackground (destination artist.Canvas) {
|
||||||
element.theme.Pattern(tomo.PatternTableCell, element.state()).
|
element.theme.Pattern(tomo.PatternTableCell, element.state()).
|
||||||
Draw(destination, element.entity.Bounds())
|
Draw(destination, element.entity.Bounds())
|
||||||
}
|
}
|
||||||
|
@ -3,14 +3,13 @@ package elements
|
|||||||
import "image"
|
import "image"
|
||||||
import "git.tebibyte.media/sashakoshka/tomo"
|
import "git.tebibyte.media/sashakoshka/tomo"
|
||||||
import "git.tebibyte.media/sashakoshka/tomo/input"
|
import "git.tebibyte.media/sashakoshka/tomo/input"
|
||||||
import "git.tebibyte.media/sashakoshka/tomo/canvas"
|
import "git.tebibyte.media/sashakoshka/tomo/artist"
|
||||||
|
import "git.tebibyte.media/sashakoshka/tomo/ability"
|
||||||
import "git.tebibyte.media/sashakoshka/tomo/textdraw"
|
import "git.tebibyte.media/sashakoshka/tomo/textdraw"
|
||||||
import "git.tebibyte.media/sashakoshka/tomo/default/theme"
|
|
||||||
import "git.tebibyte.media/sashakoshka/tomo/default/config"
|
|
||||||
|
|
||||||
// Checkbox is a toggle-able checkbox with a label.
|
// Checkbox is a toggle-able checkbox with a label.
|
||||||
type Checkbox struct {
|
type Checkbox struct {
|
||||||
entity tomo.FocusableEntity
|
entity tomo.Entity
|
||||||
drawer textdraw.Drawer
|
drawer textdraw.Drawer
|
||||||
|
|
||||||
enabled bool
|
enabled bool
|
||||||
@ -18,16 +17,13 @@ type Checkbox struct {
|
|||||||
checked bool
|
checked bool
|
||||||
text string
|
text string
|
||||||
|
|
||||||
config config.Wrapped
|
|
||||||
theme theme.Wrapped
|
|
||||||
|
|
||||||
onToggle func ()
|
onToggle func ()
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewCheckbox creates a new cbeckbox with the specified label text.
|
// NewCheckbox creates a new cbeckbox with the specified label text.
|
||||||
func NewCheckbox (text string, checked bool) (element *Checkbox) {
|
func NewCheckbox (text string, checked bool) (element *Checkbox) {
|
||||||
element = &Checkbox { checked: checked, enabled: true }
|
element = &Checkbox { checked: checked, enabled: true }
|
||||||
element.entity = tomo.NewEntity(element).(tomo.FocusableEntity)
|
element.entity = tomo.NewEntity(element).(checkboxEntity)
|
||||||
element.theme.Case = tomo.C("tomo", "checkbox")
|
element.theme.Case = tomo.C("tomo", "checkbox")
|
||||||
element.drawer.SetFace (element.theme.FontFace (
|
element.drawer.SetFace (element.theme.FontFace (
|
||||||
tomo.FontStyleRegular,
|
tomo.FontStyleRegular,
|
||||||
@ -42,7 +38,7 @@ func (element *Checkbox) Entity () tomo.Entity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Draw causes the element to draw to the specified destination canvas.
|
// Draw causes the element to draw to the specified destination canvas.
|
||||||
func (element *Checkbox) Draw (destination canvas.Canvas) {
|
func (element *Checkbox) Draw (destination artist.Canvas) {
|
||||||
bounds := element.entity.Bounds()
|
bounds := element.entity.Bounds()
|
||||||
boxBounds := image.Rect(0, 0, bounds.Dy(), bounds.Dy()).Add(bounds.Min)
|
boxBounds := image.Rect(0, 0, bounds.Dy(), bounds.Dy()).Add(bounds.Min)
|
||||||
|
|
||||||
|
@ -3,9 +3,8 @@ package elements
|
|||||||
import "image"
|
import "image"
|
||||||
import "git.tebibyte.media/sashakoshka/tomo"
|
import "git.tebibyte.media/sashakoshka/tomo"
|
||||||
import "git.tebibyte.media/sashakoshka/tomo/input"
|
import "git.tebibyte.media/sashakoshka/tomo/input"
|
||||||
import "git.tebibyte.media/sashakoshka/tomo/canvas"
|
import "git.tebibyte.media/sashakoshka/tomo/artist"
|
||||||
import "git.tebibyte.media/sashakoshka/tomo/default/theme"
|
import "git.tebibyte.media/sashakoshka/tomo/ability"
|
||||||
import "git.tebibyte.media/sashakoshka/tomo/default/config"
|
|
||||||
import "git.tebibyte.media/sashakoshka/tomo/textdraw"
|
import "git.tebibyte.media/sashakoshka/tomo/textdraw"
|
||||||
|
|
||||||
// Option specifies a ComboBox option. A blank option will display as "(None)".
|
// Option specifies a ComboBox option. A blank option will display as "(None)".
|
||||||
@ -21,7 +20,7 @@ func (option Option) Title () string {
|
|||||||
|
|
||||||
// ComboBox is an input that can be one of several predetermined values.
|
// ComboBox is an input that can be one of several predetermined values.
|
||||||
type ComboBox struct {
|
type ComboBox struct {
|
||||||
entity tomo.FocusableEntity
|
entity tomo.Entity
|
||||||
drawer textdraw.Drawer
|
drawer textdraw.Drawer
|
||||||
|
|
||||||
options []Option
|
options []Option
|
||||||
@ -30,9 +29,6 @@ type ComboBox struct {
|
|||||||
enabled bool
|
enabled bool
|
||||||
pressed bool
|
pressed bool
|
||||||
|
|
||||||
config config.Wrapped
|
|
||||||
theme theme.Wrapped
|
|
||||||
|
|
||||||
onChange func ()
|
onChange func ()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -55,7 +51,7 @@ func (element *ComboBox) Entity () tomo.Entity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Draw causes the element to draw to the specified destination canvas.
|
// Draw causes the element to draw to the specified destination canvas.
|
||||||
func (element *ComboBox) Draw (destination canvas.Canvas) {
|
func (element *ComboBox) Draw (destination artist.Canvas) {
|
||||||
state := element.state()
|
state := element.state()
|
||||||
bounds := element.entity.Bounds()
|
bounds := element.entity.Bounds()
|
||||||
pattern := element.theme.Pattern(tomo.PatternButton, state)
|
pattern := element.theme.Pattern(tomo.PatternButton, state)
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package elements
|
package elements
|
||||||
|
|
||||||
import "git.tebibyte.media/sashakoshka/tomo"
|
import "git.tebibyte.media/sashakoshka/tomo"
|
||||||
|
import "git.tebibyte.media/sashakoshka/tomo/ability"
|
||||||
|
|
||||||
type scratchEntry struct {
|
type scratchEntry struct {
|
||||||
expand bool
|
expand bool
|
||||||
@ -9,7 +10,7 @@ type scratchEntry struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type container struct {
|
type container struct {
|
||||||
entity tomo.ContainerEntity
|
entity tomo.Entity
|
||||||
scratch map[tomo.Element] scratchEntry
|
scratch map[tomo.Element] scratchEntry
|
||||||
minimumSize func ()
|
minimumSize func ()
|
||||||
}
|
}
|
||||||
|
@ -4,18 +4,13 @@ import "image"
|
|||||||
import "path/filepath"
|
import "path/filepath"
|
||||||
import "git.tebibyte.media/sashakoshka/tomo"
|
import "git.tebibyte.media/sashakoshka/tomo"
|
||||||
import "git.tebibyte.media/sashakoshka/tomo/input"
|
import "git.tebibyte.media/sashakoshka/tomo/input"
|
||||||
import "git.tebibyte.media/sashakoshka/tomo/canvas"
|
import "git.tebibyte.media/sashakoshka/tomo/artist"
|
||||||
|
import "git.tebibyte.media/sashakoshka/tomo/ability"
|
||||||
import "git.tebibyte.media/sashakoshka/tomo/shatter"
|
import "git.tebibyte.media/sashakoshka/tomo/shatter"
|
||||||
import "git.tebibyte.media/sashakoshka/tomo/default/theme"
|
|
||||||
|
|
||||||
// TODO: base on flow implementation of list. also be able to switch to a table
|
// TODO: base on flow implementation of list. also be able to switch to a table
|
||||||
// variant for a more information dense view.
|
// variant for a more information dense view.
|
||||||
|
|
||||||
type directoryEntity interface {
|
|
||||||
tomo.ContainerEntity
|
|
||||||
tomo.ScrollableEntity
|
|
||||||
}
|
|
||||||
|
|
||||||
type historyEntry struct {
|
type historyEntry struct {
|
||||||
location string
|
location string
|
||||||
filesystem ReadDirStatFS
|
filesystem ReadDirStatFS
|
||||||
@ -25,8 +20,7 @@ type historyEntry struct {
|
|||||||
// file system.
|
// file system.
|
||||||
type Directory struct {
|
type Directory struct {
|
||||||
container
|
container
|
||||||
entity directoryEntity
|
entity tomo.Entity
|
||||||
theme theme.Wrapped
|
|
||||||
|
|
||||||
scroll image.Point
|
scroll image.Point
|
||||||
contentBounds image.Rectangle
|
contentBounds image.Rectangle
|
||||||
@ -57,7 +51,7 @@ func NewDirectory (
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (element *Directory) Draw (destination canvas.Canvas) {
|
func (element *Directory) Draw (destination artist.Canvas) {
|
||||||
rocks := make([]image.Rectangle, element.entity.CountChildren())
|
rocks := make([]image.Rectangle, element.entity.CountChildren())
|
||||||
for index := 0; index < element.entity.CountChildren(); index ++ {
|
for index := 0; index < element.entity.CountChildren(); index ++ {
|
||||||
rocks[index] = element.entity.Child(index).Entity().Bounds()
|
rocks[index] = element.entity.Child(index).Entity().Bounds()
|
||||||
@ -158,7 +152,7 @@ func (element *Directory) HandleChildMouseUp (
|
|||||||
child tomo.Element,
|
child tomo.Element,
|
||||||
) { }
|
) { }
|
||||||
|
|
||||||
func (element *Directory) HandleChildFlexibleHeightChange (child tomo.Flexible) {
|
func (element *Directory) HandleChildFlexibleHeightChange (child ability.Flexible) {
|
||||||
element.updateMinimumSize()
|
element.updateMinimumSize()
|
||||||
element.entity.Invalidate()
|
element.entity.Invalidate()
|
||||||
element.entity.InvalidateLayout()
|
element.entity.InvalidateLayout()
|
||||||
@ -204,7 +198,7 @@ func (element *Directory) ScrollAxes () (horizontal, vertical bool) {
|
|||||||
return false, true
|
return false, true
|
||||||
}
|
}
|
||||||
|
|
||||||
func (element *Directory) DrawBackground (destination canvas.Canvas) {
|
func (element *Directory) DrawBackground (destination artist.Canvas) {
|
||||||
element.theme.Pattern(tomo.PatternPinboard, tomo.State { }).
|
element.theme.Pattern(tomo.PatternPinboard, tomo.State { }).
|
||||||
Draw(destination, element.entity.Bounds())
|
Draw(destination, element.entity.Bounds())
|
||||||
}
|
}
|
||||||
|
@ -2,26 +2,19 @@ package elements
|
|||||||
|
|
||||||
import "image"
|
import "image"
|
||||||
import "git.tebibyte.media/sashakoshka/tomo"
|
import "git.tebibyte.media/sashakoshka/tomo"
|
||||||
import "git.tebibyte.media/sashakoshka/tomo/canvas"
|
import "git.tebibyte.media/sashakoshka/tomo/artist"
|
||||||
|
import "git.tebibyte.media/sashakoshka/tomo/ability"
|
||||||
import "git.tebibyte.media/sashakoshka/tomo/shatter"
|
import "git.tebibyte.media/sashakoshka/tomo/shatter"
|
||||||
import "git.tebibyte.media/sashakoshka/tomo/default/theme"
|
|
||||||
|
|
||||||
type documentEntity interface {
|
|
||||||
tomo.ContainerEntity
|
|
||||||
tomo.ScrollableEntity
|
|
||||||
}
|
|
||||||
|
|
||||||
// Document is a scrollable container capcable of laying out flexible child
|
// Document is a scrollable container capcable of laying out flexible child
|
||||||
// elements. Children can be added either inline (similar to an HTML/CSS inline
|
// elements. Children can be added either inline (similar to an HTML/CSS inline
|
||||||
// element), or expanding (similar to an HTML/CSS block element).
|
// element), or expanding (similar to an HTML/CSS block element).
|
||||||
type Document struct {
|
type Document struct {
|
||||||
container
|
container
|
||||||
entity documentEntity
|
entity tomo.Entity
|
||||||
|
|
||||||
scroll image.Point
|
scroll image.Point
|
||||||
contentBounds image.Rectangle
|
contentBounds image.Rectangle
|
||||||
|
|
||||||
theme theme.Wrapped
|
|
||||||
|
|
||||||
onScrollBoundsChange func ()
|
onScrollBoundsChange func ()
|
||||||
}
|
}
|
||||||
@ -30,7 +23,7 @@ type Document struct {
|
|||||||
func NewDocument (children ...tomo.Element) (element *Document) {
|
func NewDocument (children ...tomo.Element) (element *Document) {
|
||||||
element = &Document { }
|
element = &Document { }
|
||||||
element.theme.Case = tomo.C("tomo", "document")
|
element.theme.Case = tomo.C("tomo", "document")
|
||||||
element.entity = tomo.NewEntity(element).(documentEntity)
|
element.entity = tomo.NewEntity(element)
|
||||||
element.container.entity = element.entity
|
element.container.entity = element.entity
|
||||||
element.minimumSize = element.updateMinimumSize
|
element.minimumSize = element.updateMinimumSize
|
||||||
element.init()
|
element.init()
|
||||||
@ -39,7 +32,7 @@ func NewDocument (children ...tomo.Element) (element *Document) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Draw causes the element to draw to the specified destination canvas.
|
// Draw causes the element to draw to the specified destination canvas.
|
||||||
func (element *Document) Draw (destination canvas.Canvas) {
|
func (element *Document) Draw (destination artist.Canvas) {
|
||||||
rocks := make([]image.Rectangle, element.entity.CountChildren())
|
rocks := make([]image.Rectangle, element.entity.CountChildren())
|
||||||
for index := 0; index < element.entity.CountChildren(); index ++ {
|
for index := 0; index < element.entity.CountChildren(); index ++ {
|
||||||
rocks[index] = element.entity.Child(index).Entity().Bounds()
|
rocks[index] = element.entity.Child(index).Entity().Bounds()
|
||||||
@ -130,7 +123,7 @@ func (element *Document) AdoptInline (children ...tomo.Element) {
|
|||||||
element.adopt(false, children...)
|
element.adopt(false, children...)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (element *Document) HandleChildFlexibleHeightChange (child tomo.Flexible) {
|
func (element *Document) HandleChildFlexibleHeightChange (child ability.Flexible) {
|
||||||
element.updateMinimumSize()
|
element.updateMinimumSize()
|
||||||
element.entity.Invalidate()
|
element.entity.Invalidate()
|
||||||
element.entity.InvalidateLayout()
|
element.entity.InvalidateLayout()
|
||||||
@ -138,7 +131,7 @@ func (element *Document) HandleChildFlexibleHeightChange (child tomo.Flexible) {
|
|||||||
|
|
||||||
// DrawBackground draws this element's background pattern to the specified
|
// DrawBackground draws this element's background pattern to the specified
|
||||||
// destination canvas.
|
// destination canvas.
|
||||||
func (element *Document) DrawBackground (destination canvas.Canvas) {
|
func (element *Document) DrawBackground (destination artist.Canvas) {
|
||||||
element.entity.DrawBackground(destination)
|
element.entity.DrawBackground(destination)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,22 +6,11 @@ import "image"
|
|||||||
import "git.tebibyte.media/sashakoshka/tomo"
|
import "git.tebibyte.media/sashakoshka/tomo"
|
||||||
import "git.tebibyte.media/sashakoshka/tomo/input"
|
import "git.tebibyte.media/sashakoshka/tomo/input"
|
||||||
import "git.tebibyte.media/sashakoshka/tomo/artist"
|
import "git.tebibyte.media/sashakoshka/tomo/artist"
|
||||||
import "git.tebibyte.media/sashakoshka/tomo/canvas"
|
|
||||||
import "git.tebibyte.media/sashakoshka/tomo/default/theme"
|
|
||||||
import "git.tebibyte.media/sashakoshka/tomo/default/config"
|
|
||||||
|
|
||||||
type fileEntity interface {
|
|
||||||
tomo.SelectableEntity
|
|
||||||
tomo.FocusableEntity
|
|
||||||
}
|
|
||||||
|
|
||||||
// File displays an interactive visual representation of a file within any
|
// File displays an interactive visual representation of a file within any
|
||||||
// file system.
|
// file system.
|
||||||
type File struct {
|
type File struct {
|
||||||
entity fileEntity
|
entity tomo.Entity
|
||||||
|
|
||||||
config config.Wrapped
|
|
||||||
theme theme.Wrapped
|
|
||||||
|
|
||||||
lastClick time.Time
|
lastClick time.Time
|
||||||
pressed bool
|
pressed bool
|
||||||
@ -55,7 +44,7 @@ func (element *File) Entity () tomo.Entity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Draw causes the element to draw to the specified destination canvas.
|
// Draw causes the element to draw to the specified destination canvas.
|
||||||
func (element *File) Draw (destination canvas.Canvas) {
|
func (element *File) Draw (destination artist.Canvas) {
|
||||||
// background
|
// background
|
||||||
state := element.state()
|
state := element.state()
|
||||||
bounds := element.entity.Bounds()
|
bounds := element.entity.Bounds()
|
||||||
|
@ -2,14 +2,11 @@ package elements
|
|||||||
|
|
||||||
import "image"
|
import "image"
|
||||||
import "git.tebibyte.media/sashakoshka/tomo"
|
import "git.tebibyte.media/sashakoshka/tomo"
|
||||||
import "git.tebibyte.media/sashakoshka/tomo/canvas"
|
|
||||||
import "git.tebibyte.media/sashakoshka/tomo/artist"
|
import "git.tebibyte.media/sashakoshka/tomo/artist"
|
||||||
import "git.tebibyte.media/sashakoshka/tomo/default/theme"
|
|
||||||
|
|
||||||
// Icon is an element capable of displaying a singular icon.
|
// Icon is an element capable of displaying a singular icon.
|
||||||
type Icon struct {
|
type Icon struct {
|
||||||
entity tomo.Entity
|
entity tomo.Entity
|
||||||
theme theme.Wrapped
|
|
||||||
id tomo.Icon
|
id tomo.Icon
|
||||||
size tomo.IconSize
|
size tomo.IconSize
|
||||||
}
|
}
|
||||||
@ -20,7 +17,7 @@ func NewIcon (id tomo.Icon, size tomo.IconSize) (element *Icon) {
|
|||||||
id: id,
|
id: id,
|
||||||
size: size,
|
size: size,
|
||||||
}
|
}
|
||||||
element.entity = tomo.NewEntity(element)
|
element.entity = tomo.NewEntity(element).(ability.ThemeableEntity)
|
||||||
element.theme.Case = tomo.C("tomo", "icon")
|
element.theme.Case = tomo.C("tomo", "icon")
|
||||||
element.updateMinimumSize()
|
element.updateMinimumSize()
|
||||||
return
|
return
|
||||||
@ -50,7 +47,7 @@ func (element *Icon) SetTheme (new tomo.Theme) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Draw causes the element to draw to the specified destination canvas.
|
// Draw causes the element to draw to the specified destination canvas.
|
||||||
func (element *Icon) Draw (destination canvas.Canvas) {
|
func (element *Icon) Draw (destination artist.Canvas) {
|
||||||
if element.entity == nil { return }
|
if element.entity == nil { return }
|
||||||
|
|
||||||
bounds := element.entity.Bounds()
|
bounds := element.entity.Bounds()
|
||||||
|
@ -2,7 +2,7 @@ package elements
|
|||||||
|
|
||||||
import "image"
|
import "image"
|
||||||
import "git.tebibyte.media/sashakoshka/tomo"
|
import "git.tebibyte.media/sashakoshka/tomo"
|
||||||
import "git.tebibyte.media/sashakoshka/tomo/canvas"
|
import "git.tebibyte.media/sashakoshka/tomo/artist"
|
||||||
import "git.tebibyte.media/sashakoshka/tomo/artist/patterns"
|
import "git.tebibyte.media/sashakoshka/tomo/artist/patterns"
|
||||||
|
|
||||||
// TODO: this element is lame need to make it better
|
// TODO: this element is lame need to make it better
|
||||||
@ -10,7 +10,7 @@ import "git.tebibyte.media/sashakoshka/tomo/artist/patterns"
|
|||||||
// Image is an element capable of displaying an image.
|
// Image is an element capable of displaying an image.
|
||||||
type Image struct {
|
type Image struct {
|
||||||
entity tomo.Entity
|
entity tomo.Entity
|
||||||
buffer canvas.Canvas
|
buffer artist.Canvas
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewImage creates a new image element.
|
// NewImage creates a new image element.
|
||||||
@ -28,7 +28,7 @@ func (element *Image) Entity () tomo.Entity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Draw causes the element to draw to the specified destination canvas.
|
// Draw causes the element to draw to the specified destination canvas.
|
||||||
func (element *Image) Draw (destination canvas.Canvas) {
|
func (element *Image) Draw (destination artist.Canvas) {
|
||||||
if element.entity == nil { return }
|
if element.entity == nil { return }
|
||||||
(patterns.Texture { Canvas: element.buffer }).
|
(patterns.Texture { Canvas: element.buffer }).
|
||||||
Draw(destination, element.entity.Bounds())
|
Draw(destination, element.entity.Bounds())
|
||||||
|
@ -5,14 +5,12 @@ import "golang.org/x/image/math/fixed"
|
|||||||
import "git.tebibyte.media/sashakoshka/tomo"
|
import "git.tebibyte.media/sashakoshka/tomo"
|
||||||
import "git.tebibyte.media/sashakoshka/tomo/data"
|
import "git.tebibyte.media/sashakoshka/tomo/data"
|
||||||
import "git.tebibyte.media/sashakoshka/tomo/input"
|
import "git.tebibyte.media/sashakoshka/tomo/input"
|
||||||
import "git.tebibyte.media/sashakoshka/tomo/canvas"
|
import "git.tebibyte.media/sashakoshka/tomo/artist"
|
||||||
import "git.tebibyte.media/sashakoshka/tomo/textdraw"
|
import "git.tebibyte.media/sashakoshka/tomo/textdraw"
|
||||||
import "git.tebibyte.media/sashakoshka/tomo/default/theme"
|
|
||||||
import "git.tebibyte.media/sashakoshka/tomo/default/config"
|
|
||||||
|
|
||||||
// Label is a simple text box.
|
// Label is a simple text box.
|
||||||
type Label struct {
|
type Label struct {
|
||||||
entity tomo.FlexibleEntity
|
entity tomo.Entity
|
||||||
|
|
||||||
align textdraw.Align
|
align textdraw.Align
|
||||||
wrap bool
|
wrap bool
|
||||||
@ -22,16 +20,13 @@ type Label struct {
|
|||||||
forcedColumns int
|
forcedColumns int
|
||||||
forcedRows int
|
forcedRows int
|
||||||
minHeight int
|
minHeight int
|
||||||
|
|
||||||
config config.Wrapped
|
|
||||||
theme theme.Wrapped
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewLabel creates a new label.
|
// NewLabel creates a new label.
|
||||||
func NewLabel (text string) (element *Label) {
|
func NewLabel (text string) (element *Label) {
|
||||||
element = &Label { }
|
element = &Label { }
|
||||||
element.theme.Case = tomo.C("tomo", "label")
|
element.theme.Case = tomo.C("tomo", "label")
|
||||||
element.entity = tomo.NewEntity(element).(tomo.FlexibleEntity)
|
element.entity = tomo.NewEntity(element)
|
||||||
element.drawer.SetFace (element.theme.FontFace (
|
element.drawer.SetFace (element.theme.FontFace (
|
||||||
tomo.FontStyleRegular,
|
tomo.FontStyleRegular,
|
||||||
tomo.FontSizeNormal))
|
tomo.FontSizeNormal))
|
||||||
@ -52,7 +47,7 @@ func (element *Label) Entity () tomo.Entity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Draw causes the element to draw to the specified destination canvas.
|
// Draw causes the element to draw to the specified destination canvas.
|
||||||
func (element *Label) Draw (destination canvas.Canvas) {
|
func (element *Label) Draw (destination artist.Canvas) {
|
||||||
bounds := element.entity.Bounds()
|
bounds := element.entity.Bounds()
|
||||||
|
|
||||||
if element.wrap {
|
if element.wrap {
|
||||||
|
@ -3,19 +3,11 @@ package elements
|
|||||||
import "image"
|
import "image"
|
||||||
import "git.tebibyte.media/sashakoshka/tomo"
|
import "git.tebibyte.media/sashakoshka/tomo"
|
||||||
import "git.tebibyte.media/sashakoshka/tomo/input"
|
import "git.tebibyte.media/sashakoshka/tomo/input"
|
||||||
import "git.tebibyte.media/sashakoshka/tomo/canvas"
|
|
||||||
import "git.tebibyte.media/sashakoshka/tomo/artist"
|
import "git.tebibyte.media/sashakoshka/tomo/artist"
|
||||||
import "git.tebibyte.media/sashakoshka/tomo/default/theme"
|
|
||||||
|
|
||||||
type listEntity interface {
|
|
||||||
tomo.ContainerEntity
|
|
||||||
tomo.ScrollableEntity
|
|
||||||
tomo.FocusableEntity
|
|
||||||
}
|
|
||||||
|
|
||||||
type list struct {
|
type list struct {
|
||||||
container
|
container
|
||||||
entity listEntity
|
entity tomo.Entity
|
||||||
|
|
||||||
enabled bool
|
enabled bool
|
||||||
scroll image.Point
|
scroll image.Point
|
||||||
@ -25,8 +17,6 @@ type list struct {
|
|||||||
forcedMinimumWidth int
|
forcedMinimumWidth int
|
||||||
forcedMinimumHeight int
|
forcedMinimumHeight int
|
||||||
|
|
||||||
theme theme.Wrapped
|
|
||||||
|
|
||||||
onClick func ()
|
onClick func ()
|
||||||
onSelectionChange func ()
|
onSelectionChange func ()
|
||||||
onScrollBoundsChange func ()
|
onScrollBoundsChange func ()
|
||||||
@ -43,7 +33,7 @@ type FlowList struct {
|
|||||||
func NewList (children ...tomo.Element) (element *List) {
|
func NewList (children ...tomo.Element) (element *List) {
|
||||||
element = &List { }
|
element = &List { }
|
||||||
element.theme.Case = tomo.C("tomo", "list")
|
element.theme.Case = tomo.C("tomo", "list")
|
||||||
element.entity = tomo.NewEntity(element).(listEntity)
|
element.entity = tomo.NewEntity(element)
|
||||||
element.container.entity = element.entity
|
element.container.entity = element.entity
|
||||||
element.minimumSize = element.updateMinimumSize
|
element.minimumSize = element.updateMinimumSize
|
||||||
element.init(children...)
|
element.init(children...)
|
||||||
@ -67,7 +57,7 @@ func (element *list) init (children ...tomo.Element) {
|
|||||||
element.Adopt(children...)
|
element.Adopt(children...)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (element *list) Draw (destination canvas.Canvas) {
|
func (element *list) Draw (destination artist.Canvas) {
|
||||||
rocks := make([]image.Rectangle, element.entity.CountChildren())
|
rocks := make([]image.Rectangle, element.entity.CountChildren())
|
||||||
for index := 0; index < element.entity.CountChildren(); index ++ {
|
for index := 0; index < element.entity.CountChildren(); index ++ {
|
||||||
rocks[index] = element.entity.Child(index).Entity().Bounds()
|
rocks[index] = element.entity.Child(index).Entity().Bounds()
|
||||||
@ -170,14 +160,14 @@ func (element *FlowList) Layout () {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (element *list) Selected () tomo.Selectable {
|
func (element *list) Selected () ability.Selectable {
|
||||||
if element.selected == -1 { return nil }
|
if element.selected == -1 { return nil }
|
||||||
child, ok := element.entity.Child(element.selected).(tomo.Selectable)
|
child, ok := element.entity.Child(element.selected).(tomo.Selectable)
|
||||||
if !ok { return nil }
|
if !ok { return nil }
|
||||||
return child
|
return child
|
||||||
}
|
}
|
||||||
|
|
||||||
func (element *list) Select (child tomo.Selectable) {
|
func (element *list) Select (child ability.Selectable) {
|
||||||
index := element.entity.IndexOf(child)
|
index := element.entity.IndexOf(child)
|
||||||
if element.selected == index { return }
|
if element.selected == index { return }
|
||||||
element.selectNone()
|
element.selectNone()
|
||||||
@ -248,7 +238,7 @@ func (element *list) HandleChildMouseUp (
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (element *list) HandleChildFlexibleHeightChange (child tomo.Flexible) {
|
func (element *list) HandleChildFlexibleHeightChange (child ability.Flexible) {
|
||||||
element.minimumSize()
|
element.minimumSize()
|
||||||
element.entity.Invalidate()
|
element.entity.Invalidate()
|
||||||
element.entity.InvalidateLayout()
|
element.entity.InvalidateLayout()
|
||||||
@ -280,7 +270,7 @@ func (element *list) HandleKeyDown (key input.Key, modifiers input.Modifiers) {
|
|||||||
|
|
||||||
func (element *list) HandleKeyUp(key input.Key, modifiers input.Modifiers) { }
|
func (element *list) HandleKeyUp(key input.Key, modifiers input.Modifiers) { }
|
||||||
|
|
||||||
func (element *list) DrawBackground (destination canvas.Canvas) {
|
func (element *list) DrawBackground (destination artist.Canvas) {
|
||||||
element.entity.DrawBackground(destination)
|
element.entity.DrawBackground(destination)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,17 +2,12 @@ package elements
|
|||||||
|
|
||||||
import "image"
|
import "image"
|
||||||
import "git.tebibyte.media/sashakoshka/tomo"
|
import "git.tebibyte.media/sashakoshka/tomo"
|
||||||
import "git.tebibyte.media/sashakoshka/tomo/canvas"
|
import "git.tebibyte.media/sashakoshka/tomo/artist"
|
||||||
import "git.tebibyte.media/sashakoshka/tomo/default/theme"
|
|
||||||
import "git.tebibyte.media/sashakoshka/tomo/default/config"
|
|
||||||
|
|
||||||
// ProgressBar displays a visual indication of how far along a task is.
|
// ProgressBar displays a visual indication of how far along a task is.
|
||||||
type ProgressBar struct {
|
type ProgressBar struct {
|
||||||
entity tomo.Entity
|
entity tomo.Entity
|
||||||
progress float64
|
progress float64
|
||||||
|
|
||||||
config config.Wrapped
|
|
||||||
theme theme.Wrapped
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewProgressBar creates a new progress bar displaying the given progress
|
// NewProgressBar creates a new progress bar displaying the given progress
|
||||||
@ -33,7 +28,7 @@ func (element *ProgressBar) Entity () tomo.Entity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Draw causes the element to draw to the specified destination canvas.
|
// Draw causes the element to draw to the specified destination canvas.
|
||||||
func (element *ProgressBar) Draw (destination canvas.Canvas) {
|
func (element *ProgressBar) Draw (destination artist.Canvas) {
|
||||||
bounds := element.entity.Bounds()
|
bounds := element.entity.Bounds()
|
||||||
|
|
||||||
pattern := element.theme.Pattern(tomo.PatternSunken, tomo.State { })
|
pattern := element.theme.Pattern(tomo.PatternSunken, tomo.State { })
|
||||||
@ -65,14 +60,6 @@ func (element *ProgressBar) SetTheme (new tomo.Theme) {
|
|||||||
element.entity.Invalidate()
|
element.entity.Invalidate()
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetConfig sets the element's configuration.
|
|
||||||
func (element *ProgressBar) SetConfig (new tomo.Config) {
|
|
||||||
if new == nil || new == element.config.Config { return }
|
|
||||||
element.config.Config = new
|
|
||||||
element.updateMinimumSize()
|
|
||||||
element.entity.Invalidate()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (element *ProgressBar) updateMinimumSize() {
|
func (element *ProgressBar) updateMinimumSize() {
|
||||||
padding := element.theme.Padding(tomo.PatternSunken)
|
padding := element.theme.Padding(tomo.PatternSunken)
|
||||||
innerPadding := element.theme.Padding(tomo.PatternMercury)
|
innerPadding := element.theme.Padding(tomo.PatternMercury)
|
||||||
|
@ -3,9 +3,8 @@ package elements
|
|||||||
import "image"
|
import "image"
|
||||||
import "git.tebibyte.media/sashakoshka/tomo"
|
import "git.tebibyte.media/sashakoshka/tomo"
|
||||||
import "git.tebibyte.media/sashakoshka/tomo/input"
|
import "git.tebibyte.media/sashakoshka/tomo/input"
|
||||||
import "git.tebibyte.media/sashakoshka/tomo/canvas"
|
import "git.tebibyte.media/sashakoshka/tomo/artist"
|
||||||
import "git.tebibyte.media/sashakoshka/tomo/default/theme"
|
import "git.tebibyte.media/sashakoshka/tomo/ability"
|
||||||
import "git.tebibyte.media/sashakoshka/tomo/default/config"
|
|
||||||
|
|
||||||
// ScrollMode specifies which sides of a Scroll have scroll bars.
|
// ScrollMode specifies which sides of a Scroll have scroll bars.
|
||||||
type ScrollMode int; const (
|
type ScrollMode int; const (
|
||||||
@ -24,21 +23,18 @@ func (mode ScrollMode) Includes (sub ScrollMode) bool {
|
|||||||
// Scroll adds scroll bars to any scrollable element. It also captures scroll
|
// Scroll adds scroll bars to any scrollable element. It also captures scroll
|
||||||
// wheel input.
|
// wheel input.
|
||||||
type Scroll struct {
|
type Scroll struct {
|
||||||
entity tomo.ContainerEntity
|
entity tomo.Entity
|
||||||
|
|
||||||
child tomo.Scrollable
|
child ability.Scrollable
|
||||||
horizontal *ScrollBar
|
horizontal *ScrollBar
|
||||||
vertical *ScrollBar
|
vertical *ScrollBar
|
||||||
|
|
||||||
config config.Wrapped
|
|
||||||
theme theme.Wrapped
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewScroll creates a new scroll element.
|
// NewScroll creates a new scroll element.
|
||||||
func NewScroll (mode ScrollMode, child tomo.Scrollable) (element *Scroll) {
|
func NewScroll (mode ScrollMode, child ability.Scrollable) (element *Scroll) {
|
||||||
element = &Scroll { }
|
element = &Scroll { }
|
||||||
element.theme.Case = tomo.C("tomo", "scroll")
|
element.theme.Case = tomo.C("tomo", "scroll")
|
||||||
element.entity = tomo.NewEntity(element).(tomo.ContainerEntity)
|
element.entity = tomo.NewEntity(element).(scrollEntity)
|
||||||
|
|
||||||
if mode.Includes(ScrollHorizontal) {
|
if mode.Includes(ScrollHorizontal) {
|
||||||
element.horizontal = NewHScrollBar()
|
element.horizontal = NewHScrollBar()
|
||||||
@ -79,7 +75,7 @@ func (element *Scroll) Entity () tomo.Entity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Draw causes the element to draw to the specified destination canvas.
|
// Draw causes the element to draw to the specified destination canvas.
|
||||||
func (element *Scroll) Draw (destination canvas.Canvas) {
|
func (element *Scroll) Draw (destination artist.Canvas) {
|
||||||
if element.horizontal != nil && element.vertical != nil {
|
if element.horizontal != nil && element.vertical != nil {
|
||||||
bounds := element.entity.Bounds()
|
bounds := element.entity.Bounds()
|
||||||
bounds.Min = image.Pt (
|
bounds.Min = image.Pt (
|
||||||
@ -134,12 +130,12 @@ func (element *Scroll) Layout () {
|
|||||||
|
|
||||||
// DrawBackground draws this element's background pattern to the specified
|
// DrawBackground draws this element's background pattern to the specified
|
||||||
// destination canvas.
|
// destination canvas.
|
||||||
func (element *Scroll) DrawBackground (destination canvas.Canvas) {
|
func (element *Scroll) DrawBackground (destination artist.Canvas) {
|
||||||
element.entity.DrawBackground(destination)
|
element.entity.DrawBackground(destination)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Adopt sets this element's child. If nil is passed, any child is removed.
|
// Adopt sets this element's child. If nil is passed, any child is removed.
|
||||||
func (element *Scroll) Adopt (child tomo.Scrollable) {
|
func (element *Scroll) Adopt (child ability.Scrollable) {
|
||||||
if element.child != nil {
|
if element.child != nil {
|
||||||
element.entity.Disown(element.entity.IndexOf(element.child))
|
element.entity.Disown(element.entity.IndexOf(element.child))
|
||||||
}
|
}
|
||||||
@ -156,7 +152,7 @@ func (element *Scroll) Adopt (child tomo.Scrollable) {
|
|||||||
|
|
||||||
// Child returns this element's child. If there is no child, this method will
|
// Child returns this element's child. If there is no child, this method will
|
||||||
// return nil.
|
// return nil.
|
||||||
func (element *Scroll) Child () tomo.Scrollable {
|
func (element *Scroll) Child () ability.Scrollable {
|
||||||
return element.child
|
return element.child
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -166,7 +162,7 @@ func (element *Scroll) HandleChildMinimumSizeChange (tomo.Element) {
|
|||||||
element.entity.InvalidateLayout()
|
element.entity.InvalidateLayout()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (element *Scroll) HandleChildScrollBoundsChange (tomo.Scrollable) {
|
func (element *Scroll) HandleChildScrollBoundsChange (ability.Scrollable) {
|
||||||
element.updateEnabled()
|
element.updateEnabled()
|
||||||
viewportBounds := element.child.ScrollViewportBounds()
|
viewportBounds := element.child.ScrollViewportBounds()
|
||||||
contentBounds := element.child.ScrollContentBounds()
|
contentBounds := element.child.ScrollContentBounds()
|
||||||
|
@ -3,9 +3,8 @@ package elements
|
|||||||
import "image"
|
import "image"
|
||||||
import "git.tebibyte.media/sashakoshka/tomo"
|
import "git.tebibyte.media/sashakoshka/tomo"
|
||||||
import "git.tebibyte.media/sashakoshka/tomo/input"
|
import "git.tebibyte.media/sashakoshka/tomo/input"
|
||||||
import "git.tebibyte.media/sashakoshka/tomo/canvas"
|
import "git.tebibyte.media/sashakoshka/tomo/artist"
|
||||||
import "git.tebibyte.media/sashakoshka/tomo/default/theme"
|
import "git.tebibyte.media/sashakoshka/tomo/ability"
|
||||||
import "git.tebibyte.media/sashakoshka/tomo/default/config"
|
|
||||||
|
|
||||||
// ScrollBar is an element similar to Slider, but it has special behavior that
|
// ScrollBar is an element similar to Slider, but it has special behavior that
|
||||||
// makes it well suited for controlling the viewport position on one axis of a
|
// makes it well suited for controlling the viewport position on one axis of a
|
||||||
@ -31,9 +30,6 @@ type ScrollBar struct {
|
|||||||
contentBounds image.Rectangle
|
contentBounds image.Rectangle
|
||||||
viewportBounds image.Rectangle
|
viewportBounds image.Rectangle
|
||||||
|
|
||||||
config config.Wrapped
|
|
||||||
theme theme.Wrapped
|
|
||||||
|
|
||||||
onScroll func (viewport image.Point)
|
onScroll func (viewport image.Point)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -44,7 +40,7 @@ func NewVScrollBar () (element *ScrollBar) {
|
|||||||
enabled: true,
|
enabled: true,
|
||||||
}
|
}
|
||||||
element.theme.Case = tomo.C("tomo", "scrollBarVertical")
|
element.theme.Case = tomo.C("tomo", "scrollBarVertical")
|
||||||
element.entity = tomo.NewEntity(element).(tomo.Entity)
|
element.entity = tomo.NewEntity(element).(scrollBarEntity)
|
||||||
element.updateMinimumSize()
|
element.updateMinimumSize()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -66,7 +62,7 @@ func (element *ScrollBar) Entity () tomo.Entity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Draw causes the element to draw to the specified destination canvas.
|
// Draw causes the element to draw to the specified destination canvas.
|
||||||
func (element *ScrollBar) Draw (destination canvas.Canvas) {
|
func (element *ScrollBar) Draw (destination artist.Canvas) {
|
||||||
element.recalculate()
|
element.recalculate()
|
||||||
|
|
||||||
bounds := element.entity.Bounds()
|
bounds := element.entity.Bounds()
|
||||||
|
@ -3,9 +3,8 @@ package elements
|
|||||||
import "image"
|
import "image"
|
||||||
import "git.tebibyte.media/sashakoshka/tomo"
|
import "git.tebibyte.media/sashakoshka/tomo"
|
||||||
import "git.tebibyte.media/sashakoshka/tomo/input"
|
import "git.tebibyte.media/sashakoshka/tomo/input"
|
||||||
import "git.tebibyte.media/sashakoshka/tomo/canvas"
|
import "git.tebibyte.media/sashakoshka/tomo/artist"
|
||||||
import "git.tebibyte.media/sashakoshka/tomo/default/theme"
|
import "git.tebibyte.media/sashakoshka/tomo/ability"
|
||||||
import "git.tebibyte.media/sashakoshka/tomo/default/config"
|
|
||||||
|
|
||||||
// Slider is a slider control with a floating point value between zero and one.
|
// Slider is a slider control with a floating point value between zero and one.
|
||||||
type Slider struct {
|
type Slider struct {
|
||||||
@ -23,14 +22,12 @@ func NewVSlider (value float64) (element *Slider) {
|
|||||||
func NewHSlider (value float64) (element *Slider) {
|
func NewHSlider (value float64) (element *Slider) {
|
||||||
element = &Slider { }
|
element = &Slider { }
|
||||||
element.value = value
|
element.value = value
|
||||||
element.entity = tomo.NewEntity(element).(tomo.FocusableEntity)
|
element.entity = tomo.NewEntity(element)
|
||||||
element.construct()
|
element.construct()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
type slider struct {
|
type slider struct {
|
||||||
entity tomo.FocusableEntity
|
|
||||||
|
|
||||||
value float64
|
value float64
|
||||||
vertical bool
|
vertical bool
|
||||||
dragging bool
|
dragging bool
|
||||||
@ -39,9 +36,6 @@ type slider struct {
|
|||||||
track image.Rectangle
|
track image.Rectangle
|
||||||
bar image.Rectangle
|
bar image.Rectangle
|
||||||
|
|
||||||
config config.Wrapped
|
|
||||||
theme theme.Wrapped
|
|
||||||
|
|
||||||
onSlide func ()
|
onSlide func ()
|
||||||
onRelease func ()
|
onRelease func ()
|
||||||
}
|
}
|
||||||
@ -62,7 +56,7 @@ func (element *slider) Entity () tomo.Entity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Draw causes the element to draw to the specified destination canvas.
|
// Draw causes the element to draw to the specified destination canvas.
|
||||||
func (element *slider) Draw (destination canvas.Canvas) {
|
func (element *slider) Draw (destination artist.Canvas) {
|
||||||
bounds := element.entity.Bounds()
|
bounds := element.entity.Bounds()
|
||||||
element.track = element.theme.Padding(tomo.PatternGutter).Apply(bounds)
|
element.track = element.theme.Padding(tomo.PatternGutter).Apply(bounds)
|
||||||
if element.vertical {
|
if element.vertical {
|
||||||
|
@ -1,24 +1,18 @@
|
|||||||
package elements
|
package elements
|
||||||
|
|
||||||
import "git.tebibyte.media/sashakoshka/tomo"
|
import "git.tebibyte.media/sashakoshka/tomo"
|
||||||
import "git.tebibyte.media/sashakoshka/tomo/canvas"
|
import "git.tebibyte.media/sashakoshka/tomo/artist"
|
||||||
import "git.tebibyte.media/sashakoshka/tomo/default/theme"
|
|
||||||
import "git.tebibyte.media/sashakoshka/tomo/default/config"
|
|
||||||
|
|
||||||
// Spacer can be used to put space between two elements..
|
// Spacer can be used to put space between two elements..
|
||||||
type Spacer struct {
|
type Spacer struct {
|
||||||
entity tomo.Entity
|
entity tomo.Entity
|
||||||
|
|
||||||
line bool
|
line bool
|
||||||
|
|
||||||
config config.Wrapped
|
|
||||||
theme theme.Wrapped
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewSpacer creates a new spacer.
|
// NewSpacer creates a new spacer.
|
||||||
func NewSpacer () (element *Spacer) {
|
func NewSpacer () (element *Spacer) {
|
||||||
element = &Spacer { }
|
element = &Spacer { }
|
||||||
element.entity = tomo.NewEntity(element)
|
element.entity = tomo.NewEntity(element).(spacerEntity)
|
||||||
element.theme.Case = tomo.C("tomo", "spacer")
|
element.theme.Case = tomo.C("tomo", "spacer")
|
||||||
element.updateMinimumSize()
|
element.updateMinimumSize()
|
||||||
return
|
return
|
||||||
@ -37,7 +31,7 @@ func (element *Spacer) Entity () tomo.Entity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Draw causes the element to draw to the specified destination canvas.
|
// Draw causes the element to draw to the specified destination canvas.
|
||||||
func (element *Spacer) Draw (destination canvas.Canvas) {
|
func (element *Spacer) Draw (destination artist.Canvas) {
|
||||||
bounds := element.entity.Bounds()
|
bounds := element.entity.Bounds()
|
||||||
|
|
||||||
if element.line {
|
if element.line {
|
||||||
|
@ -3,15 +3,13 @@ package elements
|
|||||||
import "image"
|
import "image"
|
||||||
import "git.tebibyte.media/sashakoshka/tomo"
|
import "git.tebibyte.media/sashakoshka/tomo"
|
||||||
import "git.tebibyte.media/sashakoshka/tomo/input"
|
import "git.tebibyte.media/sashakoshka/tomo/input"
|
||||||
import "git.tebibyte.media/sashakoshka/tomo/canvas"
|
import "git.tebibyte.media/sashakoshka/tomo/artist"
|
||||||
import "git.tebibyte.media/sashakoshka/tomo/textdraw"
|
import "git.tebibyte.media/sashakoshka/tomo/textdraw"
|
||||||
import "git.tebibyte.media/sashakoshka/tomo/default/theme"
|
|
||||||
import "git.tebibyte.media/sashakoshka/tomo/default/config"
|
|
||||||
|
|
||||||
// Switch is a toggle-able on/off switch with an optional label. It is
|
// Switch is a toggle-able on/off switch with an optional label. It is
|
||||||
// functionally identical to Checkbox, but plays a different semantic role.
|
// functionally identical to Checkbox, but plays a different semantic role.
|
||||||
type Switch struct {
|
type Switch struct {
|
||||||
entity tomo.FocusableEntity
|
entity tomo.Entity
|
||||||
drawer textdraw.Drawer
|
drawer textdraw.Drawer
|
||||||
|
|
||||||
enabled bool
|
enabled bool
|
||||||
@ -19,9 +17,6 @@ type Switch struct {
|
|||||||
checked bool
|
checked bool
|
||||||
text string
|
text string
|
||||||
|
|
||||||
config config.Wrapped
|
|
||||||
theme theme.Wrapped
|
|
||||||
|
|
||||||
onToggle func ()
|
onToggle func ()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -32,7 +27,7 @@ func NewSwitch (text string, on bool) (element *Switch) {
|
|||||||
text: text,
|
text: text,
|
||||||
enabled: true,
|
enabled: true,
|
||||||
}
|
}
|
||||||
element.entity = tomo.NewEntity(element).(tomo.FocusableEntity)
|
element.entity = tomo.NewEntity(element).(checkboxEntity)
|
||||||
element.theme.Case = tomo.C("tomo", "switch")
|
element.theme.Case = tomo.C("tomo", "switch")
|
||||||
element.drawer.SetFace (element.theme.FontFace (
|
element.drawer.SetFace (element.theme.FontFace (
|
||||||
tomo.FontStyleRegular,
|
tomo.FontStyleRegular,
|
||||||
@ -48,7 +43,7 @@ func (element *Switch) Entity () tomo.Entity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Draw causes the element to draw to the specified destination canvas.
|
// Draw causes the element to draw to the specified destination canvas.
|
||||||
func (element *Switch) Draw (destination canvas.Canvas) {
|
func (element *Switch) Draw (destination artist.Canvas) {
|
||||||
bounds := element.entity.Bounds()
|
bounds := element.entity.Bounds()
|
||||||
handleBounds := image.Rect(0, 0, bounds.Dy(), bounds.Dy()).Add(bounds.Min)
|
handleBounds := image.Rect(0, 0, bounds.Dy(), bounds.Dy()).Add(bounds.Min)
|
||||||
gutterBounds := image.Rect(0, 0, bounds.Dy() * 2, bounds.Dy()).Add(bounds.Min)
|
gutterBounds := image.Rect(0, 0, bounds.Dy() * 2, bounds.Dy()).Add(bounds.Min)
|
||||||
|
@ -4,7 +4,6 @@ import "image"
|
|||||||
import "git.tebibyte.media/sashakoshka/tomo"
|
import "git.tebibyte.media/sashakoshka/tomo"
|
||||||
import "git.tebibyte.media/sashakoshka/tomo/input"
|
import "git.tebibyte.media/sashakoshka/tomo/input"
|
||||||
import "git.tebibyte.media/sashakoshka/tomo/artist"
|
import "git.tebibyte.media/sashakoshka/tomo/artist"
|
||||||
import "git.tebibyte.media/sashakoshka/tomo/ability"
|
|
||||||
import "git.tebibyte.media/sashakoshka/tomo/artist/shapes"
|
import "git.tebibyte.media/sashakoshka/tomo/artist/shapes"
|
||||||
import "git.tebibyte.media/sashakoshka/tomo/artist/artutil"
|
import "git.tebibyte.media/sashakoshka/tomo/artist/artutil"
|
||||||
|
|
||||||
@ -13,7 +12,7 @@ var mouseCase = tomo.C("tomo", "mouse")
|
|||||||
// Mouse is an element capable of testing mouse input. When the mouse is clicked
|
// Mouse is an element capable of testing mouse input. When the mouse is clicked
|
||||||
// and dragged on it, it draws a trail.
|
// and dragged on it, it draws a trail.
|
||||||
type Mouse struct {
|
type Mouse struct {
|
||||||
entity ability.ThemeableEntity
|
entity tomo.Entity
|
||||||
pressed bool
|
pressed bool
|
||||||
lastMousePos image.Point
|
lastMousePos image.Point
|
||||||
}
|
}
|
||||||
@ -21,7 +20,7 @@ type Mouse struct {
|
|||||||
// NewMouse creates a new mouse test element.
|
// NewMouse creates a new mouse test element.
|
||||||
func NewMouse () (element *Mouse) {
|
func NewMouse () (element *Mouse) {
|
||||||
element = &Mouse { }
|
element = &Mouse { }
|
||||||
element.entity = tomo.GetBackend().NewEntity(element).(ability.ThemeableEntity)
|
element.entity = tomo.GetBackend().NewEntity(element)
|
||||||
element.entity.SetMinimumSize(32, 32)
|
element.entity.SetMinimumSize(32, 32)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -7,23 +7,14 @@ import "git.tebibyte.media/sashakoshka/tomo"
|
|||||||
import "git.tebibyte.media/sashakoshka/tomo/data"
|
import "git.tebibyte.media/sashakoshka/tomo/data"
|
||||||
import "git.tebibyte.media/sashakoshka/tomo/input"
|
import "git.tebibyte.media/sashakoshka/tomo/input"
|
||||||
import "git.tebibyte.media/sashakoshka/tomo/artist"
|
import "git.tebibyte.media/sashakoshka/tomo/artist"
|
||||||
import "git.tebibyte.media/sashakoshka/tomo/canvas"
|
|
||||||
import "git.tebibyte.media/sashakoshka/tomo/textdraw"
|
import "git.tebibyte.media/sashakoshka/tomo/textdraw"
|
||||||
import "git.tebibyte.media/sashakoshka/tomo/textmanip"
|
import "git.tebibyte.media/sashakoshka/tomo/textmanip"
|
||||||
import "git.tebibyte.media/sashakoshka/tomo/fixedutil"
|
import "git.tebibyte.media/sashakoshka/tomo/fixedutil"
|
||||||
import "git.tebibyte.media/sashakoshka/tomo/artist/shapes"
|
import "git.tebibyte.media/sashakoshka/tomo/artist/shapes"
|
||||||
import "git.tebibyte.media/sashakoshka/tomo/default/theme"
|
|
||||||
import "git.tebibyte.media/sashakoshka/tomo/default/config"
|
|
||||||
|
|
||||||
type textBoxEntity interface {
|
|
||||||
tomo.FocusableEntity
|
|
||||||
tomo.ScrollableEntity
|
|
||||||
tomo.LayoutEntity
|
|
||||||
}
|
|
||||||
|
|
||||||
// TextBox is a single-line text input.
|
// TextBox is a single-line text input.
|
||||||
type TextBox struct {
|
type TextBox struct {
|
||||||
entity textBoxEntity
|
entity tomo.Entity
|
||||||
|
|
||||||
enabled bool
|
enabled bool
|
||||||
lastClick time.Time
|
lastClick time.Time
|
||||||
@ -36,9 +27,6 @@ type TextBox struct {
|
|||||||
placeholderDrawer textdraw.Drawer
|
placeholderDrawer textdraw.Drawer
|
||||||
valueDrawer textdraw.Drawer
|
valueDrawer textdraw.Drawer
|
||||||
|
|
||||||
config config.Wrapped
|
|
||||||
theme theme.Wrapped
|
|
||||||
|
|
||||||
onKeyDown func (key input.Key, modifiers input.Modifiers) (handled bool)
|
onKeyDown func (key input.Key, modifiers input.Modifiers) (handled bool)
|
||||||
onChange func ()
|
onChange func ()
|
||||||
onEnter func ()
|
onEnter func ()
|
||||||
@ -71,7 +59,7 @@ func (element *TextBox) Entity () tomo.Entity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Draw causes the element to draw to the specified destination canvas.
|
// Draw causes the element to draw to the specified destination canvas.
|
||||||
func (element *TextBox) Draw (destination canvas.Canvas) {
|
func (element *TextBox) Draw (destination artist.Canvas) {
|
||||||
bounds := element.entity.Bounds()
|
bounds := element.entity.Bounds()
|
||||||
|
|
||||||
state := element.state()
|
state := element.state()
|
||||||
|
@ -3,23 +3,18 @@ package elements
|
|||||||
import "image"
|
import "image"
|
||||||
import "git.tebibyte.media/sashakoshka/tomo"
|
import "git.tebibyte.media/sashakoshka/tomo"
|
||||||
import "git.tebibyte.media/sashakoshka/tomo/input"
|
import "git.tebibyte.media/sashakoshka/tomo/input"
|
||||||
import "git.tebibyte.media/sashakoshka/tomo/canvas"
|
import "git.tebibyte.media/sashakoshka/tomo/artist"
|
||||||
import "git.tebibyte.media/sashakoshka/tomo/default/theme"
|
|
||||||
import "git.tebibyte.media/sashakoshka/tomo/default/config"
|
|
||||||
import "git.tebibyte.media/sashakoshka/tomo/textdraw"
|
import "git.tebibyte.media/sashakoshka/tomo/textdraw"
|
||||||
|
|
||||||
// ToggleButton is a togglable button.
|
// ToggleButton is a togglable button.
|
||||||
type ToggleButton struct {
|
type ToggleButton struct {
|
||||||
entity tomo.FocusableEntity
|
entity tomo.Entity
|
||||||
drawer textdraw.Drawer
|
drawer textdraw.Drawer
|
||||||
|
|
||||||
enabled bool
|
enabled bool
|
||||||
pressed bool
|
pressed bool
|
||||||
on bool
|
on bool
|
||||||
text string
|
text string
|
||||||
|
|
||||||
config config.Wrapped
|
|
||||||
theme theme.Wrapped
|
|
||||||
|
|
||||||
showText bool
|
showText bool
|
||||||
hasIcon bool
|
hasIcon bool
|
||||||
@ -35,7 +30,7 @@ func NewToggleButton (text string, on bool) (element *ToggleButton) {
|
|||||||
enabled: true,
|
enabled: true,
|
||||||
on: on,
|
on: on,
|
||||||
}
|
}
|
||||||
element.entity = tomo.NewEntity(element).(tomo.FocusableEntity)
|
element.entity = tomo.NewEntity(element)
|
||||||
element.theme.Case = tomo.C("tomo", "toggleButton")
|
element.theme.Case = tomo.C("tomo", "toggleButton")
|
||||||
element.drawer.SetFace (element.theme.FontFace (
|
element.drawer.SetFace (element.theme.FontFace (
|
||||||
tomo.FontStyleRegular,
|
tomo.FontStyleRegular,
|
||||||
@ -50,7 +45,7 @@ func (element *ToggleButton) Entity () tomo.Entity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Draw causes the element to draw to the specified destination canvas.
|
// Draw causes the element to draw to the specified destination canvas.
|
||||||
func (element *ToggleButton) Draw (destination canvas.Canvas) {
|
func (element *ToggleButton) Draw (destination artist.Canvas) {
|
||||||
state := element.state()
|
state := element.state()
|
||||||
bounds := element.entity.Bounds()
|
bounds := element.entity.Bounds()
|
||||||
pattern := element.theme.Pattern(tomo.PatternButton, state)
|
pattern := element.theme.Pattern(tomo.PatternButton, state)
|
||||||
|
@ -1,18 +1,22 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import "git.tebibyte.media/sashakoshka/tomo"
|
import "git.tebibyte.media/sashakoshka/tomo"
|
||||||
|
import "git.tebibyte.media/sashakoshka/tomo/nasin"
|
||||||
import "git.tebibyte.media/sashakoshka/tomo/elements/testing"
|
import "git.tebibyte.media/sashakoshka/tomo/elements/testing"
|
||||||
import _ "git.tebibyte.media/sashakoshka/tomo/backends/all"
|
|
||||||
import "git.tebibyte.media/sashakoshka/ezprof/ez"
|
import "git.tebibyte.media/sashakoshka/ezprof/ez"
|
||||||
|
|
||||||
func main () {
|
func main () {
|
||||||
tomo.Run(run)
|
nasin.Run(Application { })
|
||||||
}
|
}
|
||||||
|
|
||||||
func run () {
|
type Application struct { }
|
||||||
window, _ := tomo.NewWindow(tomo.Bounds(0, 0, 480, 360))
|
|
||||||
|
func (Application) Init () error {
|
||||||
|
window, err := nasin.NewWindow(tomo.Bounds(0, 0, 480, 360))
|
||||||
|
if err != nil { return err }
|
||||||
window.Adopt(testing.NewArtist())
|
window.Adopt(testing.NewArtist())
|
||||||
window.OnClose(tomo.Stop)
|
window.OnClose(nasin.Stop)
|
||||||
window.Show()
|
window.Show()
|
||||||
ez.Prof()
|
ez.Prof()
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user