package uilayout import "fyne.io/fyne/v2" // MinSize implements a min size layout. // // The MinSize layout will ensure that the container is rendered at a size that // is at least as large as the minimum size provided. type MinSize struct { minSize fyne.Size } // NewMinSizeLayout creates a new MinSize layout with the specified minimum size. // // Arguments: // - minSize: the minimum size for the layout. // // Returns *MinSize: a pointer to the newly created MinSize layout. func NewMinSizeLayout(minSize fyne.Size) *MinSize { return &MinSize{minSize: minSize} } // MinSize calculates the minimum size of the layout on the current screen. The // reported size will be at least as large as the configured minimum size. func (l *MinSize) MinSize(objects []fyne.CanvasObject) fyne.Size { size := l.minSize for _, o := range objects { childSize := o.MinSize() if size.Width < childSize.Width { size.Width = childSize.Width } if size.Height < childSize.Height { size.Height = childSize.Height } } return size } // Layout implements the Layout interface. func (l *MinSize) Layout(objects []fyne.CanvasObject, containerSize fyne.Size) { pos := fyne.NewPos(0, 0) for _, o := range objects { o.Resize(containerSize) o.Move(pos) } }