diff options
Diffstat (limited to 'grid.go')
| -rw-r--r-- | grid.go | 34 |
1 files changed, 17 insertions, 17 deletions
@@ -16,13 +16,13 @@ import ( // A stretchy Control implicitly fills its cell. // All cooridnates in a Grid are given in (row,column) form with (0,0) being the top-left cell. type Grid struct { - lock sync.Mutex - created bool - controls [][]Control - filling [][]bool - stretchyrow, stretchycol int - widths, heights [][]int // caches to avoid reallocating each time - rowheights, colwidths []int + lock sync.Mutex + created bool + controls [][]Control + filling [][]bool + stretchyrow, stretchycol int + widths, heights [][]int // caches to avoid reallocating each time + rowheights, colwidths []int } // NewGrid creates a new Grid with the given Controls. @@ -34,7 +34,7 @@ type Grid struct { // control10, control11, control12, // control20, control21, control22) func NewGrid(nPerRow int, controls ...Control) *Grid { - if len(controls) % nPerRow != 0 { + if len(controls)%nPerRow != 0 { panic(fmt.Errorf("incomplete grid given to NewGrid() (not enough controls to evenly divide %d controls into rows of %d controls each)", len(controls), nPerRow)) } nRows := len(controls) / nPerRow @@ -54,14 +54,14 @@ func NewGrid(nPerRow int, controls ...Control) *Grid { } } return &Grid{ - controls: cc, - filling: cf, - stretchyrow: -1, - stretchycol: -1, - widths: cw, - heights: ch, - rowheights: make([]int, nRows), - colwidths: make([]int, nPerRow), + controls: cc, + filling: cf, + stretchyrow: -1, + stretchycol: -1, + widths: cw, + heights: ch, + rowheights: make([]int, nRows), + colwidths: make([]int, nPerRow), } } @@ -108,7 +108,7 @@ func (g *Grid) make(window *sysData) error { // commit filling for the stretchy control now (see SetStretchy() above) if g.stretchyrow != -1 && g.stretchycol != -1 { g.filling[g.stretchyrow][g.stretchycol] = true - } else if (g.stretchyrow == -1 && g.stretchycol != -1) || // sanity check + } else if (g.stretchyrow == -1 && g.stretchycol != -1) || // sanity check (g.stretchyrow != -1 && g.stretchycol == -1) { panic(fmt.Errorf("internal inconsistency in Grid: stretchy (%d,%d) impossible (one component, not both, is -1/no stretchy control) in Grid.make()", g.stretchyrow, g.stretchycol)) } |
