diff options
| author | Jeff Carr <[email protected]> | 2021-10-04 21:33:03 -0500 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2021-10-04 21:33:03 -0500 |
| commit | b5b1528a29d42d01597cb15b317177ca2237e535 (patch) | |
| tree | 514173fcc7d399f8d3362f84604c3add36c8aee3 | |
| parent | 36cb4f8afcff24036af35e7f4c61e09d3e632a56 (diff) | |
TAB: code to more correctly handle gtk tabs
Signed-off-by: Jeff Carr <[email protected]>
| -rw-r--r-- | structs.go | 45 | ||||
| -rw-r--r-- | window.go | 7 |
2 files changed, 52 insertions, 0 deletions
@@ -1,5 +1,6 @@ package gui +import "log" import "image/color" import "golang.org/x/image/font" @@ -92,6 +93,50 @@ type GuiBox struct { UiBox *ui.Box } +func (s GuiBox) SetTitle(title string) { + log.Println("DID IT!", title) + if (s.Window == nil) { + return + } + if (s.Window.UiWindow == nil) { + return + } + s.Window.UiWindow.SetTitle(title) + return +} + +func (s GuiBox) InitTab(title string) { + if (s.Window == nil) { + return + } + if (s.Window.UiWindow == nil) { + return + } + + window := s.Window.UiWindow + tab := ui.NewTab() + window.SetChild(tab) + window.SetMargined(true) + + tab.Append(title, InitBlankWindow()) + tab.SetMargined(0, true) + + s.Window.UiTab = tab +} + +func (s GuiBox) AddTab(title string) { + if (s.Window == nil) { + return + } + if (s.Window.UiTab == nil) { + return + } + + tab := s.Window.UiTab + + tab.Append(title, InitBlankWindow()) +} + // Note: every mouse click is handled // as a 'Button' regardless of where // the user clicks it. You could probably @@ -209,3 +209,10 @@ func CreateBlankWindow(title string, x int, y int) *GuiBox { return &box } + +func InitBlankWindow() ui.Control { + hbox := ui.NewHorizontalBox() + hbox.SetPadded(true) + + return hbox +} |
