misc: Port latest Fyne layout changes
Specific commits ported, to update the layouts and reduce differences with upstream Fyne code: * https://github.com/fyne-io/fyne/commit/a9a66f60d2167d7945bcf7718a781335541317c0 * https://github.com/fyne-io/fyne/commit/2cde868904092382ca5f645802ee9d444d8ae6e8 * https://github.com/fyne-io/fyne/commit/99fa7e3a7dc83dd273ad366cc7d336a1e1cee5f6 * https://github.com/fyne-io/fyne/commit/4ea8a5762f1744401ede9f7bd35b3b75890f925e
This commit is contained in:
@@ -86,17 +86,18 @@ func (g *gridLayout) Layout(objects []fyne.CanvasObject, size fyne.Size) {
|
||||
rows := g.countRows(objects)
|
||||
|
||||
padding := theme.Padding() + g.Padding
|
||||
padWidth := float32(g.Cols-1) * padding
|
||||
padHeight := float32(rows-1) * padding
|
||||
cellWidth := float64(size.Width-padWidth) / float64(g.Cols)
|
||||
cellHeight := float64(size.Height-padHeight) / float64(rows)
|
||||
|
||||
if !g.horizontal() {
|
||||
padWidth, padHeight = padHeight, padWidth
|
||||
cellWidth = float64(size.Width-padWidth) / float64(rows)
|
||||
cellHeight = float64(size.Height-padHeight) / float64(g.Cols)
|
||||
primaryObjects := rows
|
||||
secondaryObjects := g.Cols
|
||||
if g.horizontal() {
|
||||
primaryObjects, secondaryObjects = secondaryObjects, primaryObjects
|
||||
}
|
||||
|
||||
padWidth := float32(primaryObjects-1) * padding
|
||||
padHeight := float32(secondaryObjects-1) * padding
|
||||
cellWidth := float64(size.Width-padWidth) / float64(primaryObjects)
|
||||
cellHeight := float64(size.Height-padHeight) / float64(secondaryObjects)
|
||||
|
||||
row, col := 0, 0
|
||||
i := 0
|
||||
for _, child := range objects {
|
||||
@@ -147,11 +148,17 @@ func (g *gridLayout) MinSize(objects []fyne.CanvasObject) fyne.Size {
|
||||
}
|
||||
|
||||
padding := theme.Padding() + g.Padding
|
||||
|
||||
primaryObjects := rows
|
||||
secondaryObjects := g.Cols
|
||||
if g.horizontal() {
|
||||
minContentSize := fyne.NewSize(minSize.Width*float32(g.Cols), minSize.Height*float32(rows))
|
||||
return minContentSize.Add(fyne.NewSize(padding*fyne.Max(float32(g.Cols-1), 0), padding*fyne.Max(float32(rows-1), 0)))
|
||||
primaryObjects, secondaryObjects = secondaryObjects, primaryObjects
|
||||
}
|
||||
|
||||
minContentSize := fyne.NewSize(minSize.Width*float32(rows), minSize.Height*float32(g.Cols))
|
||||
return minContentSize.Add(fyne.NewSize(padding*fyne.Max(float32(rows-1), 0), padding*fyne.Max(float32(g.Cols-1), 0)))
|
||||
width := minSize.Width * float32(primaryObjects)
|
||||
height := minSize.Height * float32(secondaryObjects)
|
||||
xpad := padding * fyne.Max(float32(primaryObjects-1), 0)
|
||||
ypad := padding * fyne.Max(float32(secondaryObjects-1), 0)
|
||||
|
||||
return fyne.NewSize(width+xpad, height+ypad)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user