move to "gui/widget"

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2024-01-05 13:18:44 -06:00
parent 80d0f34bc0
commit 6f1a7e9257
19 changed files with 101 additions and 101 deletions

6
box.go
View File

@ -1,14 +1,14 @@
package gui package gui
import ( import (
"go.wit.com/gui/toolkits" "go.wit.com/gui/widget"
) )
func (parent *Node) NewBox(name string, b bool) *Node { func (parent *Node) NewBox(name string, b bool) *Node {
newNode := parent.newNode(name, toolkit.Box) newNode := parent.newNode(name, widget.Box)
newNode.B = b newNode.B = b
a := newAction(newNode, toolkit.Add) a := newAction(newNode, widget.Add)
sendAction(a) sendAction(a)
return newNode return newNode
} }

View File

@ -1,12 +1,12 @@
package gui package gui
import "go.wit.com/gui/toolkits" import "go.wit.com/gui/widget"
func (parent *Node) NewButton(name string, custom func()) *Node { func (parent *Node) NewButton(name string, custom func()) *Node {
newNode := parent.newNode(name, toolkit.Button) newNode := parent.newNode(name, widget.Button)
newNode.Custom = custom newNode.Custom = custom
a := newAction(newNode, toolkit.Add) a := newAction(newNode, widget.Add)
sendAction(a) sendAction(a)
return newNode return newNode
} }

View File

@ -1,15 +1,15 @@
package gui package gui
import "go.wit.com/gui/toolkits" import "go.wit.com/gui/widget"
func (n *Node) Checked() bool { func (n *Node) Checked() bool {
return n.B return n.B
} }
func (n *Node) NewCheckbox(name string) *Node { func (n *Node) NewCheckbox(name string) *Node {
newNode := n.newNode(name, toolkit.Checkbox) newNode := n.newNode(name, widget.Checkbox)
a := newAction(newNode, toolkit.Add) a := newAction(newNode, widget.Add)
sendAction(a) sendAction(a)
return newNode return newNode
} }

View File

@ -6,31 +6,31 @@ import (
"regexp" "regexp"
"errors" "errors"
"go.wit.com/log" "go.wit.com/log"
"go.wit.com/gui/toolkits" "go.wit.com/gui/widget"
) )
// functions for handling text related GUI elements // functions for handling text related GUI elements
func (n *Node) Show() *Node { func (n *Node) Show() *Node {
a := newAction(n, toolkit.Show) a := newAction(n, widget.Show)
sendAction(a) sendAction(a)
return n return n
} }
func (n *Node) Hide() *Node { func (n *Node) Hide() *Node {
a := newAction(n, toolkit.Hide) a := newAction(n, widget.Hide)
sendAction(a) sendAction(a)
return n return n
} }
func (n *Node) Enable() *Node { func (n *Node) Enable() *Node {
a := newAction(n, toolkit.Enable) a := newAction(n, widget.Enable)
sendAction(a) sendAction(a)
return n return n
} }
func (n *Node) Disable() *Node { func (n *Node) Disable() *Node {
a := newAction(n, toolkit.Disable) a := newAction(n, widget.Disable)
sendAction(a) sendAction(a)
return n return n
} }
@ -40,7 +40,7 @@ func (n *Node) Add(str string) {
n.S = str n.S = str
a := newAction(n, toolkit.Add) a := newAction(n, widget.Add)
sendAction(a) sendAction(a)
} }
@ -50,7 +50,7 @@ func (n *Node) AddText(str string) {
n.Text = str n.Text = str
n.S = str n.S = str
a := newAction(n, toolkit.AddText) a := newAction(n, widget.AddText)
sendAction(a) sendAction(a)
} }
@ -60,7 +60,7 @@ func (n *Node) SetText(text string) *Node {
n.Text = text n.Text = text
n.S = text n.S = text
a := newAction(n, toolkit.SetText) a := newAction(n, widget.SetText)
sendAction(a) sendAction(a)
return n return n
} }
@ -86,7 +86,7 @@ func (n *Node) Set(val any) {
log.Error(errors.New("Set() unknown type"), "v =", v) log.Error(errors.New("Set() unknown type"), "v =", v)
} }
a := newAction(n, toolkit.Set) a := newAction(n, widget.Set)
sendAction(a) sendAction(a)
} }
@ -95,7 +95,7 @@ func (n *Node) AppendText(str string) {
n.Text = tmp n.Text = tmp
n.S = tmp n.S = tmp
a := newAction(n, toolkit.SetText) a := newAction(n, widget.SetText)
sendAction(a) sendAction(a)
} }
@ -169,31 +169,31 @@ func commonCallback(n *Node) {
} }
func (n *Node) Margin() *Node { func (n *Node) Margin() *Node {
a := newAction(n, toolkit.Margin) a := newAction(n, widget.Margin)
sendAction(a) sendAction(a)
return n return n
} }
func (n *Node) Unmargin() *Node { func (n *Node) Unmargin() *Node {
a := newAction(n, toolkit.Unmargin) a := newAction(n, widget.Unmargin)
sendAction(a) sendAction(a)
return n return n
} }
func (n *Node) Pad() *Node { func (n *Node) Pad() *Node {
a := newAction(n, toolkit.Pad) a := newAction(n, widget.Pad)
sendAction(a) sendAction(a)
return n return n
} }
func (n *Node) Unpad() *Node { func (n *Node) Unpad() *Node {
a := newAction(n, toolkit.Unpad) a := newAction(n, widget.Unpad)
sendAction(a) sendAction(a)
return n return n
} }
func (n *Node) Expand() *Node { func (n *Node) Expand() *Node {
a := newAction(n, toolkit.Pad) a := newAction(n, widget.Pad)
a.Expand = true a.Expand = true
sendAction(a) sendAction(a)
return n return n

View File

@ -9,7 +9,7 @@ import (
"strconv" "strconv"
"go.wit.com/log" "go.wit.com/log"
"go.wit.com/gui/toolkits" "go.wit.com/gui/widget"
) )
// for printing out the binary tree // for printing out the binary tree
@ -38,8 +38,8 @@ func (n *Node) Dump() {
} }
Indent(b, "NODE DUMP END") Indent(b, "NODE DUMP END")
a := new(toolkit.Action) a := new(widget.Action)
a.ActionType = toolkit.Dump a.ActionType = widget.Dump
a.WidgetId = n.id a.WidgetId = n.id
sendAction(a) sendAction(a)
} }

View File

