CLEAN: out of the rabbit hole
Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
parent
8c1c837879
commit
898874b0e9
|
@ -8,6 +8,8 @@ import _ "github.com/andlabs/ui/winmanifest"
|
||||||
// import "github.com/davecgh/go-spew/spew"
|
// import "github.com/davecgh/go-spew/spew"
|
||||||
|
|
||||||
|
|
||||||
|
// TODO: bring this generic mouse click function back
|
||||||
|
//
|
||||||
// This is the default mouse click handler
|
// This is the default mouse click handler
|
||||||
// Every mouse click that hasn't been assigned to
|
// Every mouse click that hasn't been assigned to
|
||||||
// something specific will fall into this routine
|
// 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 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
|
// 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 {
|
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 {
|
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()
|
n.uiFontButton = ui.NewFontButton()
|
||||||
// newGB.Box = n.box
|
|
||||||
// Data.AllButtons = append(Data.AllButtons, &newGB)
|
|
||||||
|
|
||||||
n.uiFontButton.OnChanged(func (*ui.FontButton) {
|
n.uiFontButton.OnChanged(func (*ui.FontButton) {
|
||||||
log.Println("FontButton.OnChanged() START")
|
log.Println("FontButton.OnChanged() START")
|
||||||
|
|
1
gui.go
1
gui.go
|
@ -16,7 +16,6 @@ const Yaxis = 1 // box that is vertical
|
||||||
func init() {
|
func init() {
|
||||||
log.Println("gui.init() has been run")
|
log.Println("gui.init() has been run")
|
||||||
|
|
||||||
// Data.buttonMap = make(map[*ui.Button]*GuiButton)
|
|
||||||
Data.NodeMap = make(map[string]*Node)
|
Data.NodeMap = make(map[string]*Node)
|
||||||
|
|
||||||
Data.NodeSlice = make([]*Node, 0)
|
Data.NodeSlice = make([]*Node, 0)
|
||||||
|
|
|
@ -234,6 +234,29 @@ func (n *Node) AddTabNode(title string) *Node {
|
||||||
return newNode
|
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 {
|
func (n *Node) AddTab(title string, uiC *ui.Box) *Node {
|
||||||
parent := n
|
parent := n
|
||||||
log.Println("gui.Node.AddTab() START name =", title)
|
log.Println("gui.Node.AddTab() START name =", title)
|
||||||
|
|
56
structs.go
56
structs.go
|
@ -42,51 +42,13 @@ type GuiData struct {
|
||||||
|
|
||||||
// A map of all the entry boxes
|
// A map of all the entry boxes
|
||||||
AllEntries []*GuiEntry
|
AllEntries []*GuiEntry
|
||||||
// WindowMap map[string]*GuiWindow
|
|
||||||
|
|
||||||
// Store access to everything via binary tree's
|
// Store access to everything via binary tree's
|
||||||
NodeMap map[string]*Node
|
NodeMap map[string]*Node
|
||||||
NodeArray []*Node
|
NodeArray []*Node
|
||||||
NodeSlice []*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
|
// text entry fields
|
||||||
type GuiEntry struct {
|
type GuiEntry struct {
|
||||||
Name string // field for human readable name
|
Name string // field for human readable name
|
||||||
|
@ -94,21 +56,14 @@ type GuiEntry struct {
|
||||||
Last string // the last value
|
Last string // the last value
|
||||||
Normalize func(string) string // function to 'normalize' the data
|
Normalize func(string) string // function to 'normalize' the data
|
||||||
|
|
||||||
// B *GuiButton
|
|
||||||
N *Node
|
N *Node
|
||||||
|
|
||||||
// andlabs/ui abstraction mapping
|
// andlabs/ui abstraction mapping
|
||||||
UiEntry *ui.Entry
|
UiEntry *ui.Entry
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
// AREA STRUCTURES START
|
|
||||||
// AREA STRUCTURES START
|
|
||||||
// AREA STRUCTURES START
|
|
||||||
//
|
|
||||||
type GuiArea struct {
|
type GuiArea struct {
|
||||||
// Button *GuiButton // what button handles mouse events
|
N *Node // what node to pass mouse events
|
||||||
N *Node // what button handles mouse events
|
|
||||||
|
|
||||||
UiAttrstr *ui.AttributedString
|
UiAttrstr *ui.AttributedString
|
||||||
UiArea *ui.Area
|
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
|
// TABLE DATA STRUCTURES START
|
||||||
//
|
//
|
||||||
|
|
||||||
|
@ -173,7 +120,6 @@ type HumanCellData struct {
|
||||||
TextID int
|
TextID int
|
||||||
Color color.RGBA
|
Color color.RGBA
|
||||||
ColorID int
|
ColorID int
|
||||||
// Button *GuiButton
|
|
||||||
N *Node
|
N *Node
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue