sierpinski carpet mode
Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
parent
01df3b694f
commit
7ec476ab33
6
box.go
6
box.go
|
@ -8,7 +8,9 @@ func (parent *Node) NewBox(name string, b bool) *Node {
|
|||
newNode := parent.newNode(name, widget.Box)
|
||||
newNode.B = b
|
||||
|
||||
a := newAction(newNode, widget.Add)
|
||||
sendAction(a)
|
||||
if ! newNode.hidden {
|
||||
a := newAction(newNode, widget.Add)
|
||||
sendAction(a)
|
||||
}
|
||||
return newNode
|
||||
}
|
||||
|
|
|
@ -6,8 +6,10 @@ func (parent *Node) NewButton(name string, custom func()) *Node {
|
|||
newNode := parent.newNode(name, widget.Button)
|
||||
newNode.Custom = custom
|
||||
|
||||
a := newAction(newNode, widget.Add)
|
||||
sendAction(a)
|
||||
if ! newNode.hidden {
|
||||
a := newAction(newNode, widget.Add)
|
||||
sendAction(a)
|
||||
}
|
||||
return newNode
|
||||
}
|
||||
|
||||
|
|
|
@ -9,7 +9,9 @@ func (n *Node) Checked() bool {
|
|||
func (n *Node) NewCheckbox(name string) *Node {
|
||||
newNode := n.newNode(name, widget.Checkbox)
|
||||
|
||||
a := newAction(newNode, widget.Add)
|
||||
sendAction(a)
|
||||
if ! newNode.hidden {
|
||||
a := newAction(newNode, widget.Add)
|
||||
sendAction(a)
|
||||
}
|
||||
return newNode
|
||||
}
|
||||
|
|
91
common.go
91
common.go
|
@ -12,26 +12,34 @@ import (
|
|||
// functions for handling text related GUI elements
|
||||
|
||||
func (n *Node) Show() *Node {
|
||||
a := newAction(n, widget.Show)
|
||||
sendAction(a)
|
||||
if ! n.hidden {
|
||||
a := newAction(n, widget.Show)
|
||||
sendAction(a)
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
func (n *Node) Hide() *Node {
|
||||
a := newAction(n, widget.Hide)
|
||||
sendAction(a)
|
||||
if ! n.hidden {
|
||||
a := newAction(n, widget.Hide)
|
||||
sendAction(a)
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
func (n *Node) Enable() *Node {
|
||||
a := newAction(n, widget.Enable)
|
||||
sendAction(a)
|
||||
if ! n.hidden {
|
||||
a := newAction(n, widget.Enable)
|
||||
sendAction(a)
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
func (n *Node) Disable() *Node {
|
||||
a := newAction(n, widget.Disable)
|
||||
sendAction(a)
|
||||
if ! n.hidden {
|
||||
a := newAction(n, widget.Disable)
|
||||
sendAction(a)
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
|
@ -40,8 +48,10 @@ func (n *Node) Add(str string) {
|
|||
|
||||
n.S = str
|
||||
|
||||
a := newAction(n, widget.Add)
|
||||
sendAction(a)
|
||||
if ! n.hidden {
|
||||
a := newAction(n, widget.Add)
|
||||
sendAction(a)
|
||||
}
|
||||
}
|
||||
|
||||
func (n *Node) AddText(str string) {
|
||||
|
@ -50,8 +60,10 @@ func (n *Node) AddText(str string) {
|
|||
n.Text = str
|
||||
n.S = str
|
||||
|
||||
a := newAction(n, widget.AddText)
|
||||
sendAction(a)
|
||||
if ! n.hidden {
|
||||
a := newAction(n, widget.AddText)
|
||||
sendAction(a)
|
||||
}
|
||||
}
|
||||
|
||||
func (n *Node) SetText(text string) *Node {
|
||||
|
@ -60,8 +72,10 @@ func (n *Node) SetText(text string) *Node {
|
|||
n.Text = text
|
||||
n.S = text
|
||||
|
||||
a := newAction(n, widget.SetText)
|
||||
sendAction(a)
|
||||
if ! n.hidden {
|
||||
a := newAction(n, widget.SetText)
|
||||
sendAction(a)
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
|
@ -86,8 +100,10 @@ func (n *Node) Set(val any) {
|
|||
log.Error(errors.New("Set() unknown type"), "v =", v)
|
||||
}
|
||||
|
||||
a := newAction(n, widget.Set)
|
||||
sendAction(a)
|
||||
if ! n.hidden {
|
||||
a := newAction(n, widget.Set)
|
||||
sendAction(a)
|
||||
}
|
||||
}
|
||||
|
||||
func (n *Node) AppendText(str string) {
|
||||
|
@ -95,8 +111,10 @@ func (n *Node) AppendText(str string) {
|
|||
n.Text = tmp
|
||||
n.S = tmp
|
||||
|
||||
a := newAction(n, widget.SetText)
|
||||
sendAction(a)
|
||||
if ! n.hidden {
|
||||
a := newAction(n, widget.SetText)
|
||||
sendAction(a)
|
||||
}
|
||||
}
|
||||
|
||||
// THESE TWO FUNCTIONS ARE TERRIBLY NAMED AND NEED TO BE FIXED
|
||||
|
@ -169,33 +187,48 @@ func commonCallback(n *Node) {
|
|||
}
|
||||
|
||||
func (n *Node) Margin() *Node {
|
||||
a := newAction(n, widget.Margin)
|
||||
sendAction(a)
|
||||
n.margin = true
|
||||
if ! n.hidden {
|
||||
a := newAction(n, widget.Margin)
|
||||
sendAction(a)
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
func (n *Node) Unmargin() *Node {
|
||||
a := newAction(n, widget.Unmargin)
|
||||
sendAction(a)
|
||||
n.margin = false
|
||||
if ! n.hidden {
|
||||
a := newAction(n, widget.Unmargin)
|
||||
sendAction(a)
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
func (n *Node) Pad() *Node {
|
||||
a := newAction(n, widget.Pad)
|
||||
sendAction(a)
|
||||
n.pad = true
|
||||
if ! n.hidden {
|
||||
a := newAction(n, widget.Pad)
|
||||
sendAction(a)
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
func (n *Node) Unpad() *Node {
|
||||
a := newAction(n, widget.Unpad)
|
||||
sendAction(a)
|
||||
n.pad = false
|
||||
if ! n.hidden {
|
||||
a := newAction(n, widget.Unpad)
|
||||
sendAction(a)
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
func (n *Node) Expand() *Node {
|
||||
a := newAction(n, widget.Pad)
|
||||
a.Expand = true
|
||||
sendAction(a)
|
||||
n.expand = true
|
||||
if ! n.hidden {
|
||||
a := newAction(n, widget.Pad)
|
||||
a.Expand = true
|
||||
sendAction(a)
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
|
|
12
dropdown.go
12
dropdown.go
|
@ -22,8 +22,10 @@ func (n *Node) SetDropdownName(name string) {
|
|||
func (n *Node) NewDropdown(name string) *Node {
|
||||
newNode := n.newNode(name, widget.Dropdown)
|
||||
|
||||
a := newAction(newNode, widget.Add)
|
||||
sendAction(a)
|
||||
if ! newNode.hidden {
|
||||
a := newAction(newNode, widget.Add)
|
||||
sendAction(a)
|
||||
}
|
||||
|
||||
return newNode
|
||||
}
|
||||
|
@ -31,8 +33,10 @@ func (n *Node) NewDropdown(name string) *Node {
|
|||
func (n *Node) NewCombobox(name string) *Node {
|
||||
newNode := n.newNode(name, widget.Combobox)
|
||||
|
||||
a := newAction(newNode, widget.Add)
|
||||
sendAction(a)
|
||||
if ! newNode.hidden {
|
||||
a := newAction(newNode, widget.Add)
|
||||
sendAction(a)
|
||||
}
|
||||
|
||||
return newNode
|
||||
}
|
||||
|
|
6
grid.go
6
grid.go
|
@ -31,8 +31,10 @@ func (n *Node) NewGrid(name string, w int, h int) *Node {
|
|||
newNode.NextW = 1
|
||||
newNode.NextH = 1
|
||||
|
||||
a := newAction(newNode, widget.Add)
|
||||
sendAction(a)
|
||||
if ! newNode.hidden {
|
||||
a := newAction(newNode, widget.Add)
|
||||
sendAction(a)
|
||||
}
|
||||
|
||||
// by default, always pad grids
|
||||
newNode.Pad()
|
||||
|
|
6
group.go
6
group.go
|
@ -11,8 +11,10 @@ func (parent *Node) NewGroup(name string) *Node {
|
|||
var newNode *Node
|
||||
newNode = parent.newNode(name, widget.Group)
|
||||
|
||||
a := newAction(newNode, widget.Add)
|
||||
sendAction(a)
|
||||
if ! newNode.hidden {
|
||||
a := newAction(newNode, widget.Add)
|
||||
sendAction(a)
|
||||
}
|
||||
|
||||
// by default, always pad groups
|
||||
newNode.Pad()
|
||||
|
|
6
image.go
6
image.go
|
@ -8,7 +8,9 @@ func (parent *Node) NewImage(name string) *Node {
|
|||
var newNode *Node
|
||||
newNode = parent.newNode(name, widget.Image)
|
||||
|
||||
a := newAction(newNode, widget.Add)
|
||||
sendAction(a)
|
||||
if ! newNode.hidden {
|
||||
a := newAction(newNode, widget.Add)
|
||||
sendAction(a)
|
||||
}
|
||||
return newNode
|
||||
}
|
||||
|
|
27
int.go
27
int.go
|
@ -1,27 +0,0 @@
|
|||
package gui
|
||||
|
||||
/*
|
||||
Get the int from the gui toolkit
|
||||
because eventually this gui package should become it's own seperate go routine and never interact from the
|
||||
gui subroutine back into the upstream application using the gui package
|
||||
|
||||
TODO: instead store the int in the Node structure? (this is probably a better idea)
|
||||
because technically every interaction with the toolkit has to go through the Queue() goroutine.
|
||||
Is it "has to go" or "should go"? Probably it makes sense to strictly inforce it. No "callback" functions. IPC only (go channels)
|
||||
*/
|
||||
/*
|
||||
func (n *Node) Int() int {
|
||||
return n.widget.I
|
||||
}
|
||||
|
||||
// which name to use?
|
||||
func (n *Node) Value() int {
|
||||
return n.Int()
|
||||
}
|
||||
|
||||
func (n *Node) SetValue(i int) {
|
||||
log(debugGui, "gui.SetValue() START")
|
||||
// FIXME: this needs to be redone
|
||||
// n.toolkit.SetValue(i)
|
||||
}
|
||||
*/
|
9
label.go
9
label.go
|
@ -6,9 +6,10 @@ import (
|
|||
|
||||
func (parent *Node) NewLabel(text string) *Node {
|
||||
newNode := parent.newNode(text, widget.Label)
|
||||
a := newAction(newNode, widget.Add)
|
||||
a.Text = text
|
||||
a.S = text
|
||||
sendAction(a)
|
||||
|
||||
if ! newNode.hidden {
|
||||
a := newAction(newNode, widget.Add)
|
||||
sendAction(a)
|
||||
}
|
||||
return newNode
|
||||
}
|
||||
|
|
1
main.go
1
main.go
|
@ -24,6 +24,7 @@ func init() {
|
|||
// Populates the top of the binary tree
|
||||
me.rootNode = addNode("guiBinaryTree")
|
||||
me.rootNode.WidgetType = widget.Root
|
||||
me.rootNode.hidden = false // always send the rootNode to the toolkits
|
||||
|
||||
// used to pass debugging flags to the toolkit plugins
|
||||
me.flag = me.rootNode.newNode("flag", 0)
|
||||
|
|
1
node.go
1
node.go
|
@ -19,6 +19,7 @@ func (n *Node) newNode(title string, t widget.WidgetType) *Node {
|
|||
}
|
||||
newN.AtW = n.NextW
|
||||
newN.AtH = n.NextH
|
||||
newN.hidden = n.hidden // by default, use the value from above
|
||||
|
||||
n.children = append(n.children, newN)
|
||||
newN.parent = n
|
||||
|
|
10
slider.go
10
slider.go
|
@ -14,10 +14,12 @@ func (parent *Node) NewSlider(name string, x int, y int) *Node {
|
|||
|
||||
newNode.X = x
|
||||
newNode.Y = y
|
||||
a := newAction(newNode, widget.Add)
|
||||
a.X = x
|
||||
a.Y = y
|
||||
sendAction(a)
|
||||
if ! newNode.hidden {
|
||||
a := newAction(newNode, widget.Add)
|
||||
a.X = x
|
||||
a.Y = y
|
||||
sendAction(a)
|
||||
}
|
||||
|
||||
return newNode
|
||||
}
|
||||
|
|
|
@ -15,7 +15,9 @@ func (parent *Node) NewSpinner(name string, x int, y int) *Node {
|
|||
newNode.X = x
|
||||
newNode.Y = y
|
||||
|
||||
a := newAction(newNode, widget.Add)
|
||||
sendAction(a)
|
||||
if ! newNode.hidden {
|
||||
a := newAction(newNode, widget.Add)
|
||||
sendAction(a)
|
||||
}
|
||||
return newNode
|
||||
}
|
||||
|
|
|
@ -48,7 +48,11 @@ type guiConfig struct {
|
|||
// The Node is a binary tree. This is how all GUI elements are stored
|
||||
// simply the name and the size of whatever GUI element exists
|
||||
type Node struct {
|
||||
id int
|
||||
id int // should be unique
|
||||
hidden bool // Sierpinski Carpet mode. It's there, but you can't see it.
|
||||
pad bool // the toolkit may use this. it's up to the toolkit
|
||||
margin bool // the toolkit may use this. it's up to the toolkit
|
||||
expand bool // the toolkit may use this. it's up to the toolkit
|
||||
|
||||
WidgetType widget.WidgetType
|
||||
|
||||
|
|
12
textbox.go
12
textbox.go
|
@ -13,8 +13,10 @@ func (parent *Node) NewTextbox(name string) *Node {
|
|||
log.Log(GUI, "NewTextbox changed =", name)
|
||||
}
|
||||
|
||||
a := newAction(newNode, widget.Add)
|
||||
sendAction(a)
|
||||
if ! newNode.hidden {
|
||||
a := newAction(newNode, widget.Add)
|
||||
sendAction(a)
|
||||
}
|
||||
return newNode
|
||||
}
|
||||
|
||||
|
@ -27,7 +29,9 @@ func (parent *Node) NewEntryLine(name string) *Node {
|
|||
log.Log(GUI, "NewTextbox changed =", name)
|
||||
}
|
||||
|
||||
a := newAction(newNode, widget.Add)
|
||||
sendAction(a)
|
||||
if ! newNode.hidden {
|
||||
a := newAction(newNode, widget.Add)
|
||||
sendAction(a)
|
||||
}
|
||||
return newNode
|
||||
}
|
||||
|
|
45
window.go
45
window.go
|
@ -16,7 +16,48 @@ func (parent *Node) NewWindow(title string) *Node {
|
|||
|
||||
log.Info("NewWindow()", title)
|
||||
|
||||
a := newAction(newNode, widget.Add)
|
||||
sendAction(a)
|
||||
if ! newNode.hidden {
|
||||
a := newAction(newNode, widget.Add)
|
||||
sendAction(a)
|
||||
}
|
||||
return newNode
|
||||
}
|
||||
|
||||
// allow window create without actually sending it to the toolkit
|
||||
func (parent *Node) RawWindow(title string) *Node {
|
||||
var newNode *Node
|
||||
|
||||
// Windows are created off of the master node of the Binary Tree
|
||||
newNode = parent.newNode(title, widget.Window)
|
||||
newNode.Custom = StandardExit
|
||||
newNode.hidden = true
|
||||
|
||||
log.Info("RawWindow()", title)
|
||||
return newNode
|
||||
}
|
||||
|
||||
// TODO: should do this recursively
|
||||
func (n *Node) UnDraw() *Node {
|
||||
if ! n.hidden {
|
||||
n.Hide()
|
||||
}
|
||||
n.hidden = true
|
||||
return n
|
||||
}
|
||||
|
||||
// TODO: should do this recursively
|
||||
func (n *Node) Draw() *Node {
|
||||
n.hidden = false
|
||||
|
||||
a := newAction(n, widget.Add)
|
||||
sendAction(a)
|
||||
return n
|
||||
}
|
||||
|
||||
// if the toolkit supports a gui with pixels, it might honor this. no promises
|
||||
// consider this a 'recommendation' or developer 'preference' to the toolkit
|
||||
func (n *Node) PixelSize(w, h int) *Node {
|
||||
n.width = w
|
||||
n.height = w
|
||||
return n
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue