diff options
| author | Jeff Carr <[email protected]> | 2021-11-01 00:24:56 -0500 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2021-11-01 00:24:56 -0500 |
| commit | 97a80003b9fddc15c58bcb01f371c48c8f821751 (patch) | |
| tree | 4e56021076a2d6548ce3813bd6a60e42f20baf49 | |
| parent | f5440782630ef7dd2b19a8b04df260a9a87cbba8 (diff) | |
CLEAN: out of the rabbit hole
Signed-off-by: Jeff Carr <[email protected]>
| -rw-r--r-- | button.go | 9 | ||||
| -rw-r--r-- | gui.go | 1 | ||||
| -rw-r--r-- | new-structs.go | 23 | ||||
| -rw-r--r-- | structs.go | 56 |
4 files changed, 26 insertions, 63 deletions
@@ -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") @@ -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) diff --git a/new-structs.go b/new-structs.go index 8d7a203..92ce84a 100644 --- a/new-structs.go +++ b/new-structs.go @@ -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) @@ -42,50 +42,12 @@ 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 { @@ -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 } |
