summaryrefslogtreecommitdiff
path: root/toolkit
diff options
context:
space:
mode:
Diffstat (limited to 'toolkit')
-rw-r--r--toolkit/andlabs/add.go63
-rw-r--r--toolkit/andlabs/box.go16
-rw-r--r--toolkit/andlabs/group.go16
-rw-r--r--toolkit/andlabs/tab.go4
4 files changed, 77 insertions, 22 deletions
diff --git a/toolkit/andlabs/add.go b/toolkit/andlabs/add.go
index 9c4fe54..95a637a 100644
--- a/toolkit/andlabs/add.go
+++ b/toolkit/andlabs/add.go
@@ -27,12 +27,13 @@ func add(a toolkit.Action) {
}
n := addWidget(&a, nil)
+ p := n.parent
switch n.WidgetType {
case toolkit.Window:
newWindow(n)
return
case toolkit.Tab:
- newTab(n)
+ p.newTab(n)
return
case toolkit.Label:
newLabel(&a)
@@ -62,10 +63,10 @@ func add(a toolkit.Action) {
newTextbox(&a)
return
case toolkit.Group:
- newGroup(&a)
+ p.newGroup(n)
return
case toolkit.Box:
- newBox(&a)
+ p.newBox(n)
return
case toolkit.Image:
newImage(&a)
@@ -163,3 +164,59 @@ func place(a *toolkit.Action, t *andlabsT, newt *andlabsT) bool {
}
return false
}
+func (p *node) place(n *node) bool {
+ log(logInfo, "place() START", n.WidgetType, n.Name)
+
+ if (p.tk == nil) {
+ log(logError, "p.tk == nil", p.Name, p.ParentId, p.WidgetType, p.tk)
+ log(logError, "n = ", n.Name, n.ParentId, n.WidgetType, n.tk)
+ panic("p.tk == nil")
+ }
+
+ log(logInfo, "place() switch", p.WidgetType)
+ switch p.WidgetType {
+ case toolkit.Grid:
+ log(debugGrid, "place() Grid try at Parent X,Y =", n.X, n.Y)
+ n.tk.gridX = n.X
+ n.tk.gridY = n.Y
+ log(debugGrid, "place() Grid try at gridX,gridY", n.tk.gridX, n.tk.gridY)
+ // at the very end, subtract 1 from X & Y since andlabs/ui starts counting at zero
+ p.tk.uiGrid.Append(n.tk.uiControl,
+ n.tk.gridY - 1, n.tk.gridX - 1, 1, 1,
+ false, ui.AlignFill, false, ui.AlignFill)
+ return true
+ case toolkit.Group:
+ if (p.tk.uiBox == nil) {
+ p.tk.uiGroup.SetChild(n.tk.uiControl)
+ log(debugGrid, "place() hack Group to use this as the box?", n.Name, n.WidgetType)
+ p.tk.uiBox = n.tk.uiBox
+ } else {
+ p.tk.uiBox.Append(n.tk.uiControl, stretchy)
+ }
+ return true
+ case toolkit.Tab:
+ if (p.tk.uiTab == nil) {
+ log(logError, "p.tk.uiTab == nil", p.tk)
+ panic("p.tk.uiTab == nil")
+ }
+ if (n.tk.uiControl == nil) {
+ log(logError, "n.tk.uiControl == nil", n.tk)
+ panic("n.tk.uiControl == nil")
+ }
+ p.tk.uiTab.Append(n.Text, n.tk.uiControl)
+ p.tk.boxC += 1
+ return true
+ case toolkit.Box:
+ log(logInfo, "place() uiBox =", p.tk.uiBox)
+ log(logInfo, "place() uiControl =", n.tk.uiControl)
+ p.tk.uiBox.Append(n.tk.uiControl, stretchy)
+ p.tk.boxC += 1
+ return true
+ case toolkit.Window:
+ p.tk.uiWindow.SetChild(n.tk.uiControl)
+ return true
+ default:
+ log(debugError, "place() how? Parent =", p.WidgetId, p.WidgetType)
+ }
+ return false
+}
diff --git a/toolkit/andlabs/box.go b/toolkit/andlabs/box.go
index 527041d..72ff698 100644
--- a/toolkit/andlabs/box.go
+++ b/toolkit/andlabs/box.go
@@ -1,25 +1,23 @@
package main
import (
- "git.wit.org/wit/gui/toolkit"
-
"github.com/andlabs/ui"
_ "github.com/andlabs/ui/winmanifest"
)
// make new Box here
-func newBox(a *toolkit.Action) {
- log(debugToolkit, "newBox()", a.Name)
+func (p *node) newBox(n *node) {
+ log(debugToolkit, "newBox()", n.Name)
- t := andlabs[a.ParentId]
+ t := p.tk
if (t == nil) {
- log(debugToolkit, "newBox() toolkit struct == nil. name=", a.Name)
+ log(debugToolkit, "newBox() toolkit struct == nil. name=", n.Name)
listMap(debugToolkit)
}
- newt := t.rawBox(a.Text, a.B)
+ newt := t.rawBox(n.Text, n.B)
newt.boxC = 0
- place(a, t, newt)
- andlabs[a.WidgetId] = newt
+ n.tk = newt
+ p.place(n)
}
// make new Box using andlabs/ui
diff --git a/toolkit/andlabs/group.go b/toolkit/andlabs/group.go
index 1551d66..8138576 100644
--- a/toolkit/andlabs/group.go
+++ b/toolkit/andlabs/group.go
@@ -1,23 +1,21 @@
package main
import (
- "git.wit.org/wit/gui/toolkit"
-
"github.com/andlabs/ui"
_ "github.com/andlabs/ui/winmanifest"
)
-func newGroup(a *toolkit.Action) {
- // w := a.Widget
- log(debugToolkit, "NewGroup()", a.Name)
+func (p *node) newGroup(n *node) {
+ log(debugToolkit, "NewGroup()", n.Name)
- t := andlabs[a.ParentId]
+ t := p.tk
if (t == nil) {
- log(debugToolkit, "NewGroup() toolkit struct == nil. name=", a.Name)
+ log(debugToolkit, "NewGroup() toolkit struct == nil. name=", n.Name)
listMap(debugToolkit)
}
- newt := t.rawGroup(a.Name)
- place(a, t, newt)
+ newt := t.rawGroup(n.Name)
+ n.tk = newt
+ p.place(n)
}
// make new Group here
diff --git a/toolkit/andlabs/tab.go b/toolkit/andlabs/tab.go
index 42743de..1a05f58 100644
--- a/toolkit/andlabs/tab.go
+++ b/toolkit/andlabs/tab.go
@@ -20,7 +20,6 @@ import (
any existing tabs rather than adding a new one
*/
func (p *node) newTab(n *node) {
- // var w *ui.Window
var newt *andlabsT
t := p.tk
@@ -58,6 +57,7 @@ func (p *node) newTab(n *node) {
t.Dump(debugToolkit)
log(debugToolkit, "newt:")
newt.Dump(debugToolkit)
+ n.tk = newt
}
// This sets _all_ the tabs to Margin = true
@@ -120,9 +120,11 @@ func (t *andlabsT) appendTab(name string) *andlabsT {
return &newT
}
+/*
func newTab(n *node) {
log(logInfo, "newTab() add to parent id:", n.ParentId)
p := n.parent
p.newTab(n)
}
+*/