2024-01-20 16:13:54 -06:00
|
|
|
// This creates a simple hello world window
|
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"go.wit.com/gui"
|
|
|
|
"go.wit.com/lib/gadgets"
|
|
|
|
"go.wit.com/log"
|
|
|
|
)
|
|
|
|
|
|
|
|
type choices struct {
|
|
|
|
group *gui.Node // the group
|
|
|
|
grid *gui.Node // the grid
|
|
|
|
hello *gui.Node // the hello button
|
|
|
|
computers *gui.Node
|
|
|
|
colors *gui.Node
|
|
|
|
checkers *gui.Node
|
|
|
|
|
2024-01-20 21:22:43 -06:00
|
|
|
socks *gadgets.OneLiner
|
|
|
|
animal *gadgets.BasicCombobox
|
|
|
|
place *gadgets.BasicEntry
|
2024-01-20 16:13:54 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
// This initializes the first window and some widgets
|
|
|
|
func newChoices(parent *gui.Node) *choices {
|
|
|
|
var c *choices
|
|
|
|
c = new(choices)
|
|
|
|
c.group = parent.NewGroup("choices")
|
|
|
|
c.grid = c.group.NewGrid("gridiron", 2, 1)
|
|
|
|
c.grid.NewButton("hello", func() {
|
|
|
|
log.Info("world")
|
|
|
|
})
|
2024-01-27 09:04:43 -06:00
|
|
|
c.grid.NewButton("toggle basic window", func() {
|
2024-01-20 16:13:54 -06:00
|
|
|
basicWindow.Toggle()
|
|
|
|
})
|
|
|
|
c.grid.NewLabel("a label")
|
|
|
|
|
|
|
|
c.computers = c.grid.NewDropdown().SetProgName("COMPUTERS")
|
|
|
|
c.computers.AddText("Atari 500")
|
|
|
|
c.computers.AddText("Beagleboard")
|
|
|
|
c.computers.AddText("Unmatched Rev B")
|
|
|
|
c.computers.SetText("Beagleboard")
|
2024-02-02 15:13:21 -06:00
|
|
|
c.computers.Custom = func() {
|
|
|
|
log.Info("You changed the computer to:", c.computers.String())
|
|
|
|
}
|
2024-01-20 16:13:54 -06:00
|
|
|
|
|
|
|
c.colors = c.grid.NewCombobox().SetProgName("COLORS")
|
|
|
|
c.colors.AddText("Cyan")
|
|
|
|
c.colors.AddText("Magenta")
|
|
|
|
c.colors.AddText("Yellow")
|
|
|
|
c.colors.SetText("orange")
|
|
|
|
|
|
|
|
c.checkers = c.grid.NewCheckbox("Checkers").SetProgName("CHECKERS")
|
|
|
|
c.checkers.Custom = func() {
|
|
|
|
log.Info("Checkers is", c.checkers.Bool())
|
|
|
|
}
|
|
|
|
|
|
|
|
c.socks = gadgets.NewOneLiner(c.grid, "two for one")
|
|
|
|
c.socks.SetValue("socks")
|
|
|
|
|
2024-01-20 21:22:43 -06:00
|
|
|
c.animal = gadgets.NewBasicCombobox(c.grid, "animals")
|
|
|
|
c.animal.AddText("otter")
|
|
|
|
c.animal.AddText("honey badger")
|
|
|
|
c.animal.AddText("polar bear")
|
|
|
|
|
2024-01-26 12:03:03 -06:00
|
|
|
c.place = gadgets.NewBasicEntry(c.grid, "common favorite place")
|
2024-01-27 09:04:43 -06:00
|
|
|
c.place.Custom = func() {
|
2024-01-26 12:03:03 -06:00
|
|
|
log.Info("now set to:", c.place.String())
|
|
|
|
if c.place == section1.place {
|
|
|
|
section2.place.SetText(c.place.String())
|
|
|
|
}
|
|
|
|
if c.place == section2.place {
|
|
|
|
section1.place.SetText(c.place.String())
|
|
|
|
}
|
|
|
|
}
|
2024-01-20 21:22:43 -06:00
|
|
|
c.place.SetText("coffee shop")
|
|
|
|
|
2024-01-27 09:04:43 -06:00
|
|
|
c.grid.NewButton("enable animals", func() {
|
|
|
|
c.animal.Enable()
|
|
|
|
})
|
|
|
|
c.grid.NewButton("disable animals", func() {
|
|
|
|
c.animal.Disable()
|
|
|
|
})
|
|
|
|
|
2024-01-20 16:13:54 -06:00
|
|
|
return c
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *choices) SetSocks(s string) *choices {
|
|
|
|
c.socks.SetValue(s)
|
|
|
|
return c
|
|
|
|
}
|