summaryrefslogtreecommitdiff
path: root/toolkit/andlabs/tab.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2022-10-21 11:40:08 -0500
committerJeff Carr <[email protected]>2022-10-21 11:40:08 -0500
commita3fc02c2f7e22f92b76ff6db92618be0cf3656a6 (patch)
tree70c05aada2b3acfbb95d1e6e0098291c7f8b6bcf /toolkit/andlabs/tab.go
parentb8ef0bb05dc14bc4291f3d156b199fa125cdb9d7 (diff)
v0.4.1 set sane toolkit default look and feelv0.4.1
autogenerate README.md from doc.go (goreadme cmd) remove passing arguements on a mouse click() make defaults for padding, margin, stretchy, etc add a checkbox widget function rename to NewButton() keep cleaning up toolkit code fix date. I was somehow in the future Signed-off-by: Jeff Carr <[email protected]>
Diffstat (limited to 'toolkit/andlabs/tab.go')
-rw-r--r--toolkit/andlabs/tab.go82
1 files changed, 31 insertions, 51 deletions
diff --git a/toolkit/andlabs/tab.go b/toolkit/andlabs/tab.go
index 922515d..a0565c0 100644
--- a/toolkit/andlabs/tab.go
+++ b/toolkit/andlabs/tab.go
@@ -22,59 +22,37 @@ import (
any existing tabs rather than adding a new one
*/
func (t *Toolkit) AddTab(name string) *Toolkit {
- var w *ui.Window
+ // var w *ui.Window
var newt *Toolkit
log.Println("gui.toolkit.AddTab() sleep 3")
- w = t.uiWindow
- if (w == nil) {
- log.Println("gui.toolkit.NewTab() node.UiWindow == nil. I can't add a tab without a window")
+ if (t.uiWindow == nil) {
+ log.Println("gui.Toolkit.UiWindow == nil. I can't add a toolbar without window")
return nil
}
if (t.uiTab == nil) {
// this means you have to make a new tab
log.Println("gui.toolkit.NewTab() GOOD. This should be the first tab:", name)
- newt = newTab(w, name)
+ newt = newTab(t.uiWindow, name)
t.uiTab = newt.uiTab
} else {
+ // this means you have to append a tab
log.Println("gui.toolkit.NewTab() GOOD. This should be an additional tab:", name)
newt = t.appendTab(name)
- // this means you have to append a tab
}
- log.Println("t:")
- t.Dump()
- log.Println("newt:")
- newt.Dump()
- return newt
-}
-
-func (t *Toolkit) SetTabBox(box *ui.Box) {
- var tab *ui.Tab
+ newt.Name = name
- log.Println("wit/gui/toolkit SetTabBox()")
- t.Dump()
- if (t.uiTab == nil) {
- log.Println("wit/gui/toolkit SetTabBox() got uiTab == nil")
- panic("fucknuts")
- return
- }
- if (t.uiBox == nil) {
- log.Println("wit/gui/toolkit SetTabBox() got uiBox == nil. Appending a new tab here")
- tab = t.uiTab
- tab.Append(t.Name, box)
- tabSetMargined(tab)
- return
- } else {
- log.Println("wit/gui/toolkit SetTabBox() got uiBox != nil. Appending the box to the existing box strechy = true")
- t.uiBox.Append(box, true) // strechy == true
- t.uiBox2 = box
- // t.uiBox.Append(box, false) // strechy == false
- return
+ if (DebugToolkit) {
+ log.Println("t:")
+ t.Dump()
+ log.Println("newt:")
+ newt.Dump()
}
+ return newt
}
// This sets _all_ the tabs to Margin = true
@@ -83,7 +61,8 @@ func (t *Toolkit) SetTabBox(box *ui.Box) {
func tabSetMargined(tab *ui.Tab) {
c := tab.NumPages()
for i := 0; i < c; i++ {
- tab.SetMargined(i, true)
+ log.Println("SetMargined", i, margin)
+ tab.SetMargined(i, margin)
}
}
@@ -99,20 +78,18 @@ func newTab(w *ui.Window, name string) *Toolkit {
return nil
}
log.Println("gui.toolkit.AddTab() START name =", name)
- // time.Sleep(2 * time.Second)
tab := ui.NewTab()
- w.SetMargined(true)
+ w.SetMargined(margin)
hbox := ui.NewHorizontalBox() // this makes everything go along the horizon
- // hbox := ui.NewVerticalBox()
- hbox.SetPadded(true)
+ hbox.SetPadded(padded)
tab.Append(name, hbox)
+ tabSetMargined(tab) // TODO: run this in the right place(?)
w.SetChild(tab)
t.uiWindow = w
t.uiTab = tab
t.uiBox = hbox
- // tabSetMargined(newNode.uiTab)
return &t
}
@@ -120,24 +97,27 @@ func (t *Toolkit) appendTab(name string) *Toolkit {
log.Println("gui.toolkit.NewTab() ADD", name)
var newT Toolkit
- if (t.uiWindow == nil) {
- log.Println("gui.toolkit.NewTab() node.UiWindow == nil. I can't add a tab without a window")
- log.Println("gui.toolkit.NewTab() node.UiWindow == nil. I can't add a tab without a window")
- log.Println("gui.toolkit.NewTab() node.UiWindow == nil. I can't add a tab without a window")
- time.Sleep(1 * time.Second)
- return nil
+ if (t.uiTab == nil) {
+ log.Println("gui.Toolkit.UiWindow == nil. I can't add a widget without a place to put it")
+ panic("should never have happened. wit/gui/toolkit has ui.Tab == nil")
}
log.Println("gui.toolkit.AddTab() START name =", name)
- hbox := ui.NewHorizontalBox() // this makes everything go along the horizon
- // hbox := ui.NewVerticalBox()
- hbox.SetPadded(true)
+ var hbox *ui.Box
+ if (defaultBehavior) {
+ hbox = ui.NewHorizontalBox()
+ } else {
+ if (bookshelf) {
+ hbox = ui.NewHorizontalBox()
+ } else {
+ hbox = ui.NewVerticalBox()
+ }
+ }
+ hbox.SetPadded(padded)
t.uiTab.Append(name, hbox)
- // w.SetChild(tab)
newT.uiWindow = t.uiWindow
newT.uiTab = t.uiTab
newT.uiBox = hbox
- // tabSetMargined(newNode.uiTab)
return &newT
}