diff options
| author | Jeff Carr <[email protected]> | 2023-03-23 12:35:12 -0500 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2023-03-23 12:35:12 -0500 |
| commit | d4787a1ebdd08359746516dbb72f1feaf95be5b6 (patch) | |
| tree | cb81756d61096ccf74af7c8cc9a15e4e00fe1da7 /common.go | |
| parent | 6a848bf40474365cc1c0b4da9e2f7e3e10b4d627 (diff) | |
Squashed commit of the following:v0.7.3
boxes now exist and are tracked in the binary tree
create for group and grid works
gocui plugin no longer works. TODO: fix in next release
converted everything from plugin to Action()
can remove send()
tab and window are now action()
flags moved to action()
ready for new release
pad() margion() border() all work
move worked!
go.wit.com attept 578th try
adds an early grid widget. won't work until chan
andlabs/ui grid (X,Y) works right
actually can put things in places in a grid
Queue() means shit doesn't look right on grids
lots of fucking around. why am I wasting time on image?
wow. the crazy doAppend() thing is gone
implement Action Show() and Hide()
Signed-off-by: Jeff Carr <[email protected]>
Diffstat (limited to 'common.go')
| -rw-r--r-- | common.go | 119 |
1 files changed, 87 insertions, 32 deletions
@@ -1,52 +1,112 @@ package gui +// Common actions for widgets like 'Enable' or 'Hide' + import ( "regexp" - // "errors" - // "git.wit.org/wit/gui/toolkit" + "git.wit.org/wit/gui/toolkit" ) // functions for handling text related GUI elements +func (n *Node) Show() { + var a toolkit.Action + a.Type = toolkit.Show + newaction(&a, n, nil) +} + +func (n *Node) Hide() { + var a toolkit.Action + a.Type = toolkit.Hide + newaction(&a, n, nil) +} + +func (n *Node) Enable() { + var a toolkit.Action + a.Type = toolkit.Enable + newaction(&a, n, nil) +} + +func (n *Node) Disable() { + var a toolkit.Action + a.Type = toolkit.Disable + newaction(&a, n, nil) +} + func (n *Node) Add(str string) { log(debugGui, "gui.Add() value =", str) - n.widget.Action = "Add" - n.widget.S = str - send(n.parent, n) + + var a toolkit.Action + a.Type = toolkit.Add + a.S = str + // a.Widget = &n.widget + // action(&a) + newaction(&a, n, nil) } -func (n *Node) SetText(str string) bool { - log(debugChange, "gui.SetText() value =", str) - n.widget.Action = "SetText" - n.widget.S = str - send(n.parent, n) - return true +func (n *Node) AddText(str string) { + log(debugChange, "AddText() value =", str) + + var a toolkit.Action + a.Type = toolkit.AddText + a.S = str + // a.Widget = &n.widget + // action(&a) + newaction(&a, n, nil) +} + +func (n *Node) SetText(str string) { + log(debugChange, "SetText() value =", str) + + var a toolkit.Action + a.Type = toolkit.SetText + a.S = str + // a.Widget = &n.widget + // action(&a) + newaction(&a, n, nil) +} + +func (n *Node) SetNext(x int, y int) { + n.NextX = x + n.NextY = y + log(debugError, "SetNext() x,y =", n.NextX, n.NextY) + log(debugError, "SetNext() x,y =", n.NextX, n.NextY) + log(debugError, "SetNext() x,y =", n.NextX, n.NextY) + log(debugError, "SetNext() x,y =", n.NextX, n.NextY) + log(debugError, "SetNext() x,y =", n.NextX, n.NextY) + log(debugError, "SetNext() x,y =", n.NextX, n.NextY) } -func (n *Node) Set(a any) bool { - log(debugChange, "gui.Set() value =", a) - n.widget.Action = "Set" - switch v := a.(type) { +func (n *Node) Set(val any) { + log(debugChange, "Set() value =", val) + var a toolkit.Action + a.Type = toolkit.Set + + switch v := val.(type) { case bool: - n.widget.B = a.(bool) + a.B = val.(bool) case string: - n.widget.S = a.(string) + a.S = val.(string) case int: - n.widget.I = a.(int) + a.I = val.(int) default: - log(debugError, "gui.Set() unknown type =", v, "a =", a) + log(debugError, "Set() unknown type =", v, "a =", a) } - send(n.parent, n) - return true + + // a.Widget = &n.widget + // action(&a) + newaction(&a, n, nil) } -func (n *Node) AppendText(str string) bool { - n.widget.Action = "Set" +func (n *Node) AppendText(str string) { + var a toolkit.Action + a.Type = toolkit.SetText tmp := n.widget.S + str - log(debugChange, "gui.AppendText() value =", tmp) - n.widget.S = tmp - send(n.parent, n) - return true + log(debugChange, "AppendText() value =", tmp) + a.S = tmp + // a.Widget = &n.widget + // action(&a) + newaction(&a, n, nil) } func (n *Node) GetText() string { @@ -87,11 +147,6 @@ func normalizeInt(s string) string { return clean } -func Delete(c *Node) { - c.widget.Action = "Delete" - send(c.parent, c) -} - func commonCallback(n *Node) { // TODO: make all of this common code to all the widgets // This might be common everywhere finally (2023/03/01) |
