diff options
| author | Jeff Carr <[email protected]> | 2021-10-07 05:52:22 -0500 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2021-10-07 05:52:22 -0500 |
| commit | 3eac6beec4c3809b4696d63a252a34a6c6dc8ae1 (patch) | |
| tree | 9b5e5046a59607482418a44c3e6e128cb33a9ebe /structs.go | |
| parent | 44b56de98421262ca10c741737faafe056470255 (diff) | |
NODE: start passing *Node around
Signed-off-by: Jeff Carr <[email protected]>
Diffstat (limited to 'structs.go')
| -rw-r--r-- | structs.go | 36 |
1 files changed, 19 insertions, 17 deletions
@@ -3,6 +3,7 @@ package gui import ( "image/color" "log" + "os" "github.com/andlabs/ui" "golang.org/x/image/font" @@ -87,6 +88,8 @@ type GuiWindow struct { EntryMap map[string]*GuiEntry Area *GuiArea + node *Node + // andlabs/ui abstraction mapping UiWindow *ui.Window UiTab *ui.Tab // if this != nil, the window is 'tabbed' @@ -99,6 +102,8 @@ type GuiBox struct { Axis int // does it add items to the X or Y axis Window *GuiWindow // the parent Window + node *Node + // andlabs/ui abstraction mapping UiBox *ui.Box } @@ -115,6 +120,13 @@ func (s GuiBox) SetTitle(title string) { return } +func (s GuiBox) FindNode() *Node { + if s.node != nil { + return s.node + } + return nil +} + func (s GuiBox) Append(child ui.Control, x bool) { if s.UiBox == nil { return @@ -140,7 +152,7 @@ func (w GuiWindow) InitWindow(title string) *GuiBox { } */ -func (s GuiBox) InitTab(title string, custom func() ui.Control) *ui.Tab { +func (s GuiBox) InitTab(title string, custom func() ui.Control) *Node { if s.Window == nil { return nil } @@ -158,24 +170,14 @@ func (s GuiBox) InitTab(title string, custom func() ui.Control) *ui.Tab { // tab.SetMargined(1, true) s.Window.UiTab = tab - return tab -} - -func (s GuiBox) AddTab(title string, custom ui.Control) *ui.Tab { - if s.Window == nil { - return nil + if s.node == nil { + log.Println("Fuck node = ", s.node) + os.Exit(-1) } - if s.Window.UiTab == nil { - return nil - } - - tab := s.Window.UiTab - - tab.Append(title, custom) - return tab + return s.node } -func (s GuiBox) AddTab2(title string, custom ui.Control) *ui.Tab { +func (s GuiBox) AddTab(title string, custom ui.Control) *ui.Tab { if s.Window == nil { return nil } @@ -189,7 +191,7 @@ func (s GuiBox) AddTab2(title string, custom ui.Control) *ui.Tab { } func (s GuiBox) AddBoxTab(title string) *GuiBox { - uiTab := s.AddTab2(title, InitBlankWindow()) + uiTab := s.AddTab(title, InitBlankWindow()) tabSetMargined(uiTab) var box *GuiBox |
