This repository has been archived on 2023-08-08. You can view files and clone it, but cannot push or open issues or pull requests.
tomo-old/layout.go
2023-01-16 11:54:02 -05:00

28 lines
1019 B
Go

package tomo
import "image"
// LayoutEntry associates an element with layout and positioning information so
// it can be arranged by a Layout.
type LayoutEntry struct {
Element
Position image.Point
Expand bool
}
// Layout is capable of arranging elements within a container. It is also able
// to determine the minimum amount of room it needs to do so.
type Layout interface {
// Arrange takes in a slice of entries and a bounding width and height,
// and changes the position of the entiries in the slice so that they
// are properly laid out. The given width and height should not be less
// than what is returned by MinimumSize.
Arrange (entries []LayoutEntry, width, height int)
// MinimumSize returns the minimum width and height that the layout
// needs to properly arrange the given slice of layout entries, given a
// "suqeeze" width so that the height can be determined for elements
// fulfilling the Expanding interface.
MinimumSize (entries []LayoutEntry, squeeze int) (width, height int)
}