2024-01-17 23:54:19 -06:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"go.wit.com/toolkits/tree"
|
2024-01-18 04:27:19 -06:00
|
|
|
"go.wit.com/widget"
|
2024-01-17 23:54:19 -06:00
|
|
|
|
|
|
|
"go.wit.com/dev/andlabs/ui"
|
|
|
|
_ "go.wit.com/dev/andlabs/ui/winmanifest"
|
|
|
|
)
|
|
|
|
|
|
|
|
// make new Box here
|
|
|
|
func newBox(n *tree.Node) {
|
|
|
|
if notNew(n) {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
newt := new(guiWidget)
|
|
|
|
var box *ui.Box
|
|
|
|
|
|
|
|
if n.State.Direction == widget.Horizontal {
|
|
|
|
box = ui.NewHorizontalBox()
|
|
|
|
} else {
|
|
|
|
box = ui.NewVerticalBox()
|
|
|
|
}
|
|
|
|
box.SetPadded(true)
|
|
|
|
|
|
|
|
newt.uiBox = box
|
|
|
|
newt.uiControl = box
|
|
|
|
newt.boxC = 0
|
|
|
|
n.TK = newt
|
|
|
|
place(n.Parent, n)
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2024-02-05 12:06:17 -06:00
|
|
|
rawBox -- hack to arbitrarily add a box in andlabs to work
|
|
|
|
around the problem that a "group" can not have one entry in it
|
|
|
|
TODO: fix this so that a box is "added on demand" that is,
|
|
|
|
if "go.wit.com/gui" sends you a 2nd thing to add to a group,
|
|
|
|
automatically add a box then. The problem with this, is the macos, windows and linux gtk
|
|
|
|
will panic on a move when an chind object is disasociated from the group
|
|
|
|
I haven't had time to try to debug this, so, instead, it's just probably better to always
|
|
|
|
add a box here. There doesn't seem to be any real issue with forcing a box to be inserted
|
|
|
|
into the toolkits that is "outside" the binary tree of widgets. This only means, that on
|
|
|
|
a destroy of the tree, this box must be checked
|
2024-01-17 23:54:19 -06:00
|
|
|
|
2024-02-05 12:06:17 -06:00
|
|
|
even that is a probably not senario however since clicking on the close box in the toolkit
|
|
|
|
has the operating system destroy everything in the window. it may or may not be possible
|
|
|
|
to control that behavior. at this time, it's "undetermined" and the best course of action
|
|
|
|
is to detect the window is destroyed and then remove all the toolkit information
|
|
|
|
from all the nodes in the binary tree
|
2024-01-17 23:54:19 -06:00
|
|
|
|
2024-02-05 12:06:17 -06:00
|
|
|
TODO: handle user killing/closing a window using the OS
|
2024-01-17 23:54:19 -06:00
|
|
|
*/
|
|
|
|
func rawBox(n *tree.Node) *ui.Box {
|
|
|
|
var box *ui.Box
|
|
|
|
|
|
|
|
if n.State.Direction == widget.Horizontal {
|
|
|
|
box = ui.NewHorizontalBox()
|
|
|
|
} else {
|
|
|
|
box = ui.NewVerticalBox()
|
|
|
|
}
|
|
|
|
box.SetPadded(true)
|
|
|
|
|
|
|
|
return box
|
|
|
|
}
|