@ -6,7 +6,7 @@ package gui
// since it is the same. confusing names? maybe... // since it is the same. confusing names? maybe...
import ( import (
"go.wit.com/gui/toolkits" "go.wit.com/gui/widget"
) )
// add a new entry to the dropdown name // add a new entry to the dropdown name
@ -20,18 +20,18 @@ func (n *Node) SetDropdownName(name string) {
} }
func (n *Node) NewDropdown(name string) *Node { func (n *Node) NewDropdown(name string) *Node {
newNode := n.newNode(name, toolkit.Dropdown) newNode := n.newNode(name, widget.Dropdown)
a := newAction(newNode, toolkit.Add) a := newAction(newNode, widget.Add)
sendAction(a) sendAction(a)
return newNode return newNode
} }
func (n *Node) NewCombobox(name string) *Node { func (n *Node) NewCombobox(name string) *Node {
newNode := n.newNode(name, toolkit.Combobox) newNode := n.newNode(name, widget.Combobox)
a := newAction(newNode, toolkit.Add) a := newAction(newNode, widget.Add)
sendAction(a) sendAction(a)
return newNode return newNode

View File

@ -2,7 +2,7 @@ package gui
import ( import (
"go.wit.com/log" "go.wit.com/log"
"go.wit.com/gui/toolkits" "go.wit.com/gui/widget"
) )
// Grid numbering examples (H) or (W,H) // Grid numbering examples (H) or (W,H)
@ -24,14 +24,14 @@ import (
// ----------------------------- // -----------------------------
func (n *Node) NewGrid(name string, w int, h int) *Node { func (n *Node) NewGrid(name string, w int, h int) *Node {
newNode := n.newNode(name, toolkit.Grid) newNode := n.newNode(name, widget.Grid)
newNode.W = w newNode.W = w
newNode.H = h newNode.H = h
newNode.NextW = 1 newNode.NextW = 1
newNode.NextH = 1 newNode.NextH = 1
a := newAction(newNode, toolkit.Add) a := newAction(newNode, widget.Add)
sendAction(a) sendAction(a)
// by default, always pad grids // by default, always pad grids

View File

@ -1,7 +1,7 @@
package gui package gui
import ( import (
"go.wit.com/gui/toolkits" "go.wit.com/gui/widget"
) )
// TODO: make a "Group" a "Grid" ? // TODO: make a "Group" a "Grid" ?
@ -9,9 +9,9 @@ import (
// pre-canned andlabs/ui gtk,macos,windows thing // pre-canned andlabs/ui gtk,macos,windows thing
func (parent *Node) NewGroup(name string) *Node { func (parent *Node) NewGroup(name string) *Node {
var newNode *Node var newNode *Node
newNode = parent.newNode(name, toolkit.Group) newNode = parent.newNode(name, widget.Group)
a := newAction(newNode, toolkit.Add) a := newAction(newNode, widget.Add)
sendAction(a) sendAction(a)
// by default, always pad groups // by default, always pad groups

View File

@ -1,14 +1,14 @@
package gui package gui
import ( import (
"go.wit.com/gui/toolkits" "go.wit.com/gui/widget"
) )
func (parent *Node) NewImage(name string) *Node { func (parent *Node) NewImage(name string) *Node {
var newNode *Node var newNode *Node
newNode = parent.newNode(name, toolkit.Image) newNode = parent.newNode(name, widget.Image)
a := newAction(newNode, toolkit.Add) a := newAction(newNode, widget.Add)
sendAction(a) sendAction(a)
return newNode return newNode
} }

View File

@ -1,12 +1,12 @@
package gui package gui
import ( import (
"go.wit.com/gui/toolkits" "go.wit.com/gui/widget"
) )
func (parent *Node) NewLabel(text string) *Node { func (parent *Node) NewLabel(text string) *Node {
newNode := parent.newNode(text, toolkit.Label) newNode := parent.newNode(text, widget.Label)
a := newAction(newNode, toolkit.Add) a := newAction(newNode, widget.Add)
a.Text = text a.Text = text
a.S = text a.S = text
sendAction(a) sendAction(a)

32
main.go
View File

@ -4,7 +4,7 @@ import (
"os" "os"
"go.wit.com/log" "go.wit.com/log"
"go.wit.com/gui/toolkits" "go.wit.com/gui/widget"
) )
// TODO: make a fake 'plugin' channel of communication to andlabs for mswindows // TODO: make a fake 'plugin' channel of communication to andlabs for mswindows
@ -23,16 +23,16 @@ func init() {
// Populates the top of the binary tree // Populates the top of the binary tree
me.rootNode = addNode("guiBinaryTree") me.rootNode = addNode("guiBinaryTree")
me.rootNode.WidgetType = toolkit.Root me.rootNode.WidgetType = widget.Root
// used to pass debugging flags to the toolkit plugins // used to pass debugging flags to the toolkit plugins
me.flag = me.rootNode.newNode("flag", 0) me.flag = me.rootNode.newNode("flag", 0)
me.flag.WidgetType = toolkit.Flag me.flag.WidgetType = widget.Flag
me.flag = me.rootNode.newNode("stdout", 0) me.flag = me.rootNode.newNode("stdout", 0)
me.flag.WidgetType = toolkit.Stdout me.flag.WidgetType = widget.Stdout
me.guiChan = make(chan toolkit.Action, 1) me.guiChan = make(chan widget.Action, 1)
go watchCallback() go watchCallback()
} }
@ -42,13 +42,13 @@ func watchCallback() {
log.Info("watchCallback() restarted select for toolkit user events") log.Info("watchCallback() restarted select for toolkit user events")
select { select {
case a := <-me.guiChan: case a := <-me.guiChan:
if (a.ActionType == toolkit.UserQuit) { if (a.ActionType == widget.UserQuit) {
log.Info("doUserEvent() User sent Quit()") log.Info("doUserEvent() User sent Quit()")
me.rootNode.doCustom() me.rootNode.doCustom()
log.Exit("wit/gui toolkit.UserQuit") log.Exit("wit/gui toolkit.UserQuit")
break break
} }
if (a.ActionType == toolkit.EnableDebug) { if (a.ActionType == widget.EnableDebug) {
log.Warn("doUserEvent() Enable Debugging Window") log.Warn("doUserEvent() Enable Debugging Window")
log.Warn("doUserEvent() TODO: not implemented") log.Warn("doUserEvent() TODO: not implemented")
// DebugWindow() // DebugWindow()
@ -78,37 +78,37 @@ func (n *Node) doCustom() {
go n.Custom() go n.Custom()
} }
func (n *Node) doUserEvent(a toolkit.Action) { func (n *Node) doUserEvent(a widget.Action) {
log.Info("doUserEvent() node =", n.id, n.Name) log.Info("doUserEvent() node =", n.id, n.Name)
switch n.WidgetType { switch n.WidgetType {
case toolkit.Checkbox: case widget.Checkbox:
n.B = a.B n.B = a.B
log.Info("doUserEvent() node =", n.id, n.Name, "set to:", n.B) log.Info("doUserEvent() node =", n.id, n.Name, "set to:", n.B)
n.doCustom() n.doCustom()
case toolkit.Button: case widget.Button:
log.Info("doUserEvent() node =", n.id, n.Name, "button clicked") log.Info("doUserEvent() node =", n.id, n.Name, "button clicked")
n.doCustom() n.doCustom()
case toolkit.Combobox: case widget.Combobox:
n.S = a.S n.S = a.S
log.Info("doUserEvent() node =", n.id, n.Name, "set to:", n.S) log.Info("doUserEvent() node =", n.id, n.Name, "set to:", n.S)
n.doCustom() n.doCustom()
case toolkit.Dropdown: case widget.Dropdown:
n.S = a.S n.S = a.S
log.Info("doUserEvent() node =", n.id, n.Name, "set to:", n.S) log.Info("doUserEvent() node =", n.id, n.Name, "set to:", n.S)
n.doCustom() n.doCustom()
case toolkit.Textbox: case widget.Textbox:
n.S = a.S n.S = a.S
log.Info("doUserEvent() node =", n.id, n.Name, "set to:", n.S) log.Info("doUserEvent() node =", n.id, n.Name, "set to:", n.S)
n.doCustom() n.doCustom()
case toolkit.Spinner: case widget.Spinner:
n.I = a.I n.I = a.I
log.Info("doUserEvent() node =", n.id, n.Name, "set to:", n.I) log.Info("doUserEvent() node =", n.id, n.Name, "set to:", n.I)
n.doCustom() n.doCustom()
case toolkit.Slider: case widget.Slider:
n.I = a.I n.I = a.I
log.Info("doUserEvent() node =", n.id, n.Name, "set to:", n.I) log.Info("doUserEvent() node =", n.id, n.Name, "set to:", n.I)
n.doCustom() n.doCustom()
case toolkit.Window: case widget.Window:
log.Info("doUserEvent() node =", n.id, n.Name, "window closed") log.Info("doUserEvent() node =", n.id, n.Name, "window closed")
n.doCustom() n.doCustom()
default: default:

View File

@ -2,19 +2,19 @@ package gui
import ( import (
"go.wit.com/log" "go.wit.com/log"
"go.wit.com/gui/toolkits" "go.wit.com/gui/widget"
) )
/* /*
generic function to create a new node on the binary tree generic function to create a new node on the binary tree
*/ */
func (n *Node) newNode(title string, t toolkit.WidgetType) *Node { func (n *Node) newNode(title string, t widget.WidgetType) *Node {
var newN *Node var newN *Node
newN = addNode(title) newN = addNode(title)
newN.WidgetType = t newN.WidgetType = t
if n.WidgetType == toolkit.Grid { if n.WidgetType == widget.Grid {
n.gridIncrement() n.gridIncrement()
} }
newN.AtW = n.NextW newN.AtW = n.NextW

View File

@ -11,7 +11,7 @@ import (
"plugin" "plugin"
"go.wit.com/log" "go.wit.com/log"
"go.wit.com/gui/toolkits" "go.wit.com/gui/widget"
) )
var err error var err error
@ -31,7 +31,7 @@ type aplug struct {
// From this channel, the information is then passed into the main program // From this channel, the information is then passed into the main program
// Custom() function // Custom() function
// //
Callback func(chan toolkit.Action) Callback func(chan widget.Action)
// This is how actions are sent to the toolkit. // This is how actions are sent to the toolkit.
// For example: // For example:
@ -42,8 +42,8 @@ type aplug struct {
// each toolkit has it's own goroutine and each one is sent this // each toolkit has it's own goroutine and each one is sent this
// add button request // add button request
// //
pluginChan chan toolkit.Action pluginChan chan widget.Action
PluginChannel func() chan toolkit.Action PluginChannel func() chan widget.Action
} }
var allPlugins []*aplug var allPlugins []*aplug
@ -65,8 +65,8 @@ func initPlugin(name string) *aplug {
} }
// newPlug.PluginChannel = getPluginChannel(newPlug, "PluginChannel") // newPlug.PluginChannel = getPluginChannel(newPlug, "PluginChannel")
func getPluginChannel(p *aplug, funcName string) func() chan toolkit.Action { func getPluginChannel(p *aplug, funcName string) func() chan widget.Action {
var newfunc func() chan toolkit.Action var newfunc func() chan widget.Action
var ok bool var ok bool
var test plugin.Symbol var test plugin.Symbol
@ -76,7 +76,7 @@ func getPluginChannel(p *aplug, funcName string) func() chan toolkit.Action {
return nil return nil
} }
newfunc, ok = test.(func() chan toolkit.Action) newfunc, ok = test.(func() chan widget.Action)
if !ok { if !ok {
log.Log(PLUG, "function name =", funcName, "names didn't map correctly. Fix the plugin name =", p.name) log.Log(PLUG, "function name =", funcName, "names didn't map correctly. Fix the plugin name =", p.name)
return nil return nil
@ -84,8 +84,8 @@ func getPluginChannel(p *aplug, funcName string) func() chan toolkit.Action {
return newfunc return newfunc
} }
func sendCallback(p *aplug, funcName string) func(chan toolkit.Action) { func sendCallback(p *aplug, funcName string) func(chan widget.Action) {
var newfunc func(chan toolkit.Action) var newfunc func(chan widget.Action)
var ok bool var ok bool
var test plugin.Symbol var test plugin.Symbol
@ -95,7 +95,7 @@ func sendCallback(p *aplug, funcName string) func(chan toolkit.Action) {
return nil return nil
} }
newfunc, ok = test.(func(chan toolkit.Action)) newfunc, ok = test.(func(chan widget.Action))
if !ok { if !ok {
log.Log(PLUG, "function name =", funcName, "names didn't map correctly. Fix the plugin name =", p.name) log.Log(PLUG, "function name =", funcName, "names didn't map correctly. Fix the plugin name =", p.name)
return nil return nil
@ -216,8 +216,8 @@ func initToolkit(name string, filename string) *aplug {
// 2023/05/09 pretty clean // 2023/05/09 pretty clean
// 2023/04/06 Queue() is also being used and channels are being used. memcopy() only // 2023/04/06 Queue() is also being used and channels are being used. memcopy() only
func newAction(n *Node, atype toolkit.ActionType) *toolkit.Action { func newAction(n *Node, atype widget.ActionType) *widget.Action {
var a toolkit.Action var a widget.Action
a.ActionType = atype a.ActionType = atype
if (n == nil) { if (n == nil) {
return &a return &a
@ -244,7 +244,7 @@ func newAction(n *Node, atype toolkit.ActionType) *toolkit.Action {
} }
// sends the action/event to each toolkit via a golang plugin channel // sends the action/event to each toolkit via a golang plugin channel
func sendAction(a *toolkit.Action) { func sendAction(a *widget.Action) {
for _, aplug := range allPlugins { for _, aplug := range allPlugins {
log.Log(PLUG, "Action() aplug =", aplug.name, "Action type=", a.ActionType) log.Log(PLUG, "Action() aplug =", aplug.name, "Action type=", a.ActionType)
if (aplug.pluginChan == nil) { if (aplug.pluginChan == nil) {
@ -302,8 +302,8 @@ func (n *Node) LoadToolkit(name string) *Node {
} }
log.Log(PLUG, "LoadToolkit() sending InitToolkit action to the plugin channel") log.Log(PLUG, "LoadToolkit() sending InitToolkit action to the plugin channel")
var a toolkit.Action var a widget.Action
a.ActionType = toolkit.InitToolkit a.ActionType = widget.InitToolkit
plug.pluginChan <- a plug.pluginChan <- a
// sleep(.5) // temp hack until chan communication is setup // sleep(.5) // temp hack until chan communication is setup
@ -319,8 +319,8 @@ func (n *Node) CloseToolkit(name string) bool {
log.Log(PLUG, "CloseToolkit() found", plug.name) log.Log(PLUG, "CloseToolkit() found", plug.name)
if (plug.name == name) { if (plug.name == name) {
log.Log(PLUG, "CloseToolkit() sending close", name) log.Log(PLUG, "CloseToolkit() sending close", name)
var a toolkit.Action var a widget.Action
a.ActionType = toolkit.CloseToolkit a.ActionType = widget.CloseToolkit
plug.pluginChan <- a plug.pluginChan <- a
// sleep(.5) // is this needed? TODO: properly close channel // sleep(.5) // is this needed? TODO: properly close channel
return true return true

View File

@ -2,7 +2,7 @@ package gui
import ( import (
"go.wit.com/log" "go.wit.com/log"
"go.wit.com/gui/toolkits" "go.wit.com/gui/widget"
) )
// This recreates the whole GUI for a plugin // This recreates the whole GUI for a plugin
@ -23,12 +23,12 @@ func (n *Node) redraw(p *aplug) {
func (n *Node) redo(plug *aplug) { func (n *Node) redo(plug *aplug) {
log.Info("redo()", plug.name, n.id, n.WidgetType, n.Name) log.Info("redo()", plug.name, n.id, n.WidgetType, n.Name)
var a *toolkit.Action var a *widget.Action
a = new(toolkit.Action) a = new(widget.Action)
a.Name = n.Name a.Name = n.Name
a.Text = n.Text a.Text = n.Text
a.ActionType = toolkit.Add a.ActionType = widget.Add
a.WidgetType = n.WidgetType a.WidgetType = n.WidgetType
a.WidgetId = n.id a.WidgetId = n.id

View File

@ -2,11 +2,11 @@ package gui
import ( import (
"go.wit.com/log" "go.wit.com/log"
"go.wit.com/gui/toolkits" "go.wit.com/gui/widget"
) )
func (parent *Node) NewSlider(name string, x int, y int) *Node { func (parent *Node) NewSlider(name string, x int, y int) *Node {
newNode := parent.newNode(name, toolkit.Slider) newNode := parent.newNode(name, widget.Slider)
newNode.Custom = func() { newNode.Custom = func() {
log.Log(GUI, "even newer clicker() name in NewSlider name =", name) log.Log(GUI, "even newer clicker() name in NewSlider name =", name)
@ -14,7 +14,7 @@ func (parent *Node) NewSlider(name string, x int, y int) *Node {
newNode.X = x newNode.X = x
newNode.Y = y newNode.Y = y
a := newAction(newNode, toolkit.Add) a := newAction(newNode, widget.Add)
a.X = x a.X = x
a.Y = y a.Y = y
sendAction(a) sendAction(a)

View File

@ -2,11 +2,11 @@ package gui
import ( import (
"go.wit.com/log" "go.wit.com/log"
"go.wit.com/gui/toolkits" "go.wit.com/gui/widget"
) )
func (parent *Node) NewSpinner(name string, x int, y int) *Node { func (parent *Node) NewSpinner(name string, x int, y int) *Node {
newNode := parent.newNode(name, toolkit.Spinner) newNode := parent.newNode(name, widget.Spinner)
newNode.Custom = func() { newNode.Custom = func() {
log.Info("default NewSpinner() change", name) log.Info("default NewSpinner() change", name)
@ -15,7 +15,7 @@ func (parent *Node) NewSpinner(name string, x int, y int) *Node {
newNode.X = x newNode.X = x
newNode.Y = y newNode.Y = y
a := newAction(newNode, toolkit.Add) a := newAction(newNode, widget.Add)
sendAction(a) sendAction(a)
return newNode return newNode
} }

View File

@ -3,7 +3,7 @@ package gui
import ( import (
"sync" "sync"
"embed" "embed"
"go.wit.com/gui/toolkits" "go.wit.com/gui/widget"
) )
// //
@ -35,7 +35,7 @@ type guiConfig struct {
counter int // used to make unique WidgetId's counter int // used to make unique WidgetId's
// sets the chan for the plugins to call back too // sets the chan for the plugins to call back too
guiChan chan toolkit.Action guiChan chan widget.Action
// option to pass in compiled plugins as embedded files // option to pass in compiled plugins as embedded files
resFS embed.FS resFS embed.FS
@ -50,7 +50,7 @@ type guiConfig struct {
type Node struct { type Node struct {
id int id int
WidgetType toolkit.WidgetType WidgetType widget.WidgetType
// for NewLabel("hello"), Text = 'hello' // for NewLabel("hello"), Text = 'hello'
Text string // what is visable to the user Text string // what is visable to the user

View File

@ -3,23 +3,23 @@ package gui
import ( import (
"go.wit.com/log" "go.wit.com/log"
"go.wit.com/gui/toolkits" "go.wit.com/gui/widget"
) )
func (parent *Node) NewTextbox(name string) *Node { func (parent *Node) NewTextbox(name string) *Node {
newNode := parent.newNode(name, toolkit.Textbox) newNode := parent.newNode(name, widget.Textbox)
newNode.Custom = func() { newNode.Custom = func() {
log.Log(GUI, "NewTextbox changed =", name) log.Log(GUI, "NewTextbox changed =", name)
} }
a := newAction(newNode, toolkit.Add) a := newAction(newNode, widget.Add)
sendAction(a) sendAction(a)
return newNode return newNode
} }
func (parent *Node) NewEntryLine(name string) *Node { func (parent *Node) NewEntryLine(name string) *Node {
newNode := parent.newNode(name, toolkit.Textbox) newNode := parent.newNode(name, widget.Textbox)
newNode.X = 1 newNode.X = 1
@ -27,7 +27,7 @@ func (parent *Node) NewEntryLine(name string) *Node {
log.Log(GUI, "NewTextbox changed =", name) log.Log(GUI, "NewTextbox changed =", name)
} }
a := newAction(newNode, toolkit.Add) a := newAction(newNode, widget.Add)
sendAction(a) sendAction(a)
return newNode return newNode
} }

View File

@ -2,7 +2,7 @@ package gui
import ( import (
"go.wit.com/log" "go.wit.com/log"
"go.wit.com/gui/toolkits" "go.wit.com/gui/widget"
) )
// This routine creates a blank window with a Title and size (W x H) // This routine creates a blank window with a Title and size (W x H)
@ -11,12 +11,12 @@ func (parent *Node) NewWindow(title string) *Node {
var newNode *Node var newNode *Node
// Windows are created off of the master node of the Binary Tree // Windows are created off of the master node of the Binary Tree
newNode = parent.newNode(title, toolkit.Window) newNode = parent.newNode(title, widget.Window)
newNode.Custom = StandardExit newNode.Custom = StandardExit
log.Info("NewWindow()", title) log.Info("NewWindow()", title)
a := newAction(newNode, toolkit.Add) a := newAction(newNode, widget.Add)
sendAction(a) sendAction(a)
return newNode return newNode
} }