summaryrefslogtreecommitdiff
path: root/grid.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2024-02-09 04:54:42 -0600
committerJeff Carr <[email protected]>2024-02-09 04:54:42 -0600
commit8317fa28e2da1d22d7248874ebc794189faf23b5 (patch)
treed485f1df07a5f6eb6da5655b3c342cdbdbb6244e /grid.go
parent1d04dfa4bbf35c5fa0893d375ec11cbef8849bf7 (diff)
add grid without bounds
Signed-off-by: Jeff Carr <[email protected]>
Diffstat (limited to 'grid.go')
-rw-r--r--grid.go28
1 files changed, 25 insertions, 3 deletions
diff --git a/grid.go b/grid.go
index 297a723..a6fadec 100644
--- a/grid.go
+++ b/grid.go
@@ -33,6 +33,22 @@ type GridOffset struct {
Y int
}
+func (parent *Node) RawGrid() *Node {
+ newNode := parent.newNode("GRID", widget.Grid)
+
+ newNode.W = 0
+ newNode.H = 0
+ newNode.NextW = 1
+ newNode.NextH = 1
+
+ // by default, always pad grids
+ newNode.pad = true
+
+ // inform the toolkits
+ sendAction(newNode, widget.Add)
+ return newNode
+}
+
func (parent *Node) NewGrid(progname string, w int, h int) *Node {
newNode := parent.newNode(progname, widget.Grid)
newNode.progname = progname
@@ -67,9 +83,15 @@ func (n *Node) gridIncrement() {
}
n.NextW += 1
- if n.NextW > n.W {
- n.NextW = 1
- n.NextH += 1
+ if n.W == 0 {
+ // grid does not have a fixed size
+ } else {
+ // this grid has bounds, if adding to the grid
+ // goes off the edge, then add the widget to the next row
+ if n.NextW > n.W {
+ n.NextW = 1
+ n.NextH += 1
+ }
}
n.gridIncrement()