remove dumb old stuff and clean up struct.go
This commit is contained in:
parent
8d007ec10d
commit
96fdfd1338
2
debug.go
2
debug.go
|
@ -13,7 +13,7 @@ import (
|
|||
func (w *guiWidget) dumpTree(s string) {
|
||||
// log.Log(ERROR, "dump w", w.node.WidgetId, w.WidgetType, w.String())
|
||||
if w == nil {
|
||||
log.Log(ERROR, "dump w.TK == nil", w.node.WidgetId, w.WidgetType, w.String())
|
||||
log.Log(ERROR, "dump w.TK == nil", w.node.WidgetId, w.node.WidgetType, w.String())
|
||||
return
|
||||
}
|
||||
w.dumpWidget("dumpTree() " + s)
|
||||
|
|
|
@ -149,7 +149,7 @@ func (w *guiWidget) dropdownClicked(mouseW, mouseH int) string {
|
|||
log.Log(GOCUI, "dropdownClicked() found", items[itemNumber-1])
|
||||
if items[itemNumber-1] != "" {
|
||||
if me.dropdownW != nil {
|
||||
log.Log(GOCUI, "dropdownClicked() send event for", me.dropdownW.cuiName, me.dropdownW.WidgetType)
|
||||
log.Log(GOCUI, "dropdownClicked() send event for", me.dropdownW.cuiName, me.dropdownW.node.WidgetType)
|
||||
me.dropdownW.SetText(items[itemNumber-1])
|
||||
me.dropdownW.node.SetCurrentS(items[itemNumber-1])
|
||||
me.myTree.SendUserEvent(me.dropdownW.node)
|
||||
|
@ -174,7 +174,7 @@ func dropdownUnclicked(w, h int) {
|
|||
// examine everything under X & Y on the screen)
|
||||
for _, tk := range findByXY(w, h) {
|
||||
// tk.dumpWidget("dropdownUnclicked()")
|
||||
if tk.WidgetType == widget.Dropdown {
|
||||
if tk.node.WidgetType == widget.Dropdown {
|
||||
d = tk
|
||||
}
|
||||
}
|
||||
|
|
|
@ -66,7 +66,7 @@ func theNotsure(g *gocui.Gui, v *gocui.View) error {
|
|||
log.Info("got keypress 2. now what?")
|
||||
w, h := g.MousePosition()
|
||||
for _, tk := range findByXY(w, h) {
|
||||
if tk.WidgetType == widget.Stdout {
|
||||
if tk.node.WidgetType == widget.Stdout {
|
||||
tk.dumpWidget("theNotsure()")
|
||||
log.Info("skipping stdout")
|
||||
continue
|
||||
|
|
|
@ -103,7 +103,7 @@ func click(g *gocui.Gui, v *gocui.View) error {
|
|||
for _, tk := range findByXY(w, h) {
|
||||
// will show you everything found on a mouse click. great for debugging!
|
||||
// tk.dumpWidget("click()")
|
||||
if tk.WidgetType == widget.Stdout {
|
||||
if tk.node.WidgetType == widget.Stdout {
|
||||
// don't send clicks to the stdout debugging window
|
||||
continue
|
||||
}
|
||||
|
|
10
find.go
10
find.go
|
@ -44,7 +44,7 @@ func findByXYreal(widget *guiWidget, w int, h int) []*guiWidget {
|
|||
if (widget.gocuiSize.w0 <= w) && (w <= widget.gocuiSize.w1) &&
|
||||
(widget.gocuiSize.h0 <= h) && (h <= widget.gocuiSize.h1) {
|
||||
widgets = append(widgets, widget)
|
||||
// log.Log(GOCUI, "findByXY() found", widget.WidgetType, w, h)
|
||||
// log.Log(GOCUI, "findByXY() found", widget.node.WidgetType, w, h)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -69,20 +69,20 @@ func findUnderMouse() *guiWidget {
|
|||
// up the window widgets, then it will ignore everything else
|
||||
// and allow the user (hopefully) to redraw or switch windows
|
||||
// TODO: display the window widgets on top
|
||||
if w.WidgetType == widget.Window {
|
||||
if w.node.WidgetType == widget.Window {
|
||||
return w
|
||||
}
|
||||
}
|
||||
|
||||
// return anything else that is interactive
|
||||
for _, w := range widgets {
|
||||
if w.WidgetType == widget.Button {
|
||||
if w.node.WidgetType == widget.Button {
|
||||
return w
|
||||
}
|
||||
if w.WidgetType == widget.Combobox {
|
||||
if w.node.WidgetType == widget.Combobox {
|
||||
return w
|
||||
}
|
||||
if w.WidgetType == widget.Checkbox {
|
||||
if w.node.WidgetType == widget.Checkbox {
|
||||
return w
|
||||
}
|
||||
w.dumpWidget("findUnderMouse() found something unknown")
|
||||
|
|
6
place.go
6
place.go
|
@ -35,7 +35,7 @@ func (tk *guiWidget) Position() (int, int) {
|
|||
}
|
||||
|
||||
func (w *guiWidget) placeBox(startW int, startH int) {
|
||||
if w.WidgetType != widget.Box {
|
||||
if w.node.WidgetType != widget.Box {
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -73,7 +73,7 @@ func (tk *guiWidget) placeWidgets(startW int, startH int) (int, int) {
|
|||
tk.startW = startW
|
||||
tk.startH = startH
|
||||
|
||||
switch tk.WidgetType {
|
||||
switch tk.node.WidgetType {
|
||||
case widget.Window:
|
||||
newW := startW
|
||||
newH := startH
|
||||
|
@ -128,7 +128,7 @@ func (tk *guiWidget) placeWidgets(startW int, startH int) (int, int) {
|
|||
|
||||
func (w *guiWidget) placeGrid(startW int, startH int) (int, int) {
|
||||
// w.showWidgetPlacement("grid0:")
|
||||
if w.WidgetType != widget.Grid {
|
||||
if w.node.WidgetType != widget.Grid {
|
||||
return 0, 0
|
||||
}
|
||||
|
||||
|
|
4
size.go
4
size.go
|
@ -20,7 +20,7 @@ func (tk *guiWidget) Size() (int, int) {
|
|||
return 0, 0
|
||||
}
|
||||
|
||||
switch tk.WidgetType {
|
||||
switch tk.node.WidgetType {
|
||||
case widget.Window:
|
||||
var maxH int = 0
|
||||
var maxW int = 0
|
||||
|
@ -105,7 +105,7 @@ func (w *guiWidget) sizeGrid() (int, int) {
|
|||
}
|
||||
|
||||
func (w *guiWidget) sizeBox() (int, int) {
|
||||
if w.WidgetType != widget.Box {
|
||||
if w.node.WidgetType != widget.Box {
|
||||
return 0, 0
|
||||
}
|
||||
if w.node.Hidden() {
|
||||
|
|
200
structs.go
200
structs.go
|
@ -22,7 +22,6 @@ import (
|
|||
|
||||
"go.wit.com/log"
|
||||
"go.wit.com/toolkits/tree"
|
||||
"go.wit.com/widget"
|
||||
)
|
||||
|
||||
// It's probably a terrible idea to call this 'me'
|
||||
|
@ -34,77 +33,48 @@ var redoWidgets bool = true
|
|||
// This is the window that is currently active
|
||||
// var currentWindow *tree.Node
|
||||
|
||||
// todo: move all this to a protobuf. then, redo all this mess. it got me here, but now it's time to clean it up for good
|
||||
type config struct {
|
||||
baseGui *gocui.Gui // the main gocui handle
|
||||
// rootNode *node // the base of the binary tree. it should have id == 0
|
||||
|
||||
treeRoot *tree.Node // the base of the binary tree. it should have id == 0
|
||||
myTree *tree.TreeInfo
|
||||
|
||||
ctrlDown *tree.Node // shown if you click the mouse when the ctrl key is pressed
|
||||
currentWindow *guiWidget // this is the current tab or window to show
|
||||
logStdout *tree.Node // where to show STDOUT
|
||||
startOutputW int
|
||||
startOutputH int
|
||||
helpLabel *gocui.View
|
||||
|
||||
// this is a floating widget that we show whenever the user clicks on a
|
||||
// dropdown menu or combobox
|
||||
// the dropdown widget to select dropdrown lists
|
||||
dropdownV *guiWidget
|
||||
dropdownW *guiWidget // grab the dropdown choices from this widget
|
||||
|
||||
// When the widget has a frame, like a button, it adds 2 lines runes on each side
|
||||
// so you need 3 char spacing in each direction to not have them overlap
|
||||
// the amount of padding when there is a frame
|
||||
FramePadW int `default:"1" dense:"0"`
|
||||
FramePadH int `default:"1" dense:"0"`
|
||||
|
||||
PadW int `default:"1" dense:"0"`
|
||||
PadH int `default:"1" dense:"0"`
|
||||
|
||||
// how far down to start Window or Tab headings
|
||||
WindowW int `default:"8" dense:"0"`
|
||||
WindowH int `default:"-1"`
|
||||
TabW int `default:"5" dense:"0"`
|
||||
TabH int `default:"1" dense:"0"`
|
||||
|
||||
// additional amount of space to put between window & tab widgets
|
||||
WindowPadW int `default:"8" dense:"0"`
|
||||
TabPadW int `default:"4" dense:"0"`
|
||||
|
||||
// additional amount of space to indent on a group
|
||||
GroupPadW int `default:"2" dense:"1"`
|
||||
|
||||
// additional amount of space to indent on a group
|
||||
BoxPadW int `default:"2" dense:"1"`
|
||||
|
||||
// additional amount of space to indent on a group
|
||||
GridPadW int `default:"2" dense:"1"`
|
||||
|
||||
// the raw beginning of each window (or tab)
|
||||
RawW int `default:"1"`
|
||||
RawH int `default:"5"`
|
||||
|
||||
// offset for the hidden widgets
|
||||
FakeW int `default:"20"`
|
||||
|
||||
padded bool // add space between things like buttons
|
||||
bookshelf bool // do you want things arranged in the box like a bookshelf or a stack?
|
||||
canvas bool // if set to true, the windows are a raw canvas
|
||||
menubar bool // for windows
|
||||
stretchy bool // expand things like buttons to the maximum size
|
||||
margin bool // add space around the frames of windows
|
||||
|
||||
writeMutex sync.Mutex // TODO: writeMutex protects locks the write process
|
||||
fakefile *FakeFile // JUNK? used to attempt to write to the stdout window
|
||||
dtoggle bool // is a dropdown or combobox currently active?
|
||||
showHelp bool // toggle boolean for the help menu (deprecate?)
|
||||
|
||||
// debugging things
|
||||
ecount int // counts how many mouse and keyboard events have occurred
|
||||
supermouse bool // prints out every widget found while you move the mouse around
|
||||
depth int // used for listWidgets() debugging
|
||||
baseGui *gocui.Gui // the main gocui handle
|
||||
treeRoot *tree.Node // the base of the binary tree. it should have id == 0
|
||||
myTree *tree.TreeInfo // ?
|
||||
ctrlDown *tree.Node // shown if you click the mouse when the ctrl key is pressed
|
||||
currentWindow *guiWidget // this is the current tab or window to show
|
||||
logStdout *tree.Node // where to show STDOUT
|
||||
startOutputW int // ?
|
||||
startOutputH int // ?
|
||||
helpLabel *gocui.View // ?
|
||||
dropdownV *guiWidget // this is a floating widget that we show whenever the user clicks on a
|
||||
dropdownW *guiWidget // grab the dropdown choices from this widget
|
||||
FramePadW int `default:"1" dense:"0"` // When the widget has a frame, like a button, it adds 2 lines runes on each side
|
||||
FramePadH int `default:"1" dense:"0"` // When the widget has a frame, like a button, it adds 2 lines runes on each side
|
||||
PadW int `default:"1" dense:"0"` // pad spacing
|
||||
PadH int `default:"1" dense:"0"` // pad spacing
|
||||
WindowW int `default:"8" dense:"0"` // how far down to start Window or Tab headings
|
||||
WindowH int `default:"-1"` // how far down to start Window or Tab headings
|
||||
TabW int `default:"5" dense:"0"` // how far down to start Window or Tab headings
|
||||
TabH int `default:"1" dense:"0"` // how far down to start Window or Tab headings
|
||||
WindowPadW int `default:"8" dense:"0"` // additional amount of space to put between window & tab widgets
|
||||
TabPadW int `default:"4" dense:"0"` // additional amount of space to put between window & tab widgets
|
||||
GroupPadW int `default:"2" dense:"1"` // additional amount of space to indent on a group
|
||||
BoxPadW int `default:"2" dense:"1"` // additional amount of space to indent on a box
|
||||
GridPadW int `default:"2" dense:"1"` // additional amount of space to indent on a grid
|
||||
RawW int `default:"1"` // the raw beginning of each window (or tab)
|
||||
RawH int `default:"5"` // the raw beginning of each window (or tab)
|
||||
FakeW int `default:"20"` // offset for the hidden widgets
|
||||
padded bool // add space between things like buttons
|
||||
bookshelf bool // do you want things arranged in the box like a bookshelf or a stack?
|
||||
canvas bool // if set to true, the windows are a raw canvas
|
||||
menubar bool // for windows
|
||||
stretchy bool // expand things like buttons to the maximum size
|
||||
margin bool // add space around the frames of windows
|
||||
writeMutex sync.Mutex // TODO: writeMutex protects locks the write process
|
||||
fakefile *FakeFile // JUNK? used to attempt to write to the stdout window
|
||||
dtoggle bool // is a dropdown or combobox currently active?
|
||||
showHelp bool // toggle boolean for the help menu (deprecate?)
|
||||
ecount int // counts how many mouse and keyboard events have occurred
|
||||
supermouse bool // prints out every widget found while you move the mouse around
|
||||
depth int // used for listWidgets() debugging
|
||||
}
|
||||
|
||||
// deprecate these
|
||||
|
@ -128,69 +98,31 @@ func (r *rectType) Height() int {
|
|||
}
|
||||
|
||||
type guiWidget struct {
|
||||
// the gocui package variables
|
||||
v *gocui.View // this is nil if the widget is not displayed
|
||||
cuiName string // what gocui uses to reference the widget
|
||||
|
||||
WidgetType widget.WidgetType
|
||||
|
||||
// tw *toolkit.Widget
|
||||
parent *guiWidget
|
||||
children []*guiWidget
|
||||
|
||||
node *tree.Node
|
||||
|
||||
hasTabs bool // does the window have tabs?
|
||||
currentTab bool // the visible tab
|
||||
|
||||
value string
|
||||
checked bool
|
||||
|
||||
// the actual text to display in the console
|
||||
labelN string
|
||||
|
||||
vals []string // dropdown menu items
|
||||
|
||||
active bool
|
||||
|
||||
enable bool
|
||||
defaultColor *colorT // store the color to go back to
|
||||
|
||||
// hidden bool
|
||||
|
||||
// AtW int
|
||||
// AtH int
|
||||
|
||||
// direction widget.Orientation
|
||||
|
||||
// progname string
|
||||
|
||||
// the logical size of the widget
|
||||
// For example, 40x12 would be the center of a normal terminal
|
||||
// size rectType
|
||||
|
||||
// the actual gocui display view of this widget
|
||||
// sometimes this isn't visible like with a Box or Grid
|
||||
gocuiSize rectType
|
||||
|
||||
startW int
|
||||
startH int
|
||||
|
||||
isCurrent bool // is this the currently displayed Window or Tab?
|
||||
isFake bool // widget types like 'box' are 'false'
|
||||
|
||||
// used to track the size of grids
|
||||
widths map[int]int // how tall each row in the grid is
|
||||
heights map[int]int // how wide each column in the grid is
|
||||
|
||||
tainted bool
|
||||
frame bool
|
||||
|
||||
// for a window, this is currently selected tab
|
||||
selectedTab *tree.Node
|
||||
|
||||
// what color to use
|
||||
color *colorT
|
||||
v *gocui.View // this is nil if the widget is not displayed
|
||||
cuiName string // what gocui uses to reference the widget (usually "TK <widgetId>"
|
||||
parent *guiWidget // mirrors the binary node tree
|
||||
children []*guiWidget // mirrors the binary node tree
|
||||
node *tree.Node // the pointer back to the tree
|
||||
hasTabs bool // does the window have tabs?
|
||||
currentTab bool // the visible tab
|
||||
value string // ?
|
||||
checked bool // ?
|
||||
labelN string // the actual text to display in the console
|
||||
vals []string // dropdown menu items
|
||||
active bool // ?
|
||||
enable bool // ?
|
||||
defaultColor *colorT // store the color to go back to
|
||||
gocuiSize rectType // should mirror the real display size. todo: verify these are accurate. they are not yet
|
||||
startW int // ?
|
||||
startH int // ?
|
||||
isCurrent bool // is this the currently displayed Window or Tab?
|
||||
isFake bool // widget types like 'box' are 'false'
|
||||
widths map[int]int // how tall each row in the grid is
|
||||
heights map[int]int // how wide each column in the grid is
|
||||
tainted bool // ?
|
||||
frame bool // ?
|
||||
selectedTab *tree.Node // for a window, this is currently selected tab
|
||||
color *colorT // what color to use
|
||||
}
|
||||
|
||||
// from the gocui devs:
|
||||
|
|
|
@ -53,7 +53,7 @@ func (w *guiWidget) drawTree(draw bool) {
|
|||
// deletes the old view if it exists and recreates it
|
||||
func (w *guiWidget) drawView() {
|
||||
var err error
|
||||
log.Log(INFO, "drawView() START", w.WidgetType, w.String())
|
||||
log.Log(INFO, "drawView() START", w.node.WidgetType, w.String())
|
||||
if me.baseGui == nil {
|
||||
log.Log(ERROR, "drawView() ERROR: me.baseGui == nil", w)
|
||||
return
|
||||
|
|
|
@ -18,7 +18,7 @@ func initWidget(n *tree.Node) *guiWidget {
|
|||
|
||||
w.node = n
|
||||
w.cuiName = strconv.Itoa(w.node.WidgetId) + " TK"
|
||||
w.WidgetType = n.WidgetType
|
||||
// w.node.WidgetType = n.WidgetType
|
||||
w.labelN = n.State.Label
|
||||
if w.labelN == "" {
|
||||
// remove this debugging hack once things are stable and fixed
|
||||
|
@ -38,11 +38,11 @@ func initWidget(n *tree.Node) *guiWidget {
|
|||
|
||||
p := n.Parent
|
||||
if p == nil {
|
||||
log.Log(ERROR, "parent == nil", w.String(), n.WidgetId, w.WidgetType)
|
||||
log.Log(ERROR, "parent == nil", w.String(), n.WidgetId, w.node.WidgetType)
|
||||
return w
|
||||
}
|
||||
if p.TK == nil {
|
||||
log.Log(ERROR, "parent.TK == nil", w.String(), n.WidgetId, w.WidgetType)
|
||||
log.Log(ERROR, "parent.TK == nil", w.String(), n.WidgetId, w.node.WidgetType)
|
||||
return w
|
||||
}
|
||||
|
||||
|
@ -68,7 +68,7 @@ func setupCtrlDownWidget() {
|
|||
|
||||
func (w *guiWidget) deleteView() {
|
||||
// make sure the view isn't really there
|
||||
// log.Log(GOCUI, "deleteView()", w.cuiName, w.WidgetType, w.node.WidgetId)
|
||||
// log.Log(GOCUI, "deleteView()", w.cuiName, w.node.WidgetType, w.node.WidgetId)
|
||||
me.baseGui.DeleteView(w.cuiName)
|
||||
w.v = nil
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue