Added the start of a Go version of the controlgallery example, to make sure everything works so far.

This commit is contained in:
Pietro Gagliardi 2018-08-12 12:46:30 -04:00
parent 925adc0782
commit f1717ca1df
1 changed files with 89 additions and 0 deletions

89
zz_controls.go Normal file
View File

@ -0,0 +1,89 @@
// 12 august 2018
// +build OMIT
package main
import (
"github.com/andlabs/ui"
)
func makeBasicControlsPage() ui.Control {
vbox := ui.NewVerticalBox()
vbox.SetPadded(true)
hbox := ui.NewHorizontalBox()
hbox.SetPadded(true)
vbox.Append(hbox, false)
hbox.Append(ui.NewButton("Button"), false)
hbox.Append(ui.NewCheckbox("Checkbox"), false)
vbox.Append(ui.NewLabel("This is a label. Right now, labels can only span one line."), false)
vbox.Append(ui.NewHorizontalSeparator(), false)
group := ui.NewGroup("Entries")
group.SetMargined(true)
vbox.Append(group, true)
/*
entryForm = uiNewForm();
uiFormSetPadded(entryForm, 1);
uiGroupSetChild(group, uiControl(entryForm));
uiFormAppend(entryForm,
"Entry",
uiControl(uiNewEntry()),
0);
uiFormAppend(entryForm,
"Password Entry",
uiControl(uiNewPasswordEntry()),
0);
uiFormAppend(entryForm,
"Search Entry",
uiControl(uiNewSearchEntry()),
0);
uiFormAppend(entryForm,
"Multiline Entry",
uiControl(uiNewMultilineEntry()),
1);
uiFormAppend(entryForm,
"Multiline Entry No Wrap",
uiControl(uiNewNonWrappingMultilineEntry()),
1);
*/
return vbox
}
func setupUI() {
mainwin := ui.NewWindow("libui Control Gallery", 640, 480, true)
mainwin.OnClosing(func(*ui.Window) bool {
ui.Quit()
return true
})
ui.OnShouldQuit(func() bool {
mainwin.Destroy()
return true
})
tab := ui.NewTab()
mainwin.SetChild(tab)
mainwin.SetMargined(true)
tab.Append("Basic Controls", makeBasicControlsPage())
tab.SetMargined(0, true)
// tab.Append("Numbers and Lists", makeNumbersPage());
// tab.SetMargined(1, true)
// tab.Append("Data Choosers", makeDataChoosersPage());
// tab.SetMargined(2, true)
mainwin.Show()
}
func main() {
ui.Main(setupUI)
}