summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2021-10-04 21:54:16 -0500
committerJeff Carr <[email protected]>2021-10-04 21:54:16 -0500
commite5b4e184fc20e13e4744ea7b3a46d57055460864 (patch)
tree2d83f56cfbf85e7b1d29505740b701258166894d
parentb5b1528a29d42d01597cb15b317177ca2237e535 (diff)
TAB: more tab handling cleanups
Signed-off-by: Jeff Carr <[email protected]>
-rw-r--r--structs.go17
-rw-r--r--window-template.go72
2 files changed, 87 insertions, 2 deletions
diff --git a/structs.go b/structs.go
index fa7c42c..a48f1c0 100644
--- a/structs.go
+++ b/structs.go
@@ -124,7 +124,7 @@ func (s GuiBox) InitTab(title string) {
s.Window.UiTab = tab
}
-func (s GuiBox) AddTab(title string) {
+func (s GuiBox) AddTab(title string, custom ui.Control) {
if (s.Window == nil) {
return
}
@@ -134,7 +134,20 @@ func (s GuiBox) AddTab(title string) {
tab := s.Window.UiTab
- tab.Append(title, InitBlankWindow())
+ tab.Append(title, custom)
+}
+
+func (s GuiBox) AddDemoTab(title string) {
+ if (s.Window == nil) {
+ return
+ }
+ if (s.Window.UiTab == nil) {
+ return
+ }
+
+ tab := s.Window.UiTab
+
+ tab.Append(title, makeWindowTemplate())
}
// Note: every mouse click is handled
diff --git a/window-template.go b/window-template.go
new file mode 100644
index 0000000..c3e30ef
--- /dev/null
+++ b/window-template.go
@@ -0,0 +1,72 @@
+package gui
+
+import "log"
+import "github.com/andlabs/ui"
+import _ "github.com/andlabs/ui/winmanifest"
+
+func makeWindowTemplate() 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
+}