From f3af1f5b7ff78b3f73d7510622fc9633dec36d35 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Wed, 19 Oct 2022 13:23:22 -0500 Subject: Refactor to 'gui/toolkit/' * add a example cmds/consolemouse uses a console button to launch the andlabs/ui * fix wrong return value in toolkit/NewLabel() * redirect STDIN output to a file * wonderful fix of Window() exit * finally remove the ancient stupid variables x & y * phase out struct 'box' and use 'node' instead * better names for things: use NewFoo() and NewBar() --- window-demo-toolkit.go | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 window-demo-toolkit.go (limited to 'window-demo-toolkit.go') diff --git a/window-demo-toolkit.go b/window-demo-toolkit.go new file mode 100644 index 0000000..df6268e --- /dev/null +++ b/window-demo-toolkit.go @@ -0,0 +1,43 @@ +package gui + +import "log" +// import "time" +import toolkit "git.wit.org/wit/gui/toolkit/andlabs" + +func NewStandardWindow(title string) *Node { + log.Println("NewStandardWindow() creating", title) + + Config.Title = title + Config.Width = 640 + Config.Height = 480 + Config.Exit = StandardClose + return NewWindow() +} + +// +// This creates a window that shows how the toolkit works +// internally using it's raw unchanged code for the toolkit itself +// +// This is a way to test and see if the toolkit is working at all +// right now it shows the andlabs/ui/DemoNumbersPage() +// +func DemoToolkitWindow() { + var w, d *Node + var tk *toolkit.Toolkit + + w = NewStandardWindow("Demo of the GUI Toolkit") + + d = w.New("demo") + + tk = toolkit.DemoNumbersPage(w.uiWindow) + tk.OnChanged = func(t *toolkit.Toolkit) { + log.Println("toolkit.NewSlider() value =", t.Value()) + if (d.OnChanged != nil) { + log.Println("toolkit.Demo() running node.OnChanged") + d.OnChanged(d) + } + } + d.Toolkit = tk + + log.Println("ToolkitDemoWindow() END") +} -- cgit v1.2.3