everything against 'gui/widget'

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2024-01-05 13:35:01 -06:00
parent 327e14f051
commit 8ae3b987ac
12 changed files with 82 additions and 82 deletions

View File

@ -1,7 +1,7 @@
package main package main
import ( import (
"go.wit.com/gui/toolkits" "go.wit.com/gui/widget"
) )
var fakeStartWidth int = me.FakeW var fakeStartWidth int = me.FakeW
@ -29,41 +29,41 @@ func (n *node) addWidget() {
nw := n.tk nw := n.tk
log(logInfo, "setStartWH() w.id =", n.WidgetId, "n.name", n.Name) log(logInfo, "setStartWH() w.id =", n.WidgetId, "n.name", n.Name)
switch n.WidgetType { switch n.WidgetType {
case toolkit.Root: case widget.Root:
log(logInfo, "setStartWH() rootNode w.id =", n.WidgetId, "w.name", n.Name) log(logInfo, "setStartWH() rootNode w.id =", n.WidgetId, "w.name", n.Name)
nw.color = &colorRoot nw.color = &colorRoot
n.setFake() n.setFake()
return return
case toolkit.Flag: case widget.Flag:
nw.color = &colorFlag nw.color = &colorFlag
n.setFake() n.setFake()
return return
case toolkit.Window: case widget.Window:
nw.frame = false nw.frame = false
nw.color = &colorWindow nw.color = &colorWindow
// redoWindows(0,0) // redoWindows(0,0)
return return
case toolkit.Tab: case widget.Tab:
nw.color = &colorTab nw.color = &colorTab
// redoWindows(0,0) // redoWindows(0,0)
return return
case toolkit.Button: case widget.Button:
nw.color = &colorButton nw.color = &colorButton
case toolkit.Box: case widget.Box:
nw.color = &colorBox nw.color = &colorBox
nw.isFake = true nw.isFake = true
n.setFake() n.setFake()
return return
case toolkit.Grid: case widget.Grid:
nw.color = &colorGrid nw.color = &colorGrid
nw.isFake = true nw.isFake = true
n.setFake() n.setFake()
return return
case toolkit.Group: case widget.Group:
nw.color = &colorGroup nw.color = &colorGroup
nw.frame = false nw.frame = false
return return
case toolkit.Label: case widget.Label:
nw.color = &colorLabel nw.color = &colorLabel
nw.frame = false nw.frame = false
return return

View File

@ -2,12 +2,12 @@ package main
import ( import (
// "github.com/awesome-gocui/gocui" // "github.com/awesome-gocui/gocui"
"go.wit.com/gui/toolkits" "go.wit.com/gui/widget"
) )
func (n *node) setCheckbox(b bool) { func (n *node) setCheckbox(b bool) {
w := n.tk w := n.tk
if (n.WidgetType != toolkit.Checkbox) { if (n.WidgetType != widget.Checkbox) {
return return
} }
if (b) { if (b) {

View File

@ -3,7 +3,7 @@ package main
import ( import (
"fmt" "fmt"
"github.com/awesome-gocui/gocui" "github.com/awesome-gocui/gocui"
"go.wit.com/gui/toolkits" "go.wit.com/gui/widget"
) )
// set isCurrent = false everywhere // set isCurrent = false everywhere
@ -11,7 +11,7 @@ func unsetCurrent(n *node) {
w := n.tk w := n.tk
w.isCurrent = false w.isCurrent = false
if n.WidgetType == toolkit.Tab { if n.WidgetType == widget.Tab {
// n.tk.color = &colorTab // n.tk.color = &colorTab
// n.setColor() // n.setColor()
} }
@ -26,7 +26,7 @@ func unsetCurrent(n *node) {
// to be in current display // to be in current display
func (n *node) updateCurrent() { func (n *node) updateCurrent() {
log(true, "updateCurrent()", n.Name) log(true, "updateCurrent()", n.Name)
if n.WidgetType == toolkit.Tab { if n.WidgetType == widget.Tab {
if n.IsCurrent() { if n.IsCurrent() {
// n.tk.color = &colorActiveT // n.tk.color = &colorActiveT
n.setColor(&colorActiveT) n.setColor(&colorActiveT)
@ -39,13 +39,13 @@ func (n *node) updateCurrent() {
} }
return return
} }
if n.WidgetType == toolkit.Window { if n.WidgetType == widget.Window {
if n.IsCurrent() { if n.IsCurrent() {
// setCurrentWindow(n) // setCurrentWindow(n)
} }
return return
} }
if n.WidgetType == toolkit.Root { if n.WidgetType == widget.Root {
return return
} }
n.parent.updateCurrent() n.parent.updateCurrent()
@ -57,7 +57,7 @@ func setCurrentWindow(n *node) {
return return
} }
w := n.tk w := n.tk
if n.WidgetType != toolkit.Window { if n.WidgetType != widget.Window {
return return
} }
unsetCurrent(me.rootNode) unsetCurrent(me.rootNode)
@ -76,7 +76,7 @@ func setCurrentWindow(n *node) {
// shows the widgets in a tab // shows the widgets in a tab
func setCurrentTab(n *node) { func setCurrentTab(n *node) {
w := n.tk w := n.tk
if n.WidgetType != toolkit.Tab { if n.WidgetType != widget.Tab {
return return
} }
unsetCurrent(me.rootNode) unsetCurrent(me.rootNode)
@ -88,14 +88,14 @@ func setCurrentTab(n *node) {
func (n *node) doWidgetClick() { func (n *node) doWidgetClick() {
switch n.WidgetType { switch n.WidgetType {
case toolkit.Root: case widget.Root:
// THIS IS THE BEGINING OF THE LAYOUT // THIS IS THE BEGINING OF THE LAYOUT
log(true, "doWidgetClick()", n.Name) log(true, "doWidgetClick()", n.Name)
redoWindows(0,0) redoWindows(0,0)
case toolkit.Flag: case widget.Flag:
log(true, "doWidgetClick() FLAG widget name =", n.Name) log(true, "doWidgetClick() FLAG widget name =", n.Name)
log(true, "doWidgetClick() if this is the dropdown menu, handle it here?") log(true, "doWidgetClick() if this is the dropdown menu, handle it here?")
case toolkit.Window: case widget.Window:
if (me.currentWindow == n) { if (me.currentWindow == n) {
return return
} }
@ -122,7 +122,7 @@ func (n *node) doWidgetClick() {
if ! n.hasTabs { if ! n.hasTabs {
} }
*/ */
case toolkit.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
} }
@ -133,7 +133,7 @@ func (n *node) doWidgetClick() {
p.redoTabs(me.TabW, me.TabH) p.redoTabs(me.TabW, me.TabH)
unsetCurrent(p) unsetCurrent(p)
for _, child := range p.children { for _, child := range p.children {
if child.WidgetType == toolkit.Tab { if child.WidgetType == widget.Tab {
child.setColor(&colorTab) child.setColor(&colorTab)
n.currentTab = false n.currentTab = false
} }
@ -144,17 +144,17 @@ func (n *node) doWidgetClick() {
setCurrentTab(n) setCurrentTab(n)
n.placeWidgets(me.RawW, me.RawH) n.placeWidgets(me.RawW, me.RawH)
n.showWidgets() n.showWidgets()
case toolkit.Group: case widget.Group:
// n.placeWidgets(p.tk.startH, newH) // n.placeWidgets(p.tk.startH, newH)
n.toggleTree() n.toggleTree()
case toolkit.Checkbox: case widget.Checkbox:
if (n.B) { if (n.B) {
n.setCheckbox(false) n.setCheckbox(false)
} else { } else {
n.setCheckbox(true) n.setCheckbox(true)
} }
n.doUserEvent() n.doUserEvent()
case toolkit.Grid: case widget.Grid:
newR := n.realGocuiSize() newR := n.realGocuiSize()
// w,h := n.logicalSize() // w,h := n.logicalSize()
@ -163,7 +163,7 @@ func (n *node) doWidgetClick() {
n.placeGrid(newR.w0, newR.h0) n.placeGrid(newR.w0, newR.h0)
n.showWidgets() n.showWidgets()
case toolkit.Box: case widget.Box:
// w.showWidgetPlacement(logNow, "drawTree()") // w.showWidgetPlacement(logNow, "drawTree()")
if (n.horizontal) { if (n.horizontal) {
log(true, "BOX IS HORIZONTAL", n.Name) log(true, "BOX IS HORIZONTAL", n.Name)
@ -172,9 +172,9 @@ func (n *node) doWidgetClick() {
} }
// n.placeWidgets() // n.placeWidgets()
n.toggleTree() n.toggleTree()
case toolkit.Button: case widget.Button:
n.doUserEvent() n.doUserEvent()
case toolkit.Dropdown: case widget.Dropdown:
log(true, "do the dropdown here") log(true, "do the dropdown here")
if (me.ddview == nil) { if (me.ddview == nil) {
me.ddview = addDropdown() me.ddview = addDropdown()

View File

@ -2,7 +2,7 @@ package main
import ( import (
"fmt" "fmt"
"go.wit.com/gui/toolkits" "go.wit.com/gui/widget"
) )
func (n *node) dumpTree(draw bool) { func (n *node) dumpTree(draw bool) {
@ -41,7 +41,7 @@ func (n *node) showWidgetPlacement(b bool, s string) {
s1 += fmt.Sprintf(" ") s1 += fmt.Sprintf(" ")
} }
if (n.parent != nil) { if (n.parent != nil) {
if (n.parent.WidgetType == toolkit.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)
} }
} }

View File

@ -7,7 +7,7 @@ package main
import ( import (
"os" "os"
"github.com/awesome-gocui/gocui" "github.com/awesome-gocui/gocui"
"go.wit.com/gui/toolkits" "go.wit.com/gui/widget"
) )
func defaultKeybindings(g *gocui.Gui) error { func defaultKeybindings(g *gocui.Gui) error {
@ -141,9 +141,9 @@ 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 toolkit.Action var a widget.Action
a.B = true a.B = true
a.ActionType = toolkit.EnableDebug a.ActionType = widget.EnableDebug
callback <- a callback <- a
logInfo = true logInfo = true
logVerbose = true logVerbose = true

View File

@ -6,7 +6,7 @@ package main
import ( import (
"os" "os"
"go.wit.com/gui/toolkits" "go.wit.com/gui/widget"
) )
// sets defaults and establishes communication // sets defaults and establishes communication
@ -17,7 +17,7 @@ func init() {
// init the config struct default values // init the config struct default values
Set(&me, "default") Set(&me, "default")
pluginChan = make(chan toolkit.Action) pluginChan = make(chan widget.Action)
log(logNow, "Init() start pluginChan") log(logNow, "Init() start pluginChan")
go catchActionChannel() go catchActionChannel()
@ -71,8 +71,8 @@ func standardExit() {
} }
func sendBackQuit() { func sendBackQuit() {
// send 'Quit' back to the program (?) // send 'Quit' back to the program (?)
var a toolkit.Action var a widget.Action
a.ActionType = toolkit.UserQuit a.ActionType = widget.UserQuit
callback <- a callback <- a
} }

View File

@ -2,11 +2,11 @@ package main
import ( import (
"strings" "strings"
"go.wit.com/gui/toolkits" "go.wit.com/gui/widget"
) )
func (n *node) placeBox(startW int, startH int) { func (n *node) placeBox(startW int, startH int) {
if (n.WidgetType != toolkit.Box) { if (n.WidgetType != widget.Box) {
return return
} }
n.showWidgetPlacement(logNow, "boxS()") n.showWidgetPlacement(logNow, "boxS()")
@ -45,21 +45,21 @@ func (n *node) placeWidgets(startW int, startH int) {
} }
switch n.WidgetType { switch n.WidgetType {
case toolkit.Window: case widget.Window:
for _, child := range n.children { for _, child := range n.children {
child.placeWidgets(me.RawW, me.RawH) child.placeWidgets(me.RawW, me.RawH)
return return
} }
case toolkit.Tab: case widget.Tab:
for _, child := range n.children { for _, child := range n.children {
child.placeWidgets(me.RawW, me.RawH) child.placeWidgets(me.RawW, me.RawH)
return return
} }
case toolkit.Grid: case widget.Grid:
n.placeGrid(startW, startH) n.placeGrid(startW, startH)
case toolkit.Box: case widget.Box:
n.placeBox(startW, startH) n.placeBox(startW, startH)
case toolkit.Group: case widget.Group:
// move the group to the parent's next location // move the group to the parent's next location
n.gocuiSetWH(startW, startH) n.gocuiSetWH(startW, startH)
n.showWidgetPlacement(logNow, "group()") n.showWidgetPlacement(logNow, "group()")
@ -85,7 +85,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(logInfo, "grid0:") n.showWidgetPlacement(logInfo, "grid0:")
if (n.WidgetType != toolkit.Grid) { if (n.WidgetType != widget.Grid) {
return return
} }

View File

@ -3,10 +3,10 @@ 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/gui/toolkits" "go.wit.com/gui/widget"
) )
func action(a *toolkit.Action) { func action(a *widget.Action) {
log(logInfo, "action() START", a.WidgetId, a.ActionType, a.WidgetType, a.Name) log(logInfo, "action() START", a.WidgetId, a.ActionType, a.WidgetType, a.Name)
n := me.rootNode.findWidgetId(a.WidgetId) n := me.rootNode.findWidgetId(a.WidgetId)
var w *guiWidget var w *guiWidget
@ -14,7 +14,7 @@ func action(a *toolkit.Action) {
w = n.tk w = n.tk
} }
switch a.ActionType { switch a.ActionType {
case toolkit.Add: case widget.Add:
if (w == nil) { if (w == nil) {
n := addNode(a) n := addNode(a)
// w = n.tk // w = n.tk
@ -25,14 +25,14 @@ func action(a *toolkit.Action) {
log(logError, "action() Add ignored for already defined widget", log(logError, "action() Add ignored for already defined widget",
a.WidgetId, a.ActionType, a.WidgetType, a.Name) a.WidgetId, a.ActionType, a.WidgetType, a.Name)
} }
case toolkit.Show: case widget.Show:
if (a.B) { if (a.B) {
n.showView() n.showView()
} else { } else {
n.hideWidgets() n.hideWidgets()
} }
case toolkit.Set: case widget.Set:
if a.WidgetType == toolkit.Flag { if a.WidgetType == widget.Flag {
log(logNow, "TODO: set flag here", a.ActionType, a.WidgetType, a.Name) log(logNow, "TODO: set flag here", a.ActionType, a.WidgetType, a.Name)
log(logNow, "TODO: n.WidgetType =", n.WidgetType, "n.Name =", a.Name) log(logNow, "TODO: n.WidgetType =", n.WidgetType, "n.Name =", a.Name)
} else { } else {
@ -42,23 +42,23 @@ func action(a *toolkit.Action) {
n.Set(a.A) n.Set(a.A)
} }
} }
case toolkit.SetText: case widget.SetText:
n.SetText(a.S) n.SetText(a.S)
case toolkit.AddText: case widget.AddText:
n.AddText(a.S) n.AddText(a.S)
case toolkit.Move: case widget.Move:
log(logNow, "attempt to move() =", a.ActionType, a.WidgetType, a.Name) log(logNow, "attempt to move() =", a.ActionType, a.WidgetType, a.Name)
case toolkit.CloseToolkit: case widget.CloseToolkit:
log(logNow, "attempting to close the plugin and release stdout and stderr") log(logNow, "attempting to close the plugin and release stdout and stderr")
standardExit() standardExit()
case toolkit.Enable: case widget.Enable:
if n.Visible() { if n.Visible() {
// widget was already shown // widget was already shown
} else { } else {
log(logInfo, "Setting Visable to true", a.Name) log(logInfo, "Setting Visable to true", a.Name)
n.SetVisible(true) n.SetVisible(true)
} }
case toolkit.Disable: case widget.Disable:
if n.Visible() { if n.Visible() {
log(logInfo, "Setting Visable to false", a.Name) log(logInfo, "Setting Visable to false", a.Name)
n.SetVisible(false) n.SetVisible(false)

View File

@ -5,7 +5,7 @@ import (
"fmt" "fmt"
"github.com/awesome-gocui/gocui" "github.com/awesome-gocui/gocui"
"go.wit.com/gui/toolkits" "go.wit.com/gui/widget"
) )
var outputW int = 180 var outputW int = 180
@ -47,10 +47,10 @@ func makeOutputWidget(g *gocui.Gui, stringFromMouseClick string) *gocui.View {
} }
if (me.logStdout == nil) { if (me.logStdout == nil) {
a := new(toolkit.Action) a := new(widget.Action)
a.Name = "stdout" a.Name = "stdout"
a.Text = "stdout" a.Text = "stdout"
a.WidgetType = toolkit.Stdout a.WidgetType = widget.Stdout
a.WidgetId = -3 a.WidgetId = -3
a.ParentId = 0 a.ParentId = 0
n := addNode(a) n := addNode(a)

View File

@ -4,7 +4,7 @@ package main
import ( import (
"strings" "strings"
"go.wit.com/gui/toolkits" "go.wit.com/gui/widget"
) )
func (w *guiWidget) Width() int { func (w *guiWidget) Width() int {
@ -50,13 +50,13 @@ func (n *node) gocuiSetWH(sizeW, sizeH int) {
func redoWindows(nextW int, nextH int) { func redoWindows(nextW int, nextH int) {
for _, n := range me.rootNode.children { for _, n := range me.rootNode.children {
if n.WidgetType != toolkit.Window { if n.WidgetType != widget.Window {
continue continue
} }
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 == toolkit.Tab) { if (child.WidgetType == widget.Tab) {
tabs = true tabs = true
} }
} }
@ -86,7 +86,7 @@ func redoWindows(nextW int, nextH int) {
func (p *node) redoTabs(nextW int, nextH int) { func (p *node) redoTabs(nextW int, nextH int) {
for _, n := range p.children { for _, n := range p.children {
if n.WidgetType != toolkit.Tab { if n.WidgetType != widget.Tab {
continue continue
} }
w := n.tk w := n.tk

View File

@ -8,7 +8,7 @@ import (
"strings" "strings"
"github.com/awesome-gocui/gocui" "github.com/awesome-gocui/gocui"
"go.wit.com/gui/toolkits" "go.wit.com/gui/widget"
) )
func splitLines(s string) []string { func splitLines(s string) []string {
@ -183,11 +183,11 @@ func (n *node) hideWidgets() {
w := n.tk w := n.tk
w.isCurrent = false w.isCurrent = false
switch n.WidgetType { switch n.WidgetType {
case toolkit.Root: case widget.Root:
case toolkit.Flag: case widget.Flag:
case toolkit.Window: case widget.Window:
case toolkit.Box: case widget.Box:
case toolkit.Grid: case widget.Grid:
default: default:
n.hideView() n.hideView()
} }

View File

@ -2,7 +2,7 @@ package main
import ( import (
"strconv" "strconv"
"go.wit.com/gui/toolkits" "go.wit.com/gui/widget"
) )
func initWidget(n *node) *guiWidget { func initWidget(n *node) *guiWidget {
@ -15,14 +15,14 @@ func initWidget(n *node) *guiWidget {
// set the name used by gocui to the id // set the name used by gocui to the id
w.cuiName = strconv.Itoa(n.WidgetId) w.cuiName = strconv.Itoa(n.WidgetId)
if n.WidgetType == toolkit.Root { if n.WidgetType == widget.Root {
log(logInfo, "setupWidget() FOUND ROOT w.id =", n.WidgetId) log(logInfo, "setupWidget() FOUND ROOT w.id =", n.WidgetId)
n.WidgetId = 0 n.WidgetId = 0
me.rootNode = n me.rootNode = n
return w return w
} }
if (n.WidgetType == toolkit.Box) { if (n.WidgetType == widget.Box) {
if (n.B) { if (n.B) {
n.horizontal = true n.horizontal = true
} else { } else {
@ -30,7 +30,7 @@ func initWidget(n *node) *guiWidget {
} }
} }
if (n.WidgetType == toolkit.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
} }
@ -39,9 +39,9 @@ func initWidget(n *node) *guiWidget {
} }
func setupCtrlDownWidget() { func setupCtrlDownWidget() {
a := new(toolkit.Action) a := new(widget.Action)
a.Name = "ctrlDown" a.Name = "ctrlDown"
a.WidgetType = toolkit.Dialog a.WidgetType = widget.Dialog
a.WidgetId = -1 a.WidgetId = -1
a.ParentId = 0 a.ParentId = 0
n := addNode(a) n := addNode(a)
@ -81,13 +81,13 @@ 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 == toolkit.Tab) { if (n.WidgetType == widget.Tab) {
return w.isCurrent return w.isCurrent
} }
if (n.WidgetType == toolkit.Window) { if (n.WidgetType == widget.Window) {
return w.isCurrent return w.isCurrent
} }
if (n.WidgetType == toolkit.Root) { if (n.WidgetType == widget.Root) {
return false return false
} }
return n.parent.IsCurrent() return n.parent.IsCurrent()
@ -121,7 +121,7 @@ func (n *node) SetVisible(b bool) {
func addDropdown() *node { func addDropdown() *node {
n := new(node) n := new(node)
n.WidgetType = toolkit.Flag n.WidgetType = widget.Flag
n.WidgetId = -2 n.WidgetId = -2
n.ParentId = 0 n.ParentId = 0