new paths

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2024-01-17 23:39:03 -06:00
parent bee272651a
commit a0baba0821
61 changed files with 511 additions and 905 deletions

View File

@ -3,9 +3,9 @@ package main
import (
"errors"
"go.wit.com/lib/widget"
"go.wit.com/log"
"go.wit.com/gui/widget"
"go.wit.com/gui/toolkits/tree"
"go.wit.com/toolkits/tree"
)
// this will check to make sure that the node
@ -55,8 +55,12 @@ func ready(n *tree.Node) bool {
return true
}
func (n *node) ready() bool {
if n == nil { return false }
if n.tk == nil { return false }
if n == nil {
return false
}
if n.tk == nil {
return false
}
return true
}
@ -71,7 +75,7 @@ func show(n *tree.Node, b bool) {
if tk.uiControl == nil {
return
}
if (b) {
if b {
tk.uiControl.Show()
} else {
tk.uiControl.Hide()
@ -90,7 +94,7 @@ func enable(n *tree.Node, b bool) {
if tk.uiControl == nil {
return
}
if (b) {
if b {
tk.uiControl.Enable()
} else {
tk.uiControl.Disable()
@ -101,7 +105,7 @@ func (n *node) pad(b bool) {
log.Warn("pad() on WidgetId =", n.WidgetId)
t := n.tk
if (t == nil) {
if t == nil {
log.Log(ERROR, "pad() toolkit struct == nil. for", n.WidgetId)
return
}
@ -139,7 +143,7 @@ func (n *node) move(newParent *node) {
log.Log(INFO, "TODO: move() for widget =", n.WidgetId)
stretchy = true
if (p.tk.uiBox != nil) {
if p.tk.uiBox != nil {
p.tk.uiBox.Append(n.tk.uiControl, stretchy)
}
default:
@ -184,7 +188,7 @@ func (n *node) Delete() {
case widget.Box:
log.Log(NOW, "tWidget.boxC =", p.progname)
log.Log(NOW, "is there a tParent parent? =", p.parent)
if (p.tk.boxC < 1) {
if p.tk.boxC < 1 {
log.Log(NOW, "Can not delete from Box. already empty. tWidget.boxC =", p.tk.boxC)
return
}
@ -204,7 +208,7 @@ func (n *node) Delete() {
func rawAction(a *widget.Action) {
log.Log(INFO, "rawAction() START a.ActionType =", a.ActionType, "a.Value", a.Value)
if (a.ActionType == widget.ToolkitInit) {
if a.ActionType == widget.ToolkitInit {
Init()
return
}
@ -228,23 +232,23 @@ func rawAction(a *widget.Action) {
n := me.treeRoot.FindWidgetId(a.WidgetId)
if (a.ActionType == widget.Add) {
if a.ActionType == widget.Add {
me.treeRoot.ListWidgets()
// ui.QueueMain(func() {
add(a)
add(a)
// })
// TODO: remove this artificial delay
// sleep(.001)
return
}
if (a.ActionType == widget.Dump) {
if a.ActionType == widget.Dump {
log.Log(NOW, "rawAction() Dump =", a.ActionType, a.WidgetType, n.State.ProgName)
// me.rootNode.listChildren(true)
return
}
if (n == nil) {
if n == nil {
log.Error(errors.New("andlabs rawAction() ERROR findWidgetId found nil"), a.ActionType, a.WidgetType)
log.Log(NOW, "rawAction() ERROR findWidgetId found nil for id =", a.WidgetId)
log.Log(NOW, "rawAction() ERROR findWidgetId found nil", a.ActionType, a.WidgetType)
@ -286,18 +290,18 @@ func rawAction(a *widget.Action) {
addText(n, a)
// n.addText(a)
/*
case widget.Margin:
n.pad(true)
case widget.Unmargin:
n.pad(false)
case widget.Pad:
n.pad(true)
case widget.Unpad:
n.pad(false)
case widget.Delete:
n.Delete()
case widget.Move:
log.Log(NOW, "rawAction() attempt to move() =", a.ActionType, a.WidgetType)
case widget.Margin:
n.pad(true)
case widget.Unmargin:
n.pad(false)
case widget.Pad:
n.pad(true)
case widget.Unpad:
n.pad(false)
case widget.Delete:
n.Delete()
case widget.Move:
log.Log(NOW, "rawAction() attempt to move() =", a.ActionType, a.WidgetType)
*/
default:
log.Log(ERROR, "rawAction() Unknown =", a.ActionType, a.WidgetType)

View File

@ -1,13 +1,13 @@
package main
import (
"go.wit.com/lib/widget"
"go.wit.com/log"
"go.wit.com/gui/widget"
)
func add(a *widget.Action) {
log.Warn("andlabs add()", a.WidgetId, a.State.ProgName)
if (a.WidgetType == widget.Root) {
if a.WidgetType == widget.Root {
if me.treeRoot == nil {
me.treeRoot = me.myTree.AddNode(a)
}
@ -33,9 +33,9 @@ func add(a *widget.Action) {
newBox(n)
return
/*
case widget.Tab:
newTab(n)
return
case widget.Tab:
newTab(n)
return
*/
case widget.Label:
newLabel(p, n)
@ -62,9 +62,9 @@ func add(a *widget.Action) {
newTextbox(p, n)
return
/*
case widget.Image:
newImage(p, n)
return
case widget.Image:
newImage(p, n)
return
*/
default:
log.Log(ERROR, "add() error TODO: ", n.WidgetType, n.State.ProgName)

View File

@ -1,9 +1,9 @@
package main
import (
"go.wit.com/lib/widget"
"go.wit.com/log"
"go.wit.com/gui/widget"
"go.wit.com/gui/toolkits/tree"
"go.wit.com/toolkits/tree"
)
func compareStrings(n *tree.Node, ss []string) {
@ -14,7 +14,7 @@ func addText(n *tree.Node, a *widget.Action) {
var tk *guiWidget
tk = n.TK.(*guiWidget)
log.Warn("andlabs addText() START with a.Value =", a.Value)
if (tk == nil) {
if tk == nil {
log.Log(ERROR, "addText error. tk == nil", n.State.ProgName, n.WidgetId)
return
}

View File

@ -1,8 +1,8 @@
package main
import (
"go.wit.com/gui/widget"
"go.wit.com/gui/toolkits/tree"
"go.wit.com/lib/widget"
"go.wit.com/toolkits/tree"
"go.wit.com/dev/andlabs/ui"
_ "go.wit.com/dev/andlabs/ui/winmanifest"
@ -10,7 +10,9 @@ import (
// make new Box here
func newBox(n *tree.Node) {
if notNew(n) { return }
if notNew(n) {
return
}
newt := new(guiWidget)
var box *ui.Box

View File

@ -1,7 +1,7 @@
package main
import (
"go.wit.com/gui/toolkits/tree"
"go.wit.com/toolkits/tree"
"go.wit.com/dev/andlabs/ui"
_ "go.wit.com/dev/andlabs/ui/winmanifest"
@ -9,7 +9,9 @@ import (
// func (p *node) newButton(n *node) {
func newButton(p *tree.Node, n *tree.Node) {
if notNew(n) { return }
if notNew(n) {
return
}
var ptk *guiWidget
ptk = p.TK.(*guiWidget)
newt := new(guiWidget)

View File

@ -1,14 +1,16 @@
package main
import (
"go.wit.com/gui/toolkits/tree"
"go.wit.com/toolkits/tree"
"go.wit.com/dev/andlabs/ui"
_ "go.wit.com/dev/andlabs/ui/winmanifest"
)
func newCheckbox(p *tree.Node, n *tree.Node) {
if notNew(n) { return }
if notNew(n) {
return
}
newt := new(guiWidget)
newt.uiCheckbox = ui.NewCheckbox(n.GetLabel())

View File

@ -5,11 +5,13 @@ import (
_ "go.wit.com/dev/andlabs/ui/winmanifest"
"go.wit.com/log"
"go.wit.com/gui/toolkits/tree"
"go.wit.com/toolkits/tree"
)
func newCombobox(p, n *tree.Node) {
if notNew(n) { return }
if notNew(n) {
return
}
newt := new(guiWidget)
cb := ui.NewEditableCombobox()
@ -43,20 +45,22 @@ func newCombobox(p, n *tree.Node) {
}
func addComboboxName(n *tree.Node, s string) {
if ! ready(n) { return }
if !ready(n) {
return
}
var tk *guiWidget
tk = n.TK.(*guiWidget)
log.Log(INFO, "addComboboxName()", n.WidgetId, "add:", s)
tk.uiEditableCombobox.Append(s)
if (tk.val == nil) {
if tk.val == nil {
log.Log(INFO, "make map didn't work")
return
}
tk.val[tk.c] = s
// If this is the first menu added, set the dropdown to it
if (tk.c == 0) {
if tk.c == 0 {
log.Log(INFO, "THIS IS THE FIRST combobox", s)
tk.uiEditableCombobox.SetText(s)
}
@ -64,7 +68,9 @@ func addComboboxName(n *tree.Node, s string) {
}
func setComboboxName(n *tree.Node, s string) bool {
if ! ready(n) { return false}
if !ready(n) {
return false
}
var tk *guiWidget
tk = n.TK.(*guiWidget)
log.Log(INFO, "SetComboboxName()", n.WidgetId, ",", s)

View File

@ -1,24 +1,24 @@
package main
import (
"go.wit.com/gui/widget"
"go.wit.com/lib/widget"
)
type node struct {
parent *node
parent *node
children []*node
WidgetId int // widget ID
WidgetType widget.WidgetType
ParentId int // parent ID
WidgetId int // widget ID
WidgetType widget.WidgetType
ParentId int // parent ID
state widget.State
state widget.State
// a reference name for programming and debuggign. Must be unique
progname string
progname string
// the text used for button labesl, window titles, checkbox names, etc
label string
label string
// horizontal means layout widgets like books on a bookshelf
// vertical means layout widgets like books in a stack
@ -32,20 +32,20 @@ type node struct {
strings []string
// This is used for things like a slider(0,100)
X int
Y int
X int
Y int
// This is for the grid size & widget position
W int
H int
AtW int
AtH int
W int
H int
AtW int
AtH int
vals []string // dropdown menu items
// horizontal bool `default:false`
hasTabs bool // does the window have tabs?
hasTabs bool // does the window have tabs?
currentTab bool // the visible tab
// the internal plugin toolkit structure

View File

@ -8,11 +8,11 @@ import (
var defaultBehavior bool = true
var bookshelf bool // do you want things arranged in the box like a bookshelf or a stack?
var canvas bool // if set to true, the windows are a raw canvas
var menubar bool // for windows
var stretchy bool // expand things like buttons to the maximum size
var padded bool // add space between things like buttons
var margin bool // add space around the frames of windows
var canvas bool // if set to true, the windows are a raw canvas
var menubar bool // for windows
var stretchy bool // expand things like buttons to the maximum size
var padded bool // add space between things like buttons
var margin bool // add space around the frames of windows
var debugToolkit bool = false
var debugChange bool = false
@ -26,7 +26,7 @@ var debugError bool = true
// This is important. This sets the defaults for the gui. Without this, there isn't correct padding, etc
func setDefaultBehavior(s bool) {
defaultBehavior = s
if (defaultBehavior) {
if defaultBehavior {
log.Log(NOW, "Setting this toolkit to use the default behavior.")
log.Log(NOW, "This is the 'guessing' part as defined by the wit/gui 'Principles'. Refer to the docs.")
stretchy = false
@ -41,38 +41,38 @@ func setDefaultBehavior(s bool) {
}
func (t *guiWidget) Dump(b bool) {
if ! b {
if !b {
return
}
log.Log(NOW, "Name = ", t.Width, t.Height)
if (t.uiBox != nil) {
if t.uiBox != nil {
log.Log(NOW, "uiBox =", t.uiBox)
}
if (t.uiButton != nil) {
if t.uiButton != nil {
log.Log(NOW, "uiButton =", t.uiButton)
}
if (t.uiCombobox != nil) {
if t.uiCombobox != nil {
log.Log(NOW, "uiCombobox =", t.uiCombobox)
}
if (t.uiWindow != nil) {
if t.uiWindow != nil {
log.Log(NOW, "uiWindow =", t.uiWindow)
}
if (t.uiTab != nil) {
if t.uiTab != nil {
log.Log(NOW, "uiTab =", t.uiTab)
}
if (t.uiGroup != nil) {
if t.uiGroup != nil {
log.Log(NOW, "uiGroup =", t.uiGroup)
}
if (t.uiEntry != nil) {
if t.uiEntry != nil {
log.Log(NOW, "uiEntry =", t.uiEntry)
}
if (t.uiMultilineEntry != nil) {
if t.uiMultilineEntry != nil {
log.Log(NOW, "uiMultilineEntry =", t.uiMultilineEntry)
}
if (t.uiSlider != nil) {
if t.uiSlider != nil {
log.Log(NOW, "uiSlider =", t.uiSlider)
}
if (t.uiCheckbox != nil) {
if t.uiCheckbox != nil {
log.Log(NOW, "uiCheckbox =", t.uiCheckbox)
}
}
@ -86,7 +86,7 @@ func GetDebugToolkit () bool {
func (n *node) dumpWidget(b bool) {
var info, d string
if (n == nil) {
if n == nil {
log.Log(ERROR, "dumpWidget() node == nil")
return
}
@ -98,14 +98,14 @@ func (n *node) dumpWidget(b bool) {
for i := 0; i < listChildrenDepth; i++ {
tabs = tabs + defaultPadding
}
log.Log(NOW, tabs + d)
log.Log(NOW, tabs+d)
}
var defaultPadding string = " "
var listChildrenDepth int = 0
func (n *node) listChildren(dump bool) {
if (n == nil) {
if n == nil {
return
}

View File

@ -3,8 +3,8 @@ package main
// if you include more than just this import
// then your plugin might be doing something un-ideal (just a guess from 2023/02/27)
import (
"go.wit.com/lib/widget"
"go.wit.com/log"
"go.wit.com/gui/widget"
)
// delete the child widget from the parent
@ -16,7 +16,7 @@ func (n *node) destroy() {
pt := n.parent.tk
ct := n.tk
if (ct == nil) {
if ct == nil {
log.Log(NOW, "delete FAILED (ct = mapToolkit[c] == nil) for c", pId, cId)
// this pukes out a whole universe of shit
// listMap()
@ -30,7 +30,7 @@ func (n *node) destroy() {
pt.Dump(true)
log.Log(NOW, "Child:")
ct.Dump(true)
if (pt.uiBox == nil) {
if pt.uiBox == nil {
log.Log(NOW, "Don't know how to destroy this")
} else {
log.Log(NOW, "Fuck it, destroy the whole box", n.parent.progname)
@ -46,7 +46,7 @@ func (n *node) destroy() {
log.Log(NOW, "Should delete Window here:", n.progname)
default:
log.Log(NOW, "Fuckit, let's destroy a button")
if (ct.uiButton != nil) {
if ct.uiButton != nil {
pt.uiBox.Delete(4)
ct.uiButton.Destroy()
}

View File

@ -5,11 +5,13 @@ import (
_ "go.wit.com/dev/andlabs/ui/winmanifest"
"go.wit.com/log"
"go.wit.com/gui/toolkits/tree"
"go.wit.com/toolkits/tree"
)
func newDropdown(p, n *tree.Node) {
if notNew(n) { return }
if notNew(n) {
return
}
newt := new(guiWidget)
log.Log(INFO, "gui.Toolbox.newDropdown() START", n.GetProgName())
@ -23,7 +25,7 @@ func newDropdown(p, n *tree.Node) {
cb.OnSelected(func(spin *ui.Combobox) {
i := spin.Selected()
if (newt.val == nil) {
if newt.val == nil {
log.Log(ERROR, "make map didn't work")
n.SetValue("map did not work. ui.Combobox error")
} else {
@ -32,14 +34,15 @@ func newDropdown(p, n *tree.Node) {
me.myTree.DoUserEvent(n)
})
n.TK = newt
place(p, n)
log.Warn("add dropdown entries on create:", n.State.Strings)
log.Warn("add dropdown entries on create:", n.State.Strings)
log.Warn("add dropdown entries on create:", n.State.Strings)
if n.State.Strings == nil {return}
if n.State.Strings == nil {
return
}
// add the initial dropdown entries
for i, s := range n.State.Strings {
log.Warn("add dropdown: add entries on create", n.GetProgName(), i, s)
@ -51,27 +54,31 @@ func newDropdown(p, n *tree.Node) {
}
func setDropdownInt(n *tree.Node, i int) {
if ! ready(n) { return }
if !ready(n) {
return
}
var tk *guiWidget
tk = n.TK.(*guiWidget)
tk.uiCombobox.SetSelected(i)
}
func addDropdownName(n *tree.Node, s string) {
if ! ready(n) { return }
if !ready(n) {
return
}
var tk *guiWidget
tk = n.TK.(*guiWidget)
log.Log(INFO, "addDropdownName()", n.WidgetId, "add:", s)
tk.uiCombobox.Append(s)
if (tk.val == nil) {
if tk.val == nil {
log.Log(INFO, "make map didn't work")
return
}
tk.val[tk.c] = s
// If this is the first menu added, set the dropdown to it
if (tk.c == 0) {
if tk.c == 0 {
log.Log(INFO, "THIS IS THE FIRST Dropdown", s)
tk.uiCombobox.SetSelected(0)
}
@ -79,7 +86,9 @@ func addDropdownName(n *tree.Node, s string) {
}
func setDropdownName(n *tree.Node, s string) bool {
if ! ready(n) { return false}
if !ready(n) {
return false
}
var tk *guiWidget
tk = n.TK.(*guiWidget)
log.Log(INFO, "SetDropdownName()", n.WidgetId, ",", s)

View File

@ -1,7 +1,7 @@
package main
import (
"go.wit.com/gui/toolkits/tree"
"go.wit.com/toolkits/tree"
"go.wit.com/dev/andlabs/ui"
_ "go.wit.com/dev/andlabs/ui/winmanifest"
@ -13,7 +13,9 @@ import (
// -- (1,2) -- (2,1) -- (3,1) --
// -----------------------------
func newGrid(n *tree.Node) {
if notNew(n) { return }
if notNew(n) {
return
}
var newt *guiWidget
newt = new(guiWidget)

View File

@ -2,14 +2,16 @@ package main
import (
// "go.wit.com/gui/widget"
"go.wit.com/gui/toolkits/tree"
"go.wit.com/toolkits/tree"
"go.wit.com/dev/andlabs/ui"
_ "go.wit.com/dev/andlabs/ui/winmanifest"
)
func newGroup(p, n *tree.Node) {
if notNew(n) { return }
if notNew(n) {
return
}
newt := new(guiWidget)
g := ui.NewGroup(n.GetLabel())

View File

@ -1,27 +1,27 @@
package main
var rawImage = []byte{
0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d,
0x49, 0x48, 0x44, 0x52, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x10,
0x08, 0x06, 0x00, 0x00, 0x00, 0x1f, 0xf3, 0xff, 0x61, 0x00, 0x00, 0x00,
0x01, 0x73, 0x52, 0x47, 0x42, 0x00, 0xae, 0xce, 0x1c, 0xe9, 0x00, 0x00,
0x00, 0xca, 0x49, 0x44, 0x41, 0x54, 0x38, 0x11, 0xa5, 0x93, 0xb1, 0x0d,
0xc2, 0x40, 0x0c, 0x45, 0x1d, 0xc4, 0x14, 0x0c, 0x12, 0x41, 0x0f, 0x62,
0x12, 0x46, 0x80, 0x8a, 0x2e, 0x15, 0x30, 0x02, 0x93, 0x20, 0x68, 0x11,
0x51, 0x06, 0x61, 0x0d, 0x88, 0x2d, 0x7f, 0xdb, 0x07, 0x87, 0x08, 0xdc,
0x49, 0x91, 0x7d, 0xf6, 0xf7, 0xf3, 0x4f, 0xa4, 0x54, 0xbb, 0xeb, 0xf6,
0x41, 0x05, 0x67, 0xcc, 0xb3, 0x9b, 0xfa, 0xf6, 0x17, 0x62, 0xdf, 0xcd,
0x48, 0x00, 0x32, 0xbd, 0xa8, 0x1d, 0x72, 0xee, 0x3c, 0x47, 0x16, 0xfb,
0x5c, 0x53, 0x8d, 0x03, 0x30, 0x14, 0x84, 0xf7, 0xd5, 0x89, 0x26, 0xc7,
0x25, 0x10, 0x36, 0xe4, 0x05, 0xa2, 0x51, 0xbc, 0xc4, 0x1c, 0xc3, 0x1c,
0xed, 0x30, 0x1c, 0x8f, 0x16, 0x3f, 0x02, 0x78, 0x33, 0x20, 0x06, 0x60,
0x97, 0x70, 0xaa, 0x45, 0x7f, 0x85, 0x60, 0x5d, 0xb6, 0xf4, 0xc2, 0xc4,
0x3e, 0x0f, 0x44, 0xcd, 0x1b, 0x20, 0x90, 0x0f, 0xed, 0x85, 0xa8, 0x55,
0x05, 0x42, 0x43, 0xb4, 0x9e, 0xce, 0x71, 0xb3, 0xe8, 0x0e, 0xb4, 0xc4,
0xc3, 0x39, 0x21, 0xb7, 0x73, 0xbd, 0xe4, 0x1b, 0xe4, 0x04, 0xb6, 0xaa,
0x4f, 0x18, 0x2c, 0xee, 0x42, 0x31, 0x01, 0x84, 0xfa, 0xe0, 0xd4, 0x00,
0xdf, 0xb6, 0x83, 0xf8, 0xea, 0xc2, 0x00, 0x10, 0xfc, 0x1a, 0x05, 0x30,
0x74, 0x3b, 0xe0, 0xd1, 0x45, 0xb1, 0x83, 0xaa, 0xf4, 0x77, 0x7e, 0x02,
0x87, 0x1f, 0x42, 0x7f, 0x9e, 0x2b, 0xe8, 0xdf, 0x00, 0x00, 0x00, 0x00,
0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82,
0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d,
0x49, 0x48, 0x44, 0x52, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x10,
0x08, 0x06, 0x00, 0x00, 0x00, 0x1f, 0xf3, 0xff, 0x61, 0x00, 0x00, 0x00,
0x01, 0x73, 0x52, 0x47, 0x42, 0x00, 0xae, 0xce, 0x1c, 0xe9, 0x00, 0x00,
0x00, 0xca, 0x49, 0x44, 0x41, 0x54, 0x38, 0x11, 0xa5, 0x93, 0xb1, 0x0d,
0xc2, 0x40, 0x0c, 0x45, 0x1d, 0xc4, 0x14, 0x0c, 0x12, 0x41, 0x0f, 0x62,
0x12, 0x46, 0x80, 0x8a, 0x2e, 0x15, 0x30, 0x02, 0x93, 0x20, 0x68, 0x11,
0x51, 0x06, 0x61, 0x0d, 0x88, 0x2d, 0x7f, 0xdb, 0x07, 0x87, 0x08, 0xdc,
0x49, 0x91, 0x7d, 0xf6, 0xf7, 0xf3, 0x4f, 0xa4, 0x54, 0xbb, 0xeb, 0xf6,
0x41, 0x05, 0x67, 0xcc, 0xb3, 0x9b, 0xfa, 0xf6, 0x17, 0x62, 0xdf, 0xcd,
0x48, 0x00, 0x32, 0xbd, 0xa8, 0x1d, 0x72, 0xee, 0x3c, 0x47, 0x16, 0xfb,
0x5c, 0x53, 0x8d, 0x03, 0x30, 0x14, 0x84, 0xf7, 0xd5, 0x89, 0x26, 0xc7,
0x25, 0x10, 0x36, 0xe4, 0x05, 0xa2, 0x51, 0xbc, 0xc4, 0x1c, 0xc3, 0x1c,
0xed, 0x30, 0x1c, 0x8f, 0x16, 0x3f, 0x02, 0x78, 0x33, 0x20, 0x06, 0x60,
0x97, 0x70, 0xaa, 0x45, 0x7f, 0x85, 0x60, 0x5d, 0xb6, 0xf4, 0xc2, 0xc4,
0x3e, 0x0f, 0x44, 0xcd, 0x1b, 0x20, 0x90, 0x0f, 0xed, 0x85, 0xa8, 0x55,
0x05, 0x42, 0x43, 0xb4, 0x9e, 0xce, 0x71, 0xb3, 0xe8, 0x0e, 0xb4, 0xc4,
0xc3, 0x39, 0x21, 0xb7, 0x73, 0xbd, 0xe4, 0x1b, 0xe4, 0x04, 0xb6, 0xaa,
0x4f, 0x18, 0x2c, 0xee, 0x42, 0x31, 0x01, 0x84, 0xfa, 0xe0, 0xd4, 0x00,
0xdf, 0xb6, 0x83, 0xf8, 0xea, 0xc2, 0x00, 0x10, 0xfc, 0x1a, 0x05, 0x30,
0x74, 0x3b, 0xe0, 0xd1, 0x45, 0xb1, 0x83, 0xaa, 0xf4, 0x77, 0x7e, 0x02,
0x87, 0x1f, 0x42, 0x7f, 0x9e, 0x2b, 0xe8, 0xdf, 0x00, 0x00, 0x00, 0x00,
0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82,
}

View File

@ -18,6 +18,7 @@ func (p *node) newImage(n *node) {
n.tk = newt
// p.place(n)
}
/*
if (a.Name == "image") {
log(true, "NewTextbox() trying to add a new image")

View File

@ -1,14 +1,16 @@
package main
import (
"go.wit.com/gui/toolkits/tree"
"go.wit.com/toolkits/tree"
"go.wit.com/dev/andlabs/ui"
_ "go.wit.com/dev/andlabs/ui/winmanifest"
)
func newLabel(p, n *tree.Node) {
if notNew(n) { return }
if notNew(n) {
return
}
newt := new(guiWidget)
c := ui.NewLabel(n.GetLabel())
newt.uiLabel = c

View File

@ -4,7 +4,7 @@ package main
this enables command line options from other packages like 'gui' and 'log'
*/
import (
import (
log "go.wit.com/log"
)
@ -22,10 +22,10 @@ func init() {
full := "toolkit/nocui"
short := "nocui"
NOW = log.NewFlag( "NOW", true, full, short, "temp debugging stuff")
NOW = log.NewFlag("NOW", true, full, short, "temp debugging stuff")
INFO = log.NewFlag("INFO", false, full, short, "normal debugging stuff")
WARN = log.NewFlag("WARN", true, full, short, "bad things")
WARN = log.NewFlag("WARN", true, full, short, "bad things")
SPEW = log.NewFlag("SPEW", false, full, short, "spew stuff")
ERROR = log.NewFlag("ERROR", false, full, short, "toolkit errors")

View File

@ -1,12 +1,12 @@
package main
import (
"sync"
"runtime/debug"
"sync"
"go.wit.com/lib/widget"
"go.wit.com/log"
"go.wit.com/gui/widget"
"go.wit.com/gui/toolkits/tree"
"go.wit.com/toolkits/tree"
"go.wit.com/dev/andlabs/ui"
// the _ means we only need this for the init()
@ -27,7 +27,7 @@ func queueMain(currentA widget.Action) {
me.myTree.DoToolkitPanic()
}
}()
ui.QueueMain( func() {
ui.QueueMain(func() {
rawAction(&currentA)
})
}

View File

@ -5,11 +5,10 @@ import (
"go.wit.com/dev/andlabs/ui"
_ "go.wit.com/dev/andlabs/ui/winmanifest"
"go.wit.com/lib/widget"
"go.wit.com/log"
"go.wit.com/gui/widget"
"go.wit.com/gui/toolkits/tree"
"go.wit.com/toolkits/tree"
)
// This routine is very specific to this toolkit
@ -31,7 +30,7 @@ import (
// -----------------------------
// internally for andlabs/ui
// (x&y flipped and start at zero)
// (x&y flipped and start at zero)
// -----------------------------
// -- (0,0) -- (1,0) -- (1,0) --
// -- (0,1) -- (1,1) -- (1,1) --
@ -41,7 +40,7 @@ func place(p *tree.Node, n *tree.Node) bool {
log.Warn("SPEEDY newplace() 1 START", n.WidgetId, n.GetProgName(), n.GetLabel(), n.String())
log.Warn("SPEEDY newplace() n.State.Strings =", n.State.Strings)
log.Log(INFO, "place() 1 START", n.WidgetType, n.GetProgName(), n.GetLabel())
if ! ready(n) {
if !ready(n) {
log.Warn("place() 1 START not ready()")
return false
}
@ -51,7 +50,7 @@ func place(p *tree.Node, n *tree.Node) bool {
ptk = p.TK.(*guiWidget)
log.Warn("SPEEDY newplace() 2 START", n.WidgetId, n.GetProgName(), n.GetLabel())
if (ptk == nil) {
if ptk == nil {
log.Log(ERROR, "ptk == nil", p.GetProgName(), p.ParentId, p.WidgetType, ptk)
log.Log(ERROR, "n = ", n.GetProgName(), n.ParentId, n.WidgetType, tk)
log.Warn("SPEEDY ptk == nil", n.WidgetId, n.GetProgName())
@ -71,19 +70,19 @@ func place(p *tree.Node, n *tree.Node) bool {
false, ui.AlignFill, false, ui.AlignFill)
return true
case widget.Group:
if (ptk.uiBox == nil) {
if ptk.uiBox == nil {
log.Log(WARN, "place() andlabs hack group to use add a box", n.GetProgName(), n.WidgetType)
ptk.uiBox = rawBox(n)
ptk.uiBox = rawBox(n)
ptk.uiGroup.SetChild(ptk.uiBox)
}
ptk.uiBox.Append(tk.uiControl, stretchy)
return true
case widget.Tab:
if (ptk.uiTab == nil) {
if ptk.uiTab == nil {
log.Log(ERROR, "ptk.uiTab == nil for n.WidgetId =", n.WidgetId, "ptk =", ptk)
panic("ptk.uiTab == nil")
}
if (tk.uiControl == nil) {
if tk.uiControl == nil {
log.Log(ERROR, "tk.uiControl == nil for n.WidgetId =", n.WidgetId, "tk =", tk)
panic("tk.uiControl == nil")
}

View File

@ -1,9 +1,9 @@
package main
import (
"go.wit.com/lib/widget"
"go.wit.com/log"
"go.wit.com/gui/widget"
"go.wit.com/gui/toolkits/tree"
"go.wit.com/toolkits/tree"
)
// func (n *node) setText(a *widget.Action) {
@ -13,7 +13,7 @@ func setText(n *tree.Node, a *widget.Action) {
tk = n.TK.(*guiWidget)
log.Log(CHANGE, "setText() START with text =", name)
if (tk == nil) {
if tk == nil {
log.Log(ERROR, "setText error. tk == nil", n.GetProgName(), n.WidgetId)
return
}
@ -29,10 +29,10 @@ func setText(n *tree.Node, a *widget.Action) {
case widget.Checkbox:
tk.uiCheckbox.SetText(name)
case widget.Textbox:
if (tk.uiEntry != nil) {
if tk.uiEntry != nil {
tk.uiEntry.SetText(name)
}
if (tk.uiMultilineEntry != nil) {
if tk.uiMultilineEntry != nil {
tk.uiMultilineEntry.SetText(name)
}
case widget.Label:
@ -52,7 +52,7 @@ func setText(n *tree.Node, a *widget.Action) {
// try to find the string
for i, s = range tk.val {
log.Log(CHANGE, "i, s", i, s)
if (name == s) {
if name == s {
tk.uiCombobox.SetSelected(i)
log.Log(CHANGE, "setText() Dropdown worked.", name)
return
@ -60,11 +60,11 @@ func setText(n *tree.Node, a *widget.Action) {
}
log.Log(ERROR, "setText() Dropdown did not find:", name)
// if i == -1, then there are not any things in the menu to select
if (i == -1) {
if i == -1 {
return
}
// if the string was never set, then set the dropdown to the last thing added to the menu
if (orig == -1) {
if orig == -1 {
tk.uiCombobox.SetSelected(i)
}
case widget.Combobox:
@ -72,5 +72,5 @@ func setText(n *tree.Node, a *widget.Action) {
default:
log.Log(ERROR, "plugin Send() Don't know how to setText on", n.WidgetType, "yet", a.ActionType)
}
log.Log(CHANGE, "setText() END with name =", )
log.Log(CHANGE, "setText() END with name =")
}

View File

@ -1,14 +1,16 @@
package main
import (
"go.wit.com/gui/toolkits/tree"
"go.wit.com/toolkits/tree"
"go.wit.com/dev/andlabs/ui"
_ "go.wit.com/dev/andlabs/ui/winmanifest"
)
func newSlider(p, n *tree.Node) {
if notNew(n) { return }
if notNew(n) {
return
}
newt := new(guiWidget)
var x, y int

View File

@ -1,17 +1,19 @@
package main
import (
"go.wit.com/gui/toolkits/tree"
"go.wit.com/toolkits/tree"
"go.wit.com/dev/andlabs/ui"
_ "go.wit.com/dev/andlabs/ui/winmanifest"
)
func newSpinner(p, n *tree.Node) {
if notNew(n) { return }
if notNew(n) {
return
}
newt := new(guiWidget)
s := ui.NewSpinbox(n.State.Range.Low,n.State.Range.High)
s := ui.NewSpinbox(n.State.Range.Low, n.State.Range.High)
newt.uiSpinbox = s
newt.uiControl = s

View File

@ -1,7 +1,7 @@
package main
import (
"go.wit.com/gui/toolkits/tree"
"go.wit.com/toolkits/tree"
"go.wit.com/dev/andlabs/ui"
_ "go.wit.com/dev/andlabs/ui/winmanifest"
@ -17,7 +17,7 @@ var me config
type config struct {
rootNode *tree.Node // the base of the binary tree. it should have id == 0
treeRoot *tree.Node // the base of the binary tree. it should have id == 0
myTree *tree.TreeInfo
myTree *tree.TreeInfo
}
// stores the raw toolkit internals
@ -26,7 +26,7 @@ type guiWidget struct {
Height int
// tw *toolkit.Widget
parent *guiWidget
parent *guiWidget
children []*guiWidget
// used to track if a tab has a child widget yet
@ -34,31 +34,31 @@ type guiWidget struct {
uiControl ui.Control
uiBox *ui.Box
uiButton *ui.Button
uiCombobox *ui.Combobox
uiCheckbox *ui.Checkbox
uiEntry *ui.Entry
uiGroup *ui.Group
uiLabel *ui.Label
uiSlider *ui.Slider
uiSpinbox *ui.Spinbox
uiTab *ui.Tab
uiWindow *ui.Window
uiBox *ui.Box
uiButton *ui.Button
uiCombobox *ui.Combobox
uiCheckbox *ui.Checkbox
uiEntry *ui.Entry
uiGroup *ui.Group
uiLabel *ui.Label
uiSlider *ui.Slider
uiSpinbox *ui.Spinbox
uiTab *ui.Tab
uiWindow *ui.Window
uiMultilineEntry *ui.MultilineEntry
uiEditableCombobox *ui.EditableCombobox
uiImage *ui.Image
uiEditableCombobox *ui.EditableCombobox
uiImage *ui.Image
uiGrid *ui.Grid
gridX int
gridY int
uiGrid *ui.Grid
gridX int
gridY int
// used as a counter to work around limitations of widgets like combobox
// this is probably fucked up and in many ways wrong because of unsafe goroutine threading
// but it's working for now due to the need for need for a correct interaction layer betten toolkits
c int
c int
val map[int]string
// andlabs/ui only accesses widget id numbers
boxC int // how many things on in a box or how many tabs
boxC int // how many things on in a box or how many tabs
}

View File

@ -1,32 +1,32 @@
package main
import (
"go.wit.com/lib/widget"
"go.wit.com/log"
"go.wit.com/gui/widget"
"go.wit.com/dev/andlabs/ui"
_ "go.wit.com/dev/andlabs/ui/winmanifest"
)
/*
This adds a tab
This adds a tab
andlabs/ui is goofy in the sense that you have to determine
if the ui.Window already has a tab in it. If it does, then
you need to add this tab and not run SetChild() on the window
or instead it replaces the existing tab with the new one
andlabs/ui is goofy in the sense that you have to determine
if the ui.Window already has a tab in it. If it does, then
you need to add this tab and not run SetChild() on the window
or instead it replaces the existing tab with the new one
I work around this by always sending a Toolkit that is a tab
once there is one. If you send a Window here, it will replace
any existing tabs rather than adding a new one
I work around this by always sending a Toolkit that is a tab
once there is one. If you send a Window here, it will replace
any existing tabs rather than adding a new one
*/
func (p *node) newTab(n *node) {
var newt *guiWidget
if (p == nil) {
if p == nil {
log.Log(ERROR, "newTab() p == nil. how the fuck does this happen?", n.WidgetId, n.ParentId)
}
if (p.WidgetType != widget.Window) {
if p.WidgetType != widget.Window {
log.Log(ERROR, "newTab() uiWindow == nil. I can't add a toolbar without window", n.WidgetId, n.ParentId)
return
}
@ -34,15 +34,15 @@ func (p *node) newTab(n *node) {
log.Log(TOOLKIT, "newTab() START", n.WidgetId, n.ParentId)
if (t.uiTab == nil) {
if t.uiTab == nil {
// this means you have to make a new tab
log.Log(TOOLKIT, "newTab() GOOD. This should be the first tab:", n.WidgetId, n.ParentId)
log.Log(TOOLKIT, "newTab() GOOD. This should be the first tab:", n.WidgetId, n.ParentId)
newt = rawTab(t.uiWindow, widget.GetString(n.value))
t.uiTab = newt.uiTab
} else {
// this means you have to append a tab
log.Log(TOOLKIT, "newTab() GOOD. This should be an additional tab:", n.WidgetId, n.ParentId)
if (n.WidgetType == widget.Tab) {
log.Log(TOOLKIT, "newTab() GOOD. This should be an additional tab:", n.WidgetId, n.ParentId)
if n.WidgetType == widget.Tab {
// andlabs doesn't have multiple tab widgets so make a fake one?
// this makes a guiWidget internal structure with the parent values
newt = new(guiWidget)
@ -62,16 +62,16 @@ func (p *node) newTab(n *node) {
func tabSetMargined(tab *ui.Tab, b bool) {
c := tab.NumPages()
for i := 0; i < c; i++ {
log.Log(TOOLKIT, "SetMargined", i, b)
log.Log(TOOLKIT, "SetMargined", i, b)
tab.SetMargined(i, b)
}
}
func rawTab(w *ui.Window, name string) *guiWidget {
var newt guiWidget
log.Log(TOOLKIT, "rawTab() START", name)
log.Log(TOOLKIT, "rawTab() START", name)
if (w == nil) {
if w == nil {
log.Log(ERROR, "UiWindow == nil. I can't add a tab without a window")
log.Log(ERROR, "UiWindow == nil. I can't add a tab without a window")
log.Log(ERROR, "UiWindow == nil. I can't add a tab without a window")
@ -91,17 +91,17 @@ func (t *guiWidget) appendTab(name string) *guiWidget {
var newT guiWidget
log.Log(TOOLKIT, "appendTab() ADD", name)
if (t.uiTab == nil) {
if t.uiTab == nil {
log.Log(TOOLKIT, "UiWindow == nil. I can't add a widget without a place to put it")
panic("should never have happened. wit/gui/toolkit has ui.Tab == nil")
}
log.Log(TOOLKIT, "appendTab() START name =", name)
var hbox *ui.Box
if (defaultBehavior) {
if defaultBehavior {
hbox = ui.NewHorizontalBox()
} else {
if (bookshelf) {
if bookshelf {
hbox = ui.NewHorizontalBox()
} else {
hbox = ui.NewVerticalBox()

View File

@ -1,17 +1,19 @@
package main
import (
"go.wit.com/gui/toolkits/tree"
"go.wit.com/toolkits/tree"
"go.wit.com/dev/andlabs/ui"
_ "go.wit.com/dev/andlabs/ui/winmanifest"
)
func newTextbox(p, n *tree.Node) {
if notNew(n) { return }
if notNew(n) {
return
}
newt := new(guiWidget)
if (n.State.Range.Low == 1) {
if n.State.Range.Low == 1 {
e := ui.NewEntry()
newt.uiEntry = e
newt.uiControl = e

View File

@ -12,7 +12,7 @@ package main
*/
import (
"go.wit.com/gui/widget"
"go.wit.com/lib/widget"
)
// Other goroutines must use this to access the GUI

View File

@ -1,8 +1,8 @@
package main
import (
"go.wit.com/gui/widget"
"go.wit.com/gui/toolkits/tree"
"go.wit.com/lib/widget"
"go.wit.com/toolkits/tree"
)
func initWidget(n *tree.Node) *guiWidget {

View File

@ -4,9 +4,9 @@ import (
"go.wit.com/dev/andlabs/ui"
_ "go.wit.com/dev/andlabs/ui/winmanifest"
"go.wit.com/lib/widget"
"go.wit.com/log"
"go.wit.com/gui/widget"
"go.wit.com/gui/toolkits/tree"
"go.wit.com/toolkits/tree"
)
func (t *guiWidget) MessageWindow(msg1 string, msg2 string) {
@ -22,7 +22,7 @@ func newWindow(p, n *tree.Node) {
newt = new(guiWidget)
// menubar bool is if the OS defined border on the window should be used
win := ui.NewWindow(n.GetProgName(), 640, 480, menubar)
win := ui.NewWindow(n.GetProgName(), 640, 480, menubar)
win.SetBorderless(canvas)
win.SetMargined(margin)
win.OnClosing(func(*ui.Window) bool {
@ -42,7 +42,7 @@ func newWindow(p, n *tree.Node) {
func (n *node) SetWindowTitle(title string) {
log.Log(CHANGE, "toolkit NewWindow", widget.GetString(n.value), "title", title)
win := n.tk.uiWindow
if (win == nil) {
if win == nil {
log.Log(ERROR, "Error: no window", n.WidgetId)
} else {
win.SetTitle(title)

View File

@ -1,12 +1,13 @@
package main
import (
"go.wit.com/lib/widget"
log "go.wit.com/log"
"go.wit.com/gui/widget"
)
var fakeStartWidth int = me.FakeW
var fakeStartHeight int = me.TabH + me.FramePadH
// setup fake labels for non-visible things off screen
func (n *node) setFake() {
w := n.tk
@ -16,11 +17,11 @@ func (n *node) setFake() {
fakeStartHeight += w.gocuiSize.Height()
// TODO: use the actual max hight of the terminal window
if (fakeStartHeight > 24) {
if fakeStartHeight > 24 {
fakeStartHeight = me.TabH
fakeStartWidth += me.FakeW
}
if (true) {
if true {
n.showView()
}
}
@ -70,9 +71,9 @@ func (n *node) addWidget() {
return
default:
/*
if n.IsCurrent() {
n.updateCurrent()
}
if n.IsCurrent() {
n.updateCurrent()
}
*/
}
n.showWidgetPlacement(true, "addWidget()")

View File

@ -4,7 +4,7 @@ package main
this enables command line options from other packages like 'gui' and 'log'
*/
import (
import (
"go.wit.com/log"
)
@ -22,10 +22,10 @@ func init() {
full := "toolkit/nocui"
short := "nocui"
NOW = log.NewFlag( "NOW", true, full, short, "temp debugging stuff")
NOW = log.NewFlag("NOW", true, full, short, "temp debugging stuff")
INFO = log.NewFlag("INFO", false, full, short, "normal debugging stuff")
WARN = log.NewFlag("WARN", true, full, short, "bad things")
WARN = log.NewFlag("WARN", true, full, short, "bad things")
SPEW = log.NewFlag("SPEW", false, full, short, "spew stuff")
ERROR = log.NewFlag("ERROR", false, full, short, "toolkit errors")

View File

@ -1,13 +1,13 @@
package main
import (
// "github.com/awesome-gocui/gocui"
"go.wit.com/gui/widget"
// "github.com/awesome-gocui/gocui"
"go.wit.com/lib/widget"
)
func (n *node) setCheckbox(b any) {
w := n.tk
if (n.WidgetType != widget.Checkbox) {
if n.WidgetType != widget.Checkbox {
return
}
if widget.GetBool(b) {
@ -20,13 +20,13 @@ func (n *node) setCheckbox(b any) {
t := len(n.tk.label) + 1
w.gocuiSize.w1 = w.gocuiSize.w0 + t
// w.realWidth = w.gocuiSize.Width() + me.PadW
// w.realHeight = w.gocuiSize.Height() + me.PadH
// w.realWidth = w.gocuiSize.Width() + me.PadW
// w.realHeight = w.gocuiSize.Height() + me.PadH
// if w.frame {
// w.realWidth += me.FramePadW
// w.realHeight += me.FramePadH
// }
// if w.frame {
// w.realWidth += me.FramePadW
// w.realHeight += me.FramePadH
// }
n.deleteView()
n.showView()

View File

@ -3,8 +3,8 @@ package main
import (
"fmt"
"github.com/awesome-gocui/gocui"
"go.wit.com/lib/widget"
"go.wit.com/log"
"go.wit.com/gui/widget"
)
// set isCurrent = false everywhere
@ -92,15 +92,15 @@ func (n *node) doWidgetClick() {
case widget.Root:
// THIS IS THE BEGINING OF THE LAYOUT
log.Log(NOW, "doWidgetClick()", n.progname)
redoWindows(0,0)
redoWindows(0, 0)
case widget.Flag:
log.Log(NOW, "doWidgetClick() FLAG widget name =", n.progname)
log.Log(NOW, "doWidgetClick() if this is the dropdown menu, handle it here?")
case widget.Window:
if (me.currentWindow == n) {
if me.currentWindow == n {
return
}
if (me.currentWindow != nil) {
if me.currentWindow != nil {
unsetCurrent(me.currentWindow)
me.currentWindow.setColor(&colorWindow)
me.currentWindow.hideWidgets()
@ -111,7 +111,7 @@ func (n *node) doWidgetClick() {
n.setColor(&colorActiveW)
n.redoTabs(me.TabW, me.TabH)
for _, child := range n.children {
if (child.currentTab == true) {
if child.currentTab == true {
log.Log(NOW, "FOUND CURRENT TAB", child.progname)
setCurrentTab(child)
child.placeWidgets(me.RawW, me.RawH)
@ -124,12 +124,12 @@ func (n *node) doWidgetClick() {
}
*/
case widget.Tab:
if (n.IsCurrent()) {
if n.IsCurrent() {
return // do nothing if you reclick on the already selected tab
}
// find the window and disable the active tab
p := n.parent
if (p != nil) {
if p != nil {
p.hideWidgets()
p.redoTabs(me.TabW, me.TabH)
unsetCurrent(p)
@ -149,7 +149,7 @@ func (n *node) doWidgetClick() {
// n.placeWidgets(p.tk.startH, newH)
n.toggleTree()
case widget.Checkbox:
if (widget.GetBool(n.value)) {
if widget.GetBool(n.value) {
n.setCheckbox(false)
} else {
n.setCheckbox(true)
@ -166,7 +166,7 @@ func (n *node) doWidgetClick() {
n.showWidgets()
case widget.Box:
// w.showWidgetPlacement(logNow, "drawTree()")
if (n.direction == widget.Horizontal) {
if n.direction == widget.Horizontal {
log.Log(NOW, "BOX IS HORIZONTAL", n.progname)
} else {
log.Log(NOW, "BOX IS VERTICAL", n.progname)
@ -177,7 +177,7 @@ func (n *node) doWidgetClick() {
n.doUserEvent()
case widget.Dropdown:
log.Log(NOW, "do the dropdown here")
if (me.ddview == nil) {
if me.ddview == nil {
me.ddview = addDropdown()
tk := me.ddview.tk
tk.gocuiSize.w0 = 20
@ -189,7 +189,7 @@ func (n *node) doWidgetClick() {
tk.gocuiSize.h0,
tk.gocuiSize.w1,
tk.gocuiSize.h1, 0)
if (tk.v == nil) {
if tk.v == nil {
return
}
tk.v.Wrap = true
@ -200,7 +200,7 @@ func (n *node) doWidgetClick() {
return
}
log.Log(NOW, "doWidgetClick() visible =", me.ddview.Visible())
if (me.ddview.Visible()) {
if me.ddview.Visible() {
me.ddview.SetVisible(false)
me.baseGui.DeleteView("ddview")
me.ddview.tk.v = nil
@ -224,8 +224,9 @@ func (n *node) doWidgetClick() {
}
var toggle bool = true
func (n *node) toggleTree() {
if (toggle) {
if toggle {
n.drawTree(toggle)
toggle = false
} else {
@ -234,15 +235,14 @@ func (n *node) toggleTree() {
}
}
// display the widgets in the binary tree
func (n *node) drawTree(draw bool) {
w := n.tk
if (w == nil) {
if w == nil {
return
}
n.showWidgetPlacement(true, "drawTree()")
if (draw) {
if draw {
// w.textResize()
n.showView()
} else {
@ -261,9 +261,9 @@ func click(g *gocui.Gui, v *gocui.View) error {
log.Log(INFO, "click() START", v.Name())
// n := me.rootNode.findWidgetName(v.Name())
n := findUnderMouse()
if (n != nil) {
if n != nil {
log.Log(NOW, "click() Found widget =", n.WidgetId, n.progname, ",", n.label)
if (n.progname == "DropBox") {
if n.progname == "DropBox" {
log.Log(NOW, "click() this is the dropdown menu. set a flag here what did I click? where is the mouse?")
log.Log(NOW, "click() set a global dropdown clicked flag=true here")
me.ddClicked = true
@ -285,7 +285,7 @@ func click(g *gocui.Gui, v *gocui.View) error {
func findUnderMouse() *node {
var found *node
var widgets []*node
var f func (n *node)
var f func(n *node)
w, h := me.baseGui.MousePosition()
// find buttons that are below where the mouse button click
@ -293,13 +293,13 @@ func findUnderMouse() *node {
widget := n.tk
// ignore widgets that are not visible
if n.Visible() {
if ((widget.gocuiSize.w0 <= w) && (w <= widget.gocuiSize.w1) &&
(widget.gocuiSize.h0 <= h) && (h <= widget.gocuiSize.h1)) {
if (widget.gocuiSize.w0 <= w) && (w <= widget.gocuiSize.w1) &&
(widget.gocuiSize.h0 <= h) && (h <= widget.gocuiSize.h1) {
widgets = append(widgets, n)
found = n
}
}
if (n == me.ddview) {
if n == me.ddview {
log.Log(NOW, "findUnderMouse() found ddview")
if n.Visible() {
log.Log(NOW, "findUnderMouse() and ddview is visable. hide it here. TODO: find highlighted row")
@ -331,14 +331,14 @@ func ctrlDown(g *gocui.Gui, v *gocui.View) error {
// var widgets []*node
// var f func (n *node)
found = findUnderMouse()
if (me.ctrlDown == nil) {
if me.ctrlDown == nil {
setupCtrlDownWidget()
me.ctrlDown.label = found.progname
me.ctrlDown.tk.cuiName = "ctrlDown"
// me.ctrlDown.parent = me.rootNode
}
cd := me.ctrlDown.tk
if (found == nil) {
if found == nil {
found = me.rootNode
}
me.ctrlDown.label = found.progname

View File

@ -1,8 +1,8 @@
package main
import (
"math/rand"
"github.com/awesome-gocui/gocui"
"math/rand"
"go.wit.com/log"
)
@ -13,18 +13,18 @@ import (
type colorT struct {
frame gocui.Attribute
fg gocui.Attribute
bg gocui.Attribute
fg gocui.Attribute
bg gocui.Attribute
selFg gocui.Attribute
selBg gocui.Attribute
name string
name string
}
var none gocui.Attribute = gocui.AttrNone
var lightPurple gocui.Attribute = gocui.GetColor("#DDDDDD") // light purple
var darkPurple gocui.Attribute = gocui.GetColor("#FFAA55") // Dark Purple
var heavyPurple gocui.Attribute = gocui.GetColor("#88AA55") // heavy purple
var powdererBlue gocui.Attribute = gocui.GetColor("#B0E0E6") // w3c 'powerder blue'
var lightPurple gocui.Attribute = gocui.GetColor("#DDDDDD") // light purple
var darkPurple gocui.Attribute = gocui.GetColor("#FFAA55") // Dark Purple
var heavyPurple gocui.Attribute = gocui.GetColor("#88AA55") // heavy purple
var powdererBlue gocui.Attribute = gocui.GetColor("#B0E0E6") // w3c 'powerder blue'
var superLightGrey gocui.Attribute = gocui.GetColor("#55AAFF") // super light grey
// Standard defined colors from gocui:
@ -37,28 +37,29 @@ var superLightGrey gocui.Attribute = gocui.GetColor("#55AAFF") // super light gr
// v.BgColor = gocui.GetColor("#55AAFF") // super light grey
// v.BgColor = gocui.GetColor("#FFC0CB") // 'w3c pink' yellow
// Normal Text On mouseover
// Widget Frame Text background Text background
var colorWindow colorT = colorT{ none , gocui.ColorBlue, none , none , powdererBlue , "normal window"}
var colorActiveW colorT = colorT{ none , none , powdererBlue , none , powdererBlue , "active window"}
// Normal Text On mouseover
//
// Widget Frame Text background Text background
var colorWindow colorT = colorT{none, gocui.ColorBlue, none, none, powdererBlue, "normal window"}
var colorActiveW colorT = colorT{none, none, powdererBlue, none, powdererBlue, "active window"}
var colorTab colorT = colorT{gocui.ColorBlue, gocui.ColorBlue, none , none , powdererBlue , "normal tab"}
var colorActiveT colorT = colorT{gocui.ColorBlue, none , powdererBlue , none , powdererBlue , "active tab"}
var colorTab colorT = colorT{gocui.ColorBlue, gocui.ColorBlue, none, none, powdererBlue, "normal tab"}
var colorActiveT colorT = colorT{gocui.ColorBlue, none, powdererBlue, none, powdererBlue, "active tab"}
var colorButton colorT = colorT{gocui.ColorGreen, none , gocui.ColorWhite, gocui.ColorGreen, gocui.ColorBlack, "normal button"}
var colorLabel colorT = colorT{ none , none , superLightGrey , none , superLightGrey , "normal label"}
var colorGroup colorT = colorT{ none , none , superLightGrey , none , superLightGrey , "normal group"}
var colorButton colorT = colorT{gocui.ColorGreen, none, gocui.ColorWhite, gocui.ColorGreen, gocui.ColorBlack, "normal button"}
var colorLabel colorT = colorT{none, none, superLightGrey, none, superLightGrey, "normal label"}
var colorGroup colorT = colorT{none, none, superLightGrey, none, superLightGrey, "normal group"}
// widget debugging colors. these widgets aren't displayed unless you are debugging
var colorRoot colorT = colorT{gocui.ColorRed , none , powdererBlue , none , gocui.ColorBlue, "debug root"}
var colorFlag colorT = colorT{gocui.ColorRed , none , powdererBlue , none , gocui.ColorGreen, "debug flag"}
var colorBox colorT = colorT{gocui.ColorRed , none , lightPurple , none , gocui.ColorCyan, "debug box"}
var colorGrid colorT = colorT{gocui.ColorRed , none , lightPurple , none , gocui.ColorRed, "debug grid"}
var colorNone colorT = colorT{ none , none , none , none , none , "debug none"}
var colorRoot colorT = colorT{gocui.ColorRed, none, powdererBlue, none, gocui.ColorBlue, "debug root"}
var colorFlag colorT = colorT{gocui.ColorRed, none, powdererBlue, none, gocui.ColorGreen, "debug flag"}
var colorBox colorT = colorT{gocui.ColorRed, none, lightPurple, none, gocui.ColorCyan, "debug box"}
var colorGrid colorT = colorT{gocui.ColorRed, none, lightPurple, none, gocui.ColorRed, "debug grid"}
var colorNone colorT = colorT{none, none, none, none, none, "debug none"}
// actually sets the colors for the gocui element
// actually sets the colors for the gocui element
// the user will see the colors change when this runs
// TODO: add black/white only flag for ttyS0
// TODO: add black/white only flag for ttyS0
// TODO: or fix kvm/qemu serial console & SIGWINCH.
// TODO: and minicom and uboot and 5 million other things.
// TODO: maybe enough of us could actually do that if we made it a goal.
@ -66,15 +67,15 @@ var colorNone colorT = colorT{ none , none , non
// TODO: so just a small little 'todo' item here
func (n *node) setColor(newColor *colorT) {
tk := n.tk
if (tk.color == newColor) {
if tk.color == newColor {
// nothing to do since the colors have nto changed
return
}
tk.color = newColor
if (tk.v == nil) {
if tk.v == nil {
return
}
if (tk.color == nil) {
if tk.color == nil {
log.Log(NOW, "Set the node to color = nil")
tk.color = &colorNone
}
@ -88,7 +89,7 @@ func (n *node) setDefaultWidgetColor() {
func (n *node) setDefaultHighlight() {
w := n.tk
if (w.v == nil) {
if w.v == nil {
log.Log(ERROR, "SetColor() failed on view == nil")
return
}
@ -105,7 +106,7 @@ func randColor() gocui.Attribute {
func (n *node) redoColor(draw bool) {
w := n.tk
if (w == nil) {
if w == nil {
return
}

View File

@ -12,8 +12,8 @@ package main
*/
import (
"go.wit.com/lib/widget"
"go.wit.com/log"
"go.wit.com/gui/widget"
)
// this is the channel we send user events like
@ -24,20 +24,20 @@ var callback chan widget.Action
var pluginChan chan widget.Action
type node struct {
parent *node
parent *node
children []*node
WidgetId int // widget ID
WidgetType widget.WidgetType
ParentId int // parent ID
WidgetId int // widget ID
WidgetType widget.WidgetType
ParentId int // parent ID
state widget.State
state widget.State
// a reference name for programming and debuggign. Must be unique
progname string
progname string
// the text used for button labesl, window titles, checkbox names, etc
label string
label string
// horizontal means layout widgets like books on a bookshelf
// vertical means layout widgets like books in a stack
@ -51,20 +51,20 @@ type node struct {
strings []string
// This is used for things like a slider(0,100)
X int
Y int
X int
Y int
// This is for the grid size & widget position
W int
H int
AtW int
AtH int
W int
H int
AtW int
AtH int
vals []string // dropdown menu items
// horizontal bool `default:false`
hasTabs bool // does the window have tabs?
hasTabs bool // does the window have tabs?
currentTab bool // the visible tab
// the internal plugin toolkit structure
@ -75,7 +75,7 @@ type node struct {
// searches the binary tree for a WidgetId
func (n *node) findWidgetId(id int) *node {
if (n == nil) {
if n == nil {
return nil
}
@ -85,7 +85,7 @@ func (n *node) findWidgetId(id int) *node {
for _, child := range n.children {
newN := child.findWidgetId(id)
if (newN != nil) {
if newN != nil {
return newN
}
}
@ -93,7 +93,7 @@ func (n *node) findWidgetId(id int) *node {
}
func (n *node) doUserEvent() {
if (callback == nil) {
if callback == nil {
log.Log(ERROR, "doUserEvent() callback == nil", n.WidgetId)
return
}
@ -196,12 +196,12 @@ func addNode(a *widget.Action) *node {
n.tk = initWidget(n)
// n.tk = new(guiWidget)
if (a.WidgetType == widget.Root) {
if a.WidgetType == widget.Root {
log.Log(INFO, "addNode() Root")
return n
}
if (me.rootNode.findWidgetId(a.WidgetId) != nil) {
if me.rootNode.findWidgetId(a.WidgetId) != nil {
log.Log(ERROR, "addNode() WidgetId already exists", a.WidgetId)
return me.rootNode.findWidgetId(a.WidgetId)
}

View File

@ -2,13 +2,13 @@ package main
import (
"fmt"
"go.wit.com/lib/widget"
"go.wit.com/log"
"go.wit.com/gui/widget"
)
func (n *node) dumpTree(draw bool) {
w := n.tk
if (w == nil) {
if w == nil {
return
}
n.showWidgetPlacement(true, "dumpTree()")
@ -19,7 +19,7 @@ func (n *node) dumpTree(draw bool) {
}
func (n *node) showWidgetPlacement(b bool, s string) {
if (n == nil) {
if n == nil {
log.Log(ERROR, "WTF w == nil")
return
}
@ -27,7 +27,7 @@ func (n *node) showWidgetPlacement(b bool, s string) {
var s1 string
var pId int
if (n.parent == nil) {
if n.parent == nil {
log.Log(INFO, "showWidgetPlacement() parent == nil", n.WidgetId, w.cuiName)
pId = 0
} else {
@ -41,8 +41,8 @@ func (n *node) showWidgetPlacement(b bool, s string) {
} else {
s1 += fmt.Sprintf(" ")
}
if (n.parent != nil) {
if (n.parent.WidgetType == widget.Grid) {
if n.parent != nil {
if n.parent.WidgetType == widget.Grid {
s1 += fmt.Sprintf("At(%2d,%2d) ", n.AtW, n.AtH)
}
}
@ -55,7 +55,7 @@ func (n *node) dumpWidget(pad string) {
}
func (n *node) listWidgets() {
if (n == nil) {
if n == nil {
return
}

View File

@ -2,8 +2,8 @@ package main
import (
"bytes"
"io"
"errors"
"io"
)
type FakeFile struct {

View File

@ -56,7 +56,7 @@ func gocuiEvent(g *gocui.Gui) error {
if widgetView, _ := g.View("msg"); widgetView == nil {
log.Log(NOW, "handleEvent() create output widget now", maxX, maxY, mx, my)
makeOutputWidget(g, "this is a create before a mouse click")
if (me.logStdout != nil) {
if me.logStdout != nil {
// setOutput(me.logStdout)
}
} else {
@ -75,7 +75,7 @@ func setFrame(b bool) {
// TODO: figure out what this might be useful for
// what is this do? I made it just 2 lines for now. Is this useful for something?
v := SetView("global", 5, 10, 5, 10, 0) // x0, x1, y1, y2, overlap
if (v == nil) {
if v == nil {
log.Log(ERROR, "setFrame() global failed")
}
v.Frame = b
@ -86,7 +86,7 @@ func quit(g *gocui.Gui, v *gocui.View) error {
}
func SetView(name string, x0, y0, x1, y1 int, overlaps byte) *gocui.View {
if (me.baseGui == nil) {
if me.baseGui == nil {
log.Log(ERROR, "SetView() ERROR: me.baseGui == nil")
return nil
}

View File

@ -42,13 +42,13 @@ func helplayout() error {
maxX, _ := g.Size()
var newW int = 8
for _, s := range(helpText) {
for _, s := range helpText {
if newW < len(s) {
newW = len(s)
}
}
help, err := g.SetView("help", maxX-(newW + me.FramePadW), 0, maxX-1, len(helpText) + me.FramePadH, 0)
help, err := g.SetView("help", maxX-(newW+me.FramePadW), 0, maxX-1, len(helpText)+me.FramePadH, 0)
if err != nil {
if !errors.Is(err, gocui.ErrUnknownView) {
return err

View File

@ -7,8 +7,8 @@ package main
import (
"github.com/awesome-gocui/gocui"
"go.wit.com/lib/widget"
"go.wit.com/log"
"go.wit.com/gui/widget"
)
func defaultKeybindings(g *gocui.Gui) error {
@ -30,13 +30,13 @@ func defaultKeybindings(g *gocui.Gui) error {
if err := g.SetKeybinding("", gocui.MouseLeft, gocui.ModMouseCtrl, ctrlDown); err != nil {
return err
}
// if err := g.SetKeybinding(w.v.Name(), gocui.MouseLeft, gocui.ModNone, click); err != nil {
// return err
// }
// if err := g.SetKeybinding(w.v.Name(), gocui.MouseLeft, gocui.ModNone, click); err != nil {
// return err
// }
/*
if err := g.SetKeybinding("", gocui.MouseLeft, gocui.ModNone, globalDown); err != nil {
return err
}
if err := g.SetKeybinding("", gocui.MouseLeft, gocui.ModNone, globalDown); err != nil {
return err
}
*/
if err := g.SetKeybinding("msg", gocui.MouseLeft, gocui.ModNone, msgDown); err != nil {
return err
@ -51,7 +51,7 @@ func addDebugKeys(g *gocui.Gui) {
func(g *gocui.Gui, v *gocui.View) error {
fakeStartWidth = me.FakeW
fakeStartHeight = me.TabH + me.FramePadH
if (showDebug) {
if showDebug {
me.rootNode.showFake()
showDebug = false
} else {
@ -59,12 +59,12 @@ func addDebugKeys(g *gocui.Gui) {
showDebug = true
}
return nil
})
})
// display the help menu
g.SetKeybinding("", '?', gocui.ModNone,
func(g *gocui.Gui, v *gocui.View) error {
if (showHelp) {
if showHelp {
helplayout()
showHelp = false
} else {
@ -72,48 +72,48 @@ func addDebugKeys(g *gocui.Gui) {
showHelp = true
}
return nil
})
})
// redraw all the widgets
g.SetKeybinding("", 'r', gocui.ModNone,
func(g *gocui.Gui, v *gocui.View) error {
if (redoWidgets) {
redoWindows(0,0)
if redoWidgets {
redoWindows(0, 0)
redoWidgets = false
} else {
me.rootNode.hideWidgets()
redoWidgets = true
}
return nil
})
})
// hide all widgets
g.SetKeybinding("", 'h', gocui.ModNone,
func(g *gocui.Gui, v *gocui.View) error {
me.rootNode.hideWidgets()
return nil
})
})
// show all widgets
g.SetKeybinding("", 's', gocui.ModNone,
func(g *gocui.Gui, v *gocui.View) error {
me.rootNode.showWidgets()
return nil
})
})
// list all widgets
g.SetKeybinding("", 'L', gocui.ModNone,
func(g *gocui.Gui, v *gocui.View) error {
me.rootNode.listWidgets()
return nil
})
})
// list all widgets with positions
g.SetKeybinding("", 'M', gocui.ModNone,
func(g *gocui.Gui, v *gocui.View) error {
me.rootNode.dumpTree(true)
return nil
})
})
// log to output window
g.SetKeybinding("", 'o', gocui.ModNone,
@ -127,33 +127,33 @@ func addDebugKeys(g *gocui.Gui) {
// setOutput(me.logStdout.tk)
}
return nil
})
})
// exit
g.SetKeybinding("", 'q', gocui.ModNone,
func(g *gocui.Gui, v *gocui.View) error {
standardExit()
return nil
})
})
g.SetKeybinding("", gocui.KeyCtrlC, gocui.ModNone,
func(g *gocui.Gui, v *gocui.View) error {
standardExit()
return nil
})
})
g.SetKeybinding("", gocui.KeyCtrlD, gocui.ModNone,
func(g *gocui.Gui, v *gocui.View) error {
if (showDebug) {
if showDebug {
var a widget.Action
a.Value = true
a.ActionType = widget.EnableDebug
callback <- a
}
return nil
})
})
g.SetKeybinding("", gocui.KeyCtrlV, gocui.ModNone,
func(g *gocui.Gui, v *gocui.View) error {
return nil
})
})
// panic
g.SetKeybinding("", 'p', gocui.ModNone,
@ -161,5 +161,5 @@ func addDebugKeys(g *gocui.Gui) {
standardExit()
panic("forced panic in gocui")
return nil
})
})
}

View File

@ -7,8 +7,8 @@ package main
import (
"os"
"go.wit.com/lib/widget"
"go.wit.com/log"
"go.wit.com/gui/widget"
)
// sets defaults and establishes communication
@ -38,9 +38,9 @@ func catchActionChannel() {
log.Log(INFO, "catchActionChannel() START")
for {
log.Log(INFO, "catchActionChannel() infinite for() loop restarted select on channel")
select {
select {
case a := <-pluginChan:
if (me.baseGui == nil) {
if me.baseGui == nil {
// something went wrong initializing the gocui
log.Log(ERROR, "ERROR: console did not initialize")
continue
@ -84,7 +84,7 @@ func main() {
var err error
log.Log(INFO, "main() start Init()")
outf, err = os.OpenFile("/tmp/witgui.log", os.O_RDWR | os.O_CREATE | os.O_APPEND, 0666)
outf, err = os.OpenFile("/tmp/witgui.log", os.O_RDWR|os.O_CREATE|os.O_APPEND, 0666)
if err != nil {
log.Error(err, "error opening file: %v")
os.Exit(0)

View File

@ -38,10 +38,10 @@ func msgDown(g *gocui.Gui, v *gocui.View) error {
func hideDDview() error {
w, h := me.baseGui.MousePosition()
log.Log(NOW, "hide dropdown menu() view msgMouseDown (w,h) =", w, h)
if (me.ddview == nil) {
if me.ddview == nil {
return gocui.ErrUnknownView
}
if (me.ddview.tk.v == nil) {
if me.ddview.tk.v == nil {
return gocui.ErrUnknownView
}
me.ddview.SetVisible(false)
@ -51,10 +51,10 @@ func hideDDview() error {
func showDDview() error {
w, h := me.baseGui.MousePosition()
log.Log(NOW, "show dropdown menu() view msgMouseDown (w,h) =", w, h)
if (me.ddview == nil) {
if me.ddview == nil {
return gocui.ErrUnknownView
}
if (me.ddview.tk.v == nil) {
if me.ddview.tk.v == nil {
return gocui.ErrUnknownView
}
me.ddview.SetVisible(true)
@ -64,27 +64,27 @@ func showDDview() error {
func mouseUp(g *gocui.Gui, v *gocui.View) error {
w, h := g.MousePosition()
log.Log(NOW, "mouseUp() view msgMouseDown (check here for dropdown menu click) (w,h) =", w, h)
if (me.ddClicked) {
if me.ddClicked {
me.ddClicked = false
log.Log(NOW, "mouseUp() ddview is the thing that was clicked", w, h)
log.Log(NOW, "mouseUp() find out what the string is here", w, h, me.ddview.tk.gocuiSize.h1)
var newZone string = ""
if (me.ddNode != nil) {
if me.ddNode != nil {
value := h - me.ddview.tk.gocuiSize.h0 - 1
log.Log(NOW, "mouseUp() me.ddview.tk.gocuiSize.h1 =", me.ddview.tk.gocuiSize.h1)
log.Log(NOW, "mouseUp() me.ddNode.vals =", me.ddNode.vals)
valsLen := len(me.ddNode.vals)
log.Log(NOW, "mouseUp() value =", value, "valsLen =", valsLen)
log.Log(NOW, "mouseUp() me.ddNode.vals =", me.ddNode.vals)
if ((value >= 0) && (value < valsLen)) {
if (value >= 0) && (value < valsLen) {
newZone = me.ddNode.vals[value]
log.Log(NOW, "mouseUp() value =", value, "newZone =", newZone)
}
}
hideDDview()
if (newZone != "") {
if (me.ddNode != nil) {
if newZone != "" {
if me.ddNode != nil {
me.ddNode.SetText(newZone)
me.ddNode.value = newZone
me.ddNode.doUserEvent()
@ -93,10 +93,10 @@ func mouseUp(g *gocui.Gui, v *gocui.View) error {
return nil
}
/*
// if there is a drop down view active, treat it like a dialog box and close it
if (hideDDview() == nil) {
return nil
}
// if there is a drop down view active, treat it like a dialog box and close it
if (hideDDview() == nil) {
return nil
}
*/
if msgMouseDown {
msgMouseDown = false
@ -124,8 +124,8 @@ func mouseDown(g *gocui.Gui, v *gocui.View) error {
maxX, _ := g.Size()
test := findUnderMouse()
msg := fmt.Sprintf("Mouse really down at: %d,%d", mx, my) + "foobar"
if (test == me.ddview) {
if (me.ddview.Visible()) {
if test == me.ddview {
if me.ddview.Visible() {
log.Log(NOW, "hide DDview() Mouse really down at:", mx, my)
hideDDview()
} else {

View File

@ -3,12 +3,12 @@ package main
import (
"strings"
"go.wit.com/lib/widget"
"go.wit.com/log"
"go.wit.com/gui/widget"
)
func (n *node) placeBox(startW int, startH int) {
if (n.WidgetType != widget.Box) {
if n.WidgetType != widget.Box {
return
}
n.showWidgetPlacement(true, "boxS()")
@ -21,7 +21,7 @@ func (n *node) placeBox(startW int, startH int) {
newR := child.realGocuiSize()
w := newR.w1 - newR.w0
h := newR.h1 - newR.h0
if (n.direction == widget.Horizontal) {
if n.direction == widget.Horizontal {
log.Log(NOW, "BOX IS HORIZONTAL", n.progname, "newWH()", newW, newH, "child()", w, h, child.progname)
// expand based on the child width
newW += w
@ -39,10 +39,10 @@ func (n *node) placeBox(startW int, startH int) {
}
func (n *node) placeWidgets(startW int, startH int) {
if (n == nil) {
if n == nil {
return
}
if (me.rootNode == nil) {
if me.rootNode == nil {
return
}
@ -87,7 +87,7 @@ func (n *node) placeWidgets(startW int, startH int) {
func (n *node) placeGrid(startW int, startH int) {
w := n.tk
n.showWidgetPlacement(true, "grid0:")
if (n.WidgetType != widget.Grid) {
if n.WidgetType != widget.Grid {
return
}
@ -98,10 +98,10 @@ func (n *node) placeGrid(startW int, startH int) {
childH := newR.h1 - newR.h0
// set the child's realWidth, and grid offset
if (w.widths[child.AtW] < childW) {
if w.widths[child.AtW] < childW {
w.widths[child.AtW] = childW
}
if (w.heights[child.AtH] < childH) {
if w.heights[child.AtH] < childH {
w.heights[child.AtH] = childH
}
// child.showWidgetPlacement(logInfo, "grid: ")
@ -114,12 +114,12 @@ func (n *node) placeGrid(startW int, startH int) {
var totalW, totalH int
for i, w := range w.widths {
if (i < child.AtW) {
if i < child.AtW {
totalW += w
}
}
for i, h := range w.heights {
if (i < child.AtH) {
if i < child.AtH {
totalH += h
}
}
@ -137,7 +137,7 @@ func (n *node) placeGrid(startW int, startH int) {
// computes the real, actual size of all the gocli objects in a widget
func (n *node) realGocuiSize() *rectType {
var f func (n *node, r *rectType)
var f func(n *node, r *rectType)
newR := new(rectType)
// initialize the values to opposite
newR.w0 = 80
@ -153,7 +153,7 @@ func (n *node) realGocuiSize() *rectType {
// expand the rectangle to the biggest thing displayed
f = func(n *node, r *rectType) {
newR := n.tk.gocuiSize
if ! n.tk.isFake {
if !n.tk.isFake {
if r.w0 > newR.w0 {
r.w0 = newR.w0
}
@ -179,7 +179,7 @@ func (n *node) textSize() (int, int) {
var width, height int
for _, s := range strings.Split(widget.GetString(n.value), "\n") {
if (width < len(s)) {
if width < len(s) {
width = len(s)
}
height += 1

View File

@ -3,20 +3,20 @@ package main
import (
// if you include more than just this import
// then your plugin might be doing something un-ideal (just a guess from 2023/02/27)
"go.wit.com/lib/widget"
"go.wit.com/log"
"go.wit.com/gui/widget"
)
func action(a *widget.Action) {
log.Log(INFO, "action() START", a.WidgetId, a.ActionType, a.WidgetType, a.ProgName)
n := me.rootNode.findWidgetId(a.WidgetId)
var w *guiWidget
if (n != nil) {
if n != nil {
w = n.tk
}
switch a.ActionType {
case widget.Add:
if (w == nil) {
if w == nil {
n := addNode(a)
// w = n.tk
n.addWidget()
@ -37,7 +37,7 @@ func action(a *widget.Action) {
log.Log(NOW, "TODO: set flag here", a.ActionType, a.WidgetType, a.ProgName)
log.Log(NOW, "TODO: n.WidgetType =", n.WidgetType, "n.progname =", a.ProgName)
} else {
if (a.Value == nil) {
if a.Value == nil {
log.Log(ERROR, "TODO: Set here. a == nil id =", a.WidgetId, "type =", a.WidgetType, "Name =", a.ProgName)
log.Log(ERROR, "TODO: Set here. id =", a.WidgetId, "n.progname =", n.progname)
} else {
@ -74,7 +74,7 @@ func action(a *widget.Action) {
}
func (n *node) AddText(text string) {
if (n == nil) {
if n == nil {
log.Log(NOW, "widget is nil")
return
}
@ -87,7 +87,7 @@ func (n *node) AddText(text string) {
func (n *node) SetText(text string) {
var changed bool = false
if (n == nil) {
if n == nil {
log.Log(NOW, "widget is nil")
return
}
@ -95,11 +95,11 @@ func (n *node) SetText(text string) {
n.value = text
changed = true
}
if (! changed) {
if !changed {
return
}
if (n.Visible()) {
if n.Visible() {
n.textResize()
n.deleteView()
n.showView()
@ -111,7 +111,7 @@ func (n *node) Set(val any) {
log.Log(INFO, "Set() value =", val)
n.value = val
if (n.WidgetType != widget.Checkbox) {
if n.WidgetType != widget.Checkbox {
n.setCheckbox(val)
}
}

View File

@ -6,8 +6,8 @@ import (
"github.com/awesome-gocui/gocui"
"go.wit.com/lib/widget"
"go.wit.com/log"
"go.wit.com/gui/widget"
)
var outputW int = 180
@ -18,7 +18,7 @@ func moveMsg(g *gocui.Gui) {
if !movingMsg && (mx != initialMouseX || my != initialMouseY) {
movingMsg = true
}
g.SetView("msg", mx-xOffset, my-yOffset, mx-xOffset+outputW, my-yOffset+outputH + me.FramePadH, 0)
g.SetView("msg", mx-xOffset, my-yOffset, mx-xOffset+outputW, my-yOffset+outputH+me.FramePadH, 0)
g.SetViewOnBottom("msg")
}
@ -43,12 +43,12 @@ func showMsg(g *gocui.Gui, v *gocui.View) error {
func makeOutputWidget(g *gocui.Gui, stringFromMouseClick string) *gocui.View {
maxX, maxY := g.Size()
if (me.rootNode == nil) {
if me.rootNode == nil {
// keep skipping this until the binary tree is initialized
return nil
}
if (me.logStdout == nil) {
if me.logStdout == nil {
a := new(widget.Action)
a.ProgName = "stdout"
a.WidgetType = widget.Stdout
@ -57,12 +57,12 @@ func makeOutputWidget(g *gocui.Gui, stringFromMouseClick string) *gocui.View {
n := addNode(a)
me.logStdout = n
me.logStdout.tk.gocuiSize.w0 = maxX - 32
me.logStdout.tk.gocuiSize.h0 = maxY/2
me.logStdout.tk.gocuiSize.h0 = maxY / 2
me.logStdout.tk.gocuiSize.w1 = me.logStdout.tk.gocuiSize.w0 + outputW
me.logStdout.tk.gocuiSize.h1 = me.logStdout.tk.gocuiSize.h0 + outputH
}
v, err := g.View("msg")
if (v == nil) {
if v == nil {
log.Log(NOW, "makeoutputwindow() this is supposed to happen. v == nil", err)
} else {
log.Log(NOW, "makeoutputwindow() msg != nil. WTF now? err =", err)
@ -76,12 +76,12 @@ func makeOutputWidget(g *gocui.Gui, stringFromMouseClick string) *gocui.View {
log.Log(NOW, "makeoutputwindow() this is supposed to happen?", err)
}
if (err != nil) {
if err != nil {
log.Log(NOW, "makeoutputwindow() create output window failed", err)
return nil
}
if (v == nil) {
if v == nil {
log.Log(NOW, "makeoutputwindow() msg == nil. WTF now? err =", err)
return nil
} else {
@ -91,7 +91,7 @@ func makeOutputWidget(g *gocui.Gui, stringFromMouseClick string) *gocui.View {
v.Clear()
v.SelBgColor = gocui.ColorCyan
v.SelFgColor = gocui.ColorBlack
fmt.Fprintln(v, "figure out how to capture STDOUT to here\n" + stringFromMouseClick)
fmt.Fprintln(v, "figure out how to capture STDOUT to here\n"+stringFromMouseClick)
g.SetViewOnBottom("msg")
// g.SetViewOnBottom(v.Name())
return v

View File

@ -10,11 +10,11 @@ package main
import (
"fmt"
"github.com/awesome-gocui/gocui"
"reflect"
"strconv"
"sync"
"strings"
"github.com/awesome-gocui/gocui"
"sync"
"go.wit.com/log"
)
@ -30,24 +30,24 @@ var redoWidgets bool = true
var currentWindow *node
type config struct {
baseGui *gocui.Gui // the main gocui handle
rootNode *node // the base of the binary tree. it should have id == 0
baseGui *gocui.Gui // the main gocui handle
rootNode *node // the base of the binary tree. it should have id == 0
ctrlDown *node // shown if you click the mouse when the ctrl key is pressed
ctrlDown *node // shown if you click the mouse when the ctrl key is pressed
currentWindow *node // this is the current tab or window to show
logStdout *node // where to show STDOUT
helpLabel *gocui.View
ddview *node // the gocui view to select dropdrown lists
ddClicked bool // the dropdown menu view was clicked
ddNode *node // the dropdown menu is for this widget
logStdout *node // where to show STDOUT
helpLabel *gocui.View
ddview *node // the gocui view to select dropdrown lists
ddClicked bool // the dropdown menu view was clicked
ddNode *node // the dropdown menu is for this widget
/*
// this is the channel we send user events like
// mouse clicks or keyboard events back to the program
callback chan toolkit.Action
// this is the channel we send user events like
// mouse clicks or keyboard events back to the program
callback chan toolkit.Action
// this is the channel we get requests to make widgets
pluginChan chan toolkit.Action
// this is the channel we get requests to make widgets
pluginChan chan toolkit.Action
*/
// When the widget has a frame, like a button, it adds 2 lines runes on each side
@ -62,12 +62,12 @@ type config struct {
// how far down to start Window or Tab headings
WindowW int `default:"8" dense:"0"`
WindowH int `default:"-1"`
TabW int `default:"5" dense:"0"`
TabH int `default:"1" dense:"0"`
TabW int `default:"5" dense:"0"`
TabH int `default:"1" dense:"0"`
// additional amount of space to put between window & tab widgets
WindowPadW int `default:"8" dense:"0"`
TabPadW int `default:"4" dense:"0"`
TabPadW int `default:"4" dense:"0"`
// additional amount of space to indent on a group
GroupPadW int `default:"6" dense:"2"`
@ -79,12 +79,12 @@ type config struct {
// offset for the hidden widgets
FakeW int `default:"20"`
padded bool // add space between things like buttons
padded bool // add space between things like buttons
bookshelf bool // do you want things arranged in the box like a bookshelf or a stack?
canvas bool // if set to true, the windows are a raw canvas
menubar bool // for windows
stretchy bool // expand things like buttons to the maximum size
margin bool // add space around the frames of windows
canvas bool // if set to true, the windows are a raw canvas
menubar bool // for windows
stretchy bool // expand things like buttons to the maximum size
margin bool // add space around the frames of windows
// writeMutex protects locks the write process
writeMutex sync.Mutex
@ -96,13 +96,13 @@ type config struct {
// deprecate these
var (
initialMouseX, initialMouseY, xOffset, yOffset int
globalMouseDown, msgMouseDown, movingMsg bool
globalMouseDown, msgMouseDown, movingMsg bool
)
// this is the gocui way
// corner starts at in the upper left corner
type rectType struct {
w0, h0, w1, h1 int // left top right bottom
w0, h0, w1, h1 int // left top right bottom
}
func (r *rectType) Width() int {
@ -115,11 +115,11 @@ func (r *rectType) Height() int {
type guiWidget struct {
// the gocui package variables
v *gocui.View // this is nil if the widget is not displayed
cuiName string // what gocui uses to reference the widget
v *gocui.View // this is nil if the widget is not displayed
cuiName string // what gocui uses to reference the widget
// the actual text to display in the console
label string
label string
// the logical size of the widget
// For example, 40x12 would be the center of a normal terminal
@ -130,14 +130,14 @@ type guiWidget struct {
gocuiSize rectType
isCurrent bool // is this the currently displayed Window or Tab?
isFake bool // widget types like 'box' are 'false'
isFake bool // widget types like 'box' are 'false'
// used to track the size of grids
widths map[int]int // how tall each row in the grid is
widths map[int]int // how tall each row in the grid is
heights map[int]int // how wide each column in the grid is
tainted bool
frame bool
frame bool
// for a window, this is currently selected tab
selectedTab *node
@ -156,13 +156,13 @@ func (w *guiWidget) Write(p []byte) (n int, err error) {
w.tainted = true
me.writeMutex.Lock()
defer me.writeMutex.Unlock()
if (me.logStdout.tk.v == nil) {
if me.logStdout.tk.v == nil {
// optionally write the output to /tmp
s := fmt.Sprint(string(p))
s = strings.TrimSuffix(s, "\n")
fmt.Fprintln(outf, s)
v, _ := me.baseGui.View("msg")
if (v != nil) {
if v != nil {
// fmt.Fprintln(outf, "found msg")
me.logStdout.tk.v = v
}
@ -174,7 +174,7 @@ func (w *guiWidget) Write(p []byte) (n int, err error) {
s = strings.TrimSuffix(s, "\n")
tmp := strings.Split(s, "\n")
outputS = append(outputS, tmp...)
if (len(outputS) > outputH) {
if len(outputS) > outputH {
l := len(outputS) - outputH
outputS = outputS[l:]
}

View File

@ -5,8 +5,8 @@ package main
import (
"strings"
"go.wit.com/lib/widget"
"go.wit.com/log"
"go.wit.com/gui/widget"
)
func (w *guiWidget) Width() int {
@ -58,11 +58,11 @@ func redoWindows(nextW int, nextH int) {
w := n.tk
var tabs bool
for _, child := range n.children {
if (child.WidgetType == widget.Tab) {
if child.WidgetType == widget.Tab {
tabs = true
}
}
if (tabs) {
if tabs {
// window is tabs. Don't show it as a standard button
w.frame = false
n.hasTabs = true

View File

@ -1,15 +1,15 @@
package main
import (
"fmt"
"errors"
"bufio"
"errors"
"fmt"
"strings"
"github.com/awesome-gocui/gocui"
"go.wit.com/lib/widget"
"go.wit.com/log"
"go.wit.com/gui/widget"
)
func splitLines(s string) []string {
@ -28,20 +28,20 @@ func (n *node) textResize() bool {
for i, s := range splitLines(n.tk.label) {
log.Log(INFO, "textResize() len =", len(s), i, s)
if (width < len(s)) {
if width < len(s) {
width = len(s)
}
height += 1
}
if (w.gocuiSize.w1 != w.gocuiSize.w0 + width + me.FramePadW) {
if w.gocuiSize.w1 != w.gocuiSize.w0+width+me.FramePadW {
w.gocuiSize.w1 = w.gocuiSize.w0 + width + me.FramePadW
changed = true
}
if (w.gocuiSize.h1 != w.gocuiSize.h0 + height + me.FramePadH) {
if w.gocuiSize.h1 != w.gocuiSize.h0+height+me.FramePadH {
w.gocuiSize.h1 = w.gocuiSize.h0 + height + me.FramePadH
changed = true
}
if (changed) {
if changed {
n.showWidgetPlacement(true, "textResize() changed")
}
return changed
@ -57,22 +57,22 @@ func (n *node) showView() {
var err error
w := n.tk
if (w.cuiName == "") {
if w.cuiName == "" {
log.Log(ERROR, "showView() w.cuiName was not set for widget", w)
w.cuiName = string(n.WidgetId)
}
// if the gocui element doesn't exist, create it
if (w.v == nil) {
if w.v == nil {
n.recreateView()
}
}
x0, y0, x1, y1, err := me.baseGui.ViewPosition(w.cuiName)
log.Log(INFO, "showView() w.v already defined for widget", n.progname, err)
// n.smartGocuiSize()
changed := n.textResize()
if (changed) {
if changed {
log.Log(NOW, "showView() textResize() changed. Should recreateView here wId =", w.cuiName)
} else {
log.Log(NOW, "showView() Clear() and Fprint() here wId =", w.cuiName)
@ -85,21 +85,21 @@ func (n *node) showView() {
// if the gocui element has changed where it is supposed to be on the screen
// recreate it
if (x0 != w.gocuiSize.w0) {
if x0 != w.gocuiSize.w0 {
n.recreateView()
return
}
if (y0 != w.gocuiSize.h0) {
if y0 != w.gocuiSize.h0 {
log.Log(ERROR, "showView() start hight mismatch id=", w.cuiName, "gocui h vs computed h =", w.gocuiSize.h0, y0)
n.recreateView()
return
}
if (x1 != w.gocuiSize.w1) {
if x1 != w.gocuiSize.w1 {
log.Log(ERROR, "showView() too wide", w.cuiName, "w,w", w.gocuiSize.w1, x1)
n.recreateView()
return
}
if (y1 != w.gocuiSize.h1) {
if y1 != w.gocuiSize.h1 {
log.Log(ERROR, "showView() too high", w.cuiName, "h,h", w.gocuiSize.h1, y1)
n.recreateView()
return
@ -114,7 +114,7 @@ func (n *node) recreateView() {
var err error
w := n.tk
log.Log(ERROR, "recreateView() START", n.WidgetType, n.progname)
if (me.baseGui == nil) {
if me.baseGui == nil {
log.Log(ERROR, "recreateView() ERROR: me.baseGui == nil", w)
return
}
@ -123,11 +123,11 @@ func (n *node) recreateView() {
me.baseGui.DeleteView(w.cuiName)
w.v = nil
if (n.progname == "CLOUDFLARE_EMAIL") {
n.showWidgetPlacement(true, "n.progname=" + n.progname + " n.tk.label=" + n.tk.label + " " + w.cuiName)
if n.progname == "CLOUDFLARE_EMAIL" {
n.showWidgetPlacement(true, "n.progname="+n.progname+" n.tk.label="+n.tk.label+" "+w.cuiName)
n.dumpWidget("jwc")
n.textResize()
n.showWidgetPlacement(true, "n.progname=" + n.progname + " n.tk.label=" + n.tk.label + " " + w.cuiName)
n.showWidgetPlacement(true, "n.progname="+n.progname+" n.tk.label="+n.tk.label+" "+w.cuiName)
}
a := w.gocuiSize.w0
@ -166,15 +166,15 @@ func (n *node) recreateView() {
// n.dumpWidget("jwc 2")
// if you don't do this here, it will be black & white only
if (w.color != nil) {
if w.color != nil {
w.v.FrameColor = w.color.frame
w.v.FgColor = w.color.fg
w.v.BgColor = w.color.bg
w.v.SelFgColor = w.color.selFg
w.v.SelBgColor = w.color.selBg
}
if (n.progname == "CLOUDFLARE_EMAIL") {
n.showWidgetPlacement(true, "n.progname=" + n.progname + " n.tk.label=" + n.tk.label + " " + w.cuiName)
if n.progname == "CLOUDFLARE_EMAIL" {
n.showWidgetPlacement(true, "n.progname="+n.progname+" n.tk.label="+n.tk.label+" "+w.cuiName)
n.dumpTree(true)
}
log.Log(ERROR, "recreateView() END")
@ -199,7 +199,7 @@ func (n *node) hideWidgets() {
func (n *node) hideFake() {
w := n.tk
if (w.isFake) {
if w.isFake {
n.hideView()
}
for _, child := range n.children {
@ -209,7 +209,7 @@ func (n *node) hideFake() {
func (n *node) showFake() {
w := n.tk
if (w.isFake) {
if w.isFake {
n.setFake()
n.showWidgetPlacement(true, "showFake:")
n.showView()
@ -221,7 +221,7 @@ func (n *node) showFake() {
func (n *node) showWidgets() {
w := n.tk
if (w.isFake) {
if w.isFake {
// don't display by default
} else {
n.showWidgetPlacement(true, "current:")

View File

@ -1,8 +1,8 @@
package main
import (
"go.wit.com/lib/widget"
"go.wit.com/log"
"go.wit.com/gui/widget"
)
func initWidget(n *node) *guiWidget {
@ -22,8 +22,8 @@ func initWidget(n *node) *guiWidget {
return w
}
if (n.WidgetType == widget.Grid) {
w.widths = make(map[int]int) // how tall each row in the grid is
if n.WidgetType == widget.Grid {
w.widths = make(map[int]int) // how tall each row in the grid is
w.heights = make(map[int]int) // how wide each column in the grid is
}
@ -43,7 +43,7 @@ func setupCtrlDownWidget() {
func (n *node) deleteView() {
w := n.tk
if (w.v != nil) {
if w.v != nil {
w.v.Visible = false
return
}
@ -54,7 +54,7 @@ func (n *node) deleteView() {
// searches the binary tree for a WidgetId
func (n *node) findWidgetName(name string) *node {
if (n == nil) {
if n == nil {
return nil
}
@ -64,7 +64,7 @@ func (n *node) findWidgetName(name string) *node {
for _, child := range n.children {
newN := child.findWidgetName(name)
if (newN != nil) {
if newN != nil {
return newN
}
}
@ -73,39 +73,39 @@ func (n *node) findWidgetName(name string) *node {
func (n *node) IsCurrent() bool {
w := n.tk
if (n.WidgetType == widget.Tab) {
if n.WidgetType == widget.Tab {
return w.isCurrent
}
if (n.WidgetType == widget.Window) {
if n.WidgetType == widget.Window {
return w.isCurrent
}
if (n.WidgetType == widget.Root) {
if n.WidgetType == widget.Root {
return false
}
return n.parent.IsCurrent()
}
func (n *node) Visible() bool {
if (n == nil) {
if n == nil {
return false
}
if (n.tk == nil) {
if n.tk == nil {
return false
}
if (n.tk.v == nil) {
if n.tk.v == nil {
return false
}
return n.tk.v.Visible
}
func (n *node) SetVisible(b bool) {
if (n == nil) {
if n == nil {
return
}
if (n.tk == nil) {
if n.tk == nil {
return
}
if (n.tk.v == nil) {
if n.tk.v == nil {
return
}
n.tk.v.Visible = b

View File

@ -8,7 +8,7 @@ package main
import (
"go.wit.com/log"
"go.wit.com/gui/widget"
"go.wit.com/lib/widget"
// "go.wit.com/gui/toolkits/tree"
)

View File

@ -9,7 +9,7 @@ package main
import (
"go.wit.com/log"
"go.wit.com/gui/toolkits/tree"
"go.wit.com/toolkits/tree"
)
func init() {

View File

@ -9,7 +9,7 @@ import (
"strconv"
"go.wit.com/log"
"go.wit.com/gui/widget"
"go.wit.com/lib/widget"
)
func simpleStdin() {

View File

@ -1,7 +1,7 @@
package main
import (
"go.wit.com/gui/toolkits/tree"
"go.wit.com/toolkits/tree"
)
// stores the raw toolkit internals

View File

@ -5,7 +5,7 @@ package main
*/
import (
"go.wit.com/gui/widget"
"go.wit.com/lib/widget"
)
// Other goroutines must use this to access the GUI

View File

@ -1,47 +0,0 @@
package tree
import (
"errors"
"go.wit.com/log"
"go.wit.com/gui/widget"
)
// this is in common.go, do not move it
func (me *TreeInfo) AddNode(a *widget.Action) *Node {
n := new(Node)
n.WidgetType = a.WidgetType
n.WidgetId = a.WidgetId
n.ParentId = a.ParentId
n.State = a.State
n.Strings = make(map[string]int)
if (a.WidgetType == widget.Root) {
log.Info("AddNode() Root")
n.Parent = n
me.treeRoot = n
return n
}
if (me.treeRoot.FindWidgetId(a.WidgetId) != nil) {
log.Warn("AddNode() WidgetId already exists", a.WidgetId)
log.Warn("probably this is a Show() / Hide() issue")
log.Warn("TODO: figure out what to do here")
return me.treeRoot.FindWidgetId(a.WidgetId)
}
// add this new widget on the binary tree
p := me.treeRoot.FindWidgetId(a.ParentId)
n.Parent = p
if n.Parent == nil {
log.Error(errors.New("tree.AddNode() ERROR n.Parent == nil"), a.WidgetId, a.ParentId, a.ActionType)
log.Warn("AddNode() ERROR n.Parent == nil", a.WidgetId, a.ParentId, a.ActionType)
log.Warn("AddNode() ERROR n.Parent == nil", a.WidgetId, a.ParentId, a.WidgetType)
return n
}
log.Warn("AddNode() Adding to parent =", p.ParentId, p.WidgetType, p.GetProgName())
log.Warn("AddNode() Adding child =", n.ParentId, n.WidgetType, n.GetProgName())
p.children = append(p.children, n)
return n
}

View File

@ -1,35 +0,0 @@
package tree
import (
"go.wit.com/gui/widget"
)
func (n *Node) GetProgName() string {
return n.State.ProgName
}
func (n *Node) GetValue() any {
return n.State.Value
}
func (n *Node) Bool() bool {
return widget.GetBool(n.State.Value)
}
func (n *Node) String() string {
return widget.GetString(n.State.Value)
}
/* avoid this function name as confusing
func (n *Node) GetText() string {
return widget.GetString(n.State.Value)
}
*/
func (n *Node) SetValue(a any) {
n.State.Value = a
}
func (n *Node) GetLabel() string {
return n.State.Label
}

View File

@ -1,44 +0,0 @@
package tree
import (
"go.wit.com/log"
"go.wit.com/gui/widget"
)
func (n *Node) ShowButtons() {
if n.WidgetType == widget.Button {
n.DumpWidget("Button:")
}
for _, child := range n.children {
child.ShowButtons()
}
}
func (n *Node) DumpWidget(pad string) {
log.Warn("node:", pad, n.WidgetId, ",", n.WidgetType, ",", n.GetProgName())
}
var depth int = 0
func (n *Node) ListWidgets() {
if (n == nil) {
log.Warn("ERRRORRRR: n == nil in ListWidgets()")
log.Warn("ERRRORRRR: n == nil in ListWidgets()")
log.Warn("ERRRORRRR: n == nil in ListWidgets()")
return
}
var pad string
for i := 0; i < depth; i++ {
pad = pad + " "
}
n.DumpWidget(pad)
for _, child := range n.children {
depth += 1
child.ListWidgets()
depth -= 1
}
return
}

View File

@ -1,88 +0,0 @@
package tree
/*
These code should be common to all gui plugins
There are some helper functions that are probably going to be
the same everywhere. Mostly due to handling the binary tree structure
and the channel communication
For now, it's just a symlink to the 'master' version in
./toolkit/nocui/common.go
*/
import (
"go.wit.com/log"
"go.wit.com/gui/widget"
)
func (me *TreeInfo) DoEnableDebugger() {
if (me.callback == nil) {
log.Warn("DoUserEvent() toolkit panic() callback == nil")
return
}
var a widget.Action
a.ActionType = widget.EnableDebug
a.ProgName = me.PluginName
me.callback <- a
return
}
func (me *TreeInfo) DoToolkitLoad(s string) {
if (me.callback == nil) {
log.Warn("DoUserEvent() toolkit load callback == nil")
return
}
var a widget.Action
a.ActionType = widget.ToolkitLoad
a.ProgName = me.PluginName
a.Value = s
log.Warn("DoUserEvent() START: toolkit load", s)
me.callback <- a
log.Warn("DoUserEvent() END: toolkit load", s)
return
}
func (me *TreeInfo) DoToolkitPanic() {
if (me.callback == nil) {
log.Warn("DoUserEvent() toolkit panic() callback == nil")
return
}
var a widget.Action
a.ActionType = widget.ToolkitPanic
a.ProgName = me.PluginName
log.Info("DoUserEvent() START: toolkit panic()")
me.callback <- a
log.Info("DoUserEvent() END: toolkit panic()")
return
}
func (me *TreeInfo) DoWindowCloseEvent(n *Node) {
if (me.callback == nil) {
log.Warn("DoUserEvent() callback == nil", n.WidgetId)
return
}
var a widget.Action
a.WidgetId = n.WidgetId
a.ActionType = widget.CloseWindow
log.Info("DoUserEvent() START: user closed the window", n.GetProgName())
me.callback <- a
log.Info("DoUserEvent() END: user closed the window", n.GetProgName())
return
}
// Other goroutines must use this to access the GUI
func (me *TreeInfo) DoUserEvent(n *Node) {
if (me.callback == nil) {
log.Warn("DoUserEvent() callback == nil", n.WidgetId)
return
}
var a widget.Action
a.WidgetId = n.WidgetId
a.Value = n.State.Value
a.ActionType = widget.User
log.Info("DoUserEvent() START: send a user event to the callback channel")
me.callback <- a
log.Info("DoUserEvent() END: sent a user event to the callback channel")
return
}

View File

@ -1,58 +0,0 @@
package tree
import (
"sync"
"errors"
"go.wit.com/log"
"go.wit.com/gui/widget"
)
var muAction sync.Mutex
func (me *TreeInfo) toolkit(a widget.Action) {
if me.ActionFromChannel == nil {
log.Error(errors.New("toolkit ActionFromChannel == nil"), a.WidgetId, a.ActionType, a.WidgetType)
return
}
me.ActionFromChannel(a)
}
func (me *TreeInfo) catchActionChannel() {
defer func() {
if r := recover(); r != nil {
log.Warn("nocui YAHOOOO Recovered in simpleStdin()", r)
me.DoToolkitPanic()
panic(-1)
}
}()
log.Info("catchActionChannel() START")
for {
log.Info("catchActionChannel() for loop")
select {
case a := <-me.pluginChan:
log.Info("catchActionChannel() SELECT widget id =", a.WidgetId, a.ProgName)
log.Warn("catchActionChannel() STUFF", a.WidgetId, a.ActionType, a.WidgetType)
if a.WidgetType == widget.Dropdown {
log.Warn("Found dropdown", a.WidgetId, a.ActionType, a.WidgetType)
for i, s := range a.State.Strings {
log.Warn("a.State.Strings =", i, s)
}
}
muAction.Lock()
me.toolkit(a)
muAction.Unlock()
log.Info("catchActionChannel() STUFF END", a.WidgetId, a.ActionType, a.WidgetType)
}
}
}
func New() *TreeInfo {
me := new(TreeInfo)
me.pluginChan = make(chan widget.Action, 1)
log.Info("Init() start channel reciever")
go me.catchActionChannel()
log.Info("Init() END")
return me
}

View File

@ -1,60 +0,0 @@
package tree
import (
"fmt"
"go.wit.com/log"
"go.wit.com/gui/widget"
)
// makes a JSON version to pass to the toolkits ?
// probably this should be in gui/toolkits/tree
/*
{"widget": {
"debug": "on",
"window": {
"title": "Sample Konfabulator Widget",
"name": "main_window",
"width": 500,
"height": 500
},
"image": {
"src": "Images/Sun.png",
"name": "sun1",
"hOffset": 250,
"vOffset": 250,
"alignment": "center"
},
"text": {
"data": "Click Here",
"size": 36,
"style": "bold",
"name": "text1",
"hOffset": 250,
"vOffset": 100,
"alignment": "center",
"onMouseUp": "sun1.opacity = (sun1.opacity / 100) * 90;"
}
}}
*/
func (n *Node) Json() []string {
var all []string
switch n.WidgetType {
case widget.Checkbox:
case widget.Button:
case widget.Combobox:
case widget.Dropdown:
case widget.Textbox:
case widget.Spinner:
case widget.Slider:
case widget.Window:
tmp := fmt.Sprint("{ WidgetType :", n.WidgetType, "}")
all = append(all, tmp)
log.Warn(tmp)
return all
default:
log.Info("doUserEvent() type =", n.WidgetType)
}
return all
}

View File

@ -1,50 +0,0 @@
package tree
/*
These code should be common to all gui plugins
There are some helper functions that are probably going to be
the same everywhere. Mostly due to handling the binary tree structure
and the channel communication
For now, it's just a symlink to the 'master' version in
./toolkit/nocui/common.go
*/
import (
"go.wit.com/gui/widget"
)
// searches the binary tree for a WidgetId
func (n *Node) FindWidgetId(id int) *Node {
if (n == nil) {
return nil
}
if n.WidgetId == id {
return n
}
for _, child := range n.children {
newN := child.FindWidgetId(id)
if (newN != nil) {
return newN
}
}
return nil
}
// Other goroutines must use this to access the GUI
//
// You can not acess / process the GUI thread directly from
// other goroutines. This is due to the nature of how
// Linux, MacOS and Windows work (they all work differently. suprise. surprise.)
//
// this sets the channel to send user events back from the plugin
func (me *TreeInfo) Callback(guiCallback chan widget.Action) {
me.callback = guiCallback
}
func (me *TreeInfo) PluginChannel() chan widget.Action {
return me.pluginChan
}

View File

@ -1,51 +0,0 @@
package tree
/*
These code should be common to all gui plugins
There are some helper functions that are probably going to be
the same everywhere. Mostly due to handling the binary tree structure
and the channel communication
For now, it's just a symlink to the 'master' version in
./toolkit/nocui/common.go
*/
import (
// "go.wit.com/log"
"go.wit.com/gui/widget"
)
// var me *TreeInfo
type TreeInfo struct {
// this is the channel we send user events like
// mouse clicks or keyboard events back to the program
callback chan widget.Action
// this is the channel we get requests to make widgets
pluginChan chan widget.Action
treeRoot *Node
NodeI interface {}
ActionFromChannel func (widget.Action) ()
PluginName string
}
type Node struct {
Parent *Node
children []*Node
WidgetId int // widget ID
WidgetType widget.WidgetType
ParentId int // parent ID
State widget.State
Strings map[string]int
// the internal plugin toolkit structure
// in the gtk plugin, it has gtk things like margin & border settings
// in the text console one, it has text console things like colors for menus & buttons
TK any
}