CLEAN: out of the rabbit hole

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2021-11-01 00:24:56 -05:00
parent 8c1c837879
commit 898874b0e9
4 changed files with 26 additions and 63 deletions

View File

@ -8,6 +8,8 @@ import _ "github.com/andlabs/ui/winmanifest"
// import "github.com/davecgh/go-spew/spew"
// TODO: bring this generic mouse click function back
//
// This is the default mouse click handler
// Every mouse click that hasn't been assigned to
// something specific will fall into this routine
@ -17,8 +19,6 @@ import _ "github.com/andlabs/ui/winmanifest"
// This routine MUST be here as this is how the andlabs/ui works
// This is the raw routine passed to every button in andlabs libui / ui
//
// There is a []GuiButton which has all the buttons. We search
// for the button and then call the function below
//
func (n *Node) AddButton(name string, custom func(*Node)) *Node {
@ -47,12 +47,7 @@ func (n *Node) AddButton(name string, custom func(*Node)) *Node {
}
func (n *Node) CreateFontButton(action string) *Node {
// create a 'fake' button entry for the mouse clicks
// var newGB GuiButton
// newGB.Name = "FONT"
n.uiFontButton = ui.NewFontButton()
// newGB.Box = n.box
// Data.AllButtons = append(Data.AllButtons, &newGB)
n.uiFontButton.OnChanged(func (*ui.FontButton) {
log.Println("FontButton.OnChanged() START")

1
gui.go
View File

@ -16,7 +16,6 @@ const Yaxis = 1 // box that is vertical
func init() {
log.Println("gui.init() has been run")
// Data.buttonMap = make(map[*ui.Button]*GuiButton)
Data.NodeMap = make(map[string]*Node)
Data.NodeSlice = make([]*Node, 0)

View File

@ -234,6 +234,29 @@ func (n *Node) AddTabNode(title string) *Node {
return newNode
}
func (n *Node) AddHorizontalBox(title string) *Node {
hbox := ui.NewHorizontalBox()
hbox.SetPadded(true)
if (n.uiBox != nil) {
log.Println("add new hbox to uiBox =", n.uiBox)
n.uiBox.Append(hbox, false)
newNode := n.makeNode(title, 333, 333 + Config.counter)
newNode.parent = n
newNode.uiBox = hbox
// newNode.uiControl = hbox
return newNode
}
if (n.uiTab != nil) {
log.Println("add new hbox to uiTab =", n.uiTab)
n.uiTab.Append(title, hbox)
newNode := n.makeNode(title, 333, 333 + Config.counter)
newNode.parent = n
newNode.uiBox = hbox
// newNode.uiControl = hbox
return newNode
}
return n
}
func (n *Node) AddTab(title string, uiC *ui.Box) *Node {
parent := n
log.Println("gui.Node.AddTab() START name =", title)

View File

@ -42,51 +42,13 @@ type GuiData struct {
// A map of all the entry boxes
AllEntries []*GuiEntry
// WindowMap map[string]*GuiWindow
// Store access to everything via binary tree's
NodeMap map[string]*Node
NodeArray []*Node
NodeSlice []*Node
// A map of all buttons everywhere on all
// windows, all tabs, across all goroutines
// This is "GLOBAL"
//
// This has to work this way because of how
// andlabs/ui & andlabs/libui work
// AllButtons []*GuiButton
// buttonMap map[*ui.Button]*GuiButton
}
/*
type GuiTab struct {
Name string // field for human readable name
Number int // the andlabs/ui tab index
// Window *GuiWindow // the parent Window
}
*/
/*
// Note: every mouse click is handled
// as a 'Button' regardless of where
// the user clicks it. You could probably
// call this 'GuiMouseClick'
type GuiButton struct {
Name string // field for human readable name
// a callback function for the main application
Custom func(*GuiButton)
Values interface{}
Color color.RGBA
// andlabs/ui abstraction mapping
B *ui.Button
FB *ui.FontButton
CB *ui.ColorButton
}
*/
// text entry fields
type GuiEntry struct {
Name string // field for human readable name
@ -94,21 +56,14 @@ type GuiEntry struct {
Last string // the last value
Normalize func(string) string // function to 'normalize' the data
// B *GuiButton
N *Node
// andlabs/ui abstraction mapping
UiEntry *ui.Entry
}
//
// AREA STRUCTURES START
// AREA STRUCTURES START
// AREA STRUCTURES START
//
type GuiArea struct {
// Button *GuiButton // what button handles mouse events
N *Node // what button handles mouse events
N *Node // what node to pass mouse events
UiAttrstr *ui.AttributedString
UiArea *ui.Area
@ -122,14 +77,6 @@ type FontString struct {
}
//
// AREA STRUCTURES END
// AREA STRUCTURES END
// AREA STRUCTURES END
//
//
// TABLE DATA STRUCTURES START
// TABLE DATA STRUCTURES START
// TABLE DATA STRUCTURES START
//
@ -173,7 +120,6 @@ type HumanCellData struct {
TextID int
Color color.RGBA
ColorID int
// Button *GuiButton
N *Node
}