Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ContentScale ¶
type ContentScale interface {
// Scale returns the scale factor to apply to the source to fit the destination.
Scale(srcSize, dstSize layoutnode.LayoutDimensions) ScaleFactor
}
ContentScale defines how to scale the source content to fit the destination space.
var ( // ContentScaleNone maintains the source size. ContentScaleNone ContentScale = contentScaleFunc(func(srcSize, dstSize layoutnode.LayoutDimensions) ScaleFactor { return ScaleFactor{ScaleX: 1.0, ScaleY: 1.0} }) // ContentScaleFillBounds scales the source to fill the destination bounds, potentially changing the aspect ratio. ContentScaleFillBounds ContentScale = contentScaleFunc(func(srcSize, dstSize layoutnode.LayoutDimensions) ScaleFactor { return computeFillScale(srcSize, dstSize) }) // ContentScaleFillWidth scales the source to fill the destination width, maintaining the aspect ratio. ContentScaleFillWidth ContentScale = contentScaleFunc(func(srcSize, dstSize layoutnode.LayoutDimensions) ScaleFactor { return computeFillWidth(srcSize, dstSize) }) // ContentScaleFillHeight scales the source to fill the destination height, maintaining the aspect ratio. ContentScaleFillHeight ContentScale = contentScaleFunc(func(srcSize, dstSize layoutnode.LayoutDimensions) ScaleFactor { return computeFillHeight(srcSize, dstSize) }) // ContentScaleFit scales the source to fit within the destination bounds, maintaining the aspect ratio. // The source will be completely visible. ContentScaleFit ContentScale = contentScaleFunc(func(srcSize, dstSize layoutnode.LayoutDimensions) ScaleFactor { return computeFitScale(srcSize, dstSize) }) // ContentScaleCrop scales the source to fill the destination bounds, maintaining the aspect ratio. // The source may be cropped. ContentScaleCrop ContentScale = contentScaleFunc(func(srcSize, dstSize layoutnode.LayoutDimensions) ScaleFactor { return computeCropScale(srcSize, dstSize) }) // ContentScaleInside scales the source to fit within the destination bounds only if the source is larger than the destination. // Otherwise, it maintains the source size. ContentScaleInside ContentScale = contentScaleFunc(func(srcSize, dstSize layoutnode.LayoutDimensions) ScaleFactor { if srcSize.Size.X <= dstSize.Size.X && srcSize.Size.Y <= dstSize.Size.Y { return ScaleFactor{ScaleX: 1.0, ScaleY: 1.0} } return computeFitScale(srcSize, dstSize) }) )
type LayoutCoordinates ¶
type LayoutCoordinates interface {
// IsAttached returns true if the layout is currently attached to the composition.
IsAttached() bool
// Size returns the size of this layout in pixels.
Size() unit.IntSize
// PositionInRoot returns the position of this layout relative to the root.
PositionInRoot() geometry.Offset
// PositionInWindow returns the position of this layout in window coordinates.
PositionInWindow() geometry.Offset
// LocalPositionOf converts a position from another LayoutCoordinates to this one.
LocalPositionOf(sourceCoordinates LayoutCoordinates, relativeToSource geometry.Offset) geometry.Offset
// VisibleBounds returns the visible bounds of this layout in local coordinates.
VisibleBounds() geometry.Rect
// BoundsInWindow returns the bounds of this layout in window coordinates.
BoundsInWindow() geometry.Rect
}
LayoutCoordinates provides access to the position and size of a layout.
type ScaleFactor ¶
Click to show internal directories.
Click to hide internal directories.