parent
bee272651a
commit
a0baba0821
|
@ -3,9 +3,9 @@ package main
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
|
|
||||||
|
"go.wit.com/lib/widget"
|
||||||
"go.wit.com/log"
|
"go.wit.com/log"
|
||||||
"go.wit.com/gui/widget"
|
"go.wit.com/toolkits/tree"
|
||||||
"go.wit.com/gui/toolkits/tree"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// this will check to make sure that the node
|
// this will check to make sure that the node
|
||||||
|
@ -55,8 +55,12 @@ func ready(n *tree.Node) bool {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
func (n *node) ready() bool {
|
func (n *node) ready() bool {
|
||||||
if n == nil { return false }
|
if n == nil {
|
||||||
if n.tk == nil { return false }
|
return false
|
||||||
|
}
|
||||||
|
if n.tk == nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,7 +75,7 @@ func show(n *tree.Node, b bool) {
|
||||||
if tk.uiControl == nil {
|
if tk.uiControl == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (b) {
|
if b {
|
||||||
tk.uiControl.Show()
|
tk.uiControl.Show()
|
||||||
} else {
|
} else {
|
||||||
tk.uiControl.Hide()
|
tk.uiControl.Hide()
|
||||||
|
@ -90,7 +94,7 @@ func enable(n *tree.Node, b bool) {
|
||||||
if tk.uiControl == nil {
|
if tk.uiControl == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (b) {
|
if b {
|
||||||
tk.uiControl.Enable()
|
tk.uiControl.Enable()
|
||||||
} else {
|
} else {
|
||||||
tk.uiControl.Disable()
|
tk.uiControl.Disable()
|
||||||
|
@ -101,7 +105,7 @@ func (n *node) pad(b bool) {
|
||||||
log.Warn("pad() on WidgetId =", n.WidgetId)
|
log.Warn("pad() on WidgetId =", n.WidgetId)
|
||||||
|
|
||||||
t := n.tk
|
t := n.tk
|
||||||
if (t == nil) {
|
if t == nil {
|
||||||
log.Log(ERROR, "pad() toolkit struct == nil. for", n.WidgetId)
|
log.Log(ERROR, "pad() toolkit struct == nil. for", n.WidgetId)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -139,7 +143,7 @@ func (n *node) move(newParent *node) {
|
||||||
log.Log(INFO, "TODO: move() for widget =", n.WidgetId)
|
log.Log(INFO, "TODO: move() for widget =", n.WidgetId)
|
||||||
|
|
||||||
stretchy = true
|
stretchy = true
|
||||||
if (p.tk.uiBox != nil) {
|
if p.tk.uiBox != nil {
|
||||||
p.tk.uiBox.Append(n.tk.uiControl, stretchy)
|
p.tk.uiBox.Append(n.tk.uiControl, stretchy)
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
@ -184,7 +188,7 @@ func (n *node) Delete() {
|
||||||
case widget.Box:
|
case widget.Box:
|
||||||
log.Log(NOW, "tWidget.boxC =", p.progname)
|
log.Log(NOW, "tWidget.boxC =", p.progname)
|
||||||
log.Log(NOW, "is there a tParent parent? =", p.parent)
|
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)
|
log.Log(NOW, "Can not delete from Box. already empty. tWidget.boxC =", p.tk.boxC)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -204,7 +208,7 @@ func (n *node) Delete() {
|
||||||
func rawAction(a *widget.Action) {
|
func rawAction(a *widget.Action) {
|
||||||
log.Log(INFO, "rawAction() START a.ActionType =", a.ActionType, "a.Value", a.Value)
|
log.Log(INFO, "rawAction() START a.ActionType =", a.ActionType, "a.Value", a.Value)
|
||||||
|
|
||||||
if (a.ActionType == widget.ToolkitInit) {
|
if a.ActionType == widget.ToolkitInit {
|
||||||
Init()
|
Init()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -228,7 +232,7 @@ func rawAction(a *widget.Action) {
|
||||||
|
|
||||||
n := me.treeRoot.FindWidgetId(a.WidgetId)
|
n := me.treeRoot.FindWidgetId(a.WidgetId)
|
||||||
|
|
||||||
if (a.ActionType == widget.Add) {
|
if a.ActionType == widget.Add {
|
||||||
me.treeRoot.ListWidgets()
|
me.treeRoot.ListWidgets()
|
||||||
// ui.QueueMain(func() {
|
// ui.QueueMain(func() {
|
||||||
add(a)
|
add(a)
|
||||||
|
@ -238,13 +242,13 @@ func rawAction(a *widget.Action) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if (a.ActionType == widget.Dump) {
|
if a.ActionType == widget.Dump {
|
||||||
log.Log(NOW, "rawAction() Dump =", a.ActionType, a.WidgetType, n.State.ProgName)
|
log.Log(NOW, "rawAction() Dump =", a.ActionType, a.WidgetType, n.State.ProgName)
|
||||||
// me.rootNode.listChildren(true)
|
// me.rootNode.listChildren(true)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if (n == nil) {
|
if n == nil {
|
||||||
log.Error(errors.New("andlabs rawAction() ERROR findWidgetId found nil"), a.ActionType, a.WidgetType)
|
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 for id =", a.WidgetId)
|
||||||
log.Log(NOW, "rawAction() ERROR findWidgetId found nil", a.ActionType, a.WidgetType)
|
log.Log(NOW, "rawAction() ERROR findWidgetId found nil", a.ActionType, a.WidgetType)
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"go.wit.com/lib/widget"
|
||||||
"go.wit.com/log"
|
"go.wit.com/log"
|
||||||
"go.wit.com/gui/widget"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func add(a *widget.Action) {
|
func add(a *widget.Action) {
|
||||||
log.Warn("andlabs add()", a.WidgetId, a.State.ProgName)
|
log.Warn("andlabs add()", a.WidgetId, a.State.ProgName)
|
||||||
if (a.WidgetType == widget.Root) {
|
if a.WidgetType == widget.Root {
|
||||||
if me.treeRoot == nil {
|
if me.treeRoot == nil {
|
||||||
me.treeRoot = me.myTree.AddNode(a)
|
me.treeRoot = me.myTree.AddNode(a)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"go.wit.com/lib/widget"
|
||||||
"go.wit.com/log"
|
"go.wit.com/log"
|
||||||
"go.wit.com/gui/widget"
|
"go.wit.com/toolkits/tree"
|
||||||
"go.wit.com/gui/toolkits/tree"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func compareStrings(n *tree.Node, ss []string) {
|
func compareStrings(n *tree.Node, ss []string) {
|
||||||
|
@ -14,7 +14,7 @@ func addText(n *tree.Node, a *widget.Action) {
|
||||||
var tk *guiWidget
|
var tk *guiWidget
|
||||||
tk = n.TK.(*guiWidget)
|
tk = n.TK.(*guiWidget)
|
||||||
log.Warn("andlabs addText() START with a.Value =", a.Value)
|
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)
|
log.Log(ERROR, "addText error. tk == nil", n.State.ProgName, n.WidgetId)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"go.wit.com/gui/widget"
|
"go.wit.com/lib/widget"
|
||||||
"go.wit.com/gui/toolkits/tree"
|
"go.wit.com/toolkits/tree"
|
||||||
|
|
||||||
"go.wit.com/dev/andlabs/ui"
|
"go.wit.com/dev/andlabs/ui"
|
||||||
_ "go.wit.com/dev/andlabs/ui/winmanifest"
|
_ "go.wit.com/dev/andlabs/ui/winmanifest"
|
||||||
|
@ -10,7 +10,9 @@ import (
|
||||||
|
|
||||||
// make new Box here
|
// make new Box here
|
||||||
func newBox(n *tree.Node) {
|
func newBox(n *tree.Node) {
|
||||||
if notNew(n) { return }
|
if notNew(n) {
|
||||||
|
return
|
||||||
|
}
|
||||||
newt := new(guiWidget)
|
newt := new(guiWidget)
|
||||||
var box *ui.Box
|
var box *ui.Box
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"go.wit.com/gui/toolkits/tree"
|
"go.wit.com/toolkits/tree"
|
||||||
|
|
||||||
"go.wit.com/dev/andlabs/ui"
|
"go.wit.com/dev/andlabs/ui"
|
||||||
_ "go.wit.com/dev/andlabs/ui/winmanifest"
|
_ "go.wit.com/dev/andlabs/ui/winmanifest"
|
||||||
|
@ -9,7 +9,9 @@ import (
|
||||||
|
|
||||||
// func (p *node) newButton(n *node) {
|
// func (p *node) newButton(n *node) {
|
||||||
func newButton(p *tree.Node, n *tree.Node) {
|
func newButton(p *tree.Node, n *tree.Node) {
|
||||||
if notNew(n) { return }
|
if notNew(n) {
|
||||||
|
return
|
||||||
|
}
|
||||||
var ptk *guiWidget
|
var ptk *guiWidget
|
||||||
ptk = p.TK.(*guiWidget)
|
ptk = p.TK.(*guiWidget)
|
||||||
newt := new(guiWidget)
|
newt := new(guiWidget)
|
||||||
|
|
|
@ -1,14 +1,16 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"go.wit.com/gui/toolkits/tree"
|
"go.wit.com/toolkits/tree"
|
||||||
|
|
||||||
"go.wit.com/dev/andlabs/ui"
|
"go.wit.com/dev/andlabs/ui"
|
||||||
_ "go.wit.com/dev/andlabs/ui/winmanifest"
|
_ "go.wit.com/dev/andlabs/ui/winmanifest"
|
||||||
)
|
)
|
||||||
|
|
||||||
func newCheckbox(p *tree.Node, n *tree.Node) {
|
func newCheckbox(p *tree.Node, n *tree.Node) {
|
||||||
if notNew(n) { return }
|
if notNew(n) {
|
||||||
|
return
|
||||||
|
}
|
||||||
newt := new(guiWidget)
|
newt := new(guiWidget)
|
||||||
|
|
||||||
newt.uiCheckbox = ui.NewCheckbox(n.GetLabel())
|
newt.uiCheckbox = ui.NewCheckbox(n.GetLabel())
|
||||||
|
|
|
@ -5,11 +5,13 @@ import (
|
||||||
_ "go.wit.com/dev/andlabs/ui/winmanifest"
|
_ "go.wit.com/dev/andlabs/ui/winmanifest"
|
||||||
|
|
||||||
"go.wit.com/log"
|
"go.wit.com/log"
|
||||||
"go.wit.com/gui/toolkits/tree"
|
"go.wit.com/toolkits/tree"
|
||||||
)
|
)
|
||||||
|
|
||||||
func newCombobox(p, n *tree.Node) {
|
func newCombobox(p, n *tree.Node) {
|
||||||
if notNew(n) { return }
|
if notNew(n) {
|
||||||
|
return
|
||||||
|
}
|
||||||
newt := new(guiWidget)
|
newt := new(guiWidget)
|
||||||
|
|
||||||
cb := ui.NewEditableCombobox()
|
cb := ui.NewEditableCombobox()
|
||||||
|
@ -43,20 +45,22 @@ func newCombobox(p, n *tree.Node) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func addComboboxName(n *tree.Node, s string) {
|
func addComboboxName(n *tree.Node, s string) {
|
||||||
if ! ready(n) { return }
|
if !ready(n) {
|
||||||
|
return
|
||||||
|
}
|
||||||
var tk *guiWidget
|
var tk *guiWidget
|
||||||
tk = n.TK.(*guiWidget)
|
tk = n.TK.(*guiWidget)
|
||||||
log.Log(INFO, "addComboboxName()", n.WidgetId, "add:", s)
|
log.Log(INFO, "addComboboxName()", n.WidgetId, "add:", s)
|
||||||
|
|
||||||
tk.uiEditableCombobox.Append(s)
|
tk.uiEditableCombobox.Append(s)
|
||||||
if (tk.val == nil) {
|
if tk.val == nil {
|
||||||
log.Log(INFO, "make map didn't work")
|
log.Log(INFO, "make map didn't work")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
tk.val[tk.c] = s
|
tk.val[tk.c] = s
|
||||||
|
|
||||||
// If this is the first menu added, set the dropdown to it
|
// 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)
|
log.Log(INFO, "THIS IS THE FIRST combobox", s)
|
||||||
tk.uiEditableCombobox.SetText(s)
|
tk.uiEditableCombobox.SetText(s)
|
||||||
}
|
}
|
||||||
|
@ -64,7 +68,9 @@ func addComboboxName(n *tree.Node, s string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func setComboboxName(n *tree.Node, s string) bool {
|
func setComboboxName(n *tree.Node, s string) bool {
|
||||||
if ! ready(n) { return false}
|
if !ready(n) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
var tk *guiWidget
|
var tk *guiWidget
|
||||||
tk = n.TK.(*guiWidget)
|
tk = n.TK.(*guiWidget)
|
||||||
log.Log(INFO, "SetComboboxName()", n.WidgetId, ",", s)
|
log.Log(INFO, "SetComboboxName()", n.WidgetId, ",", s)
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"go.wit.com/gui/widget"
|
"go.wit.com/lib/widget"
|
||||||
)
|
)
|
||||||
|
|
||||||
type node struct {
|
type node struct {
|
||||||
|
|
|
@ -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
|
// This is important. This sets the defaults for the gui. Without this, there isn't correct padding, etc
|
||||||
func setDefaultBehavior(s bool) {
|
func setDefaultBehavior(s bool) {
|
||||||
defaultBehavior = s
|
defaultBehavior = s
|
||||||
if (defaultBehavior) {
|
if defaultBehavior {
|
||||||
log.Log(NOW, "Setting this toolkit to use the default behavior.")
|
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.")
|
log.Log(NOW, "This is the 'guessing' part as defined by the wit/gui 'Principles'. Refer to the docs.")
|
||||||
stretchy = false
|
stretchy = false
|
||||||
|
@ -41,38 +41,38 @@ func setDefaultBehavior(s bool) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *guiWidget) Dump(b bool) {
|
func (t *guiWidget) Dump(b bool) {
|
||||||
if ! b {
|
if !b {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
log.Log(NOW, "Name = ", t.Width, t.Height)
|
log.Log(NOW, "Name = ", t.Width, t.Height)
|
||||||
if (t.uiBox != nil) {
|
if t.uiBox != nil {
|
||||||
log.Log(NOW, "uiBox =", t.uiBox)
|
log.Log(NOW, "uiBox =", t.uiBox)
|
||||||
}
|
}
|
||||||
if (t.uiButton != nil) {
|
if t.uiButton != nil {
|
||||||
log.Log(NOW, "uiButton =", t.uiButton)
|
log.Log(NOW, "uiButton =", t.uiButton)
|
||||||
}
|
}
|
||||||
if (t.uiCombobox != nil) {
|
if t.uiCombobox != nil {
|
||||||
log.Log(NOW, "uiCombobox =", t.uiCombobox)
|
log.Log(NOW, "uiCombobox =", t.uiCombobox)
|
||||||
}
|
}
|
||||||
if (t.uiWindow != nil) {
|
if t.uiWindow != nil {
|
||||||
log.Log(NOW, "uiWindow =", t.uiWindow)
|
log.Log(NOW, "uiWindow =", t.uiWindow)
|
||||||
}
|
}
|
||||||
if (t.uiTab != nil) {
|
if t.uiTab != nil {
|
||||||
log.Log(NOW, "uiTab =", t.uiTab)
|
log.Log(NOW, "uiTab =", t.uiTab)
|
||||||
}
|
}
|
||||||
if (t.uiGroup != nil) {
|
if t.uiGroup != nil {
|
||||||
log.Log(NOW, "uiGroup =", t.uiGroup)
|
log.Log(NOW, "uiGroup =", t.uiGroup)
|
||||||
}
|
}
|
||||||
if (t.uiEntry != nil) {
|
if t.uiEntry != nil {
|
||||||
log.Log(NOW, "uiEntry =", t.uiEntry)
|
log.Log(NOW, "uiEntry =", t.uiEntry)
|
||||||
}
|
}
|
||||||
if (t.uiMultilineEntry != nil) {
|
if t.uiMultilineEntry != nil {
|
||||||
log.Log(NOW, "uiMultilineEntry =", t.uiMultilineEntry)
|
log.Log(NOW, "uiMultilineEntry =", t.uiMultilineEntry)
|
||||||
}
|
}
|
||||||
if (t.uiSlider != nil) {
|
if t.uiSlider != nil {
|
||||||
log.Log(NOW, "uiSlider =", t.uiSlider)
|
log.Log(NOW, "uiSlider =", t.uiSlider)
|
||||||
}
|
}
|
||||||
if (t.uiCheckbox != nil) {
|
if t.uiCheckbox != nil {
|
||||||
log.Log(NOW, "uiCheckbox =", t.uiCheckbox)
|
log.Log(NOW, "uiCheckbox =", t.uiCheckbox)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -86,7 +86,7 @@ func GetDebugToolkit () bool {
|
||||||
func (n *node) dumpWidget(b bool) {
|
func (n *node) dumpWidget(b bool) {
|
||||||
var info, d string
|
var info, d string
|
||||||
|
|
||||||
if (n == nil) {
|
if n == nil {
|
||||||
log.Log(ERROR, "dumpWidget() node == nil")
|
log.Log(ERROR, "dumpWidget() node == nil")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -98,14 +98,14 @@ func (n *node) dumpWidget(b bool) {
|
||||||
for i := 0; i < listChildrenDepth; i++ {
|
for i := 0; i < listChildrenDepth; i++ {
|
||||||
tabs = tabs + defaultPadding
|
tabs = tabs + defaultPadding
|
||||||
}
|
}
|
||||||
log.Log(NOW, tabs + d)
|
log.Log(NOW, tabs+d)
|
||||||
}
|
}
|
||||||
|
|
||||||
var defaultPadding string = " "
|
var defaultPadding string = " "
|
||||||
var listChildrenDepth int = 0
|
var listChildrenDepth int = 0
|
||||||
|
|
||||||
func (n *node) listChildren(dump bool) {
|
func (n *node) listChildren(dump bool) {
|
||||||
if (n == nil) {
|
if n == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,8 +3,8 @@ package main
|
||||||
// if you include more than just this 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)
|
// then your plugin might be doing something un-ideal (just a guess from 2023/02/27)
|
||||||
import (
|
import (
|
||||||
|
"go.wit.com/lib/widget"
|
||||||
"go.wit.com/log"
|
"go.wit.com/log"
|
||||||
"go.wit.com/gui/widget"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// delete the child widget from the parent
|
// delete the child widget from the parent
|
||||||
|
@ -16,7 +16,7 @@ func (n *node) destroy() {
|
||||||
|
|
||||||
pt := n.parent.tk
|
pt := n.parent.tk
|
||||||
ct := n.tk
|
ct := n.tk
|
||||||
if (ct == nil) {
|
if ct == nil {
|
||||||
log.Log(NOW, "delete FAILED (ct = mapToolkit[c] == nil) for c", pId, cId)
|
log.Log(NOW, "delete FAILED (ct = mapToolkit[c] == nil) for c", pId, cId)
|
||||||
// this pukes out a whole universe of shit
|
// this pukes out a whole universe of shit
|
||||||
// listMap()
|
// listMap()
|
||||||
|
@ -30,7 +30,7 @@ func (n *node) destroy() {
|
||||||
pt.Dump(true)
|
pt.Dump(true)
|
||||||
log.Log(NOW, "Child:")
|
log.Log(NOW, "Child:")
|
||||||
ct.Dump(true)
|
ct.Dump(true)
|
||||||
if (pt.uiBox == nil) {
|
if pt.uiBox == nil {
|
||||||
log.Log(NOW, "Don't know how to destroy this")
|
log.Log(NOW, "Don't know how to destroy this")
|
||||||
} else {
|
} else {
|
||||||
log.Log(NOW, "Fuck it, destroy the whole box", n.parent.progname)
|
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)
|
log.Log(NOW, "Should delete Window here:", n.progname)
|
||||||
default:
|
default:
|
||||||
log.Log(NOW, "Fuckit, let's destroy a button")
|
log.Log(NOW, "Fuckit, let's destroy a button")
|
||||||
if (ct.uiButton != nil) {
|
if ct.uiButton != nil {
|
||||||
pt.uiBox.Delete(4)
|
pt.uiBox.Delete(4)
|
||||||
ct.uiButton.Destroy()
|
ct.uiButton.Destroy()
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,11 +5,13 @@ import (
|
||||||
_ "go.wit.com/dev/andlabs/ui/winmanifest"
|
_ "go.wit.com/dev/andlabs/ui/winmanifest"
|
||||||
|
|
||||||
"go.wit.com/log"
|
"go.wit.com/log"
|
||||||
"go.wit.com/gui/toolkits/tree"
|
"go.wit.com/toolkits/tree"
|
||||||
)
|
)
|
||||||
|
|
||||||
func newDropdown(p, n *tree.Node) {
|
func newDropdown(p, n *tree.Node) {
|
||||||
if notNew(n) { return }
|
if notNew(n) {
|
||||||
|
return
|
||||||
|
}
|
||||||
newt := new(guiWidget)
|
newt := new(guiWidget)
|
||||||
log.Log(INFO, "gui.Toolbox.newDropdown() START", n.GetProgName())
|
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) {
|
cb.OnSelected(func(spin *ui.Combobox) {
|
||||||
i := spin.Selected()
|
i := spin.Selected()
|
||||||
if (newt.val == nil) {
|
if newt.val == nil {
|
||||||
log.Log(ERROR, "make map didn't work")
|
log.Log(ERROR, "make map didn't work")
|
||||||
n.SetValue("map did not work. ui.Combobox error")
|
n.SetValue("map did not work. ui.Combobox error")
|
||||||
} else {
|
} else {
|
||||||
|
@ -32,14 +34,15 @@ func newDropdown(p, n *tree.Node) {
|
||||||
me.myTree.DoUserEvent(n)
|
me.myTree.DoUserEvent(n)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
n.TK = newt
|
n.TK = newt
|
||||||
place(p, n)
|
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)
|
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
|
// add the initial dropdown entries
|
||||||
for i, s := range n.State.Strings {
|
for i, s := range n.State.Strings {
|
||||||
log.Warn("add dropdown: add entries on create", n.GetProgName(), i, s)
|
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) {
|
func setDropdownInt(n *tree.Node, i int) {
|
||||||
if ! ready(n) { return }
|
if !ready(n) {
|
||||||
|
return
|
||||||
|
}
|
||||||
var tk *guiWidget
|
var tk *guiWidget
|
||||||
tk = n.TK.(*guiWidget)
|
tk = n.TK.(*guiWidget)
|
||||||
tk.uiCombobox.SetSelected(i)
|
tk.uiCombobox.SetSelected(i)
|
||||||
}
|
}
|
||||||
|
|
||||||
func addDropdownName(n *tree.Node, s string) {
|
func addDropdownName(n *tree.Node, s string) {
|
||||||
if ! ready(n) { return }
|
if !ready(n) {
|
||||||
|
return
|
||||||
|
}
|
||||||
var tk *guiWidget
|
var tk *guiWidget
|
||||||
tk = n.TK.(*guiWidget)
|
tk = n.TK.(*guiWidget)
|
||||||
log.Log(INFO, "addDropdownName()", n.WidgetId, "add:", s)
|
log.Log(INFO, "addDropdownName()", n.WidgetId, "add:", s)
|
||||||
|
|
||||||
tk.uiCombobox.Append(s)
|
tk.uiCombobox.Append(s)
|
||||||
if (tk.val == nil) {
|
if tk.val == nil {
|
||||||
log.Log(INFO, "make map didn't work")
|
log.Log(INFO, "make map didn't work")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
tk.val[tk.c] = s
|
tk.val[tk.c] = s
|
||||||
|
|
||||||
// If this is the first menu added, set the dropdown to it
|
// 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)
|
log.Log(INFO, "THIS IS THE FIRST Dropdown", s)
|
||||||
tk.uiCombobox.SetSelected(0)
|
tk.uiCombobox.SetSelected(0)
|
||||||
}
|
}
|
||||||
|
@ -79,7 +86,9 @@ func addDropdownName(n *tree.Node, s string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func setDropdownName(n *tree.Node, s string) bool {
|
func setDropdownName(n *tree.Node, s string) bool {
|
||||||
if ! ready(n) { return false}
|
if !ready(n) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
var tk *guiWidget
|
var tk *guiWidget
|
||||||
tk = n.TK.(*guiWidget)
|
tk = n.TK.(*guiWidget)
|
||||||
log.Log(INFO, "SetDropdownName()", n.WidgetId, ",", s)
|
log.Log(INFO, "SetDropdownName()", n.WidgetId, ",", s)
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"go.wit.com/gui/toolkits/tree"
|
"go.wit.com/toolkits/tree"
|
||||||
|
|
||||||
"go.wit.com/dev/andlabs/ui"
|
"go.wit.com/dev/andlabs/ui"
|
||||||
_ "go.wit.com/dev/andlabs/ui/winmanifest"
|
_ "go.wit.com/dev/andlabs/ui/winmanifest"
|
||||||
|
@ -13,7 +13,9 @@ import (
|
||||||
// -- (1,2) -- (2,1) -- (3,1) --
|
// -- (1,2) -- (2,1) -- (3,1) --
|
||||||
// -----------------------------
|
// -----------------------------
|
||||||
func newGrid(n *tree.Node) {
|
func newGrid(n *tree.Node) {
|
||||||
if notNew(n) { return }
|
if notNew(n) {
|
||||||
|
return
|
||||||
|
}
|
||||||
var newt *guiWidget
|
var newt *guiWidget
|
||||||
newt = new(guiWidget)
|
newt = new(guiWidget)
|
||||||
|
|
||||||
|
|
|
@ -2,14 +2,16 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
// "go.wit.com/gui/widget"
|
// "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"
|
||||||
_ "go.wit.com/dev/andlabs/ui/winmanifest"
|
_ "go.wit.com/dev/andlabs/ui/winmanifest"
|
||||||
)
|
)
|
||||||
|
|
||||||
func newGroup(p, n *tree.Node) {
|
func newGroup(p, n *tree.Node) {
|
||||||
if notNew(n) { return }
|
if notNew(n) {
|
||||||
|
return
|
||||||
|
}
|
||||||
newt := new(guiWidget)
|
newt := new(guiWidget)
|
||||||
|
|
||||||
g := ui.NewGroup(n.GetLabel())
|
g := ui.NewGroup(n.GetLabel())
|
||||||
|
|
|
@ -18,6 +18,7 @@ func (p *node) newImage(n *node) {
|
||||||
n.tk = newt
|
n.tk = newt
|
||||||
// p.place(n)
|
// p.place(n)
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
if (a.Name == "image") {
|
if (a.Name == "image") {
|
||||||
log(true, "NewTextbox() trying to add a new image")
|
log(true, "NewTextbox() trying to add a new image")
|
||||||
|
|
|
@ -1,14 +1,16 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"go.wit.com/gui/toolkits/tree"
|
"go.wit.com/toolkits/tree"
|
||||||
|
|
||||||
"go.wit.com/dev/andlabs/ui"
|
"go.wit.com/dev/andlabs/ui"
|
||||||
_ "go.wit.com/dev/andlabs/ui/winmanifest"
|
_ "go.wit.com/dev/andlabs/ui/winmanifest"
|
||||||
)
|
)
|
||||||
|
|
||||||
func newLabel(p, n *tree.Node) {
|
func newLabel(p, n *tree.Node) {
|
||||||
if notNew(n) { return }
|
if notNew(n) {
|
||||||
|
return
|
||||||
|
}
|
||||||
newt := new(guiWidget)
|
newt := new(guiWidget)
|
||||||
c := ui.NewLabel(n.GetLabel())
|
c := ui.NewLabel(n.GetLabel())
|
||||||
newt.uiLabel = c
|
newt.uiLabel = c
|
||||||
|
|
|
@ -22,7 +22,7 @@ func init() {
|
||||||
full := "toolkit/nocui"
|
full := "toolkit/nocui"
|
||||||
short := "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")
|
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")
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"sync"
|
|
||||||
"runtime/debug"
|
"runtime/debug"
|
||||||
|
"sync"
|
||||||
|
|
||||||
|
"go.wit.com/lib/widget"
|
||||||
"go.wit.com/log"
|
"go.wit.com/log"
|
||||||
"go.wit.com/gui/widget"
|
"go.wit.com/toolkits/tree"
|
||||||
"go.wit.com/gui/toolkits/tree"
|
|
||||||
|
|
||||||
"go.wit.com/dev/andlabs/ui"
|
"go.wit.com/dev/andlabs/ui"
|
||||||
// the _ means we only need this for the init()
|
// the _ means we only need this for the init()
|
||||||
|
@ -27,7 +27,7 @@ func queueMain(currentA widget.Action) {
|
||||||
me.myTree.DoToolkitPanic()
|
me.myTree.DoToolkitPanic()
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
ui.QueueMain( func() {
|
ui.QueueMain(func() {
|
||||||
rawAction(¤tA)
|
rawAction(¤tA)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,11 +5,10 @@ import (
|
||||||
"go.wit.com/dev/andlabs/ui"
|
"go.wit.com/dev/andlabs/ui"
|
||||||
_ "go.wit.com/dev/andlabs/ui/winmanifest"
|
_ "go.wit.com/dev/andlabs/ui/winmanifest"
|
||||||
|
|
||||||
|
"go.wit.com/lib/widget"
|
||||||
"go.wit.com/log"
|
"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
|
// This routine is very specific to this toolkit
|
||||||
|
@ -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() 1 START", n.WidgetId, n.GetProgName(), n.GetLabel(), n.String())
|
||||||
log.Warn("SPEEDY newplace() n.State.Strings =", n.State.Strings)
|
log.Warn("SPEEDY newplace() n.State.Strings =", n.State.Strings)
|
||||||
log.Log(INFO, "place() 1 START", n.WidgetType, n.GetProgName(), n.GetLabel())
|
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()")
|
log.Warn("place() 1 START not ready()")
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
@ -51,7 +50,7 @@ func place(p *tree.Node, n *tree.Node) bool {
|
||||||
ptk = p.TK.(*guiWidget)
|
ptk = p.TK.(*guiWidget)
|
||||||
log.Warn("SPEEDY newplace() 2 START", n.WidgetId, n.GetProgName(), n.GetLabel())
|
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, "ptk == nil", p.GetProgName(), p.ParentId, p.WidgetType, ptk)
|
||||||
log.Log(ERROR, "n = ", n.GetProgName(), n.ParentId, n.WidgetType, tk)
|
log.Log(ERROR, "n = ", n.GetProgName(), n.ParentId, n.WidgetType, tk)
|
||||||
log.Warn("SPEEDY ptk == nil", n.WidgetId, n.GetProgName())
|
log.Warn("SPEEDY ptk == nil", n.WidgetId, n.GetProgName())
|
||||||
|
@ -71,7 +70,7 @@ func place(p *tree.Node, n *tree.Node) bool {
|
||||||
false, ui.AlignFill, false, ui.AlignFill)
|
false, ui.AlignFill, false, ui.AlignFill)
|
||||||
return true
|
return true
|
||||||
case widget.Group:
|
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)
|
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.uiGroup.SetChild(ptk.uiBox)
|
||||||
|
@ -79,11 +78,11 @@ func place(p *tree.Node, n *tree.Node) bool {
|
||||||
ptk.uiBox.Append(tk.uiControl, stretchy)
|
ptk.uiBox.Append(tk.uiControl, stretchy)
|
||||||
return true
|
return true
|
||||||
case widget.Tab:
|
case widget.Tab:
|
||||||
if (ptk.uiTab == nil) {
|
if ptk.uiTab == nil {
|
||||||
log.Log(ERROR, "ptk.uiTab == nil for n.WidgetId =", n.WidgetId, "ptk =", ptk)
|
log.Log(ERROR, "ptk.uiTab == nil for n.WidgetId =", n.WidgetId, "ptk =", ptk)
|
||||||
panic("ptk.uiTab == nil")
|
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)
|
log.Log(ERROR, "tk.uiControl == nil for n.WidgetId =", n.WidgetId, "tk =", tk)
|
||||||
panic("tk.uiControl == nil")
|
panic("tk.uiControl == nil")
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"go.wit.com/lib/widget"
|
||||||
"go.wit.com/log"
|
"go.wit.com/log"
|
||||||
"go.wit.com/gui/widget"
|
"go.wit.com/toolkits/tree"
|
||||||
"go.wit.com/gui/toolkits/tree"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// func (n *node) setText(a *widget.Action) {
|
// func (n *node) setText(a *widget.Action) {
|
||||||
|
@ -13,7 +13,7 @@ func setText(n *tree.Node, a *widget.Action) {
|
||||||
tk = n.TK.(*guiWidget)
|
tk = n.TK.(*guiWidget)
|
||||||
|
|
||||||
log.Log(CHANGE, "setText() START with text =", name)
|
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)
|
log.Log(ERROR, "setText error. tk == nil", n.GetProgName(), n.WidgetId)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -29,10 +29,10 @@ func setText(n *tree.Node, a *widget.Action) {
|
||||||
case widget.Checkbox:
|
case widget.Checkbox:
|
||||||
tk.uiCheckbox.SetText(name)
|
tk.uiCheckbox.SetText(name)
|
||||||
case widget.Textbox:
|
case widget.Textbox:
|
||||||
if (tk.uiEntry != nil) {
|
if tk.uiEntry != nil {
|
||||||
tk.uiEntry.SetText(name)
|
tk.uiEntry.SetText(name)
|
||||||
}
|
}
|
||||||
if (tk.uiMultilineEntry != nil) {
|
if tk.uiMultilineEntry != nil {
|
||||||
tk.uiMultilineEntry.SetText(name)
|
tk.uiMultilineEntry.SetText(name)
|
||||||
}
|
}
|
||||||
case widget.Label:
|
case widget.Label:
|
||||||
|
@ -52,7 +52,7 @@ func setText(n *tree.Node, a *widget.Action) {
|
||||||
// try to find the string
|
// try to find the string
|
||||||
for i, s = range tk.val {
|
for i, s = range tk.val {
|
||||||
log.Log(CHANGE, "i, s", i, s)
|
log.Log(CHANGE, "i, s", i, s)
|
||||||
if (name == s) {
|
if name == s {
|
||||||
tk.uiCombobox.SetSelected(i)
|
tk.uiCombobox.SetSelected(i)
|
||||||
log.Log(CHANGE, "setText() Dropdown worked.", name)
|
log.Log(CHANGE, "setText() Dropdown worked.", name)
|
||||||
return
|
return
|
||||||
|
@ -60,11 +60,11 @@ func setText(n *tree.Node, a *widget.Action) {
|
||||||
}
|
}
|
||||||
log.Log(ERROR, "setText() Dropdown did not find:", name)
|
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, then there are not any things in the menu to select
|
||||||
if (i == -1) {
|
if i == -1 {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// if the string was never set, then set the dropdown to the last thing added to the menu
|
// 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)
|
tk.uiCombobox.SetSelected(i)
|
||||||
}
|
}
|
||||||
case widget.Combobox:
|
case widget.Combobox:
|
||||||
|
@ -72,5 +72,5 @@ func setText(n *tree.Node, a *widget.Action) {
|
||||||
default:
|
default:
|
||||||
log.Log(ERROR, "plugin Send() Don't know how to setText on", n.WidgetType, "yet", a.ActionType)
|
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 =")
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,14 +1,16 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"go.wit.com/gui/toolkits/tree"
|
"go.wit.com/toolkits/tree"
|
||||||
|
|
||||||
"go.wit.com/dev/andlabs/ui"
|
"go.wit.com/dev/andlabs/ui"
|
||||||
_ "go.wit.com/dev/andlabs/ui/winmanifest"
|
_ "go.wit.com/dev/andlabs/ui/winmanifest"
|
||||||
)
|
)
|
||||||
|
|
||||||
func newSlider(p, n *tree.Node) {
|
func newSlider(p, n *tree.Node) {
|
||||||
if notNew(n) { return }
|
if notNew(n) {
|
||||||
|
return
|
||||||
|
}
|
||||||
newt := new(guiWidget)
|
newt := new(guiWidget)
|
||||||
|
|
||||||
var x, y int
|
var x, y int
|
||||||
|
|
|
@ -1,17 +1,19 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"go.wit.com/gui/toolkits/tree"
|
"go.wit.com/toolkits/tree"
|
||||||
|
|
||||||
"go.wit.com/dev/andlabs/ui"
|
"go.wit.com/dev/andlabs/ui"
|
||||||
_ "go.wit.com/dev/andlabs/ui/winmanifest"
|
_ "go.wit.com/dev/andlabs/ui/winmanifest"
|
||||||
)
|
)
|
||||||
|
|
||||||
func newSpinner(p, n *tree.Node) {
|
func newSpinner(p, n *tree.Node) {
|
||||||
if notNew(n) { return }
|
if notNew(n) {
|
||||||
|
return
|
||||||
|
}
|
||||||
newt := new(guiWidget)
|
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.uiSpinbox = s
|
||||||
newt.uiControl = s
|
newt.uiControl = s
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"go.wit.com/gui/toolkits/tree"
|
"go.wit.com/toolkits/tree"
|
||||||
|
|
||||||
"go.wit.com/dev/andlabs/ui"
|
"go.wit.com/dev/andlabs/ui"
|
||||||
_ "go.wit.com/dev/andlabs/ui/winmanifest"
|
_ "go.wit.com/dev/andlabs/ui/winmanifest"
|
||||||
|
|
|
@ -1,32 +1,32 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"go.wit.com/lib/widget"
|
||||||
"go.wit.com/log"
|
"go.wit.com/log"
|
||||||
"go.wit.com/gui/widget"
|
|
||||||
|
|
||||||
"go.wit.com/dev/andlabs/ui"
|
"go.wit.com/dev/andlabs/ui"
|
||||||
_ "go.wit.com/dev/andlabs/ui/winmanifest"
|
_ "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
|
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
|
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
|
you need to add this tab and not run SetChild() on the window
|
||||||
or instead it replaces the existing tab with the new one
|
or instead it replaces the existing tab with the new one
|
||||||
|
|
||||||
I work around this by always sending a Toolkit that is a tab
|
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
|
once there is one. If you send a Window here, it will replace
|
||||||
any existing tabs rather than adding a new one
|
any existing tabs rather than adding a new one
|
||||||
*/
|
*/
|
||||||
func (p *node) newTab(n *node) {
|
func (p *node) newTab(n *node) {
|
||||||
var newt *guiWidget
|
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)
|
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)
|
log.Log(ERROR, "newTab() uiWindow == nil. I can't add a toolbar without window", n.WidgetId, n.ParentId)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,7 @@ func (p *node) newTab(n *node) {
|
||||||
|
|
||||||
log.Log(TOOLKIT, "newTab() START", n.WidgetId, n.ParentId)
|
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
|
// 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))
|
newt = rawTab(t.uiWindow, widget.GetString(n.value))
|
||||||
|
@ -42,7 +42,7 @@ func (p *node) newTab(n *node) {
|
||||||
} else {
|
} else {
|
||||||
// this means you have to append a tab
|
// this means you have to append a tab
|
||||||
log.Log(TOOLKIT, "newTab() GOOD. This should be an additional tab:", n.WidgetId, n.ParentId)
|
log.Log(TOOLKIT, "newTab() GOOD. This should be an additional tab:", n.WidgetId, n.ParentId)
|
||||||
if (n.WidgetType == widget.Tab) {
|
if n.WidgetType == widget.Tab {
|
||||||
// andlabs doesn't have multiple tab widgets so make a fake one?
|
// andlabs doesn't have multiple tab widgets so make a fake one?
|
||||||
// this makes a guiWidget internal structure with the parent values
|
// this makes a guiWidget internal structure with the parent values
|
||||||
newt = new(guiWidget)
|
newt = new(guiWidget)
|
||||||
|
@ -71,7 +71,7 @@ func rawTab(w *ui.Window, name string) *guiWidget {
|
||||||
var newt 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")
|
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
|
var newT guiWidget
|
||||||
log.Log(TOOLKIT, "appendTab() ADD", name)
|
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")
|
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")
|
panic("should never have happened. wit/gui/toolkit has ui.Tab == nil")
|
||||||
}
|
}
|
||||||
log.Log(TOOLKIT, "appendTab() START name =", name)
|
log.Log(TOOLKIT, "appendTab() START name =", name)
|
||||||
|
|
||||||
var hbox *ui.Box
|
var hbox *ui.Box
|
||||||
if (defaultBehavior) {
|
if defaultBehavior {
|
||||||
hbox = ui.NewHorizontalBox()
|
hbox = ui.NewHorizontalBox()
|
||||||
} else {
|
} else {
|
||||||
if (bookshelf) {
|
if bookshelf {
|
||||||
hbox = ui.NewHorizontalBox()
|
hbox = ui.NewHorizontalBox()
|
||||||
} else {
|
} else {
|
||||||
hbox = ui.NewVerticalBox()
|
hbox = ui.NewVerticalBox()
|
||||||
|
|
|
@ -1,17 +1,19 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"go.wit.com/gui/toolkits/tree"
|
"go.wit.com/toolkits/tree"
|
||||||
|
|
||||||
"go.wit.com/dev/andlabs/ui"
|
"go.wit.com/dev/andlabs/ui"
|
||||||
_ "go.wit.com/dev/andlabs/ui/winmanifest"
|
_ "go.wit.com/dev/andlabs/ui/winmanifest"
|
||||||
)
|
)
|
||||||
|
|
||||||
func newTextbox(p, n *tree.Node) {
|
func newTextbox(p, n *tree.Node) {
|
||||||
if notNew(n) { return }
|
if notNew(n) {
|
||||||
|
return
|
||||||
|
}
|
||||||
newt := new(guiWidget)
|
newt := new(guiWidget)
|
||||||
|
|
||||||
if (n.State.Range.Low == 1) {
|
if n.State.Range.Low == 1 {
|
||||||
e := ui.NewEntry()
|
e := ui.NewEntry()
|
||||||
newt.uiEntry = e
|
newt.uiEntry = e
|
||||||
newt.uiControl = e
|
newt.uiControl = e
|
||||||
|
|
|
@ -12,7 +12,7 @@ package main
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"go.wit.com/gui/widget"
|
"go.wit.com/lib/widget"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Other goroutines must use this to access the GUI
|
// Other goroutines must use this to access the GUI
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"go.wit.com/gui/widget"
|
"go.wit.com/lib/widget"
|
||||||
"go.wit.com/gui/toolkits/tree"
|
"go.wit.com/toolkits/tree"
|
||||||
)
|
)
|
||||||
|
|
||||||
func initWidget(n *tree.Node) *guiWidget {
|
func initWidget(n *tree.Node) *guiWidget {
|
||||||
|
|
|
@ -4,9 +4,9 @@ import (
|
||||||
"go.wit.com/dev/andlabs/ui"
|
"go.wit.com/dev/andlabs/ui"
|
||||||
_ "go.wit.com/dev/andlabs/ui/winmanifest"
|
_ "go.wit.com/dev/andlabs/ui/winmanifest"
|
||||||
|
|
||||||
|
"go.wit.com/lib/widget"
|
||||||
"go.wit.com/log"
|
"go.wit.com/log"
|
||||||
"go.wit.com/gui/widget"
|
"go.wit.com/toolkits/tree"
|
||||||
"go.wit.com/gui/toolkits/tree"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func (t *guiWidget) MessageWindow(msg1 string, msg2 string) {
|
func (t *guiWidget) MessageWindow(msg1 string, msg2 string) {
|
||||||
|
@ -42,7 +42,7 @@ func newWindow(p, n *tree.Node) {
|
||||||
func (n *node) SetWindowTitle(title string) {
|
func (n *node) SetWindowTitle(title string) {
|
||||||
log.Log(CHANGE, "toolkit NewWindow", widget.GetString(n.value), "title", title)
|
log.Log(CHANGE, "toolkit NewWindow", widget.GetString(n.value), "title", title)
|
||||||
win := n.tk.uiWindow
|
win := n.tk.uiWindow
|
||||||
if (win == nil) {
|
if win == nil {
|
||||||
log.Log(ERROR, "Error: no window", n.WidgetId)
|
log.Log(ERROR, "Error: no window", n.WidgetId)
|
||||||
} else {
|
} else {
|
||||||
win.SetTitle(title)
|
win.SetTitle(title)
|
||||||
|
|
|
@ -1,12 +1,13 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"go.wit.com/lib/widget"
|
||||||
log "go.wit.com/log"
|
log "go.wit.com/log"
|
||||||
"go.wit.com/gui/widget"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var fakeStartWidth int = me.FakeW
|
var fakeStartWidth int = me.FakeW
|
||||||
var fakeStartHeight int = me.TabH + me.FramePadH
|
var fakeStartHeight int = me.TabH + me.FramePadH
|
||||||
|
|
||||||
// setup fake labels for non-visible things off screen
|
// setup fake labels for non-visible things off screen
|
||||||
func (n *node) setFake() {
|
func (n *node) setFake() {
|
||||||
w := n.tk
|
w := n.tk
|
||||||
|
@ -16,11 +17,11 @@ func (n *node) setFake() {
|
||||||
|
|
||||||
fakeStartHeight += w.gocuiSize.Height()
|
fakeStartHeight += w.gocuiSize.Height()
|
||||||
// TODO: use the actual max hight of the terminal window
|
// TODO: use the actual max hight of the terminal window
|
||||||
if (fakeStartHeight > 24) {
|
if fakeStartHeight > 24 {
|
||||||
fakeStartHeight = me.TabH
|
fakeStartHeight = me.TabH
|
||||||
fakeStartWidth += me.FakeW
|
fakeStartWidth += me.FakeW
|
||||||
}
|
}
|
||||||
if (true) {
|
if true {
|
||||||
n.showView()
|
n.showView()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,7 @@ func init() {
|
||||||
full := "toolkit/nocui"
|
full := "toolkit/nocui"
|
||||||
short := "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")
|
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")
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
// "github.com/awesome-gocui/gocui"
|
// "github.com/awesome-gocui/gocui"
|
||||||
"go.wit.com/gui/widget"
|
"go.wit.com/lib/widget"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (n *node) setCheckbox(b any) {
|
func (n *node) setCheckbox(b any) {
|
||||||
w := n.tk
|
w := n.tk
|
||||||
if (n.WidgetType != widget.Checkbox) {
|
if n.WidgetType != widget.Checkbox {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if widget.GetBool(b) {
|
if widget.GetBool(b) {
|
||||||
|
@ -20,13 +20,13 @@ func (n *node) setCheckbox(b any) {
|
||||||
t := len(n.tk.label) + 1
|
t := len(n.tk.label) + 1
|
||||||
w.gocuiSize.w1 = w.gocuiSize.w0 + t
|
w.gocuiSize.w1 = w.gocuiSize.w0 + t
|
||||||
|
|
||||||
// w.realWidth = w.gocuiSize.Width() + me.PadW
|
// w.realWidth = w.gocuiSize.Width() + me.PadW
|
||||||
// w.realHeight = w.gocuiSize.Height() + me.PadH
|
// w.realHeight = w.gocuiSize.Height() + me.PadH
|
||||||
|
|
||||||
// if w.frame {
|
// if w.frame {
|
||||||
// w.realWidth += me.FramePadW
|
// w.realWidth += me.FramePadW
|
||||||
// w.realHeight += me.FramePadH
|
// w.realHeight += me.FramePadH
|
||||||
// }
|
// }
|
||||||
|
|
||||||
n.deleteView()
|
n.deleteView()
|
||||||
n.showView()
|
n.showView()
|
||||||
|
|
|
@ -3,8 +3,8 @@ package main
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/awesome-gocui/gocui"
|
"github.com/awesome-gocui/gocui"
|
||||||
|
"go.wit.com/lib/widget"
|
||||||
"go.wit.com/log"
|
"go.wit.com/log"
|
||||||
"go.wit.com/gui/widget"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// set isCurrent = false everywhere
|
// set isCurrent = false everywhere
|
||||||
|
@ -92,15 +92,15 @@ func (n *node) doWidgetClick() {
|
||||||
case widget.Root:
|
case widget.Root:
|
||||||
// THIS IS THE BEGINING OF THE LAYOUT
|
// THIS IS THE BEGINING OF THE LAYOUT
|
||||||
log.Log(NOW, "doWidgetClick()", n.progname)
|
log.Log(NOW, "doWidgetClick()", n.progname)
|
||||||
redoWindows(0,0)
|
redoWindows(0, 0)
|
||||||
case widget.Flag:
|
case widget.Flag:
|
||||||
log.Log(NOW, "doWidgetClick() FLAG widget name =", n.progname)
|
log.Log(NOW, "doWidgetClick() FLAG widget name =", n.progname)
|
||||||
log.Log(NOW, "doWidgetClick() if this is the dropdown menu, handle it here?")
|
log.Log(NOW, "doWidgetClick() if this is the dropdown menu, handle it here?")
|
||||||
case widget.Window:
|
case widget.Window:
|
||||||
if (me.currentWindow == n) {
|
if me.currentWindow == n {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (me.currentWindow != nil) {
|
if me.currentWindow != nil {
|
||||||
unsetCurrent(me.currentWindow)
|
unsetCurrent(me.currentWindow)
|
||||||
me.currentWindow.setColor(&colorWindow)
|
me.currentWindow.setColor(&colorWindow)
|
||||||
me.currentWindow.hideWidgets()
|
me.currentWindow.hideWidgets()
|
||||||
|
@ -111,7 +111,7 @@ func (n *node) doWidgetClick() {
|
||||||
n.setColor(&colorActiveW)
|
n.setColor(&colorActiveW)
|
||||||
n.redoTabs(me.TabW, me.TabH)
|
n.redoTabs(me.TabW, me.TabH)
|
||||||
for _, child := range n.children {
|
for _, child := range n.children {
|
||||||
if (child.currentTab == true) {
|
if child.currentTab == true {
|
||||||
log.Log(NOW, "FOUND CURRENT TAB", child.progname)
|
log.Log(NOW, "FOUND CURRENT TAB", child.progname)
|
||||||
setCurrentTab(child)
|
setCurrentTab(child)
|
||||||
child.placeWidgets(me.RawW, me.RawH)
|
child.placeWidgets(me.RawW, me.RawH)
|
||||||
|
@ -124,12 +124,12 @@ func (n *node) doWidgetClick() {
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
case widget.Tab:
|
case widget.Tab:
|
||||||
if (n.IsCurrent()) {
|
if n.IsCurrent() {
|
||||||
return // do nothing if you reclick on the already selected tab
|
return // do nothing if you reclick on the already selected tab
|
||||||
}
|
}
|
||||||
// find the window and disable the active tab
|
// find the window and disable the active tab
|
||||||
p := n.parent
|
p := n.parent
|
||||||
if (p != nil) {
|
if p != nil {
|
||||||
p.hideWidgets()
|
p.hideWidgets()
|
||||||
p.redoTabs(me.TabW, me.TabH)
|
p.redoTabs(me.TabW, me.TabH)
|
||||||
unsetCurrent(p)
|
unsetCurrent(p)
|
||||||
|
@ -149,7 +149,7 @@ func (n *node) doWidgetClick() {
|
||||||
// n.placeWidgets(p.tk.startH, newH)
|
// n.placeWidgets(p.tk.startH, newH)
|
||||||
n.toggleTree()
|
n.toggleTree()
|
||||||
case widget.Checkbox:
|
case widget.Checkbox:
|
||||||
if (widget.GetBool(n.value)) {
|
if widget.GetBool(n.value) {
|
||||||
n.setCheckbox(false)
|
n.setCheckbox(false)
|
||||||
} else {
|
} else {
|
||||||
n.setCheckbox(true)
|
n.setCheckbox(true)
|
||||||
|
@ -166,7 +166,7 @@ func (n *node) doWidgetClick() {
|
||||||
n.showWidgets()
|
n.showWidgets()
|
||||||
case widget.Box:
|
case widget.Box:
|
||||||
// w.showWidgetPlacement(logNow, "drawTree()")
|
// w.showWidgetPlacement(logNow, "drawTree()")
|
||||||
if (n.direction == widget.Horizontal) {
|
if n.direction == widget.Horizontal {
|
||||||
log.Log(NOW, "BOX IS HORIZONTAL", n.progname)
|
log.Log(NOW, "BOX IS HORIZONTAL", n.progname)
|
||||||
} else {
|
} else {
|
||||||
log.Log(NOW, "BOX IS VERTICAL", n.progname)
|
log.Log(NOW, "BOX IS VERTICAL", n.progname)
|
||||||
|
@ -177,7 +177,7 @@ func (n *node) doWidgetClick() {
|
||||||
n.doUserEvent()
|
n.doUserEvent()
|
||||||
case widget.Dropdown:
|
case widget.Dropdown:
|
||||||
log.Log(NOW, "do the dropdown here")
|
log.Log(NOW, "do the dropdown here")
|
||||||
if (me.ddview == nil) {
|
if me.ddview == nil {
|
||||||
me.ddview = addDropdown()
|
me.ddview = addDropdown()
|
||||||
tk := me.ddview.tk
|
tk := me.ddview.tk
|
||||||
tk.gocuiSize.w0 = 20
|
tk.gocuiSize.w0 = 20
|
||||||
|
@ -189,7 +189,7 @@ func (n *node) doWidgetClick() {
|
||||||
tk.gocuiSize.h0,
|
tk.gocuiSize.h0,
|
||||||
tk.gocuiSize.w1,
|
tk.gocuiSize.w1,
|
||||||
tk.gocuiSize.h1, 0)
|
tk.gocuiSize.h1, 0)
|
||||||
if (tk.v == nil) {
|
if tk.v == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
tk.v.Wrap = true
|
tk.v.Wrap = true
|
||||||
|
@ -200,7 +200,7 @@ func (n *node) doWidgetClick() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
log.Log(NOW, "doWidgetClick() visible =", me.ddview.Visible())
|
log.Log(NOW, "doWidgetClick() visible =", me.ddview.Visible())
|
||||||
if (me.ddview.Visible()) {
|
if me.ddview.Visible() {
|
||||||
me.ddview.SetVisible(false)
|
me.ddview.SetVisible(false)
|
||||||
me.baseGui.DeleteView("ddview")
|
me.baseGui.DeleteView("ddview")
|
||||||
me.ddview.tk.v = nil
|
me.ddview.tk.v = nil
|
||||||
|
@ -224,8 +224,9 @@ func (n *node) doWidgetClick() {
|
||||||
}
|
}
|
||||||
|
|
||||||
var toggle bool = true
|
var toggle bool = true
|
||||||
|
|
||||||
func (n *node) toggleTree() {
|
func (n *node) toggleTree() {
|
||||||
if (toggle) {
|
if toggle {
|
||||||
n.drawTree(toggle)
|
n.drawTree(toggle)
|
||||||
toggle = false
|
toggle = false
|
||||||
} else {
|
} else {
|
||||||
|
@ -234,15 +235,14 @@ func (n *node) toggleTree() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// display the widgets in the binary tree
|
// display the widgets in the binary tree
|
||||||
func (n *node) drawTree(draw bool) {
|
func (n *node) drawTree(draw bool) {
|
||||||
w := n.tk
|
w := n.tk
|
||||||
if (w == nil) {
|
if w == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
n.showWidgetPlacement(true, "drawTree()")
|
n.showWidgetPlacement(true, "drawTree()")
|
||||||
if (draw) {
|
if draw {
|
||||||
// w.textResize()
|
// w.textResize()
|
||||||
n.showView()
|
n.showView()
|
||||||
} else {
|
} else {
|
||||||
|
@ -261,9 +261,9 @@ func click(g *gocui.Gui, v *gocui.View) error {
|
||||||
log.Log(INFO, "click() START", v.Name())
|
log.Log(INFO, "click() START", v.Name())
|
||||||
// n := me.rootNode.findWidgetName(v.Name())
|
// n := me.rootNode.findWidgetName(v.Name())
|
||||||
n := findUnderMouse()
|
n := findUnderMouse()
|
||||||
if (n != nil) {
|
if n != nil {
|
||||||
log.Log(NOW, "click() Found widget =", n.WidgetId, n.progname, ",", n.label)
|
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() 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")
|
log.Log(NOW, "click() set a global dropdown clicked flag=true here")
|
||||||
me.ddClicked = true
|
me.ddClicked = true
|
||||||
|
@ -285,7 +285,7 @@ func click(g *gocui.Gui, v *gocui.View) error {
|
||||||
func findUnderMouse() *node {
|
func findUnderMouse() *node {
|
||||||
var found *node
|
var found *node
|
||||||
var widgets []*node
|
var widgets []*node
|
||||||
var f func (n *node)
|
var f func(n *node)
|
||||||
w, h := me.baseGui.MousePosition()
|
w, h := me.baseGui.MousePosition()
|
||||||
|
|
||||||
// find buttons that are below where the mouse button click
|
// find buttons that are below where the mouse button click
|
||||||
|
@ -293,13 +293,13 @@ func findUnderMouse() *node {
|
||||||
widget := n.tk
|
widget := n.tk
|
||||||
// ignore widgets that are not visible
|
// ignore widgets that are not visible
|
||||||
if n.Visible() {
|
if n.Visible() {
|
||||||
if ((widget.gocuiSize.w0 <= w) && (w <= widget.gocuiSize.w1) &&
|
if (widget.gocuiSize.w0 <= w) && (w <= widget.gocuiSize.w1) &&
|
||||||
(widget.gocuiSize.h0 <= h) && (h <= widget.gocuiSize.h1)) {
|
(widget.gocuiSize.h0 <= h) && (h <= widget.gocuiSize.h1) {
|
||||||
widgets = append(widgets, n)
|
widgets = append(widgets, n)
|
||||||
found = n
|
found = n
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (n == me.ddview) {
|
if n == me.ddview {
|
||||||
log.Log(NOW, "findUnderMouse() found ddview")
|
log.Log(NOW, "findUnderMouse() found ddview")
|
||||||
if n.Visible() {
|
if n.Visible() {
|
||||||
log.Log(NOW, "findUnderMouse() and ddview is visable. hide it here. TODO: find highlighted row")
|
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 widgets []*node
|
||||||
// var f func (n *node)
|
// var f func (n *node)
|
||||||
found = findUnderMouse()
|
found = findUnderMouse()
|
||||||
if (me.ctrlDown == nil) {
|
if me.ctrlDown == nil {
|
||||||
setupCtrlDownWidget()
|
setupCtrlDownWidget()
|
||||||
me.ctrlDown.label = found.progname
|
me.ctrlDown.label = found.progname
|
||||||
me.ctrlDown.tk.cuiName = "ctrlDown"
|
me.ctrlDown.tk.cuiName = "ctrlDown"
|
||||||
// me.ctrlDown.parent = me.rootNode
|
// me.ctrlDown.parent = me.rootNode
|
||||||
}
|
}
|
||||||
cd := me.ctrlDown.tk
|
cd := me.ctrlDown.tk
|
||||||
if (found == nil) {
|
if found == nil {
|
||||||
found = me.rootNode
|
found = me.rootNode
|
||||||
}
|
}
|
||||||
me.ctrlDown.label = found.progname
|
me.ctrlDown.label = found.progname
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"math/rand"
|
|
||||||
"github.com/awesome-gocui/gocui"
|
"github.com/awesome-gocui/gocui"
|
||||||
|
"math/rand"
|
||||||
|
|
||||||
"go.wit.com/log"
|
"go.wit.com/log"
|
||||||
)
|
)
|
||||||
|
@ -38,23 +38,24 @@ var superLightGrey gocui.Attribute = gocui.GetColor("#55AAFF") // super light gr
|
||||||
// v.BgColor = gocui.GetColor("#FFC0CB") // 'w3c pink' yellow
|
// v.BgColor = gocui.GetColor("#FFC0CB") // 'w3c pink' yellow
|
||||||
|
|
||||||
// Normal Text On mouseover
|
// Normal Text On mouseover
|
||||||
|
//
|
||||||
// Widget Frame Text background Text background
|
// Widget Frame Text background Text background
|
||||||
var colorWindow colorT = colorT{ none , gocui.ColorBlue, none , none , powdererBlue , "normal window"}
|
var colorWindow colorT = colorT{none, gocui.ColorBlue, none, none, powdererBlue, "normal window"}
|
||||||
var colorActiveW colorT = colorT{ none , none , powdererBlue , none , powdererBlue , "active 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 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 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 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 colorLabel colorT = colorT{none, none, superLightGrey, none, superLightGrey, "normal label"}
|
||||||
var colorGroup colorT = colorT{ none , none , superLightGrey , none , superLightGrey , "normal group"}
|
var colorGroup colorT = colorT{none, none, superLightGrey, none, superLightGrey, "normal group"}
|
||||||
|
|
||||||
// widget debugging colors. these widgets aren't displayed unless you are debugging
|
// 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 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 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 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 colorGrid colorT = colorT{gocui.ColorRed, none, lightPurple, none, gocui.ColorRed, "debug grid"}
|
||||||
var colorNone colorT = colorT{ none , none , none , none , none , "debug none"}
|
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
|
// the user will see the colors change when this runs
|
||||||
|
@ -66,15 +67,15 @@ var colorNone colorT = colorT{ none , none , non
|
||||||
// TODO: so just a small little 'todo' item here
|
// TODO: so just a small little 'todo' item here
|
||||||
func (n *node) setColor(newColor *colorT) {
|
func (n *node) setColor(newColor *colorT) {
|
||||||
tk := n.tk
|
tk := n.tk
|
||||||
if (tk.color == newColor) {
|
if tk.color == newColor {
|
||||||
// nothing to do since the colors have nto changed
|
// nothing to do since the colors have nto changed
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
tk.color = newColor
|
tk.color = newColor
|
||||||
if (tk.v == nil) {
|
if tk.v == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (tk.color == nil) {
|
if tk.color == nil {
|
||||||
log.Log(NOW, "Set the node to color = nil")
|
log.Log(NOW, "Set the node to color = nil")
|
||||||
tk.color = &colorNone
|
tk.color = &colorNone
|
||||||
}
|
}
|
||||||
|
@ -88,7 +89,7 @@ func (n *node) setDefaultWidgetColor() {
|
||||||
|
|
||||||
func (n *node) setDefaultHighlight() {
|
func (n *node) setDefaultHighlight() {
|
||||||
w := n.tk
|
w := n.tk
|
||||||
if (w.v == nil) {
|
if w.v == nil {
|
||||||
log.Log(ERROR, "SetColor() failed on view == nil")
|
log.Log(ERROR, "SetColor() failed on view == nil")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -105,7 +106,7 @@ func randColor() gocui.Attribute {
|
||||||
|
|
||||||
func (n *node) redoColor(draw bool) {
|
func (n *node) redoColor(draw bool) {
|
||||||
w := n.tk
|
w := n.tk
|
||||||
if (w == nil) {
|
if w == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,8 +12,8 @@ package main
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"go.wit.com/lib/widget"
|
||||||
"go.wit.com/log"
|
"go.wit.com/log"
|
||||||
"go.wit.com/gui/widget"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// this is the channel we send user events like
|
// this is the channel we send user events like
|
||||||
|
@ -75,7 +75,7 @@ type node struct {
|
||||||
|
|
||||||
// searches the binary tree for a WidgetId
|
// searches the binary tree for a WidgetId
|
||||||
func (n *node) findWidgetId(id int) *node {
|
func (n *node) findWidgetId(id int) *node {
|
||||||
if (n == nil) {
|
if n == nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -85,7 +85,7 @@ func (n *node) findWidgetId(id int) *node {
|
||||||
|
|
||||||
for _, child := range n.children {
|
for _, child := range n.children {
|
||||||
newN := child.findWidgetId(id)
|
newN := child.findWidgetId(id)
|
||||||
if (newN != nil) {
|
if newN != nil {
|
||||||
return newN
|
return newN
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -93,7 +93,7 @@ func (n *node) findWidgetId(id int) *node {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *node) doUserEvent() {
|
func (n *node) doUserEvent() {
|
||||||
if (callback == nil) {
|
if callback == nil {
|
||||||
log.Log(ERROR, "doUserEvent() callback == nil", n.WidgetId)
|
log.Log(ERROR, "doUserEvent() callback == nil", n.WidgetId)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -196,12 +196,12 @@ func addNode(a *widget.Action) *node {
|
||||||
n.tk = initWidget(n)
|
n.tk = initWidget(n)
|
||||||
// n.tk = new(guiWidget)
|
// n.tk = new(guiWidget)
|
||||||
|
|
||||||
if (a.WidgetType == widget.Root) {
|
if a.WidgetType == widget.Root {
|
||||||
log.Log(INFO, "addNode() Root")
|
log.Log(INFO, "addNode() Root")
|
||||||
return n
|
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)
|
log.Log(ERROR, "addNode() WidgetId already exists", a.WidgetId)
|
||||||
return me.rootNode.findWidgetId(a.WidgetId)
|
return me.rootNode.findWidgetId(a.WidgetId)
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,13 +2,13 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"go.wit.com/lib/widget"
|
||||||
"go.wit.com/log"
|
"go.wit.com/log"
|
||||||
"go.wit.com/gui/widget"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func (n *node) dumpTree(draw bool) {
|
func (n *node) dumpTree(draw bool) {
|
||||||
w := n.tk
|
w := n.tk
|
||||||
if (w == nil) {
|
if w == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
n.showWidgetPlacement(true, "dumpTree()")
|
n.showWidgetPlacement(true, "dumpTree()")
|
||||||
|
@ -19,7 +19,7 @@ func (n *node) dumpTree(draw bool) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *node) showWidgetPlacement(b bool, s string) {
|
func (n *node) showWidgetPlacement(b bool, s string) {
|
||||||
if (n == nil) {
|
if n == nil {
|
||||||
log.Log(ERROR, "WTF w == nil")
|
log.Log(ERROR, "WTF w == nil")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,7 @@ func (n *node) showWidgetPlacement(b bool, s string) {
|
||||||
|
|
||||||
var s1 string
|
var s1 string
|
||||||
var pId int
|
var pId int
|
||||||
if (n.parent == nil) {
|
if n.parent == nil {
|
||||||
log.Log(INFO, "showWidgetPlacement() parent == nil", n.WidgetId, w.cuiName)
|
log.Log(INFO, "showWidgetPlacement() parent == nil", n.WidgetId, w.cuiName)
|
||||||
pId = 0
|
pId = 0
|
||||||
} else {
|
} else {
|
||||||
|
@ -41,8 +41,8 @@ func (n *node) showWidgetPlacement(b bool, s string) {
|
||||||
} else {
|
} else {
|
||||||
s1 += fmt.Sprintf(" ")
|
s1 += fmt.Sprintf(" ")
|
||||||
}
|
}
|
||||||
if (n.parent != nil) {
|
if n.parent != nil {
|
||||||
if (n.parent.WidgetType == widget.Grid) {
|
if n.parent.WidgetType == widget.Grid {
|
||||||
s1 += fmt.Sprintf("At(%2d,%2d) ", n.AtW, n.AtH)
|
s1 += fmt.Sprintf("At(%2d,%2d) ", n.AtW, n.AtH)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -55,7 +55,7 @@ func (n *node) dumpWidget(pad string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *node) listWidgets() {
|
func (n *node) listWidgets() {
|
||||||
if (n == nil) {
|
if n == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,8 +2,8 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"io"
|
|
||||||
"errors"
|
"errors"
|
||||||
|
"io"
|
||||||
)
|
)
|
||||||
|
|
||||||
type FakeFile struct {
|
type FakeFile struct {
|
||||||
|
|
|
@ -56,7 +56,7 @@ func gocuiEvent(g *gocui.Gui) error {
|
||||||
if widgetView, _ := g.View("msg"); widgetView == nil {
|
if widgetView, _ := g.View("msg"); widgetView == nil {
|
||||||
log.Log(NOW, "handleEvent() create output widget now", maxX, maxY, mx, my)
|
log.Log(NOW, "handleEvent() create output widget now", maxX, maxY, mx, my)
|
||||||
makeOutputWidget(g, "this is a create before a mouse click")
|
makeOutputWidget(g, "this is a create before a mouse click")
|
||||||
if (me.logStdout != nil) {
|
if me.logStdout != nil {
|
||||||
// setOutput(me.logStdout)
|
// setOutput(me.logStdout)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -75,7 +75,7 @@ func setFrame(b bool) {
|
||||||
// TODO: figure out what this might be useful for
|
// 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?
|
// 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
|
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")
|
log.Log(ERROR, "setFrame() global failed")
|
||||||
}
|
}
|
||||||
v.Frame = b
|
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 {
|
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")
|
log.Log(ERROR, "SetView() ERROR: me.baseGui == nil")
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,13 +42,13 @@ func helplayout() error {
|
||||||
maxX, _ := g.Size()
|
maxX, _ := g.Size()
|
||||||
|
|
||||||
var newW int = 8
|
var newW int = 8
|
||||||
for _, s := range(helpText) {
|
for _, s := range helpText {
|
||||||
if newW < len(s) {
|
if newW < len(s) {
|
||||||
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 err != nil {
|
||||||
if !errors.Is(err, gocui.ErrUnknownView) {
|
if !errors.Is(err, gocui.ErrUnknownView) {
|
||||||
return err
|
return err
|
||||||
|
|
|
@ -7,8 +7,8 @@ package main
|
||||||
import (
|
import (
|
||||||
"github.com/awesome-gocui/gocui"
|
"github.com/awesome-gocui/gocui"
|
||||||
|
|
||||||
|
"go.wit.com/lib/widget"
|
||||||
"go.wit.com/log"
|
"go.wit.com/log"
|
||||||
"go.wit.com/gui/widget"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func defaultKeybindings(g *gocui.Gui) error {
|
func defaultKeybindings(g *gocui.Gui) error {
|
||||||
|
@ -30,9 +30,9 @@ func defaultKeybindings(g *gocui.Gui) error {
|
||||||
if err := g.SetKeybinding("", gocui.MouseLeft, gocui.ModMouseCtrl, ctrlDown); err != nil {
|
if err := g.SetKeybinding("", gocui.MouseLeft, gocui.ModMouseCtrl, ctrlDown); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
// if err := g.SetKeybinding(w.v.Name(), gocui.MouseLeft, gocui.ModNone, click); err != nil {
|
// if err := g.SetKeybinding(w.v.Name(), gocui.MouseLeft, gocui.ModNone, click); err != nil {
|
||||||
// return err
|
// return err
|
||||||
// }
|
// }
|
||||||
/*
|
/*
|
||||||
if err := g.SetKeybinding("", gocui.MouseLeft, gocui.ModNone, globalDown); err != nil {
|
if err := g.SetKeybinding("", gocui.MouseLeft, gocui.ModNone, globalDown); err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -51,7 +51,7 @@ func addDebugKeys(g *gocui.Gui) {
|
||||||
func(g *gocui.Gui, v *gocui.View) error {
|
func(g *gocui.Gui, v *gocui.View) error {
|
||||||
fakeStartWidth = me.FakeW
|
fakeStartWidth = me.FakeW
|
||||||
fakeStartHeight = me.TabH + me.FramePadH
|
fakeStartHeight = me.TabH + me.FramePadH
|
||||||
if (showDebug) {
|
if showDebug {
|
||||||
me.rootNode.showFake()
|
me.rootNode.showFake()
|
||||||
showDebug = false
|
showDebug = false
|
||||||
} else {
|
} else {
|
||||||
|
@ -64,7 +64,7 @@ func addDebugKeys(g *gocui.Gui) {
|
||||||
// display the help menu
|
// display the help menu
|
||||||
g.SetKeybinding("", '?', gocui.ModNone,
|
g.SetKeybinding("", '?', gocui.ModNone,
|
||||||
func(g *gocui.Gui, v *gocui.View) error {
|
func(g *gocui.Gui, v *gocui.View) error {
|
||||||
if (showHelp) {
|
if showHelp {
|
||||||
helplayout()
|
helplayout()
|
||||||
showHelp = false
|
showHelp = false
|
||||||
} else {
|
} else {
|
||||||
|
@ -77,8 +77,8 @@ func addDebugKeys(g *gocui.Gui) {
|
||||||
// redraw all the widgets
|
// redraw all the widgets
|
||||||
g.SetKeybinding("", 'r', gocui.ModNone,
|
g.SetKeybinding("", 'r', gocui.ModNone,
|
||||||
func(g *gocui.Gui, v *gocui.View) error {
|
func(g *gocui.Gui, v *gocui.View) error {
|
||||||
if (redoWidgets) {
|
if redoWidgets {
|
||||||
redoWindows(0,0)
|
redoWindows(0, 0)
|
||||||
redoWidgets = false
|
redoWidgets = false
|
||||||
} else {
|
} else {
|
||||||
me.rootNode.hideWidgets()
|
me.rootNode.hideWidgets()
|
||||||
|
@ -142,7 +142,7 @@ func addDebugKeys(g *gocui.Gui) {
|
||||||
})
|
})
|
||||||
g.SetKeybinding("", gocui.KeyCtrlD, gocui.ModNone,
|
g.SetKeybinding("", gocui.KeyCtrlD, gocui.ModNone,
|
||||||
func(g *gocui.Gui, v *gocui.View) error {
|
func(g *gocui.Gui, v *gocui.View) error {
|
||||||
if (showDebug) {
|
if showDebug {
|
||||||
var a widget.Action
|
var a widget.Action
|
||||||
a.Value = true
|
a.Value = true
|
||||||
a.ActionType = widget.EnableDebug
|
a.ActionType = widget.EnableDebug
|
||||||
|
|
|
@ -7,8 +7,8 @@ package main
|
||||||
import (
|
import (
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
|
"go.wit.com/lib/widget"
|
||||||
"go.wit.com/log"
|
"go.wit.com/log"
|
||||||
"go.wit.com/gui/widget"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// sets defaults and establishes communication
|
// sets defaults and establishes communication
|
||||||
|
@ -40,7 +40,7 @@ func catchActionChannel() {
|
||||||
log.Log(INFO, "catchActionChannel() infinite for() loop restarted select on channel")
|
log.Log(INFO, "catchActionChannel() infinite for() loop restarted select on channel")
|
||||||
select {
|
select {
|
||||||
case a := <-pluginChan:
|
case a := <-pluginChan:
|
||||||
if (me.baseGui == nil) {
|
if me.baseGui == nil {
|
||||||
// something went wrong initializing the gocui
|
// something went wrong initializing the gocui
|
||||||
log.Log(ERROR, "ERROR: console did not initialize")
|
log.Log(ERROR, "ERROR: console did not initialize")
|
||||||
continue
|
continue
|
||||||
|
@ -84,7 +84,7 @@ func main() {
|
||||||
var err error
|
var err error
|
||||||
log.Log(INFO, "main() start Init()")
|
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 {
|
if err != nil {
|
||||||
log.Error(err, "error opening file: %v")
|
log.Error(err, "error opening file: %v")
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
|
|
|
@ -38,10 +38,10 @@ func msgDown(g *gocui.Gui, v *gocui.View) error {
|
||||||
func hideDDview() error {
|
func hideDDview() error {
|
||||||
w, h := me.baseGui.MousePosition()
|
w, h := me.baseGui.MousePosition()
|
||||||
log.Log(NOW, "hide dropdown menu() view msgMouseDown (w,h) =", w, h)
|
log.Log(NOW, "hide dropdown menu() view msgMouseDown (w,h) =", w, h)
|
||||||
if (me.ddview == nil) {
|
if me.ddview == nil {
|
||||||
return gocui.ErrUnknownView
|
return gocui.ErrUnknownView
|
||||||
}
|
}
|
||||||
if (me.ddview.tk.v == nil) {
|
if me.ddview.tk.v == nil {
|
||||||
return gocui.ErrUnknownView
|
return gocui.ErrUnknownView
|
||||||
}
|
}
|
||||||
me.ddview.SetVisible(false)
|
me.ddview.SetVisible(false)
|
||||||
|
@ -51,10 +51,10 @@ func hideDDview() error {
|
||||||
func showDDview() error {
|
func showDDview() error {
|
||||||
w, h := me.baseGui.MousePosition()
|
w, h := me.baseGui.MousePosition()
|
||||||
log.Log(NOW, "show dropdown menu() view msgMouseDown (w,h) =", w, h)
|
log.Log(NOW, "show dropdown menu() view msgMouseDown (w,h) =", w, h)
|
||||||
if (me.ddview == nil) {
|
if me.ddview == nil {
|
||||||
return gocui.ErrUnknownView
|
return gocui.ErrUnknownView
|
||||||
}
|
}
|
||||||
if (me.ddview.tk.v == nil) {
|
if me.ddview.tk.v == nil {
|
||||||
return gocui.ErrUnknownView
|
return gocui.ErrUnknownView
|
||||||
}
|
}
|
||||||
me.ddview.SetVisible(true)
|
me.ddview.SetVisible(true)
|
||||||
|
@ -64,27 +64,27 @@ func showDDview() error {
|
||||||
func mouseUp(g *gocui.Gui, v *gocui.View) error {
|
func mouseUp(g *gocui.Gui, v *gocui.View) error {
|
||||||
w, h := g.MousePosition()
|
w, h := g.MousePosition()
|
||||||
log.Log(NOW, "mouseUp() view msgMouseDown (check here for dropdown menu click) (w,h) =", w, h)
|
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
|
me.ddClicked = false
|
||||||
log.Log(NOW, "mouseUp() ddview is the thing that was clicked", w, h)
|
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)
|
log.Log(NOW, "mouseUp() find out what the string is here", w, h, me.ddview.tk.gocuiSize.h1)
|
||||||
|
|
||||||
var newZone string = ""
|
var newZone string = ""
|
||||||
if (me.ddNode != nil) {
|
if me.ddNode != nil {
|
||||||
value := h - me.ddview.tk.gocuiSize.h0 - 1
|
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.ddview.tk.gocuiSize.h1 =", me.ddview.tk.gocuiSize.h1)
|
||||||
log.Log(NOW, "mouseUp() me.ddNode.vals =", me.ddNode.vals)
|
log.Log(NOW, "mouseUp() me.ddNode.vals =", me.ddNode.vals)
|
||||||
valsLen := len(me.ddNode.vals)
|
valsLen := len(me.ddNode.vals)
|
||||||
log.Log(NOW, "mouseUp() value =", value, "valsLen =", valsLen)
|
log.Log(NOW, "mouseUp() value =", value, "valsLen =", valsLen)
|
||||||
log.Log(NOW, "mouseUp() me.ddNode.vals =", me.ddNode.vals)
|
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]
|
newZone = me.ddNode.vals[value]
|
||||||
log.Log(NOW, "mouseUp() value =", value, "newZone =", newZone)
|
log.Log(NOW, "mouseUp() value =", value, "newZone =", newZone)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
hideDDview()
|
hideDDview()
|
||||||
if (newZone != "") {
|
if newZone != "" {
|
||||||
if (me.ddNode != nil) {
|
if me.ddNode != nil {
|
||||||
me.ddNode.SetText(newZone)
|
me.ddNode.SetText(newZone)
|
||||||
me.ddNode.value = newZone
|
me.ddNode.value = newZone
|
||||||
me.ddNode.doUserEvent()
|
me.ddNode.doUserEvent()
|
||||||
|
@ -124,8 +124,8 @@ func mouseDown(g *gocui.Gui, v *gocui.View) error {
|
||||||
maxX, _ := g.Size()
|
maxX, _ := g.Size()
|
||||||
test := findUnderMouse()
|
test := findUnderMouse()
|
||||||
msg := fmt.Sprintf("Mouse really down at: %d,%d", mx, my) + "foobar"
|
msg := fmt.Sprintf("Mouse really down at: %d,%d", mx, my) + "foobar"
|
||||||
if (test == me.ddview) {
|
if test == me.ddview {
|
||||||
if (me.ddview.Visible()) {
|
if me.ddview.Visible() {
|
||||||
log.Log(NOW, "hide DDview() Mouse really down at:", mx, my)
|
log.Log(NOW, "hide DDview() Mouse really down at:", mx, my)
|
||||||
hideDDview()
|
hideDDview()
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -3,12 +3,12 @@ package main
|
||||||
import (
|
import (
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"go.wit.com/lib/widget"
|
||||||
"go.wit.com/log"
|
"go.wit.com/log"
|
||||||
"go.wit.com/gui/widget"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func (n *node) placeBox(startW int, startH int) {
|
func (n *node) placeBox(startW int, startH int) {
|
||||||
if (n.WidgetType != widget.Box) {
|
if n.WidgetType != widget.Box {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
n.showWidgetPlacement(true, "boxS()")
|
n.showWidgetPlacement(true, "boxS()")
|
||||||
|
@ -21,7 +21,7 @@ func (n *node) placeBox(startW int, startH int) {
|
||||||
newR := child.realGocuiSize()
|
newR := child.realGocuiSize()
|
||||||
w := newR.w1 - newR.w0
|
w := newR.w1 - newR.w0
|
||||||
h := newR.h1 - newR.h0
|
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)
|
log.Log(NOW, "BOX IS HORIZONTAL", n.progname, "newWH()", newW, newH, "child()", w, h, child.progname)
|
||||||
// expand based on the child width
|
// expand based on the child width
|
||||||
newW += w
|
newW += w
|
||||||
|
@ -39,10 +39,10 @@ func (n *node) placeBox(startW int, startH int) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *node) placeWidgets(startW int, startH int) {
|
func (n *node) placeWidgets(startW int, startH int) {
|
||||||
if (n == nil) {
|
if n == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (me.rootNode == nil) {
|
if me.rootNode == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -87,7 +87,7 @@ func (n *node) placeWidgets(startW int, startH int) {
|
||||||
func (n *node) placeGrid(startW int, startH int) {
|
func (n *node) placeGrid(startW int, startH int) {
|
||||||
w := n.tk
|
w := n.tk
|
||||||
n.showWidgetPlacement(true, "grid0:")
|
n.showWidgetPlacement(true, "grid0:")
|
||||||
if (n.WidgetType != widget.Grid) {
|
if n.WidgetType != widget.Grid {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,10 +98,10 @@ func (n *node) placeGrid(startW int, startH int) {
|
||||||
childH := newR.h1 - newR.h0
|
childH := newR.h1 - newR.h0
|
||||||
|
|
||||||
// set the child's realWidth, and grid offset
|
// 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
|
w.widths[child.AtW] = childW
|
||||||
}
|
}
|
||||||
if (w.heights[child.AtH] < childH) {
|
if w.heights[child.AtH] < childH {
|
||||||
w.heights[child.AtH] = childH
|
w.heights[child.AtH] = childH
|
||||||
}
|
}
|
||||||
// child.showWidgetPlacement(logInfo, "grid: ")
|
// child.showWidgetPlacement(logInfo, "grid: ")
|
||||||
|
@ -114,12 +114,12 @@ func (n *node) placeGrid(startW int, startH int) {
|
||||||
|
|
||||||
var totalW, totalH int
|
var totalW, totalH int
|
||||||
for i, w := range w.widths {
|
for i, w := range w.widths {
|
||||||
if (i < child.AtW) {
|
if i < child.AtW {
|
||||||
totalW += w
|
totalW += w
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for i, h := range w.heights {
|
for i, h := range w.heights {
|
||||||
if (i < child.AtH) {
|
if i < child.AtH {
|
||||||
totalH += h
|
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
|
// computes the real, actual size of all the gocli objects in a widget
|
||||||
func (n *node) realGocuiSize() *rectType {
|
func (n *node) realGocuiSize() *rectType {
|
||||||
var f func (n *node, r *rectType)
|
var f func(n *node, r *rectType)
|
||||||
newR := new(rectType)
|
newR := new(rectType)
|
||||||
// initialize the values to opposite
|
// initialize the values to opposite
|
||||||
newR.w0 = 80
|
newR.w0 = 80
|
||||||
|
@ -153,7 +153,7 @@ func (n *node) realGocuiSize() *rectType {
|
||||||
// expand the rectangle to the biggest thing displayed
|
// expand the rectangle to the biggest thing displayed
|
||||||
f = func(n *node, r *rectType) {
|
f = func(n *node, r *rectType) {
|
||||||
newR := n.tk.gocuiSize
|
newR := n.tk.gocuiSize
|
||||||
if ! n.tk.isFake {
|
if !n.tk.isFake {
|
||||||
if r.w0 > newR.w0 {
|
if r.w0 > newR.w0 {
|
||||||
r.w0 = newR.w0
|
r.w0 = newR.w0
|
||||||
}
|
}
|
||||||
|
@ -179,7 +179,7 @@ func (n *node) textSize() (int, int) {
|
||||||
var width, height int
|
var width, height int
|
||||||
|
|
||||||
for _, s := range strings.Split(widget.GetString(n.value), "\n") {
|
for _, s := range strings.Split(widget.GetString(n.value), "\n") {
|
||||||
if (width < len(s)) {
|
if width < len(s) {
|
||||||
width = len(s)
|
width = len(s)
|
||||||
}
|
}
|
||||||
height += 1
|
height += 1
|
||||||
|
|
|
@ -3,20 +3,20 @@ package main
|
||||||
import (
|
import (
|
||||||
// if you include more than just this 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)
|
// 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/log"
|
||||||
"go.wit.com/gui/widget"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func action(a *widget.Action) {
|
func action(a *widget.Action) {
|
||||||
log.Log(INFO, "action() START", a.WidgetId, a.ActionType, a.WidgetType, a.ProgName)
|
log.Log(INFO, "action() START", a.WidgetId, a.ActionType, a.WidgetType, a.ProgName)
|
||||||
n := me.rootNode.findWidgetId(a.WidgetId)
|
n := me.rootNode.findWidgetId(a.WidgetId)
|
||||||
var w *guiWidget
|
var w *guiWidget
|
||||||
if (n != nil) {
|
if n != nil {
|
||||||
w = n.tk
|
w = n.tk
|
||||||
}
|
}
|
||||||
switch a.ActionType {
|
switch a.ActionType {
|
||||||
case widget.Add:
|
case widget.Add:
|
||||||
if (w == nil) {
|
if w == nil {
|
||||||
n := addNode(a)
|
n := addNode(a)
|
||||||
// w = n.tk
|
// w = n.tk
|
||||||
n.addWidget()
|
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: set flag here", a.ActionType, a.WidgetType, a.ProgName)
|
||||||
log.Log(NOW, "TODO: n.WidgetType =", n.WidgetType, "n.progname =", a.ProgName)
|
log.Log(NOW, "TODO: n.WidgetType =", n.WidgetType, "n.progname =", a.ProgName)
|
||||||
} else {
|
} 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. a == nil id =", a.WidgetId, "type =", a.WidgetType, "Name =", a.ProgName)
|
||||||
log.Log(ERROR, "TODO: Set here. id =", a.WidgetId, "n.progname =", n.progname)
|
log.Log(ERROR, "TODO: Set here. id =", a.WidgetId, "n.progname =", n.progname)
|
||||||
} else {
|
} else {
|
||||||
|
@ -74,7 +74,7 @@ func action(a *widget.Action) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *node) AddText(text string) {
|
func (n *node) AddText(text string) {
|
||||||
if (n == nil) {
|
if n == nil {
|
||||||
log.Log(NOW, "widget is nil")
|
log.Log(NOW, "widget is nil")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -87,7 +87,7 @@ func (n *node) AddText(text string) {
|
||||||
|
|
||||||
func (n *node) SetText(text string) {
|
func (n *node) SetText(text string) {
|
||||||
var changed bool = false
|
var changed bool = false
|
||||||
if (n == nil) {
|
if n == nil {
|
||||||
log.Log(NOW, "widget is nil")
|
log.Log(NOW, "widget is nil")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -95,11 +95,11 @@ func (n *node) SetText(text string) {
|
||||||
n.value = text
|
n.value = text
|
||||||
changed = true
|
changed = true
|
||||||
}
|
}
|
||||||
if (! changed) {
|
if !changed {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if (n.Visible()) {
|
if n.Visible() {
|
||||||
n.textResize()
|
n.textResize()
|
||||||
n.deleteView()
|
n.deleteView()
|
||||||
n.showView()
|
n.showView()
|
||||||
|
@ -111,7 +111,7 @@ func (n *node) Set(val any) {
|
||||||
log.Log(INFO, "Set() value =", val)
|
log.Log(INFO, "Set() value =", val)
|
||||||
|
|
||||||
n.value = val
|
n.value = val
|
||||||
if (n.WidgetType != widget.Checkbox) {
|
if n.WidgetType != widget.Checkbox {
|
||||||
n.setCheckbox(val)
|
n.setCheckbox(val)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,8 +6,8 @@ import (
|
||||||
|
|
||||||
"github.com/awesome-gocui/gocui"
|
"github.com/awesome-gocui/gocui"
|
||||||
|
|
||||||
|
"go.wit.com/lib/widget"
|
||||||
"go.wit.com/log"
|
"go.wit.com/log"
|
||||||
"go.wit.com/gui/widget"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var outputW int = 180
|
var outputW int = 180
|
||||||
|
@ -18,7 +18,7 @@ func moveMsg(g *gocui.Gui) {
|
||||||
if !movingMsg && (mx != initialMouseX || my != initialMouseY) {
|
if !movingMsg && (mx != initialMouseX || my != initialMouseY) {
|
||||||
movingMsg = true
|
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")
|
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 {
|
func makeOutputWidget(g *gocui.Gui, stringFromMouseClick string) *gocui.View {
|
||||||
maxX, maxY := g.Size()
|
maxX, maxY := g.Size()
|
||||||
|
|
||||||
if (me.rootNode == nil) {
|
if me.rootNode == nil {
|
||||||
// keep skipping this until the binary tree is initialized
|
// keep skipping this until the binary tree is initialized
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if (me.logStdout == nil) {
|
if me.logStdout == nil {
|
||||||
a := new(widget.Action)
|
a := new(widget.Action)
|
||||||
a.ProgName = "stdout"
|
a.ProgName = "stdout"
|
||||||
a.WidgetType = widget.Stdout
|
a.WidgetType = widget.Stdout
|
||||||
|
@ -57,12 +57,12 @@ func makeOutputWidget(g *gocui.Gui, stringFromMouseClick string) *gocui.View {
|
||||||
n := addNode(a)
|
n := addNode(a)
|
||||||
me.logStdout = n
|
me.logStdout = n
|
||||||
me.logStdout.tk.gocuiSize.w0 = maxX - 32
|
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.w1 = me.logStdout.tk.gocuiSize.w0 + outputW
|
||||||
me.logStdout.tk.gocuiSize.h1 = me.logStdout.tk.gocuiSize.h0 + outputH
|
me.logStdout.tk.gocuiSize.h1 = me.logStdout.tk.gocuiSize.h0 + outputH
|
||||||
}
|
}
|
||||||
v, err := g.View("msg")
|
v, err := g.View("msg")
|
||||||
if (v == nil) {
|
if v == nil {
|
||||||
log.Log(NOW, "makeoutputwindow() this is supposed to happen. v == nil", err)
|
log.Log(NOW, "makeoutputwindow() this is supposed to happen. v == nil", err)
|
||||||
} else {
|
} else {
|
||||||
log.Log(NOW, "makeoutputwindow() msg != nil. WTF now? err =", err)
|
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)
|
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)
|
log.Log(NOW, "makeoutputwindow() create output window failed", err)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if (v == nil) {
|
if v == nil {
|
||||||
log.Log(NOW, "makeoutputwindow() msg == nil. WTF now? err =", err)
|
log.Log(NOW, "makeoutputwindow() msg == nil. WTF now? err =", err)
|
||||||
return nil
|
return nil
|
||||||
} else {
|
} else {
|
||||||
|
@ -91,7 +91,7 @@ func makeOutputWidget(g *gocui.Gui, stringFromMouseClick string) *gocui.View {
|
||||||
v.Clear()
|
v.Clear()
|
||||||
v.SelBgColor = gocui.ColorCyan
|
v.SelBgColor = gocui.ColorCyan
|
||||||
v.SelFgColor = gocui.ColorBlack
|
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("msg")
|
||||||
// g.SetViewOnBottom(v.Name())
|
// g.SetViewOnBottom(v.Name())
|
||||||
return v
|
return v
|
||||||
|
|
|
@ -10,11 +10,11 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"github.com/awesome-gocui/gocui"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strconv"
|
"strconv"
|
||||||
"sync"
|
|
||||||
"strings"
|
"strings"
|
||||||
"github.com/awesome-gocui/gocui"
|
"sync"
|
||||||
|
|
||||||
"go.wit.com/log"
|
"go.wit.com/log"
|
||||||
)
|
)
|
||||||
|
@ -156,13 +156,13 @@ func (w *guiWidget) Write(p []byte) (n int, err error) {
|
||||||
w.tainted = true
|
w.tainted = true
|
||||||
me.writeMutex.Lock()
|
me.writeMutex.Lock()
|
||||||
defer me.writeMutex.Unlock()
|
defer me.writeMutex.Unlock()
|
||||||
if (me.logStdout.tk.v == nil) {
|
if me.logStdout.tk.v == nil {
|
||||||
// optionally write the output to /tmp
|
// optionally write the output to /tmp
|
||||||
s := fmt.Sprint(string(p))
|
s := fmt.Sprint(string(p))
|
||||||
s = strings.TrimSuffix(s, "\n")
|
s = strings.TrimSuffix(s, "\n")
|
||||||
fmt.Fprintln(outf, s)
|
fmt.Fprintln(outf, s)
|
||||||
v, _ := me.baseGui.View("msg")
|
v, _ := me.baseGui.View("msg")
|
||||||
if (v != nil) {
|
if v != nil {
|
||||||
// fmt.Fprintln(outf, "found msg")
|
// fmt.Fprintln(outf, "found msg")
|
||||||
me.logStdout.tk.v = v
|
me.logStdout.tk.v = v
|
||||||
}
|
}
|
||||||
|
@ -174,7 +174,7 @@ func (w *guiWidget) Write(p []byte) (n int, err error) {
|
||||||
s = strings.TrimSuffix(s, "\n")
|
s = strings.TrimSuffix(s, "\n")
|
||||||
tmp := strings.Split(s, "\n")
|
tmp := strings.Split(s, "\n")
|
||||||
outputS = append(outputS, tmp...)
|
outputS = append(outputS, tmp...)
|
||||||
if (len(outputS) > outputH) {
|
if len(outputS) > outputH {
|
||||||
l := len(outputS) - outputH
|
l := len(outputS) - outputH
|
||||||
outputS = outputS[l:]
|
outputS = outputS[l:]
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,8 +5,8 @@ package main
|
||||||
import (
|
import (
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"go.wit.com/lib/widget"
|
||||||
"go.wit.com/log"
|
"go.wit.com/log"
|
||||||
"go.wit.com/gui/widget"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func (w *guiWidget) Width() int {
|
func (w *guiWidget) Width() int {
|
||||||
|
@ -58,11 +58,11 @@ func redoWindows(nextW int, nextH int) {
|
||||||
w := n.tk
|
w := n.tk
|
||||||
var tabs bool
|
var tabs bool
|
||||||
for _, child := range n.children {
|
for _, child := range n.children {
|
||||||
if (child.WidgetType == widget.Tab) {
|
if child.WidgetType == widget.Tab {
|
||||||
tabs = true
|
tabs = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (tabs) {
|
if tabs {
|
||||||
// window is tabs. Don't show it as a standard button
|
// window is tabs. Don't show it as a standard button
|
||||||
w.frame = false
|
w.frame = false
|
||||||
n.hasTabs = true
|
n.hasTabs = true
|
||||||
|
|
|
@ -1,15 +1,15 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"errors"
|
|
||||||
"bufio"
|
"bufio"
|
||||||
|
"errors"
|
||||||
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/awesome-gocui/gocui"
|
"github.com/awesome-gocui/gocui"
|
||||||
|
|
||||||
|
"go.wit.com/lib/widget"
|
||||||
"go.wit.com/log"
|
"go.wit.com/log"
|
||||||
"go.wit.com/gui/widget"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func splitLines(s string) []string {
|
func splitLines(s string) []string {
|
||||||
|
@ -28,20 +28,20 @@ func (n *node) textResize() bool {
|
||||||
|
|
||||||
for i, s := range splitLines(n.tk.label) {
|
for i, s := range splitLines(n.tk.label) {
|
||||||
log.Log(INFO, "textResize() len =", len(s), i, s)
|
log.Log(INFO, "textResize() len =", len(s), i, s)
|
||||||
if (width < len(s)) {
|
if width < len(s) {
|
||||||
width = len(s)
|
width = len(s)
|
||||||
}
|
}
|
||||||
height += 1
|
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
|
w.gocuiSize.w1 = w.gocuiSize.w0 + width + me.FramePadW
|
||||||
changed = true
|
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
|
w.gocuiSize.h1 = w.gocuiSize.h0 + height + me.FramePadH
|
||||||
changed = true
|
changed = true
|
||||||
}
|
}
|
||||||
if (changed) {
|
if changed {
|
||||||
n.showWidgetPlacement(true, "textResize() changed")
|
n.showWidgetPlacement(true, "textResize() changed")
|
||||||
}
|
}
|
||||||
return changed
|
return changed
|
||||||
|
@ -57,13 +57,13 @@ func (n *node) showView() {
|
||||||
var err error
|
var err error
|
||||||
w := n.tk
|
w := n.tk
|
||||||
|
|
||||||
if (w.cuiName == "") {
|
if w.cuiName == "" {
|
||||||
log.Log(ERROR, "showView() w.cuiName was not set for widget", w)
|
log.Log(ERROR, "showView() w.cuiName was not set for widget", w)
|
||||||
w.cuiName = string(n.WidgetId)
|
w.cuiName = string(n.WidgetId)
|
||||||
}
|
}
|
||||||
|
|
||||||
// if the gocui element doesn't exist, create it
|
// if the gocui element doesn't exist, create it
|
||||||
if (w.v == nil) {
|
if w.v == nil {
|
||||||
n.recreateView()
|
n.recreateView()
|
||||||
}
|
}
|
||||||
x0, y0, x1, y1, err := me.baseGui.ViewPosition(w.cuiName)
|
x0, y0, x1, y1, err := me.baseGui.ViewPosition(w.cuiName)
|
||||||
|
@ -72,7 +72,7 @@ func (n *node) showView() {
|
||||||
// n.smartGocuiSize()
|
// n.smartGocuiSize()
|
||||||
changed := n.textResize()
|
changed := n.textResize()
|
||||||
|
|
||||||
if (changed) {
|
if changed {
|
||||||
log.Log(NOW, "showView() textResize() changed. Should recreateView here wId =", w.cuiName)
|
log.Log(NOW, "showView() textResize() changed. Should recreateView here wId =", w.cuiName)
|
||||||
} else {
|
} else {
|
||||||
log.Log(NOW, "showView() Clear() and Fprint() here wId =", w.cuiName)
|
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
|
// if the gocui element has changed where it is supposed to be on the screen
|
||||||
// recreate it
|
// recreate it
|
||||||
if (x0 != w.gocuiSize.w0) {
|
if x0 != w.gocuiSize.w0 {
|
||||||
n.recreateView()
|
n.recreateView()
|
||||||
return
|
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)
|
log.Log(ERROR, "showView() start hight mismatch id=", w.cuiName, "gocui h vs computed h =", w.gocuiSize.h0, y0)
|
||||||
n.recreateView()
|
n.recreateView()
|
||||||
return
|
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)
|
log.Log(ERROR, "showView() too wide", w.cuiName, "w,w", w.gocuiSize.w1, x1)
|
||||||
n.recreateView()
|
n.recreateView()
|
||||||
return
|
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)
|
log.Log(ERROR, "showView() too high", w.cuiName, "h,h", w.gocuiSize.h1, y1)
|
||||||
n.recreateView()
|
n.recreateView()
|
||||||
return
|
return
|
||||||
|
@ -114,7 +114,7 @@ func (n *node) recreateView() {
|
||||||
var err error
|
var err error
|
||||||
w := n.tk
|
w := n.tk
|
||||||
log.Log(ERROR, "recreateView() START", n.WidgetType, n.progname)
|
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)
|
log.Log(ERROR, "recreateView() ERROR: me.baseGui == nil", w)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -123,11 +123,11 @@ func (n *node) recreateView() {
|
||||||
me.baseGui.DeleteView(w.cuiName)
|
me.baseGui.DeleteView(w.cuiName)
|
||||||
w.v = nil
|
w.v = nil
|
||||||
|
|
||||||
if (n.progname == "CLOUDFLARE_EMAIL") {
|
if n.progname == "CLOUDFLARE_EMAIL" {
|
||||||
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)
|
||||||
n.dumpWidget("jwc")
|
n.dumpWidget("jwc")
|
||||||
n.textResize()
|
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
|
a := w.gocuiSize.w0
|
||||||
|
@ -166,15 +166,15 @@ func (n *node) recreateView() {
|
||||||
// n.dumpWidget("jwc 2")
|
// n.dumpWidget("jwc 2")
|
||||||
|
|
||||||
// if you don't do this here, it will be black & white only
|
// 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.FrameColor = w.color.frame
|
||||||
w.v.FgColor = w.color.fg
|
w.v.FgColor = w.color.fg
|
||||||
w.v.BgColor = w.color.bg
|
w.v.BgColor = w.color.bg
|
||||||
w.v.SelFgColor = w.color.selFg
|
w.v.SelFgColor = w.color.selFg
|
||||||
w.v.SelBgColor = w.color.selBg
|
w.v.SelBgColor = w.color.selBg
|
||||||
}
|
}
|
||||||
if (n.progname == "CLOUDFLARE_EMAIL") {
|
if n.progname == "CLOUDFLARE_EMAIL" {
|
||||||
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)
|
||||||
n.dumpTree(true)
|
n.dumpTree(true)
|
||||||
}
|
}
|
||||||
log.Log(ERROR, "recreateView() END")
|
log.Log(ERROR, "recreateView() END")
|
||||||
|
@ -199,7 +199,7 @@ func (n *node) hideWidgets() {
|
||||||
|
|
||||||
func (n *node) hideFake() {
|
func (n *node) hideFake() {
|
||||||
w := n.tk
|
w := n.tk
|
||||||
if (w.isFake) {
|
if w.isFake {
|
||||||
n.hideView()
|
n.hideView()
|
||||||
}
|
}
|
||||||
for _, child := range n.children {
|
for _, child := range n.children {
|
||||||
|
@ -209,7 +209,7 @@ func (n *node) hideFake() {
|
||||||
|
|
||||||
func (n *node) showFake() {
|
func (n *node) showFake() {
|
||||||
w := n.tk
|
w := n.tk
|
||||||
if (w.isFake) {
|
if w.isFake {
|
||||||
n.setFake()
|
n.setFake()
|
||||||
n.showWidgetPlacement(true, "showFake:")
|
n.showWidgetPlacement(true, "showFake:")
|
||||||
n.showView()
|
n.showView()
|
||||||
|
@ -221,7 +221,7 @@ func (n *node) showFake() {
|
||||||
|
|
||||||
func (n *node) showWidgets() {
|
func (n *node) showWidgets() {
|
||||||
w := n.tk
|
w := n.tk
|
||||||
if (w.isFake) {
|
if w.isFake {
|
||||||
// don't display by default
|
// don't display by default
|
||||||
} else {
|
} else {
|
||||||
n.showWidgetPlacement(true, "current:")
|
n.showWidgetPlacement(true, "current:")
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"go.wit.com/lib/widget"
|
||||||
"go.wit.com/log"
|
"go.wit.com/log"
|
||||||
"go.wit.com/gui/widget"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func initWidget(n *node) *guiWidget {
|
func initWidget(n *node) *guiWidget {
|
||||||
|
@ -22,7 +22,7 @@ func initWidget(n *node) *guiWidget {
|
||||||
return w
|
return w
|
||||||
}
|
}
|
||||||
|
|
||||||
if (n.WidgetType == widget.Grid) {
|
if n.WidgetType == widget.Grid {
|
||||||
w.widths = make(map[int]int) // how tall each row in the grid is
|
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
|
w.heights = make(map[int]int) // how wide each column in the grid is
|
||||||
}
|
}
|
||||||
|
@ -43,7 +43,7 @@ func setupCtrlDownWidget() {
|
||||||
|
|
||||||
func (n *node) deleteView() {
|
func (n *node) deleteView() {
|
||||||
w := n.tk
|
w := n.tk
|
||||||
if (w.v != nil) {
|
if w.v != nil {
|
||||||
w.v.Visible = false
|
w.v.Visible = false
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -54,7 +54,7 @@ func (n *node) deleteView() {
|
||||||
|
|
||||||
// searches the binary tree for a WidgetId
|
// searches the binary tree for a WidgetId
|
||||||
func (n *node) findWidgetName(name string) *node {
|
func (n *node) findWidgetName(name string) *node {
|
||||||
if (n == nil) {
|
if n == nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,7 +64,7 @@ func (n *node) findWidgetName(name string) *node {
|
||||||
|
|
||||||
for _, child := range n.children {
|
for _, child := range n.children {
|
||||||
newN := child.findWidgetName(name)
|
newN := child.findWidgetName(name)
|
||||||
if (newN != nil) {
|
if newN != nil {
|
||||||
return newN
|
return newN
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -73,39 +73,39 @@ func (n *node) findWidgetName(name string) *node {
|
||||||
|
|
||||||
func (n *node) IsCurrent() bool {
|
func (n *node) IsCurrent() bool {
|
||||||
w := n.tk
|
w := n.tk
|
||||||
if (n.WidgetType == widget.Tab) {
|
if n.WidgetType == widget.Tab {
|
||||||
return w.isCurrent
|
return w.isCurrent
|
||||||
}
|
}
|
||||||
if (n.WidgetType == widget.Window) {
|
if n.WidgetType == widget.Window {
|
||||||
return w.isCurrent
|
return w.isCurrent
|
||||||
}
|
}
|
||||||
if (n.WidgetType == widget.Root) {
|
if n.WidgetType == widget.Root {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
return n.parent.IsCurrent()
|
return n.parent.IsCurrent()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *node) Visible() bool {
|
func (n *node) Visible() bool {
|
||||||
if (n == nil) {
|
if n == nil {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
if (n.tk == nil) {
|
if n.tk == nil {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
if (n.tk.v == nil) {
|
if n.tk.v == nil {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
return n.tk.v.Visible
|
return n.tk.v.Visible
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *node) SetVisible(b bool) {
|
func (n *node) SetVisible(b bool) {
|
||||||
if (n == nil) {
|
if n == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (n.tk == nil) {
|
if n.tk == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (n.tk.v == nil) {
|
if n.tk.v == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
n.tk.v.Visible = b
|
n.tk.v.Visible = b
|
||||||
|
|
|
@ -8,7 +8,7 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"go.wit.com/log"
|
"go.wit.com/log"
|
||||||
"go.wit.com/gui/widget"
|
"go.wit.com/lib/widget"
|
||||||
// "go.wit.com/gui/toolkits/tree"
|
// "go.wit.com/gui/toolkits/tree"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"go.wit.com/log"
|
"go.wit.com/log"
|
||||||
"go.wit.com/gui/toolkits/tree"
|
"go.wit.com/toolkits/tree"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
|
|
@ -9,7 +9,7 @@ import (
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"go.wit.com/log"
|
"go.wit.com/log"
|
||||||
"go.wit.com/gui/widget"
|
"go.wit.com/lib/widget"
|
||||||
)
|
)
|
||||||
|
|
||||||
func simpleStdin() {
|
func simpleStdin() {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"go.wit.com/gui/toolkits/tree"
|
"go.wit.com/toolkits/tree"
|
||||||
)
|
)
|
||||||
|
|
||||||
// stores the raw toolkit internals
|
// stores the raw toolkit internals
|
||||||
|
|
|
@ -5,7 +5,7 @@ package main
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"go.wit.com/gui/widget"
|
"go.wit.com/lib/widget"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Other goroutines must use this to access the GUI
|
// Other goroutines must use this to access the GUI
|
||||||
|
|
|
@ -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
|
|
||||||
}
|
|
|
@ -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
|
|
||||||
}
|
|
|
@ -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
|
|
||||||
}
|
|
|
@ -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
|
|
||||||
}
|
|
58
tree/init.go
58
tree/init.go
|
@ -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
|
|
||||||
}
|
|
60
tree/json.go
60
tree/json.go
|
@ -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
|
|
||||||
}
|
|
|
@ -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
|
|
||||||
}
|
|
|
@ -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
|
|
||||||
}
|
|
Loading…
Reference in New Issue