aboutsummaryrefslogtreecommitdiffstats
path: root/lib/ui
diff options
context:
space:
mode:
Diffstat (limited to 'lib/ui')
-rw-r--r--lib/ui/grid.go14
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/ui/grid.go b/lib/ui/grid.go
index 3f5dd60e..96da1cba 100644
--- a/lib/ui/grid.go
+++ b/lib/ui/grid.go
@@ -54,6 +54,20 @@ func NewGrid() *Grid {
return &Grid{invalid: true}
}
+// MakeGrid creates a grid with the specified number of columns and rows. Each
+// cell has a size of 1.
+func MakeGrid(numRows, numCols, rowStrategy, colStrategy int) *Grid {
+ rows := make([]GridSpec, numRows)
+ for i := 0; i < numRows; i++ {
+ rows[i] = GridSpec{rowStrategy, 1}
+ }
+ cols := make([]GridSpec, numCols)
+ for i := 0; i < numCols; i++ {
+ cols[i] = GridSpec{colStrategy, 1}
+ }
+ return NewGrid().Rows(rows).Columns(cols)
+}
+
func (cell *GridCell) At(row, col int) *GridCell {
cell.Row = row
cell.Column = col