2019-03-05 20:52:18 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"image/color"
|
|
|
|
"log"
|
|
|
|
|
|
|
|
"opslag.de/schobers/geom"
|
|
|
|
|
|
|
|
"opslag.de/schobers/zntg/allg5"
|
|
|
|
"opslag.de/schobers/zntg/ui"
|
|
|
|
"opslag.de/schobers/zntg/ui/allg5ui"
|
|
|
|
)
|
|
|
|
|
|
|
|
func run() error {
|
|
|
|
var render, err = allg5ui.NewRenderer(800, 600, allg5.NewDisplayOptions{})
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
defer render.Destroy()
|
|
|
|
|
|
|
|
err = render.RegisterFont("../resources/font/OpenSans-Regular.ttf", "default", 14)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2019-03-13 18:49:00 +00:00
|
|
|
plus, err := render.CreateImagePath("../resources/images/plus.png")
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
defer plus.Destroy()
|
2019-03-05 20:52:18 +00:00
|
|
|
|
2019-04-10 19:27:24 +00:00
|
|
|
var stretch = func(content ui.Control, margin float32) ui.Control {
|
|
|
|
return ui.BuildSpacing(content, func(s *ui.Spacing) {
|
|
|
|
s.Width = ui.Infinite()
|
|
|
|
s.Margin.Left = ui.Fixed(margin)
|
|
|
|
s.Margin.Top = ui.Fixed(margin)
|
|
|
|
s.Margin.Right = ui.Fixed(margin)
|
|
|
|
s.Margin.Bottom = ui.Fixed(margin)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
var view = ui.BuildStackPanel(ui.OrientationVertical, func(p *ui.StackPanel) {
|
|
|
|
p.Background = color.White
|
|
|
|
p.Children = []ui.Control{
|
2019-03-05 20:52:18 +00:00
|
|
|
&ui.Label{Text: "Hello, world!"},
|
2019-04-10 19:27:24 +00:00
|
|
|
ui.BuildStackPanel(ui.OrientationHorizontal, func(p *ui.StackPanel) {
|
|
|
|
p.Children = []ui.Control{
|
|
|
|
stretch(ui.BuildIconButton(plus, "Contained", func(b *ui.Button) { b.Type = ui.ButtonTypeContained }), 8),
|
|
|
|
stretch(ui.BuildIconButton(plus, "Icon", func(b *ui.Button) { b.Type = ui.ButtonTypeIcon }), 8),
|
|
|
|
stretch(ui.BuildIconButton(plus, "Outlined", func(b *ui.Button) { b.Type = ui.ButtonTypeOutlined }), 8),
|
|
|
|
stretch(ui.BuildIconButton(plus, "Text", func(b *ui.Button) { b.Type = ui.ButtonTypeText }), 8),
|
|
|
|
}
|
|
|
|
}),
|
2019-03-13 18:49:00 +00:00
|
|
|
ui.Margin(ui.BuildButton("Quit", func(b *ui.Button) {
|
2019-03-05 20:52:18 +00:00
|
|
|
b.OnClick(func(ctx ui.Context, _ ui.Control, _ geom.PointF32, _ ui.MouseButton) {
|
|
|
|
ctx.Quit()
|
|
|
|
})
|
2019-03-13 18:49:00 +00:00
|
|
|
}), 8),
|
2019-03-05 20:52:18 +00:00
|
|
|
ui.Stretch(&ui.Label{Text: "Content"}),
|
2019-04-10 19:27:24 +00:00
|
|
|
ui.StretchWidth(ui.BuildTextBox(func(b *ui.TextBox) {
|
|
|
|
b.Text = "Type here..."
|
|
|
|
})),
|
2019-03-05 20:52:18 +00:00
|
|
|
&ui.Label{Text: "Status"},
|
2019-04-10 19:27:24 +00:00
|
|
|
}
|
|
|
|
})
|
2019-03-05 20:52:18 +00:00
|
|
|
|
|
|
|
return ui.RunWait(render, ui.DefaultStyle(), view, true)
|
|
|
|
}
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
var err = run()
|
|
|
|
if err != nil {
|
|
|
|
log.Fatal(err)
|
|
|
|
}
|
|
|
|
}
|