doodle/lib/ui/eg/main.go
Noah Petherbridge b06c52a705 UI: Add MainWindow Widget and start an example app
* MainWindow is ideal for apps that just want a UI and
  don't manage their own SDL windows.
* The example app will grow into a series of demos that
  test the UI toolkit to help fix bugs and grow features.
2019-06-08 17:03:59 -07:00

48 lines
834 B
Go

package main
import (
"git.kirsle.net/apps/doodle/lib/render"
"git.kirsle.net/apps/doodle/lib/ui"
)
func main() {
mw, err := ui.NewMainWindow("UI Toolkit Demo")
if err != nil {
panic(err)
}
leftFrame := ui.NewFrame("Left Frame")
leftFrame.Configure(ui.Config{
Width: 200,
BorderSize: 1,
BorderStyle: ui.BorderRaised,
Background: render.Grey,
})
mw.Pack(leftFrame, ui.Pack{
Anchor: ui.W,
FillY: true,
})
mainFrame := ui.NewFrame("Main Frame")
mainFrame.Configure(ui.Config{
Background: render.RGBA(255, 255, 255, 180),
})
mw.Pack(mainFrame, ui.Pack{
Anchor: ui.W,
Expand: true,
PadX: 10,
})
label := ui.NewLabel(ui.Label{
Text: "Hello world",
})
leftFrame.Pack(label, ui.Pack{
Anchor: ui.SE,
})
err = mw.MainLoop()
if err != nil {
panic("MainLoop:" + err.Error())
}
}