complete the move to 'go.wit.com/log'
Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
parent
df5fd148c6
commit
dbbdb953f2
12
args.go
12
args.go
|
@ -6,10 +6,12 @@ import (
|
||||||
"go.wit.com/log"
|
"go.wit.com/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var INFO log.LogFlag
|
||||||
|
|
||||||
var GUI log.LogFlag
|
var GUI log.LogFlag
|
||||||
var NODE log.LogFlag
|
var NODE log.LogFlag
|
||||||
var PLUG log.LogFlag
|
var PLUG log.LogFlag
|
||||||
var INFO log.LogFlag
|
var CHANGE log.LogFlag
|
||||||
|
|
||||||
var argGui ArgsGui
|
var argGui ArgsGui
|
||||||
|
|
||||||
|
@ -27,8 +29,6 @@ func ArgToolkit() string {
|
||||||
func init() {
|
func init() {
|
||||||
arg.Register(&argGui)
|
arg.Register(&argGui)
|
||||||
|
|
||||||
log.Register("gui", "debugGui", &debugGui)
|
|
||||||
|
|
||||||
INFO.B = false
|
INFO.B = false
|
||||||
INFO.Name = "INFO"
|
INFO.Name = "INFO"
|
||||||
INFO.Subsystem = "gui"
|
INFO.Subsystem = "gui"
|
||||||
|
@ -53,6 +53,12 @@ func init() {
|
||||||
PLUG.Desc = "basic PLUG debugging"
|
PLUG.Desc = "basic PLUG debugging"
|
||||||
PLUG.Register()
|
PLUG.Register()
|
||||||
|
|
||||||
|
CHANGE.B = false
|
||||||
|
CHANGE.Name = "CHANGE"
|
||||||
|
CHANGE.Subsystem = "gui"
|
||||||
|
CHANGE.Desc = "user changed something"
|
||||||
|
CHANGE.Register()
|
||||||
|
|
||||||
for _, s := range log.ListFlags() {
|
for _, s := range log.ListFlags() {
|
||||||
log.Info("go.wit.com/gui/gui ListFlags() returned:", s)
|
log.Info("go.wit.com/gui/gui ListFlags() returned:", s)
|
||||||
}
|
}
|
||||||
|
|
2
box.go
2
box.go
|
@ -1,7 +1,7 @@
|
||||||
package gui
|
package gui
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"go.wit.com/gui/gui/toolkit"
|
"go.wit.com/gui/toolkits"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (parent *Node) NewBox(name string, b bool) *Node {
|
func (parent *Node) NewBox(name string, b bool) *Node {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package gui
|
package gui
|
||||||
|
|
||||||
import "go.wit.com/gui/gui/toolkit"
|
import "go.wit.com/gui/toolkits"
|
||||||
|
|
||||||
func (parent *Node) NewButton(name string, custom func()) *Node {
|
func (parent *Node) NewButton(name string, custom func()) *Node {
|
||||||
newNode := parent.newNode(name, toolkit.Button)
|
newNode := parent.newNode(name, toolkit.Button)
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package gui
|
package gui
|
||||||
|
|
||||||
import "go.wit.com/gui/gui/toolkit"
|
import "go.wit.com/gui/toolkits"
|
||||||
|
|
||||||
func (n *Node) Checked() bool {
|
func (n *Node) Checked() bool {
|
||||||
return n.B
|
return n.B
|
||||||
|
|
39
common.go
39
common.go
|
@ -4,8 +4,9 @@ package gui
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"regexp"
|
"regexp"
|
||||||
"go.wit.com/gui/gui/toolkit"
|
"errors"
|
||||||
newlog "go.wit.com/log"
|
"go.wit.com/log"
|
||||||
|
"go.wit.com/gui/toolkits"
|
||||||
)
|
)
|
||||||
|
|
||||||
// functions for handling text related GUI elements
|
// functions for handling text related GUI elements
|
||||||
|
@ -35,7 +36,7 @@ func (n *Node) Disable() *Node {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *Node) Add(str string) {
|
func (n *Node) Add(str string) {
|
||||||
newlog.Log(debugGui, "gui.Add() value =", str)
|
log.Log(GUI, "gui.Add() value =", str)
|
||||||
|
|
||||||
n.S = str
|
n.S = str
|
||||||
|
|
||||||
|
@ -44,7 +45,7 @@ func (n *Node) Add(str string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *Node) AddText(str string) {
|
func (n *Node) AddText(str string) {
|
||||||
newlog.Log(debugChange, "AddText() value =", str)
|
log.Log(CHANGE, "AddText() value =", str)
|
||||||
|
|
||||||
n.Text = str
|
n.Text = str
|
||||||
n.S = str
|
n.S = str
|
||||||
|
@ -54,7 +55,7 @@ func (n *Node) AddText(str string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *Node) SetText(text string) *Node {
|
func (n *Node) SetText(text string) *Node {
|
||||||
newlog.Log(debugChange, "SetText() value =", text)
|
log.Log(CHANGE, "SetText() value =", text)
|
||||||
|
|
||||||
n.Text = text
|
n.Text = text
|
||||||
n.S = text
|
n.S = text
|
||||||
|
@ -67,11 +68,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
|
||||||
newlog.Log(debugNow, "SetNext() w,h =", n.NextW, n.NextH)
|
log.Info("SetNext() w,h =", n.NextW, n.NextH)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *Node) Set(val any) {
|
func (n *Node) Set(val any) {
|
||||||
newlog.Log(debugChange, "Set() value =", val)
|
log.Log(CHANGE, "Set() value =", val)
|
||||||
|
|
||||||
switch v := val.(type) {
|
switch v := val.(type) {
|
||||||
case bool:
|
case bool:
|
||||||
|
@ -82,7 +83,7 @@ func (n *Node) Set(val any) {
|
||||||
case int:
|
case int:
|
||||||
n.I = val.(int)
|
n.I = val.(int)
|
||||||
default:
|
default:
|
||||||
newlog.Log(debugError, "Set() unknown type =", v)
|
log.Error(errors.New("Set() unknown type"), "v =", v)
|
||||||
}
|
}
|
||||||
|
|
||||||
a := newAction(n, toolkit.Set)
|
a := newAction(n, toolkit.Set)
|
||||||
|
@ -106,9 +107,9 @@ func (n *Node) AppendText(str string) {
|
||||||
// should get the value of the node
|
// should get the value of the node
|
||||||
func (n *Node) GetText() string {
|
func (n *Node) GetText() string {
|
||||||
if (n.S != n.Text) {
|
if (n.S != n.Text) {
|
||||||
newlog.Warn("GetText() is screwed up. TODO: fix this dumb crap")
|
log.Warn("GetText() is screwed up. TODO: fix this dumb crap")
|
||||||
stuff := newlog.ListFlags()
|
stuff := log.ListFlags()
|
||||||
newlog.Warn("ListFlags() =", stuff)
|
log.Warn("ListFlags() =", stuff)
|
||||||
}
|
}
|
||||||
if (n.S != "") {
|
if (n.S != "") {
|
||||||
return n.S
|
return n.S
|
||||||
|
@ -130,7 +131,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) {
|
||||||
newlog.Log(debugGui, "%q is not valid\n", username)
|
log.Log(GUI, "%q is not valid\n", username)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -150,11 +151,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 {
|
||||||
newlog.Log(debugGui, "normalizeInt() regexp.Compile() ERROR =", err)
|
log.Log(GUI, "normalizeInt() regexp.Compile() ERROR =", err)
|
||||||
return s
|
return s
|
||||||
}
|
}
|
||||||
clean := reg.ReplaceAllString(s, "")
|
clean := reg.ReplaceAllString(s, "")
|
||||||
newlog.Log(debugGui, "normalizeInt() s =", clean)
|
log.Log(GUI, "normalizeInt() s =", clean)
|
||||||
return clean
|
return clean
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -162,9 +163,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) {
|
||||||
newlog.Log(debugChange, "Not Running n.Custom(n) == nil")
|
log.Log(CHANGE, "Not Running n.Custom(n) == nil")
|
||||||
} else {
|
} else {
|
||||||
newlog.Log(debugChange, "Running n.Custom(n)")
|
log.Log(CHANGE, "Running n.Custom(n)")
|
||||||
n.Custom()
|
n.Custom()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -206,7 +207,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 {
|
||||||
newlog.Log(debugError, "Window()", n)
|
log.Warn("Window()", n)
|
||||||
return n.NewWindow(title)
|
return n.NewWindow(title)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -214,12 +215,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 {
|
||||||
newlog.Log(debugInfo, "Standard() not implemented yet")
|
log.Warn("Standard() not implemented yet")
|
||||||
return n
|
return n
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *Node) SetMargin() *Node {
|
func (n *Node) SetMargin() *Node {
|
||||||
newlog.Log(debugError, "DoMargin() not implemented yet")
|
log.Warn("DoMargin() not implemented yet")
|
||||||
return n
|
return n
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
79
debug.go
79
debug.go
|
@ -1,6 +1,7 @@
|
||||||
package gui
|
package gui
|
||||||
|
|
||||||
// Lots of debugging things:
|
// old debugging things. probably deprecate
|
||||||
|
// everything should be moved to "go.wit.com/gui/debugger"
|
||||||
// A function dump out the binary tree
|
// A function dump out the binary tree
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -8,88 +9,14 @@ import (
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"go.wit.com/log"
|
"go.wit.com/log"
|
||||||
"go.wit.com/gui/gui/toolkit"
|
"go.wit.com/gui/toolkits"
|
||||||
)
|
)
|
||||||
|
|
||||||
// various debugging flags
|
|
||||||
var debugNow bool = true // useful for active development
|
|
||||||
var debugGui bool = false
|
|
||||||
var debugError bool = true
|
|
||||||
var debugDump bool = false
|
|
||||||
var debugNode bool = false
|
|
||||||
var debugTabs bool = false
|
|
||||||
var debugFlags bool = false
|
|
||||||
var debugChange bool = false // shows user events like mouse and keyboard
|
|
||||||
var debugPlugin bool = false
|
|
||||||
var debugAction bool = false
|
|
||||||
|
|
||||||
// for printing out the binary tree
|
// for printing out the binary tree
|
||||||
var listChildrenParent *Node
|
var listChildrenParent *Node
|
||||||
var listChildrenDepth int = 0
|
var listChildrenDepth int = 0
|
||||||
var defaultPadding = " "
|
var defaultPadding = " "
|
||||||
|
|
||||||
func SetDebug (s bool) {
|
|
||||||
debugGui = s
|
|
||||||
debugTabs = s
|
|
||||||
|
|
||||||
SetFlag("Node", s)
|
|
||||||
SetFlag("Tabs", s)
|
|
||||||
SetFlag("Dump", s)
|
|
||||||
SetFlag("Flags", s)
|
|
||||||
SetFlag("Plugin", s)
|
|
||||||
SetFlag("Change", s)
|
|
||||||
SetFlag("Error", s)
|
|
||||||
|
|
||||||
// This flag is only for the internal toolkit debugging
|
|
||||||
SetFlag("Toolkit", s)
|
|
||||||
}
|
|
||||||
|
|
||||||
func SetFlag (s string, b bool) {
|
|
||||||
switch s {
|
|
||||||
case "Toolkit":
|
|
||||||
// This flag is only for internal toolkit debugging
|
|
||||||
case "Tabs":
|
|
||||||
debugTabs = b
|
|
||||||
case "Node":
|
|
||||||
debugNode = b
|
|
||||||
case "Dump":
|
|
||||||
debugDump = b
|
|
||||||
case "Error":
|
|
||||||
debugError = b
|
|
||||||
case "Change":
|
|
||||||
debugChange = b
|
|
||||||
case "Flags":
|
|
||||||
debugFlags = b
|
|
||||||
case "Plugin":
|
|
||||||
debugPlugin = b
|
|
||||||
case "Show":
|
|
||||||
// ShowDebugValues() // print them here?
|
|
||||||
default:
|
|
||||||
log.Log(GUI, "Can't set unknown flag", s)
|
|
||||||
}
|
|
||||||
|
|
||||||
a := new(toolkit.Action)
|
|
||||||
a.ActionType = toolkit.Set
|
|
||||||
a.WidgetType = toolkit.Flag
|
|
||||||
a.S = s
|
|
||||||
a.B = b
|
|
||||||
sendAction(a)
|
|
||||||
}
|
|
||||||
|
|
||||||
func ShowDebugValues() {
|
|
||||||
// The order here should match the order in the GUI
|
|
||||||
// TODO: get the order from the node binary tree
|
|
||||||
log.Log(true, "Debug =", debugGui)
|
|
||||||
log.Log(true, "DebugError =", debugError)
|
|
||||||
log.Log(true, "DebugChange =", debugChange)
|
|
||||||
log.Log(true, "DebugDump =", debugDump)
|
|
||||||
log.Log(true, "DebugTabs =", debugTabs)
|
|
||||||
log.Log(true, "DebugPlugin =", debugPlugin)
|
|
||||||
log.Log(true, "DebugNode =", debugNode)
|
|
||||||
|
|
||||||
SetFlag("Show", true)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (n *Node) Dump() {
|
func (n *Node) Dump() {
|
||||||
b := true
|
b := true
|
||||||
Indent(b, "NODE DUMP START")
|
Indent(b, "NODE DUMP START")
|
||||||
|
|
|
@ -6,7 +6,7 @@ package gui
|
||||||
// since it is the same. confusing names? maybe...
|
// since it is the same. confusing names? maybe...
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"go.wit.com/gui/gui/toolkit"
|
"go.wit.com/gui/toolkits"
|
||||||
)
|
)
|
||||||
|
|
||||||
// add a new entry to the dropdown name
|
// add a new entry to the dropdown name
|
||||||
|
|
2
grid.go
2
grid.go
|
@ -2,7 +2,7 @@ package gui
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"go.wit.com/log"
|
"go.wit.com/log"
|
||||||
"go.wit.com/gui/gui/toolkit"
|
"go.wit.com/gui/toolkits"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Grid numbering examples (H) or (W,H)
|
// Grid numbering examples (H) or (W,H)
|
||||||
|
|
2
group.go
2
group.go
|
@ -1,7 +1,7 @@
|
||||||
package gui
|
package gui
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"go.wit.com/gui/gui/toolkit"
|
"go.wit.com/gui/toolkits"
|
||||||
)
|
)
|
||||||
|
|
||||||
// TODO: make a "Group" a "Grid" ?
|
// TODO: make a "Group" a "Grid" ?
|
||||||
|
|
2
image.go
2
image.go
|
@ -1,7 +1,7 @@
|
||||||
package gui
|
package gui
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"go.wit.com/gui/gui/toolkit"
|
"go.wit.com/gui/toolkits"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (parent *Node) NewImage(name string) *Node {
|
func (parent *Node) NewImage(name string) *Node {
|
||||||
|
|
2
label.go
2
label.go
|
@ -1,7 +1,7 @@
|
||||||
package gui
|
package gui
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"go.wit.com/gui/gui/toolkit"
|
"go.wit.com/gui/toolkits"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (parent *Node) NewLabel(text string) *Node {
|
func (parent *Node) NewLabel(text string) *Node {
|
||||||
|
|
2
main.go
2
main.go
|
@ -4,7 +4,7 @@ import (
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"go.wit.com/log"
|
"go.wit.com/log"
|
||||||
"go.wit.com/gui/gui/toolkit"
|
"go.wit.com/gui/toolkits"
|
||||||
)
|
)
|
||||||
|
|
||||||
// TODO: make a fake 'plugin' channel of communication to andlabs for mswindows
|
// TODO: make a fake 'plugin' channel of communication to andlabs for mswindows
|
||||||
|
|
2
node.go
2
node.go
|
@ -2,7 +2,7 @@ package gui
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"go.wit.com/log"
|
"go.wit.com/log"
|
||||||
"go.wit.com/gui/gui/toolkit"
|
"go.wit.com/gui/toolkits"
|
||||||
)
|
)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -11,7 +11,7 @@ import (
|
||||||
"plugin"
|
"plugin"
|
||||||
|
|
||||||
"go.wit.com/log"
|
"go.wit.com/log"
|
||||||
"go.wit.com/gui/gui/toolkit"
|
"go.wit.com/gui/toolkits"
|
||||||
)
|
)
|
||||||
|
|
||||||
var err error
|
var err error
|
||||||
|
|
|
@ -2,7 +2,7 @@ package gui
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"go.wit.com/log"
|
"go.wit.com/log"
|
||||||
"go.wit.com/gui/gui/toolkit"
|
"go.wit.com/gui/toolkits"
|
||||||
)
|
)
|
||||||
|
|
||||||
// This recreates the whole GUI for a plugin
|
// This recreates the whole GUI for a plugin
|
||||||
|
|
|
@ -2,7 +2,7 @@ package gui
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"go.wit.com/log"
|
"go.wit.com/log"
|
||||||
"go.wit.com/gui/gui/toolkit"
|
"go.wit.com/gui/toolkits"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (parent *Node) NewSlider(name string, x int, y int) *Node {
|
func (parent *Node) NewSlider(name string, x int, y int) *Node {
|
||||||
|
|
|
@ -2,7 +2,7 @@ package gui
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"go.wit.com/log"
|
"go.wit.com/log"
|
||||||
"go.wit.com/gui/gui/toolkit"
|
"go.wit.com/gui/toolkits"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (parent *Node) NewSpinner(name string, x int, y int) *Node {
|
func (parent *Node) NewSpinner(name string, x int, y int) *Node {
|
||||||
|
|
|
@ -3,7 +3,7 @@ package gui
|
||||||
import (
|
import (
|
||||||
"sync"
|
"sync"
|
||||||
"embed"
|
"embed"
|
||||||
"go.wit.com/gui/gui/toolkit"
|
"go.wit.com/gui/toolkits"
|
||||||
)
|
)
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
2
tab.go
2
tab.go
|
@ -3,7 +3,7 @@ package gui
|
||||||
import (
|
import (
|
||||||
"go.wit.com/log"
|
"go.wit.com/log"
|
||||||
|
|
||||||
"go.wit.com/gui/gui/toolkit"
|
"go.wit.com/gui/toolkits"
|
||||||
)
|
)
|
||||||
|
|
||||||
// This function should make a new node with the parent and
|
// This function should make a new node with the parent and
|
||||||
|
|
|
@ -3,7 +3,7 @@ package gui
|
||||||
import (
|
import (
|
||||||
"go.wit.com/log"
|
"go.wit.com/log"
|
||||||
|
|
||||||
"go.wit.com/gui/gui/toolkit"
|
"go.wit.com/gui/toolkits"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (parent *Node) NewTextbox(name string) *Node {
|
func (parent *Node) NewTextbox(name string) *Node {
|
||||||
|
|
|
@ -1,204 +0,0 @@
|
||||||
package toolkit
|
|
||||||
|
|
||||||
// passes information between the toolkit library (plugin)
|
|
||||||
//
|
|
||||||
// This is the only thing that is passed between the toolkit plugin
|
|
||||||
//
|
|
||||||
// what names should be used? This is not part of [[Graphical Widget]]
|
|
||||||
// Event() seems like a good name.
|
|
||||||
// Event is used too much: web dev, cloud, etc
|
|
||||||
// I'm using "Action". Maybe it should really be
|
|
||||||
// "Interaction" as per wikipedia [[User interface]]
|
|
||||||
//
|
|
||||||
// TODO: convert this to a protobuf (?)
|
|
||||||
//
|
|
||||||
|
|
||||||
type WidgetType int // Button, Menu, Checkbox, etc.
|
|
||||||
type ActionType int // Add, SetText, Click, Hide, Append, Delete, etc
|
|
||||||
|
|
||||||
type Action struct {
|
|
||||||
ActionType ActionType
|
|
||||||
WidgetType WidgetType
|
|
||||||
|
|
||||||
WidgetId int
|
|
||||||
ParentId int
|
|
||||||
|
|
||||||
Text string // what is visable to the user
|
|
||||||
Name string // a name useful for programming
|
|
||||||
|
|
||||||
// This is how the values are passed back and forth
|
|
||||||
// values from things like checkboxes & dropdown's
|
|
||||||
B bool
|
|
||||||
I int
|
|
||||||
S string
|
|
||||||
|
|
||||||
// This is used for things like a slider(0,100)
|
|
||||||
X int
|
|
||||||
Y int
|
|
||||||
|
|
||||||
// This is for the grid size & widget position
|
|
||||||
W int
|
|
||||||
H int
|
|
||||||
AtW int
|
|
||||||
AtH int
|
|
||||||
|
|
||||||
// Put space around elements to improve look & feel
|
|
||||||
Margin bool
|
|
||||||
|
|
||||||
// Make widgets fill up the space available
|
|
||||||
Expand bool
|
|
||||||
|
|
||||||
A any // switch to this or deprecate this? pros/cons?
|
|
||||||
}
|
|
||||||
|
|
||||||
const (
|
|
||||||
Unknown WidgetType = iota
|
|
||||||
Root // the master 'root' node of the binary tree
|
|
||||||
Flag // used to send configuration values to plugins
|
|
||||||
Window // in certain gui's (ncurses), these are tabs
|
|
||||||
Tab // internally, this is a window
|
|
||||||
Frame // deprecate?
|
|
||||||
Grid // like drawers in a chest
|
|
||||||
Group // like the 'Appetizers' section on a menu
|
|
||||||
Box // a vertical or horizontal stack of widgets
|
|
||||||
Button
|
|
||||||
Checkbox // select 'on' or 'off'
|
|
||||||
Dropdown
|
|
||||||
Combobox // dropdown with edit=true
|
|
||||||
Label
|
|
||||||
Textbox // is this a Label with edit=true
|
|
||||||
Slider // like a progress bar
|
|
||||||
Spinner // like setting the oven temperature
|
|
||||||
Separator // TODO
|
|
||||||
Image // TODO
|
|
||||||
Area // TODO
|
|
||||||
Form // TODO
|
|
||||||
Font // TODO
|
|
||||||
Color // TODO
|
|
||||||
Dialog // TODO
|
|
||||||
Stdout // can be used to capture and display log output
|
|
||||||
)
|
|
||||||
|
|
||||||
const (
|
|
||||||
Add ActionType = iota
|
|
||||||
Delete
|
|
||||||
Get
|
|
||||||
Set
|
|
||||||
GetText
|
|
||||||
SetText
|
|
||||||
AddText
|
|
||||||
Show
|
|
||||||
Hide
|
|
||||||
Enable
|
|
||||||
Disable
|
|
||||||
Margin
|
|
||||||
Unmargin
|
|
||||||
Pad
|
|
||||||
Unpad
|
|
||||||
Append
|
|
||||||
Move
|
|
||||||
Dump
|
|
||||||
User // the user did something (mouse, keyboard, etc)
|
|
||||||
InitToolkit // initializes the toolkit
|
|
||||||
CloseToolkit // closes the toolkit
|
|
||||||
UserQuit // the user closed the GUI
|
|
||||||
EnableDebug // open the debugging window
|
|
||||||
)
|
|
||||||
|
|
||||||
func (s WidgetType) String() string {
|
|
||||||
switch s {
|
|
||||||
case Root:
|
|
||||||
return "Root"
|
|
||||||
case Flag:
|
|
||||||
return "Flag"
|
|
||||||
case Window:
|
|
||||||
return "Window"
|
|
||||||
case Tab:
|
|
||||||
return "Tab"
|
|
||||||
case Frame:
|
|
||||||
return "Frame"
|
|
||||||
case Grid:
|
|
||||||
return "Grid"
|
|
||||||
case Group:
|
|
||||||
return "Group"
|
|
||||||
case Box:
|
|
||||||
return "Box"
|
|
||||||
case Button:
|
|
||||||
return "Button"
|
|
||||||
case Checkbox:
|
|
||||||
return "Checkbox"
|
|
||||||
case Dropdown:
|
|
||||||
return "Dropdown"
|
|
||||||
case Combobox:
|
|
||||||
return "Combobox"
|
|
||||||
case Label:
|
|
||||||
return "Label"
|
|
||||||
case Textbox:
|
|
||||||
return "Textbox"
|
|
||||||
case Slider:
|
|
||||||
return "Slider"
|
|
||||||
case Spinner:
|
|
||||||
return "Spinner"
|
|
||||||
case Separator:
|
|
||||||
return "Separator"
|
|
||||||
case Image:
|
|
||||||
return "Image"
|
|
||||||
case Area:
|
|
||||||
return "Area"
|
|
||||||
case Form:
|
|
||||||
return "Form"
|
|
||||||
case Font:
|
|
||||||
return "Font"
|
|
||||||
case Color:
|
|
||||||
return "Color"
|
|
||||||
case Dialog:
|
|
||||||
return "Dialog"
|
|
||||||
case Stdout:
|
|
||||||
return "Stdout"
|
|
||||||
case Unknown:
|
|
||||||
return "Unknown"
|
|
||||||
}
|
|
||||||
return "WidgetType.String() Error"
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s ActionType) String() string {
|
|
||||||
switch s {
|
|
||||||
case Add:
|
|
||||||
return "Add"
|
|
||||||
case Delete:
|
|
||||||
return "Delete"
|
|
||||||
case Get:
|
|
||||||
return "Get"
|
|
||||||
case Set:
|
|
||||||
return "Set"
|
|
||||||
case GetText:
|
|
||||||
return "GetText"
|
|
||||||
case SetText:
|
|
||||||
return "SetText"
|
|
||||||
case AddText:
|
|
||||||
return "AddText"
|
|
||||||
case Show:
|
|
||||||
return "Show"
|
|
||||||
case Hide:
|
|
||||||
return "Hide"
|
|
||||||
case Enable:
|
|
||||||
return "Enable"
|
|
||||||
case Disable:
|
|
||||||
return "Disable"
|
|
||||||
case Margin:
|
|
||||||
return "Margin"
|
|
||||||
case Unmargin:
|
|
||||||
return "Unmargin"
|
|
||||||
case Pad:
|
|
||||||
return "Pad"
|
|
||||||
case Unpad:
|
|
||||||
return "Unpad"
|
|
||||||
case Append:
|
|
||||||
return "Append"
|
|
||||||
case Move:
|
|
||||||
return "Move"
|
|
||||||
case Dump:
|
|
||||||
return "Dump"
|
|
||||||
}
|
|
||||||
return "ActionType.String() Error"
|
|
||||||
}
|
|
Loading…
Reference in New Issue