From 3ad83abc3aa5f33394ddba89764a8b7feb189460 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Mon, 25 Oct 2021 05:46:25 -0500 Subject: [PATCH] DEMO: leave a clean "pure" andlabs/ui tab example Signed-off-by: Jeff Carr --- window-demo-andlabs-ui.go | 84 +++++++++++++++++++++++++++++++++++++++ window-demo.go | 4 +- 2 files changed, 86 insertions(+), 2 deletions(-) create mode 100644 window-demo-andlabs-ui.go diff --git a/window-demo-andlabs-ui.go b/window-demo-andlabs-ui.go new file mode 100644 index 0000000..f7f5606 --- /dev/null +++ b/window-demo-andlabs-ui.go @@ -0,0 +1,84 @@ +package gui + +import "log" +import "github.com/andlabs/ui" +import _ "github.com/andlabs/ui/winmanifest" + +// This will create a tab in a window using direct +// calls to andlabs/ui. This can be used to bypass +// the obvuscation added in this package if it is desired +// or needed. +func (n *Node) AddAndlabsUiDemoTab(title string) { + newNode := n.AddTab(title, makeAndlabsUiTab()) + if (Config.DebugNode) { + newNode.Dump() + } + tabSetMargined(newNode.uiTab) +} + +func makeAndlabsUiTab() ui.Control { + hbox := ui.NewHorizontalBox() + hbox.SetPadded(true) + + group := ui.NewGroup("Numbers") + group.SetMargined(true) + hbox.Append(group, true) + + vbox := ui.NewVerticalBox() + vbox.SetPadded(true) + group.SetChild(vbox) + + spinbox := ui.NewSpinbox(47, 100) + slider := ui.NewSlider(21, 100) + pbar := ui.NewProgressBar() + + spinbox.OnChanged(func(*ui.Spinbox) { + slider.SetValue(spinbox.Value()) + pbar.SetValue(spinbox.Value()) + }) + slider.OnChanged(func(*ui.Slider) { + spinbox.SetValue(slider.Value()) + pbar.SetValue(slider.Value()) + }) + vbox.Append(spinbox, false) + vbox.Append(slider, false) + vbox.Append(pbar, false) + + ip := ui.NewProgressBar() + ip.SetValue(-1) + vbox.Append(ip, false) + + group = ui.NewGroup("Lists") + group.SetMargined(true) + hbox.Append(group, true) + + vbox = ui.NewVerticalBox() + vbox.SetPadded(true) + group.SetChild(vbox) + + cbox := ui.NewCombobox() + cbox.Append("Combobox Item 1") + cbox.Append("Combobox Item 2") + cbox.Append("Combobox Item 3") + vbox.Append(cbox, false) + + ecbox := ui.NewEditableCombobox() + ecbox.Append("Editable Item 1") + ecbox.Append("Editable Item 2") + ecbox.Append("Editable Item 3") + vbox.Append(ecbox, false) + + ecbox.OnChanged(func(*ui.EditableCombobox) { + log.Println("test") + test := ecbox.Text() + log.Println("test=", test) + }) + + rb := ui.NewRadioButtons() + rb.Append("Radio Button 1") + rb.Append("Radio Button 2") + rb.Append("Radio Button 3") + vbox.Append(rb, false) + + return hbox +} diff --git a/window-demo.go b/window-demo.go index 82162dd..8d205b5 100644 --- a/window-demo.go +++ b/window-demo.go @@ -5,14 +5,14 @@ import "github.com/andlabs/ui" import _ "github.com/andlabs/ui/winmanifest" func (n *Node) AddDemoTab(title string) { - newNode := n.AddTab(title, makeWindowTemplate()) + newNode := n.AddTab(title, makeDemoTab()) if (Config.DebugNode) { newNode.Dump() } tabSetMargined(newNode.uiTab) } -func makeWindowTemplate() ui.Control { +func makeDemoTab() ui.Control { hbox := ui.NewHorizontalBox() hbox.SetPadded(true)