Update Tomo API

This commit is contained in:
Sasha Koshka 2024-05-27 15:22:18 -04:00
parent 6389556199
commit bd9dbb762d
6 changed files with 13 additions and 16 deletions

View File

@ -31,8 +31,7 @@ func NewCheckbox (value bool) *Checkbox {
func (this *Checkbox) SetValue (value bool) { func (this *Checkbox) SetValue (value bool) {
this.value = value this.value = value
if this.value { if this.value {
// FIXME: we need checkbox icons this.SetTextureCenter(tomo.IconCheckboxChecked.Texture(tomo.IconSizeSmall))
this.SetTextureCenter(tomo.Icon("").Texture(tomo.IconSizeSmall))
} else { } else {
this.SetTextureCenter(nil) this.SetTextureCenter(nil)
} }

View File

@ -75,8 +75,7 @@ func NewDialog (kind DialogKind, parent tomo.Window, title, message string, opti
// NewDialogOk creates a new dialog window with an OK option. // NewDialogOk creates a new dialog window with an OK option.
func NewDialogOk (kind DialogKind, parent tomo.Window, title, message string, onOk func ()) (*Dialog, error) { func NewDialogOk (kind DialogKind, parent tomo.Window, title, message string, onOk func ()) (*Dialog, error) {
okButton := NewButton("OK") okButton := NewButton("OK")
// FIXME: need dialog accept/reject action icons okButton.SetIcon(tomo.IconDialogOkay)
// okButton.SetIcon(tomo.IconStatusOkay)
okButton.OnClick(func () { okButton.OnClick(func () {
if onOk != nil { onOk() } if onOk != nil { onOk() }
}) })
@ -88,12 +87,10 @@ func NewDialogOk (kind DialogKind, parent tomo.Window, title, message string, on
// NewDialogOkCancel creates a new dialog window with OK and Cancel options. // NewDialogOkCancel creates a new dialog window with OK and Cancel options.
func NewDialogOkCancel (kind DialogKind, parent tomo.Window, title, message string, onOk func ()) (*Dialog, error) { func NewDialogOkCancel (kind DialogKind, parent tomo.Window, title, message string, onOk func ()) (*Dialog, error) {
cancelButton := NewButton("Cancel") cancelButton := NewButton("Cancel")
// FIXME: need dialog accept/reject action icons cancelButton.SetIcon(tomo.IconDialogCancel)
// cancelButton.SetIcon(tomo.IconStatusCancel)
okButton := NewButton("OK") okButton := NewButton("OK")
// FIXME: need dialog accept/reject action icons okButton.SetIcon(tomo.IconDialogOkay)
// okButton.SetIcon(tomo.IconStatusOkay)
okButton.OnClick(func () { okButton.OnClick(func () {
if onOk != nil { onOk() } if onOk != nil { onOk() }
}) })

2
go.mod
View File

@ -2,6 +2,6 @@ module git.tebibyte.media/tomo/objects
go 1.20 go 1.20
require git.tebibyte.media/tomo/tomo v0.33.0 require git.tebibyte.media/tomo/tomo v0.34.0
require golang.org/x/image v0.11.0 // indirect require golang.org/x/image v0.11.0 // indirect

4
go.sum
View File

@ -1,5 +1,5 @@
git.tebibyte.media/tomo/tomo v0.33.0 h1:BBm1oRsogBLeqVKeevNqG9RPCOdmbGeiQM/9hd2GHE8= git.tebibyte.media/tomo/tomo v0.34.0 h1:r5yJPks9rtzdDI2RyAUdqa1qb6BebG0QFe2cTmcFi+0=
git.tebibyte.media/tomo/tomo v0.33.0/go.mod h1:C9EzepS9wjkTJjnZaPBh22YvVPyA4hbBAJVU20Rdmps= git.tebibyte.media/tomo/tomo v0.34.0/go.mod h1:C9EzepS9wjkTJjnZaPBh22YvVPyA4hbBAJVU20Rdmps=
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=

View File

@ -33,8 +33,8 @@ func NewNumberInput (value float64) *NumberInput {
box.Add(box.decrement) box.Add(box.decrement)
box.Add(box.increment) box.Add(box.increment)
box.SetLayout(layouts.NewGrid([]bool { true, false, false }, []bool { true })) box.SetLayout(layouts.NewGrid([]bool { true, false, false }, []bool { true }))
box.increment.SetIcon(tomo.IconListAdd) // FIXME: need incr/decrment icons box.increment.SetIcon(tomo.IconValueIncrement)
box.decrement.SetIcon(tomo.IconListRemove) box.decrement.SetIcon(tomo.IconValueDecrement)
box.SetValue(value) box.SetValue(value)

View File

@ -306,9 +306,10 @@ func (this scrollbarLayout) Arrange (hints tomo.LayoutHints, boxes []tomo.Box) {
handleLength := gutterLength * this.viewportContentRatio() handleLength := gutterLength * this.viewportContentRatio()
if handleLength < handleMin { handleLength = handleMin } if handleLength < handleMin { handleLength = handleMin }
if handleLength >= gutterLength { if handleLength >= gutterLength {
// just hide the handle if it isn't needed. // just hide the handle if it isn't needed. we are the layout
// TODO: we need a way to hide and show boxes, this is janky as // and we shouldn't be adding and removing boxes, so this is
// fuck // really the only good way to hide things.
// TODO perhaps have a "Hidden" rectangle in the Tomo API?
boxes[0].SetBounds(image.Rect(-16, -16, 0, 0)) boxes[0].SetBounds(image.Rect(-16, -16, 0, 0))
return return
} }