From c8e32a0980e984deb04dc9688f422b9108783cda Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Mon, 25 Oct 2021 06:50:27 -0500 Subject: REORG: move more find() functions into find.go Signed-off-by: Jeff Carr --- find.go | 38 ++++++++++++++++++++++++++++++++++++-- new-structs.go | 19 ------------------- structs.go | 17 ----------------- 3 files changed, 36 insertions(+), 38 deletions(-) diff --git a/find.go b/find.go index 441f496..037ce0d 100644 --- a/find.go +++ b/find.go @@ -4,11 +4,45 @@ import ( "log" "os" -// "github.com/andlabs/ui" -// _ "github.com/andlabs/ui/winmanifest" + "github.com/andlabs/ui" + _ "github.com/andlabs/ui/winmanifest" // "github.com/davecgh/go-spew/spew" ) +func (n *Node) FindTab() *ui.Tab { + return n.uiTab +} + +func (n *Node) FindControl() *ui.Control { + return n.uiControl +} + +func (n *Node) FindBox() *GuiBox { + return n.box +} + +func (n *Node) FindWindowBox() *GuiBox { + if (n.box == nil) { + panic("SERIOUS ERROR n.box == nil in FindWindowBox()") + } + return n.box +} + +func (w *GuiWindow) FindNode() *Node { + return w.node +} + +func (b *GuiBox) FindNode() *Node { + log.Println("gui.FindNode() on GuiBox") + if b.node != nil { + return b.node + } + Data.ListChildren(true) + b.Dump() + log.Println("gui.FindNode() on GuiBox is nil") + os.Exit(-1) + return nil +} func FindWindow(s string) *GuiWindow { for name, window := range Data.WindowMap { diff --git a/new-structs.go b/new-structs.go index 7cd6d90..d50de32 100644 --- a/new-structs.go +++ b/new-structs.go @@ -106,25 +106,6 @@ func (n *Node) SetName(name string) { return } -func (n *Node) FindTab() *ui.Tab { - return n.uiTab -} - -func (n *Node) FindControl() *ui.Control { - return n.uiControl -} - -func (n *Node) FindBox() *GuiBox { - return n.box -} - -func (n *Node) FindWindowBox() *GuiBox { - if (n.box == nil) { - panic("SERIOUS ERROR n.box == nil in FindWindowBox()") - } - return n.box -} - func (n *Node) Append(child *Node) { // if (n.UiBox == nil) { // return diff --git a/structs.go b/structs.go index cf84746..8a401ca 100644 --- a/structs.go +++ b/structs.go @@ -3,7 +3,6 @@ package gui import ( "image/color" "log" - "os" "github.com/andlabs/ui" "golang.org/x/image/font" @@ -169,22 +168,6 @@ func (b *GuiBox) SetNode(n *Node) { } } -func (w *GuiWindow) FindNode() *Node { - return w.node -} - -func (b *GuiBox) FindNode() *Node { - log.Println("gui.FindNode() on GuiBox") - if b.node != nil { - return b.node - } - Data.ListChildren(true) - b.Dump() - log.Println("gui.FindNode() on GuiBox is nil") - os.Exit(-1) - return nil -} - func (s GuiBox) Append(child ui.Control, x bool) { if s.UiBox == nil { return -- cgit v1.2.3