andlabs: more into the binary tree
Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
parent
3cdbc285e3
commit
bec9a99a15
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue