don't re-calculate values in loops for layouts

This commit is contained in:
Drew Weymouth
2023-05-03 09:09:13 -07:00
parent fd01e37260
commit e486fcddad
5 changed files with 16 additions and 10 deletions
+4 -2
View File
@@ -26,11 +26,13 @@ func (c *MaxPadLayout) Layout(objects []fyne.CanvasObject, size fyne.Size) {
if len(objects) == 0 {
return
}
pos := fyne.NewPos(c.PadLeft, c.PadTop)
objSize := fyne.NewSize(size.Width-c.PadLeft-c.PadRight, size.Height-c.PadTop-c.PadBottom)
for _, child := range objects {
if !child.Visible() {
continue
}
child.Move(fyne.NewPos(c.PadLeft, c.PadTop))
child.Resize(fyne.NewSize(size.Width-c.PadLeft-c.PadRight, size.Height-c.PadTop-c.PadBottom))
child.Move(pos)
child.Resize(objSize)
}
}