diff options
| author | Jeff Carr <[email protected]> | 2023-05-10 14:28:30 -0500 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2023-05-10 14:28:30 -0500 |
| commit | 19e6ea76f3c09fe3a5d9a4d4caff7d14571f4ba5 (patch) | |
| tree | 6e1c9e86c9a591d6b0a7ca686026d783de1d67ac | |
| parent | cb0e8a7146c055b47f42d0a1005b93e08492e6ca (diff) | |
andlabs: debugging flags working againv0.8.6
Signed-off-by: Jeff Carr <[email protected]>
| -rw-r--r-- | cmds/buttonplugin/main.go | 10 | ||||
| -rw-r--r-- | grid.go | 25 | ||||
| -rw-r--r-- | structs.go | 15 | ||||
| -rw-r--r-- | toolkit/andlabs/action.go | 10 | ||||
| -rw-r--r-- | toolkit/andlabs/add.go | 8 | ||||
| -rw-r--r-- | toolkit/andlabs/debug.go | 20 | ||||
| -rw-r--r-- | toolkit/andlabs/log.go | 4 | ||||
| -rw-r--r-- | toolkit/andlabs/main.go | 10 | ||||
| -rw-r--r-- | toolkit/gocui/click.go | 2 | ||||
| -rw-r--r-- | toolkit/gocui/common.go | 2 | ||||
| -rw-r--r-- | toolkit/gocui/place.go | 2 | ||||
| -rw-r--r-- | toolkit/gocui/structs.go | 10 |
12 files changed, 67 insertions, 51 deletions
diff --git a/cmds/buttonplugin/main.go b/cmds/buttonplugin/main.go index 4b6a2ff..1fd8b5f 100644 --- a/cmds/buttonplugin/main.go +++ b/cmds/buttonplugin/main.go @@ -14,7 +14,7 @@ var myGui *gui.Node var buttonCounter int = 5 var gridW int = 5 -var gridH int = 2 +var gridH int = 3 func main() { // This will turn on all debugging @@ -72,8 +72,8 @@ func buttonWindow() { }) g.NewButton("NewButton(more)", func () { - log.Println("new foobar 2. Adding button 'foobar 3'") name := "foobar " + strconv.Itoa(buttonCounter) + log.Println("NewButton(more) Adding button", name) buttonCounter += 1 more.NewButton(name, func () { log.Println("Got all the way to main() name =", name) @@ -81,8 +81,8 @@ func buttonWindow() { }) g.NewButton("NewButton(more2)", func () { - log.Println("new foobar 2. Adding button 'foobar 3'") name := "foobar " + strconv.Itoa(buttonCounter) + log.Println("NewButton(more2) Adding button", name) buttonCounter += 1 more2.NewButton(name, func () { log.Println("Got all the way to main() name =", name) @@ -90,8 +90,8 @@ func buttonWindow() { }) g.NewButton("NewButton(more2 d)", func () { - log.Println("new foobar 2. Adding button 'foobar 3'") name := "d" + strconv.Itoa(buttonCounter) + log.Println("NewButton(more2 d) Adding button", name) buttonCounter += 1 more2.NewButton(name, func () { log.Println("Got all the way to main() name =", name) @@ -99,8 +99,8 @@ func buttonWindow() { }) g.NewButton("NewGroup()", func () { - log.Println("new foobar 2. Adding button 'foobar 3'") name := "neat " + strconv.Itoa(buttonCounter) + log.Println("NewGroup() Adding button", name) buttonCounter += 1 more.NewGroup(name) }) @@ -25,8 +25,8 @@ import ( func (n *Node) NewGrid(name string, w int, h int) *Node { newNode := n.newNode(name, toolkit.Grid) - newNode.X = w - newNode.Y = h + newNode.W = w + newNode.H = h newNode.NextW = 1 newNode.NextH = 1 @@ -51,10 +51,10 @@ func (n *Node) gridIncrement() { return } - n.NextH += 1 - if (n.NextH > n.Y) { - n.NextW += 1 - n.NextH = 1 + n.NextW += 1 + if (n.NextW > n.W) { + n.NextW = 1 + n.NextH += 1 } n.gridIncrement() @@ -74,16 +74,3 @@ func (n *Node) At(w int, h int) *Node { } return n } - -// finds the next place on the grid to place the new node 'n' -func placeGrid(a *toolkit.Action, n *Node, where *Node) { - where.NextH += 1 - if (where.NextH > where.Y) { - where.NextW += 1 - where.NextH = 1 - } - - a.X = where.NextW - a.Y = where.NextH - log(logNow, "placeGrid() (X,Y)", where.X, where.Y, " next(X,Y) =", where.NextW, where.NextH) -} @@ -66,17 +66,22 @@ type Node struct { width int height int - // used for anything that needs a range + // used for anything that needs a range (for example: a slider) X int Y int - // the position of the widget in a grid - AtW int - AtH int - // where the next widget should be put in a grid + // the grid max width and height + // ignore max height when there is no space left? + W int + H int + // where the next widget should be put in this grid NextW int NextH int + // if this widget is in a grid, this is the position + AtW int + AtH int + // used for values I int S string diff --git a/toolkit/andlabs/action.go b/toolkit/andlabs/action.go index 49a3465..c792a09 100644 --- a/toolkit/andlabs/action.go +++ b/toolkit/andlabs/action.go @@ -171,8 +171,8 @@ func (n *node) Delete() { } func rawAction(a toolkit.Action) { - log(logNow, "rawAction() START a.ActionType =", a.ActionType) - log(logNow, "rawAction() START a.S =", a.S) + log(logInfo, "rawAction() START a.ActionType =", a.ActionType) + log(logInfo, "rawAction() START a.S =", a.S) if (a.ActionType == toolkit.InitToolkit) { // TODO: make sure to only do this once @@ -184,7 +184,7 @@ func rawAction(a toolkit.Action) { return } - log(logNow, "rawAction() START a.WidgetId =", a.WidgetId, "a.ParentId =", a.ParentId) + log(logInfo, "rawAction() START a.WidgetId =", a.WidgetId, "a.ParentId =", a.ParentId) switch a.WidgetType { case toolkit.Flag: flag(&a) @@ -198,7 +198,7 @@ func rawAction(a toolkit.Action) { ui.QueueMain(func() { add(a) }) - sleep(.1) + sleep(.05) case toolkit.Show: n.show(true) case toolkit.Hide: @@ -237,5 +237,5 @@ func rawAction(a toolkit.Action) { default: log(debugError, "rawAction() Unknown =", a.ActionType, a.WidgetType) } - log(debugAction, "rawAction() END =", a.ActionType, a.WidgetType) + log(logInfo, "rawAction() END =", a.ActionType, a.WidgetType) } diff --git a/toolkit/andlabs/add.go b/toolkit/andlabs/add.go index c25603d..fcdc56b 100644 --- a/toolkit/andlabs/add.go +++ b/toolkit/andlabs/add.go @@ -107,19 +107,19 @@ func (p *node) place(n *node) bool { log(logInfo, "place() switch", p.WidgetType) switch p.WidgetType { case toolkit.Grid: - log(debugGrid, "place() Grid try at Parent X,Y =", n.X, n.Y) + log(logInfo, "place() Grid try at Parent X,Y =", n.X, 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) + log(logInfo, "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, n.tk.gridX, 1, 1, + n.tk.gridX, n.tk.gridY, 1, 1, false, ui.AlignFill, false, ui.AlignFill) return true case toolkit.Group: if (p.tk.uiBox == nil) { p.tk.uiGroup.SetChild(n.tk.uiControl) - log(debugGrid, "place() hack Group to use this as the box?", n.Name, n.WidgetType) + log(logInfo, "place() hack Group to use this as the box?", n.Name, n.WidgetType) p.tk.uiBox = n.tk.uiBox } else { p.tk.uiBox.Append(n.tk.uiControl, stretchy) diff --git a/toolkit/andlabs/debug.go b/toolkit/andlabs/debug.go index cc32b71..7abd2d1 100644 --- a/toolkit/andlabs/debug.go +++ b/toolkit/andlabs/debug.go @@ -92,6 +92,24 @@ func GetDebugToolkit () bool { func flag(a *toolkit.Action) { // should set the checkbox to this value switch a.S { + case "Quiet": + logInfo = a.B + logVerbose = a.B + logWarn = a.B + logError = a.B + case "Error": + logError = a.B + case "Info": + logInfo = a.B + case "Verbose": + logInfo = a.B + logVerbose = a.B + logWarn = a.B + logError = a.B + debugToolkit = a.B + debugChange = a.B + debugPlugin = a.B + debugFlags = a.B case "Toolkit": debugToolkit = a.B case "Change": @@ -100,8 +118,6 @@ func flag(a *toolkit.Action) { debugPlugin = a.B case "Flags": debugFlags = a.B - case "Error": - debugError = a.B case "Now": debugNow = a.B case "Show": diff --git a/toolkit/andlabs/log.go b/toolkit/andlabs/log.go index 1a36188..5dbb914 100644 --- a/toolkit/andlabs/log.go +++ b/toolkit/andlabs/log.go @@ -8,8 +8,8 @@ import ( var logNow bool = true // useful for active development var logError bool = true var logWarn bool = true -var logInfo bool = true -var logVerbose bool = true +var logInfo bool = false +var logVerbose bool = false func log(a ...any) { witlog.Where = "wit/gui/andlabs" diff --git a/toolkit/andlabs/main.go b/toolkit/andlabs/main.go index 92f75d0..f66849d 100644 --- a/toolkit/andlabs/main.go +++ b/toolkit/andlabs/main.go @@ -20,19 +20,19 @@ var uiMain sync.Once var muAction sync.Mutex func catchActionChannel() { - log(logNow, "catchActionChannel() START") + log(logInfo, "catchActionChannel() START") for { - log(logNow, "catchActionChannel() for loop") + log(logInfo, "catchActionChannel() for loop") select { case a := <-pluginChan: - log(logNow, "catchActionChannel() SELECT widget id =", a.WidgetId, a.Name) - log(logNow, "catchActionChannel() STUFF", a.WidgetId, a.ActionType, a.WidgetType) + log(logInfo, "catchActionChannel() SELECT widget id =", a.WidgetId, a.Name) + log(logInfo, "catchActionChannel() STUFF", a.WidgetId, a.ActionType, a.WidgetType) muAction.Lock() // TODO ui.QueueMain(f) // TODO ui.QueueMain( func() {rawAction(a)} ) rawAction(a) muAction.Unlock() - log(logNow, "catchActionChannel() STUFF END", a.WidgetId, a.ActionType, a.WidgetType) + log(logInfo, "catchActionChannel() STUFF END", a.WidgetId, a.ActionType, a.WidgetType) } } } diff --git a/toolkit/gocui/click.go b/toolkit/gocui/click.go index a4246a6..8802674 100644 --- a/toolkit/gocui/click.go +++ b/toolkit/gocui/click.go @@ -260,7 +260,7 @@ func ctrlDown(g *gocui.Gui, v *gocui.View) error { if (found == nil) { found = me.rootNode } - found.setRealSize() + // ? TODO: found.setRealSize() me.ctrlDown.gocuiSize.w0 = found.startW me.ctrlDown.gocuiSize.h0 = found.startH me.ctrlDown.gocuiSize.w1 = me.ctrlDown.gocuiSize.w0 + found.realWidth diff --git a/toolkit/gocui/common.go b/toolkit/gocui/common.go index 94b63b1..325a556 100644 --- a/toolkit/gocui/common.go +++ b/toolkit/gocui/common.go @@ -15,10 +15,10 @@ func makeWidget(a *toolkit.Action) *cuiWidget { w.b = a.B w.i = a.I w.s = a.S + w.X = a.X w.Y = a.Y - t := len(w.text) w.gocuiSize.w1 = w.gocuiSize.w0 + t + me.PadW w.gocuiSize.h1 = w.gocuiSize.h0 + me.DefaultHeight + me.PadH diff --git a/toolkit/gocui/place.go b/toolkit/gocui/place.go index bcb273b..0919308 100644 --- a/toolkit/gocui/place.go +++ b/toolkit/gocui/place.go @@ -257,5 +257,7 @@ func (w *cuiWidget) placeGrid() { w.showWidgetPlacement(logNow, "grid3:") } +/* func (w *cuiWidget) setRealSize() { } +*/ diff --git a/toolkit/gocui/structs.go b/toolkit/gocui/structs.go index b2a8b20..1fa6692 100644 --- a/toolkit/gocui/structs.go +++ b/toolkit/gocui/structs.go @@ -93,7 +93,7 @@ var ( // this is the standard binary tree structure for toolkits type node struct { - parent *node + parent *node children []*node WidgetId int // widget ID @@ -115,6 +115,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 *cuiWidget } @@ -199,7 +205,7 @@ type cuiWidget struct { v *gocui.View frame bool - parent *cuiWidget + parent *cuiWidget children []*cuiWidget } |
