continue move to remove tabs
Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
parent
3394ee6861
commit
606f9d5ec0
35
common.go
35
common.go
|
@ -5,6 +5,7 @@ package gui
|
||||||
import (
|
import (
|
||||||
"regexp"
|
"regexp"
|
||||||
"go.wit.com/gui/toolkit"
|
"go.wit.com/gui/toolkit"
|
||||||
|
newlog "go.wit.com/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
// functions for handling text related GUI elements
|
// functions for handling text related GUI elements
|
||||||
|
@ -34,7 +35,7 @@ func (n *Node) Disable() *Node {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *Node) Add(str string) {
|
func (n *Node) Add(str string) {
|
||||||
log(debugGui, "gui.Add() value =", str)
|
newlog.Log(debugGui, "gui.Add() value =", str)
|
||||||
|
|
||||||
n.S = str
|
n.S = str
|
||||||
|
|
||||||
|
@ -43,7 +44,7 @@ func (n *Node) Add(str string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *Node) AddText(str string) {
|
func (n *Node) AddText(str string) {
|
||||||
log(debugChange, "AddText() value =", str)
|
newlog.Log(debugChange, "AddText() value =", str)
|
||||||
|
|
||||||
n.Text = str
|
n.Text = str
|
||||||
n.S = str
|
n.S = str
|
||||||
|
@ -53,7 +54,7 @@ func (n *Node) AddText(str string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *Node) SetText(text string) *Node {
|
func (n *Node) SetText(text string) *Node {
|
||||||
log(debugChange, "SetText() value =", text)
|
newlog.Log(debugChange, "SetText() value =", text)
|
||||||
|
|
||||||
n.Text = text
|
n.Text = text
|
||||||
n.S = text
|
n.S = text
|
||||||
|
@ -66,11 +67,11 @@ func (n *Node) SetText(text string) *Node {
|
||||||
func (n *Node) SetNext(w int, h int) {
|
func (n *Node) SetNext(w int, h int) {
|
||||||
n.NextW = w
|
n.NextW = w
|
||||||
n.NextH = h
|
n.NextH = h
|
||||||
log(debugNow, "SetNext() w,h =", n.NextW, n.NextH)
|
newlog.Log(debugNow, "SetNext() w,h =", n.NextW, n.NextH)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *Node) Set(val any) {
|
func (n *Node) Set(val any) {
|
||||||
log(debugChange, "Set() value =", val)
|
newlog.Log(debugChange, "Set() value =", val)
|
||||||
|
|
||||||
switch v := val.(type) {
|
switch v := val.(type) {
|
||||||
case bool:
|
case bool:
|
||||||
|
@ -81,7 +82,7 @@ func (n *Node) Set(val any) {
|
||||||
case int:
|
case int:
|
||||||
n.I = val.(int)
|
n.I = val.(int)
|
||||||
default:
|
default:
|
||||||
log(debugError, "Set() unknown type =", v)
|
newlog.Log(debugError, "Set() unknown type =", v)
|
||||||
}
|
}
|
||||||
|
|
||||||
a := newAction(n, toolkit.Set)
|
a := newAction(n, toolkit.Set)
|
||||||
|
@ -98,7 +99,13 @@ func (n *Node) AppendText(str string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *Node) GetText() string {
|
func (n *Node) GetText() string {
|
||||||
|
if (n.S != n.Text) {
|
||||||
|
newlog.Warn("GetText() is screwed up. TODO: fix this dumb crap")
|
||||||
|
}
|
||||||
|
if (n.S != "") {
|
||||||
return n.S
|
return n.S
|
||||||
|
}
|
||||||
|
return n.Text
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -107,7 +114,7 @@ isAlpha := regexp.MustCompile(`^[A-Za-z]+$`).MatchString
|
||||||
|
|
||||||
for _, username := range []string{"userone", "user2", "user-three"} {
|
for _, username := range []string{"userone", "user2", "user-three"} {
|
||||||
if !isAlpha(username) {
|
if !isAlpha(username) {
|
||||||
log(debugGui, "%q is not valid\n", username)
|
newlog.Log(debugGui, "%q is not valid\n", username)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -127,11 +134,11 @@ func normalizeInt(s string) string {
|
||||||
// reg, err := regexp.Compile("[^a-zA-Z0-9]+")
|
// reg, err := regexp.Compile("[^a-zA-Z0-9]+")
|
||||||
reg, err := regexp.Compile("[^0-9]+")
|
reg, err := regexp.Compile("[^0-9]+")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log(debugGui, "normalizeInt() regexp.Compile() ERROR =", err)
|
newlog.Log(debugGui, "normalizeInt() regexp.Compile() ERROR =", err)
|
||||||
return s
|
return s
|
||||||
}
|
}
|
||||||
clean := reg.ReplaceAllString(s, "")
|
clean := reg.ReplaceAllString(s, "")
|
||||||
log(debugGui, "normalizeInt() s =", clean)
|
newlog.Log(debugGui, "normalizeInt() s =", clean)
|
||||||
return clean
|
return clean
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -139,9 +146,9 @@ func commonCallback(n *Node) {
|
||||||
// TODO: make all of this common code to all the widgets
|
// TODO: make all of this common code to all the widgets
|
||||||
// This might be common everywhere finally (2023/03/01)
|
// This might be common everywhere finally (2023/03/01)
|
||||||
if (n.Custom == nil) {
|
if (n.Custom == nil) {
|
||||||
log(debugChange, "Not Running n.Custom(n) == nil")
|
newlog.Log(debugChange, "Not Running n.Custom(n) == nil")
|
||||||
} else {
|
} else {
|
||||||
log(debugChange, "Running n.Custom(n)")
|
newlog.Log(debugChange, "Running n.Custom(n)")
|
||||||
n.Custom()
|
n.Custom()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -183,7 +190,7 @@ func (n *Node) Expand() *Node {
|
||||||
// myFunnyWindow = myGui.NewWindow("Hello").Standard().SetText("Hola")
|
// myFunnyWindow = myGui.NewWindow("Hello").Standard().SetText("Hola")
|
||||||
|
|
||||||
func (n *Node) Window(title string) *Node {
|
func (n *Node) Window(title string) *Node {
|
||||||
log(debugError, "Window()", n)
|
newlog.Log(debugError, "Window()", n)
|
||||||
return n.NewWindow(title)
|
return n.NewWindow(title)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -191,12 +198,12 @@ func (n *Node) Window(title string) *Node {
|
||||||
// should be the default way
|
// should be the default way
|
||||||
/*
|
/*
|
||||||
func (n *Node) Standard() *Node {
|
func (n *Node) Standard() *Node {
|
||||||
log(debugInfo, "Standard() not implemented yet")
|
newlog.Log(debugInfo, "Standard() not implemented yet")
|
||||||
return n
|
return n
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *Node) SetMargin() *Node {
|
func (n *Node) SetMargin() *Node {
|
||||||
log(debugError, "DoMargin() not implemented yet")
|
newlog.Log(debugError, "DoMargin() not implemented yet")
|
||||||
return n
|
return n
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -41,7 +41,7 @@ func (p *Node) NewLogFlag(name string) *LogSettings {
|
||||||
|
|
||||||
// Let's you toggle on and off the various types of debugging output
|
// Let's you toggle on and off the various types of debugging output
|
||||||
// These checkboxes should be in the same order as the are printed
|
// These checkboxes should be in the same order as the are printed
|
||||||
func (n *Node) DebugFlags(makeWindow bool) {
|
func (n *Node) DebugFlags() {
|
||||||
var w, g *Node
|
var w, g *Node
|
||||||
|
|
||||||
logGadgets := make(map[string]*LogSettings)
|
logGadgets := make(map[string]*LogSettings)
|
||||||
|
@ -49,7 +49,7 @@ func (n *Node) DebugFlags(makeWindow bool) {
|
||||||
// Either:
|
// Either:
|
||||||
// make a new window
|
// make a new window
|
||||||
// make a new tab in the existing window
|
// make a new tab in the existing window
|
||||||
if (makeWindow) {
|
if (n.UseTabs()) {
|
||||||
w = me.rootNode.NewWindow("Debug Flags")
|
w = me.rootNode.NewWindow("Debug Flags")
|
||||||
w.Custom = w.StandardClose
|
w.Custom = w.StandardClose
|
||||||
w = w.NewBox("hBox", true)
|
w = w.NewBox("hBox", true)
|
||||||
|
|
|
@ -11,18 +11,11 @@ import (
|
||||||
var debugWG *sync.WaitGroup
|
var debugWG *sync.WaitGroup
|
||||||
var debugNumberChan chan int
|
var debugNumberChan chan int
|
||||||
|
|
||||||
func (n *Node) DebugGoChannels(makeWindow bool) {
|
func (n *Node) DebugGoChannels() {
|
||||||
var w, g *Node
|
var w, g *Node
|
||||||
|
|
||||||
// Either:
|
w = n.NewWindow("Debug GO Channels")
|
||||||
// make a new window
|
|
||||||
// make a new tab in the existing window
|
|
||||||
if (makeWindow) {
|
|
||||||
w = me.rootNode.NewWindow("Debug GO Channels")
|
|
||||||
w.Custom = w.StandardClose
|
w.Custom = w.StandardClose
|
||||||
} else {
|
|
||||||
w = n.NewTab("Chan")
|
|
||||||
}
|
|
||||||
|
|
||||||
g = w.NewGroup("Channel stuff")
|
g = w.NewGroup("Channel stuff")
|
||||||
|
|
||||||
|
|
|
@ -9,18 +9,11 @@ import (
|
||||||
"runtime/pprof"
|
"runtime/pprof"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (n *Node) DebugGolangWindow(makeWindow bool) {
|
func (n *Node) DebugGolangWindow() {
|
||||||
var w, g, og, outputTextbox *Node
|
var w, g, og, outputTextbox *Node
|
||||||
|
|
||||||
// Either:
|
w = n.NewWindow("GO")
|
||||||
// make a new window
|
|
||||||
// make a new tab in the existing window
|
|
||||||
if (makeWindow) {
|
|
||||||
w = me.rootNode.NewWindow("GO")
|
|
||||||
w.Custom = w.StandardClose
|
w.Custom = w.StandardClose
|
||||||
} else {
|
|
||||||
w = n.NewTab("GOLANG")
|
|
||||||
}
|
|
||||||
|
|
||||||
g = w.NewGroup("Language Internals")
|
g = w.NewGroup("Language Internals")
|
||||||
|
|
||||||
|
|
|
@ -59,7 +59,7 @@ func DebugWidgetWindow(w *Node) {
|
||||||
// Either:
|
// Either:
|
||||||
// make a new window
|
// make a new window
|
||||||
// make a new tab in the existing window
|
// make a new tab in the existing window
|
||||||
if (makeTabs) {
|
if (me.rootNode.UseTabs()) {
|
||||||
bugWidget = me.rootNode.NewWindow("Widgets")
|
bugWidget = me.rootNode.NewWindow("Widgets")
|
||||||
bugWidget.Custom = bugWidget.StandardClose
|
bugWidget.Custom = bugWidget.StandardClose
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -8,8 +8,6 @@ import (
|
||||||
|
|
||||||
// main debugging window
|
// main debugging window
|
||||||
var bugWin *Node
|
var bugWin *Node
|
||||||
// if there should be new windows or just tabs
|
|
||||||
var makeTabs bool = true
|
|
||||||
|
|
||||||
var mapWindows map[string]*Node
|
var mapWindows map[string]*Node
|
||||||
var checkd, checkdn, checkdt, checkdtk, lb1, lb2 *Node
|
var checkd, checkdn, checkdt, checkdtk, lb1, lb2 *Node
|
||||||
|
@ -21,12 +19,22 @@ var myButton *Node
|
||||||
func DebugWindow() {
|
func DebugWindow() {
|
||||||
bugWin = me.rootNode.NewWindow("go.wit.com/gui debug window").DebugTab("Debug Tab")
|
bugWin = me.rootNode.NewWindow("go.wit.com/gui debug window").DebugTab("Debug Tab")
|
||||||
bugWin.Custom = bugWin.StandardClose
|
bugWin.Custom = bugWin.StandardClose
|
||||||
// bugWin.DebugTab("Debug Tab")
|
|
||||||
if newlog.ArgDebug() {
|
if newlog.ArgDebug() {
|
||||||
bugWin.DebugFlags(true)
|
newlog.SetTmp()
|
||||||
|
bugWin.DebugFlags()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// should the debugging windows be new windows or tabs
|
||||||
|
// var makeTabs bool = true
|
||||||
|
func (n *Node) UseTabs() bool {
|
||||||
|
return me.makeTabs
|
||||||
|
}
|
||||||
|
|
||||||
|
func (n *Node) SetTabs(b bool) {
|
||||||
|
me.makeTabs = b
|
||||||
|
}
|
||||||
|
|
||||||
func (n *Node) DebugTab(title string) *Node {
|
func (n *Node) DebugTab(title string) *Node {
|
||||||
var newN, gog, g1 *Node
|
var newN, gog, g1 *Node
|
||||||
// var logSettings *gadgets.LogSettings
|
// var logSettings *gadgets.LogSettings
|
||||||
|
@ -40,23 +48,23 @@ func (n *Node) DebugTab(title string) *Node {
|
||||||
// generally useful debugging
|
// generally useful debugging
|
||||||
cb := gog.NewCheckbox("Seperate windows")
|
cb := gog.NewCheckbox("Seperate windows")
|
||||||
cb.Custom = func() {
|
cb.Custom = func() {
|
||||||
makeTabs = cb.B
|
|
||||||
log(debugGui, "Custom() n.widget =", cb.Name, cb.B)
|
log(debugGui, "Custom() n.widget =", cb.Name, cb.B)
|
||||||
|
n.SetTabs(cb.B)
|
||||||
}
|
}
|
||||||
makeTabs = false
|
|
||||||
cb.Set(false)
|
cb.Set(false)
|
||||||
|
n.SetTabs(false)
|
||||||
|
|
||||||
gog.NewButton("logging", func () {
|
gog.NewButton("logging", func () {
|
||||||
bugWin.DebugFlags(makeTabs)
|
bugWin.DebugFlags()
|
||||||
})
|
})
|
||||||
gog.NewButton("Debug Widgets", func () {
|
gog.NewButton("Debug Widgets", func () {
|
||||||
DebugWidgetWindow(newN)
|
DebugWidgetWindow(newN)
|
||||||
})
|
})
|
||||||
gog.NewButton("GO Language Internals", func () {
|
gog.NewButton("GO Language Internals", func () {
|
||||||
bugWin.DebugGolangWindow(makeTabs)
|
bugWin.DebugGolangWindow()
|
||||||
})
|
})
|
||||||
gog.NewButton("GO Channels debug", func () {
|
gog.NewButton("GO Channels debug", func () {
|
||||||
bugWin.DebugGoChannels(makeTabs)
|
bugWin.DebugGoChannels()
|
||||||
})
|
})
|
||||||
|
|
||||||
gog.NewLabel("Force Quit:")
|
gog.NewLabel("Force Quit:")
|
||||||
|
|
|
@ -0,0 +1,79 @@
|
||||||
|
/*
|
||||||
|
A Labeled Dropdown widget:
|
||||||
|
|
||||||
|
-----------------------------
|
||||||
|
| | |
|
||||||
|
| Food: | <dropdown> |
|
||||||
|
| | |
|
||||||
|
-----------------------------
|
||||||
|
|
||||||
|
This being a 'Basic Dropdown', the dropdown names must be unique
|
||||||
|
*/
|
||||||
|
package gadgets
|
||||||
|
|
||||||
|
import (
|
||||||
|
"go.wit.com/log"
|
||||||
|
"go.wit.com/gui"
|
||||||
|
)
|
||||||
|
|
||||||
|
type BasicDropdown struct {
|
||||||
|
ready bool
|
||||||
|
name string
|
||||||
|
|
||||||
|
parent *gui.Node // parent widget
|
||||||
|
l *gui.Node // label widget
|
||||||
|
d *gui.Node // dropdown widget
|
||||||
|
|
||||||
|
value string
|
||||||
|
label string
|
||||||
|
|
||||||
|
Custom func()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (d *BasicDropdown) Get() string {
|
||||||
|
if ! d.Ready() {return ""}
|
||||||
|
return d.d.GetText()
|
||||||
|
}
|
||||||
|
|
||||||
|
// Returns true if the status is valid
|
||||||
|
func (d *BasicDropdown) Ready() bool {
|
||||||
|
if d == nil {return false}
|
||||||
|
return d.ready
|
||||||
|
}
|
||||||
|
|
||||||
|
func (d *BasicDropdown) Add(value string) {
|
||||||
|
if ! d.Ready() {return}
|
||||||
|
log.Println("BasicDropdown.Set() =", value)
|
||||||
|
d.d.AddDropdownName(value)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func (d *BasicDropdown) Set(value string) bool {
|
||||||
|
if ! d.Ready() {return false}
|
||||||
|
log.Println("BasicDropdown.Set() =", value)
|
||||||
|
d.l.SetText(value)
|
||||||
|
d.value = value
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewBasicDropdown(p *gui.Node, name string) *BasicDropdown {
|
||||||
|
d := BasicDropdown {
|
||||||
|
parent: p,
|
||||||
|
name: name,
|
||||||
|
ready: false,
|
||||||
|
}
|
||||||
|
|
||||||
|
// various timeout settings
|
||||||
|
d.l = p.NewLabel(name)
|
||||||
|
d.d = p.NewDropdown("")
|
||||||
|
d.d.Custom = func() {
|
||||||
|
d.value = d.Get()
|
||||||
|
log.Println("BasicDropdown.Custom() user changed value to =", d.value)
|
||||||
|
if d.Custom != nil {
|
||||||
|
d.Custom()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
d.ready = true
|
||||||
|
return &d
|
||||||
|
}
|
2
label.go
2
label.go
|
@ -7,6 +7,8 @@ import (
|
||||||
func (parent *Node) NewLabel(text string) *Node {
|
func (parent *Node) NewLabel(text string) *Node {
|
||||||
newNode := parent.newNode(text, toolkit.Label)
|
newNode := parent.newNode(text, toolkit.Label)
|
||||||
a := newAction(newNode, toolkit.Add)
|
a := newAction(newNode, toolkit.Add)
|
||||||
|
a.Text = text
|
||||||
|
a.S = text
|
||||||
sendAction(a)
|
sendAction(a)
|
||||||
return newNode
|
return newNode
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,6 +29,9 @@ type guiConfig struct {
|
||||||
// This is the master node. The Binary Tree starts here
|
// This is the master node. The Binary Tree starts here
|
||||||
rootNode *Node
|
rootNode *Node
|
||||||
|
|
||||||
|
// if the user prefers new windows or 'windows within windows' tabs
|
||||||
|
makeTabs bool
|
||||||
|
|
||||||
// A node off of rootNode for passing debugging flags
|
// A node off of rootNode for passing debugging flags
|
||||||
flag *Node
|
flag *Node
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue