Upgrade tomo version

This commit is contained in:
Sasha Koshka 2023-08-24 16:34:52 -04:00
parent 0d7536b575
commit e00bc615c2
3 changed files with 29 additions and 23 deletions

2
go.mod
View File

@ -3,6 +3,6 @@ module git.tebibyte.media/tomo/aluminum
go 1.20
require (
git.tebibyte.media/tomo/tomo v0.24.0
git.tebibyte.media/tomo/tomo v0.26.1
golang.org/x/image v0.11.0
)

4
go.sum
View File

@ -1,5 +1,5 @@
git.tebibyte.media/tomo/tomo v0.24.0 h1:Zv5S/SmGjoEzssIOx/ADZBmnIfdeeVEwHdHVQHcls9M=
git.tebibyte.media/tomo/tomo v0.24.0/go.mod h1:C9EzepS9wjkTJjnZaPBh22YvVPyA4hbBAJVU20Rdmps=
git.tebibyte.media/tomo/tomo v0.26.1 h1:V5ciRuixMYb79aAawgquFEfJ1icyEmMKBKFPWwi94NE=
git.tebibyte.media/tomo/tomo v0.26.1/go.mod h1:C9EzepS9wjkTJjnZaPBh22YvVPyA4hbBAJVU20Rdmps=
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-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=

View File

@ -8,6 +8,7 @@ import "git.tebibyte.media/tomo/tomo/data"
import "git.tebibyte.media/tomo/tomo/theme"
import "git.tebibyte.media/tomo/tomo/input"
import "git.tebibyte.media/tomo/tomo/event"
import "git.tebibyte.media/tomo/tomo/canvas"
func hex (color uint32) (c color.RGBA) {
c.A = uint8(color)
@ -45,7 +46,9 @@ var backgroundColor = hex(0xd6d6d6FF)
var gutterColor = hex(0xbfc6d1FF)
var gutterColorHovered = hex(0xc5cbd6FF)
type Theme struct { }
type Theme struct {
initialized bool
}
func (this *Theme) RGBA (id theme.Color) (r, g, b, a uint32) {
switch id {
@ -67,11 +70,11 @@ func (this *Theme) Apply (object tomo.Object, role theme.Role) event.Cookie {
textBox.SetTextColor(textColor)
textBox.SetFace(basicfont.Face7x13)
}
if containerBox, ok := box.(tomo.ContainerBox); ok {
containerBox.SetGap(image.Pt(8, 8))
}
switch role.Object {
case "Button":
pressed := false
@ -85,7 +88,7 @@ func (this *Theme) Apply (object tomo.Object, role theme.Role) event.Cookie {
}
padding := tomo.I(4, 8)
box.SetColor(buttonColor)
if box.Focused() {
box.SetColor(buttonColorFocused)
border[1] = focusedBorder
@ -122,7 +125,7 @@ func (this *Theme) Apply (object tomo.Object, role theme.Role) event.Cookie {
hovered = false
updateStyle()
}))
case "TextInput", "NumberInput":
box.SetPadding(tomo.I(5, 4, 4, 5))
updateStyle := func () {
@ -132,31 +135,31 @@ func (this *Theme) Apply (object tomo.Object, role theme.Role) event.Cookie {
sunkenShadow,
}
box.SetColor(inputColor)
if box.Focused() {
border[1] = focusedBorder
}
box.SetBorder(border...)
}
updateStyle()
return event.MultiCookie (
box.OnFocusEnter(updateStyle),
box.OnFocusLeave(updateStyle))
case "Container":
if role.Variant == "outer" {
box.SetPadding(tomo.I(8))
}
}
case "Heading":
if textBox, ok := box.(tomo.TextBox); ok {
textBox.SetAlign(tomo.AlignMiddle, tomo.AlignMiddle)
}
case "Separator":
box.SetBorder(engravedBorder)
case "Slider":
pressed := false
hovered := false
@ -166,7 +169,7 @@ func (this *Theme) Apply (object tomo.Object, role theme.Role) event.Cookie {
} else {
box.SetMinimumSize(image.Pt(48, 0))
}
updateStyle := func () {
border := []tomo.Border {
engravedBorder,
@ -174,14 +177,14 @@ func (this *Theme) Apply (object tomo.Object, role theme.Role) event.Cookie {
sunkenShadow,
}
box.SetColor(gutterColor)
if box.Focused() {
border[1] = focusedBorder
}
if hovered && !pressed {
box.SetColor(gutterColorHovered)
}
box.SetBorder(border...)
}
updateStyle()
@ -204,7 +207,7 @@ func (this *Theme) Apply (object tomo.Object, role theme.Role) event.Cookie {
hovered = false
updateStyle()
}))
case "SliderHandle":
box.SetMinimumSize(image.Pt(12, 12))
border := []tomo.Border {
@ -212,30 +215,33 @@ func (this *Theme) Apply (object tomo.Object, role theme.Role) event.Cookie {
gapBorder,
buttonBorder,
}
box.SetBorder(border...)
box.SetBorder(border...)
box.SetColor(buttonColor)
}
return event.MultiCookie()
}
func (this *Theme) Icon (theme.Icon, theme.IconSize) tomo.Texture {
func (this *Theme) Icon (theme.Icon, theme.IconSize) canvas.Texture {
this.ensure()
// TODO
return nil
}
func (this *Theme) MimeIcon (data.Mime, theme.IconSize) tomo.Texture {
func (this *Theme) MimeIcon (data.Mime, theme.IconSize) canvas.Texture {
this.ensure()
// TODO
return nil
}
func (this *Theme) ApplicationIcon (theme.ApplicationIcon, theme.IconSize) tomo.Texture {
func (this *Theme) ApplicationIcon (theme.ApplicationIcon, theme.IconSize) canvas.Texture {
this.ensure()
// TODO
return nil
}
func (this *Theme) ensure () {
if this.initialized { return }
this.initialized = true
// TODO
}