diff options
| -rw-r--r-- | box.go | 2 | ||||
| -rw-r--r-- | button.go | 3 | ||||
| -rw-r--r-- | checkbox.go | 2 | ||||
| -rw-r--r-- | dropdown.go | 4 | ||||
| -rw-r--r-- | grid.go | 10 | ||||
| -rw-r--r-- | group.go | 2 | ||||
| -rw-r--r-- | image.go | 2 | ||||
| -rw-r--r-- | label.go | 2 | ||||
| -rw-r--r-- | main.go | 4 | ||||
| -rw-r--r-- | node.go | 3 | ||||
| -rw-r--r-- | slider.go | 6 | ||||
| -rw-r--r-- | spinner.go | 6 | ||||
| -rw-r--r-- | tab.go | 2 | ||||
| -rw-r--r-- | textbox.go | 6 | ||||
| -rw-r--r-- | toolkit/andlabs/add.go | 6 | ||||
| -rw-r--r-- | toolkit/andlabs/grid.go | 2 | ||||
| -rw-r--r-- | toolkit/andlabs/process.go | 72 | ||||
| -rw-r--r-- | toolkit/andlabs/structs.go | 6 | ||||
| -rw-r--r-- | toolkit/nocui/common.go | 6 | ||||
| -rw-r--r-- | toolkit/nocui/structs.go | 6 | ||||
| -rw-r--r-- | window.go | 3 |
21 files changed, 50 insertions, 105 deletions
@@ -5,7 +5,7 @@ import ( ) func (parent *Node) NewBox(name string, b bool) *Node { - newNode := parent.newNode(name, toolkit.Box, nil) + newNode := parent.newNode(name, toolkit.Box) newNode.B = b a := newAction(newNode, toolkit.Add) @@ -3,7 +3,8 @@ package gui import "git.wit.org/wit/gui/toolkit" func (parent *Node) NewButton(name string, custom func()) *Node { - newNode := parent.newNode(name, toolkit.Button, custom) + newNode := parent.newNode(name, toolkit.Button) + newNode.Custom = custom a := newAction(newNode, toolkit.Add) sendAction(a) diff --git a/checkbox.go b/checkbox.go index 502acb4..db3eb19 100644 --- a/checkbox.go +++ b/checkbox.go @@ -7,7 +7,7 @@ func (n *Node) Checked() bool { } func (n *Node) NewCheckbox(name string) *Node { - newNode := n.newNode(name, toolkit.Checkbox, nil) + newNode := n.newNode(name, toolkit.Checkbox) a := newAction(newNode, toolkit.Add) sendAction(a) diff --git a/dropdown.go b/dropdown.go index ce49db6..cd00bf3 100644 --- a/dropdown.go +++ b/dropdown.go @@ -20,7 +20,7 @@ func (n *Node) SetDropdownName(name string) { } func (n *Node) NewDropdown(name string) *Node { - newNode := n.newNode(name, toolkit.Dropdown, nil) + newNode := n.newNode(name, toolkit.Dropdown) a := newAction(newNode, toolkit.Add) sendAction(a) @@ -29,7 +29,7 @@ func (n *Node) NewDropdown(name string) *Node { } func (n *Node) NewCombobox(name string) *Node { - newNode := n.newNode(name, toolkit.Combobox, nil) + newNode := n.newNode(name, toolkit.Combobox) a := newAction(newNode, toolkit.Add) sendAction(a) @@ -23,21 +23,15 @@ import ( // ----------------------------- func (n *Node) NewGrid(name string, w int, h int) *Node { - newNode := n.newNode(name, toolkit.Grid, func() { - log(debugChange, "click() NewGrid not defined =", name) - }) + newNode := n.newNode(name, toolkit.Grid) - a := newAction(newNode, toolkit.Add) - - a.X = w - a.Y = h newNode.X = w newNode.Y = h newNode.NextW = 1 newNode.NextH = 1 + a := newAction(newNode, toolkit.Add) sendAction(a) - return newNode } @@ -9,7 +9,7 @@ import ( // pre-canned andlabs/ui gtk,macos,windows thing func (parent *Node) NewGroup(name string) *Node { var newNode *Node - newNode = parent.newNode(name, toolkit.Group, nil) + newNode = parent.newNode(name, toolkit.Group) a := newAction(newNode, toolkit.Add) sendAction(a) @@ -6,7 +6,7 @@ import ( func (parent *Node) NewImage(name string) *Node { var newNode *Node - newNode = parent.newNode(name, toolkit.Image, nil) + newNode = parent.newNode(name, toolkit.Image) a := newAction(newNode, toolkit.Add) sendAction(a) @@ -5,7 +5,7 @@ import ( ) func (parent *Node) NewLabel(text string) *Node { - newNode := parent.newNode(text, toolkit.Label, nil) + newNode := parent.newNode(text, toolkit.Label) a := newAction(newNode, toolkit.Add) sendAction(a) return newNode @@ -24,10 +24,10 @@ func init() { me.rootNode.WidgetType = toolkit.Root // used to pass debugging flags to the toolkit plugins - me.flag = me.rootNode.newNode("flag", 0, nil) + me.flag = me.rootNode.newNode("flag", 0) me.flag.WidgetType = toolkit.Flag - me.flag = me.rootNode.newNode("stdout", 0, nil) + me.flag = me.rootNode.newNode("stdout", 0) me.flag.WidgetType = toolkit.Stdout me.guiChan = make(chan toolkit.Action, 1) @@ -5,12 +5,11 @@ import "git.wit.org/wit/gui/toolkit" /* generic function to create a new node on the binary tree */ -func (n *Node) newNode(title string, t toolkit.WidgetType, custom func()) *Node { +func (n *Node) newNode(title string, t toolkit.WidgetType) *Node { var newN *Node newN = addNode(title) newN.WidgetType = t - newN.Custom = custom if n.WidgetType == toolkit.Grid { n.gridIncrement() @@ -5,9 +5,11 @@ import ( ) func (parent *Node) NewSlider(name string, x int, y int) *Node { - newNode := parent.newNode(name, toolkit.Slider, func() { + newNode := parent.newNode(name, toolkit.Slider) + + newNode.Custom = func() { log(debugGui, "even newer clicker() name in NewSlider name =", name) - }) + } newNode.X = x newNode.Y = y @@ -5,9 +5,11 @@ import ( ) func (parent *Node) NewSpinner(name string, x int, y int) *Node { - newNode := parent.newNode(name, toolkit.Spinner, func() { + newNode := parent.newNode(name, toolkit.Spinner) + + newNode.Custom = func() { log(debugChange, "default NewSpinner() change", name) - }) + } newNode.X = x newNode.Y = y @@ -28,7 +28,7 @@ func (n *Node) NewTab(text string) *Node { // go up the binary tree until we find a window widget to add a tab too return n.parent.NewTab(text) } - newNode := n.newNode(text, toolkit.Tab, nil) + newNode := n.newNode(text, toolkit.Tab) a := newAction(newNode, toolkit.Add) sendAction(a) @@ -5,9 +5,11 @@ import ( ) func (parent *Node) NewTextbox(name string) *Node { - newNode := parent.newNode(name, toolkit.Textbox, func() { + newNode := parent.newNode(name, toolkit.Textbox) + + newNode.Custom = func() { log(debugGui, "NewTextbox changed =", name) - }) + } a := newAction(newNode, toolkit.Add) sendAction(a) diff --git a/toolkit/andlabs/add.go b/toolkit/andlabs/add.go index 9d40b4f..c25603d 100644 --- a/toolkit/andlabs/add.go +++ b/toolkit/andlabs/add.go @@ -108,12 +108,12 @@ func (p *node) place(n *node) bool { switch p.WidgetType { case toolkit.Grid: log(debugGrid, "place() Grid try at Parent X,Y =", n.X, n.Y) - n.tk.gridX = n.X - n.tk.gridY = n.Y + n.tk.gridX = n.AtW - 1 + n.tk.gridY = n.AtH - 1 log(debugGrid, "place() Grid try at gridX,gridY", n.tk.gridX, n.tk.gridY) // at the very end, subtract 1 from X & Y since andlabs/ui starts counting at zero p.tk.uiGrid.Append(n.tk.uiControl, - n.tk.gridY - 1, n.tk.gridX - 1, 1, 1, + n.tk.gridY, n.tk.gridX, 1, 1, false, ui.AlignFill, false, ui.AlignFill) return true case toolkit.Group: diff --git a/toolkit/andlabs/grid.go b/toolkit/andlabs/grid.go index 60e2ebf..8764962 100644 --- a/toolkit/andlabs/grid.go +++ b/toolkit/andlabs/grid.go @@ -19,8 +19,6 @@ func (p *node) newGrid(n *node) { c := ui.NewGrid() newt.uiGrid = c newt.uiControl = c - newt.gridX = 0 - newt.gridY = 0 n.tk = newt p.place(n) diff --git a/toolkit/andlabs/process.go b/toolkit/andlabs/process.go deleted file mode 100644 index d70877e..0000000 --- a/toolkit/andlabs/process.go +++ /dev/null @@ -1,72 +0,0 @@ -// myplugin/myplugin.go -package main - -/* -from chatgpt: - -// put this in widget.go -import ( - "fmt" - // "toolkit" -) - -type Plugin interface { - Process(input chan string, output chan string) -} - -// put this in wit/gui/toolkit/* -type myPlugin struct{} - -var Plugin myPlugin - -func (p *myPlugin) Process(input chan string, output chan string) { - go func() { - for msg := range input { - // Your processing logic goes here - result := fmt.Sprintf("Processed: %s", msg) - output <- result - } - }() -} - -// main.go put this in wit/gui -package main - -import ( - "fmt" - "plugin" - "pluginapi" -) - -func main() { - plug, err := plugin.Open("myplugin.so") - if err != nil { - panic(err) - } - - symPlugin, err := plug.Lookup("Plugin") - if err != nil { - panic(err) - } - - p, ok := symPlugin.(pluginapi.Plugin) - if !ok { - panic("Invalid plugin type") - } - - input := make(chan string) - output := make(chan string) - - p.Process(input, output) - - input <- "Hello, World!" - close(input) - - for result := range output { - fmt.Println(result) - } -} - -*/ - -// func main() {} diff --git a/toolkit/andlabs/structs.go b/toolkit/andlabs/structs.go index ac35183..c71732d 100644 --- a/toolkit/andlabs/structs.go +++ b/toolkit/andlabs/structs.go @@ -32,6 +32,12 @@ type node struct { X int Y int + // This is for the grid size & widget position + W int + H int + AtW int + AtH int + // the internal plugin toolkit structure tk *andlabsT } diff --git a/toolkit/nocui/common.go b/toolkit/nocui/common.go index e68308d..a012138 100644 --- a/toolkit/nocui/common.go +++ b/toolkit/nocui/common.go @@ -35,9 +35,15 @@ func addWidget(a *toolkit.Action) *node { n.I = a.I n.S = a.S n.B = a.B + n.X = a.X n.Y = a.Y + n.W = a.W + n.H = a.H + n.AtW = a.AtW + n.AtH = a.AtH + // store the internal toolkit information n.tk = new(nocuiT) diff --git a/toolkit/nocui/structs.go b/toolkit/nocui/structs.go index ed004de..c3ece3b 100644 --- a/toolkit/nocui/structs.go +++ b/toolkit/nocui/structs.go @@ -27,6 +27,12 @@ type node struct { X int Y int + // This is for the grid size & widget position + W int + H int + AtW int + AtH int + // the internal plugin toolkit structure tk *nocuiT } @@ -10,7 +10,8 @@ func (parent *Node) NewWindow(title string) *Node { var newNode *Node // Windows are created off of the master node of the Binary Tree - newNode = parent.newNode(title, toolkit.Window, StandardExit) + newNode = parent.newNode(title, toolkit.Window) + newNode.Custom = StandardExit log(logInfo, "NewWindow()", title) |
