Compare commits

..

2 Commits

Author SHA1 Message Date
dfd566b23d Include new objects in Wintergreen theme 2024-05-07 20:22:53 -04:00
da4af8d240 Add examples 2024-05-07 20:22:39 -04:00
5 changed files with 88 additions and 24 deletions

View File

@ -8,6 +8,8 @@ import "git.tebibyte.media/tomo/objects"
import "git.tebibyte.media/tomo/tomo/theme"
import "git.tebibyte.media/tomo/objects/layouts"
const scrollIcons = false
type Application struct {
size theme.IconSize
grid tomo.ContainerBox
@ -50,9 +52,16 @@ func (this *Application) Init () error {
container := objects.NewOuterContainer (
layouts.NewGrid([]bool { true }, []bool { false, true, false }),
objects.NewLabel("A smorgasbord of icons:"),
this.grid,
iconButtons)
objects.NewLabel("A smorgasbord of icons:"))
if scrollIcons {
iconScroller := objects.NewScrollContainer(objects.ScrollVertical)
this.grid.SetOverflow(false, true)
iconScroller.SetRoot(this.grid)
container.Add(iconScroller)
} else {
container.Add(this.grid)
}
container.Add(iconButtons)
window.SetRoot(container)
window.OnClose(tomo.Stop)

37
examples/inputs/main.go Normal file
View File

@ -0,0 +1,37 @@
// Example inputs demonstrates the use of various user input methods.
package main
import "image"
import "git.tebibyte.media/tomo/tomo"
import "git.tebibyte.media/tomo/nasin"
import "git.tebibyte.media/tomo/objects"
// import "git.tebibyte.media/tomo/tomo/theme"
import "git.tebibyte.media/tomo/objects/layouts"
type Application struct { }
func (this *Application) Describe () nasin.ApplicationDescription {
return nasin.ApplicationDescription {
Name: "Tomo Input Example",
ID: "xyz.holanet.TomoInputExample",
}
}
func (this *Application) Init () error {
window, err := nasin.NewApplicationWindow(this, image.Rect(0, 0, 128, 128))
if err != nil { return err }
window.SetRoot(objects.NewOuterContainer(layouts.Column { },
objects.NewTextInput(""),
objects.NewHorizontalSlider(0.5),
objects.NewLabelCheckbox(false, "checkbox"),
))
window.OnClose(tomo.Stop)
window.Show()
return nil
}
func main () {
nasin.RunApplication(&Application { })
}

2
go.mod
View File

@ -3,7 +3,7 @@ module git.tebibyte.media/tomo/nasin
go 1.20
require (
git.tebibyte.media/tomo/objects v0.9.0
git.tebibyte.media/tomo/objects v0.10.0
git.tebibyte.media/tomo/tomo v0.31.0
git.tebibyte.media/tomo/x v0.7.1
git.tebibyte.media/tomo/xdg v0.1.0

4
go.sum
View File

@ -1,6 +1,6 @@
git.tebibyte.media/sashakoshka/xgbkb v1.0.0/go.mod h1:pNcE6TRO93vHd6q42SdwLSTTj25L0Yzggz7yLe0JV6Q=
git.tebibyte.media/tomo/objects v0.9.0 h1:ElyltNRAHRliSZX80BL7vTWzip/d0P46gaCtGZeJhB4=
git.tebibyte.media/tomo/objects v0.9.0/go.mod h1:34UDkPEHxBgIsAYWyqqE4u1KvVtwzwdpCO6AdkgsrKo=
git.tebibyte.media/tomo/objects v0.10.0 h1:wrqWCW9z4thqPqGWlTsNAMGgrcrJPsvXYCjoLlymMMk=
git.tebibyte.media/tomo/objects v0.10.0/go.mod h1:34UDkPEHxBgIsAYWyqqE4u1KvVtwzwdpCO6AdkgsrKo=
git.tebibyte.media/tomo/tomo v0.31.0 h1:LHPpj3AWycochnC8F441aaRNS6Tq6w6WnBrp/LGjyhM=
git.tebibyte.media/tomo/tomo v0.31.0/go.mod h1:C9EzepS9wjkTJjnZaPBh22YvVPyA4hbBAJVU20Rdmps=
git.tebibyte.media/tomo/typeset v0.7.1 h1:aZrsHwCG5ZB4f5CruRFsxLv5ezJUCFUFsQJJso2sXQ8=

View File

@ -109,24 +109,7 @@ var rules = []dataTheme.Rule {
dataTheme.Rule {
Role: theme.R("", "NumberInput", ""),
Default: dataTheme.AS (
dataTheme.AttrBorder {
outline,
tomo.Border {
Width: tomo.I(1),
Color: borderColorInput,
},
},
dataTheme.AttrColor { Color: colorInput },
dataTheme.AttrPadding(tomo.I(5, 4, 4, 5)),
),
Focused: dataTheme.AS (
dataTheme.AttrBorder {
outline,
tomo.Border {
Width: tomo.I(1),
Color: borderColorFocused,
},
},
dataTheme.AttrGap { },
),
},
@ -213,4 +196,39 @@ var rules = []dataTheme.Rule {
dataTheme.AttrMinimumSize { X: 12, Y: 12, },
),
},
// *.Checkbox[*]
dataTheme.Rule {
Role: theme.R("", "Checkbox", ""),
Default: dataTheme.AS (
dataTheme.AttrBorder {
outline,
tomo.Border {
Width: tomo.I(1, 0, 0, 1),
Color: borderColorEngraved,
},
},
dataTheme.AttrColor { Color: theme.ColorSunken },
dataTheme.AttrPadding(tomo.I(0, 1, 1, 0)),
dataTheme.AttrMinimumSize { X: 19, Y: 19 },
),
Focused: dataTheme.AS (
dataTheme.AttrBorder {
outline,
tomo.Border {
Width: tomo.I(1),
Color: borderColorFocused,
},
},
dataTheme.AttrPadding(tomo.I(0)),
),
},
// *.LabelCheckbox[*]
dataTheme.Rule {
Role: theme.R("", "LabelCheckbox", ""),
Default: dataTheme.AS (
dataTheme.AttrGap { X: 8, Y: 8 },
),
},
}