continue move to remove tabs

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2023-12-31 07:40:53 -06:00
parent 3394ee6861
commit 606f9d5ec0
9 changed files with 132 additions and 47 deletions

View File

@ -5,6 +5,7 @@ package gui
import (
"regexp"
"go.wit.com/gui/toolkit"
newlog "go.wit.com/log"
)
// functions for handling text related GUI elements
@ -34,7 +35,7 @@ func (n *Node) Disable() *Node {
}
func (n *Node) Add(str string) {
log(debugGui, "gui.Add() value =", str)
newlog.Log(debugGui, "gui.Add() value =", str)
n.S = str
@ -43,7 +44,7 @@ func (n *Node) Add(str string) {
}
func (n *Node) AddText(str string) {
log(debugChange, "AddText() value =", str)
newlog.Log(debugChange, "AddText() value =", str)
n.Text = str
n.S = str
@ -53,7 +54,7 @@ func (n *Node) AddText(str string) {
}
func (n *Node) SetText(text string) *Node {
log(debugChange, "SetText() value =", text)
newlog.Log(debugChange, "SetText() value =", text)
n.Text = text
n.S = text
@ -66,11 +67,11 @@ func (n *Node) SetText(text string) *Node {
func (n *Node) SetNext(w int, h int) {
n.NextW = w
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) {
log(debugChange, "Set() value =", val)
newlog.Log(debugChange, "Set() value =", val)
switch v := val.(type) {
case bool:
@ -81,7 +82,7 @@ func (n *Node) Set(val any) {
case int:
n.I = val.(int)
default:
log(debugError, "Set() unknown type =", v)
newlog.Log(debugError, "Set() unknown type =", v)
}
a := newAction(n, toolkit.Set)
@ -98,7 +99,13 @@ func (n *Node) AppendText(str string) {
}
func (n *Node) GetText() string {
return n.S
if (n.S != n.Text) {
newlog.Warn("GetText() is screwed up. TODO: fix this dumb crap")
}
if (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"} {
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("[^0-9]+")
if err != nil {
log(debugGui, "normalizeInt() regexp.Compile() ERROR =", err)
newlog.Log(debugGui, "normalizeInt() regexp.Compile() ERROR =", err)
return s
}
clean := reg.ReplaceAllString(s, "")
log(debugGui, "normalizeInt() s =", clean)
newlog.Log(debugGui, "normalizeInt() s =", clean)
return clean
}
@ -139,9 +146,9 @@ func commonCallback(n *Node) {
// TODO: make all of this common code to all the widgets
// This might be common everywhere finally (2023/03/01)
if (n.Custom == nil) {
log(debugChange, "Not Running n.Custom(n) == nil")
newlog.Log(debugChange, "Not Running n.Custom(n) == nil")
} else {
log(debugChange, "Running n.Custom(n)")
newlog.Log(debugChange, "Running n.Custom(n)")
n.Custom()
}
}
@ -183,7 +190,7 @@ func (n *Node) Expand() *Node {
// myFunnyWindow = myGui.NewWindow("Hello").Standard().SetText("Hola")
func (n *Node) Window(title string) *Node {
log(debugError, "Window()", n)
newlog.Log(debugError, "Window()", n)
return n.NewWindow(title)
}
@ -191,12 +198,12 @@ func (n *Node) Window(title string) *Node {
// should be the default way
/*
func (n *Node) Standard() *Node {
log(debugInfo, "Standard() not implemented yet")
newlog.Log(debugInfo, "Standard() not implemented yet")
return n
}
func (n *Node) SetMargin() *Node {
log(debugError, "DoMargin() not implemented yet")
newlog.Log(debugError, "DoMargin() not implemented yet")
return n
}
*/

View File

@ -41,7 +41,7 @@ func (p *Node) NewLogFlag(name string) *LogSettings {
// 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
func (n *Node) DebugFlags(makeWindow bool) {
func (n *Node) DebugFlags() {
var w, g *Node
logGadgets := make(map[string]*LogSettings)
@ -49,7 +49,7 @@ func (n *Node) DebugFlags(makeWindow bool) {
// Either:
// make a new window
// make a new tab in the existing window
if (makeWindow) {
if (n.UseTabs()) {
w = me.rootNode.NewWindow("Debug Flags")
w.Custom = w.StandardClose
w = w.NewBox("hBox", true)

View File

@ -11,18 +11,11 @@ import (
var debugWG *sync.WaitGroup
var debugNumberChan chan int
func (n *Node) DebugGoChannels(makeWindow bool) {
func (n *Node) DebugGoChannels() {
var w, g *Node
// Either:
// 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
} else {
w = n.NewTab("Chan")
}
w = n.NewWindow("Debug GO Channels")
w.Custom = w.StandardClose
g = w.NewGroup("Channel stuff")

View File

@ -9,18 +9,11 @@ import (
"runtime/pprof"
)
func (n *Node) DebugGolangWindow(makeWindow bool) {
func (n *Node) DebugGolangWindow() {
var w, g, og, outputTextbox *Node
// Either:
// make a new window
// make a new tab in the existing window
if (makeWindow) {
w = me.rootNode.NewWindow("GO")
w.Custom = w.StandardClose
} else {
w = n.NewTab("GOLANG")
}
w = n.NewWindow("GO")
w.Custom = w.StandardClose
g = w.NewGroup("Language Internals")

View File

@ -59,7 +59,7 @@ func DebugWidgetWindow(w *Node) {
// Either:
// make a new window
// make a new tab in the existing window
if (makeTabs) {
if (me.rootNode.UseTabs()) {
bugWidget = me.rootNode.NewWindow("Widgets")
bugWidget.Custom = bugWidget.StandardClose
} else {

View File

@ -8,8 +8,6 @@ import (
// main debugging window
var bugWin *Node
// if there should be new windows or just tabs
var makeTabs bool = true
var mapWindows map[string]*Node
var checkd, checkdn, checkdt, checkdtk, lb1, lb2 *Node
@ -21,12 +19,22 @@ var myButton *Node
func DebugWindow() {
bugWin = me.rootNode.NewWindow("go.wit.com/gui debug window").DebugTab("Debug Tab")
bugWin.Custom = bugWin.StandardClose
// bugWin.DebugTab("Debug Tab")
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 {
var newN, gog, g1 *Node
// var logSettings *gadgets.LogSettings
@ -40,23 +48,23 @@ func (n *Node) DebugTab(title string) *Node {
// generally useful debugging
cb := gog.NewCheckbox("Seperate windows")
cb.Custom = func() {
makeTabs = cb.B
log(debugGui, "Custom() n.widget =", cb.Name, cb.B)
n.SetTabs(cb.B)
}
makeTabs = false
cb.Set(false)
n.SetTabs(false)
gog.NewButton("logging", func () {
bugWin.DebugFlags(makeTabs)
bugWin.DebugFlags()
})
gog.NewButton("Debug Widgets", func () {
DebugWidgetWindow(newN)
})
gog.NewButton("GO Language Internals", func () {
bugWin.DebugGolangWindow(makeTabs)
bugWin.DebugGolangWindow()
})
gog.NewButton("GO Channels debug", func () {
bugWin.DebugGoChannels(makeTabs)
bugWin.DebugGoChannels()
})
gog.NewLabel("Force Quit:")

79
gadgets/basicDropdown.go Normal file
View File

@ -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
}

View File

@ -7,6 +7,8 @@ import (
func (parent *Node) NewLabel(text string) *Node {
newNode := parent.newNode(text, toolkit.Label)
a := newAction(newNode, toolkit.Add)
a.Text = text
a.S = text
sendAction(a)
return newNode
}

View File

@ -29,6 +29,9 @@ type guiConfig struct {
// This is the master node. The Binary Tree starts here
rootNode *Node
// if the user prefers new windows or 'windows within windows' tabs
makeTabs bool
// A node off of rootNode for passing debugging flags
flag *Node