Fix grid creating too large subcontexts
The grid was not checking there was enough space for the cells so would just attempt to create subcontexts that don't actually fit. This attempts to use the remaining space and then if there is no space then it just skips drawing this cell.
This commit is contained in:
parent
2f626ddd18
commit
1cf90897f7
1 changed files with 9 additions and 0 deletions
|
@ -127,6 +127,15 @@ func (grid *Grid) Draw(ctx *Context) {
|
||||||
for _, row := range rows {
|
for _, row := range rows {
|
||||||
height += row.Size
|
height += row.Size
|
||||||
}
|
}
|
||||||
|
if x+width > ctx.Width() {
|
||||||
|
width = ctx.Width() - x
|
||||||
|
}
|
||||||
|
if y+height > ctx.Height() {
|
||||||
|
height = ctx.Height() - y
|
||||||
|
}
|
||||||
|
if width <= 0 || height <= 0 {
|
||||||
|
continue
|
||||||
|
}
|
||||||
subctx := ctx.Subcontext(x, y, width, height)
|
subctx := ctx.Subcontext(x, y, width, height)
|
||||||
cell.Content.Draw(subctx)
|
cell.Content.Draw(subctx)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue