net.kernelpanicsoft.archie.gui.layout¶
Types¶
AbsoluteAlignment¶
object AbsoluteAlignment
A collection of common Alignments unaware of the layout direction.
Alignment¶
@Stable
fun interface Alignment
An interface to calculate the position of a sized box inside an available space. Alignment is often used to define the alignment of a layout inside a parent layout.
Arrangement¶
@Immutable
object Arrangement
Used to specify the arrangement of the layout's children in layouts like Row or Column in the main axis direction (horizontal and vertical, respectively).
BiasAbsoluteAlignment¶
@Immutable
data class BiasAbsoluteAlignment(horizontalBias: Float, verticalBias: Float) : Alignment
An Alignment specified by bias: for example, a bias of -1 represents alignment to the left/top, a bias of 0 will represent centering, and a bias of 1 will represent right/bottom. Any value can be specified to obtain an alignment. Inside the -1, 1 range, the obtained alignment will position the aligned size fully inside the available space, while outside the range it will the aligned size will be positioned partially or completely outside.
BiasAlignment¶
@Immutable
data class BiasAlignment(val horizontalBias: Float, val verticalBias: Float) : Alignment
An Alignment specified by bias: for example, a bias of -1 represents alignment to the start/top, a bias of 0 will represent centering, and a bias of 1 will represent end/bottom. Any value can be specified to obtain an alignment. Inside the -1, 1 range, the obtained alignment will position the aligned size fully inside the available space, while outside the range it will the aligned size will be positioned partially or completely outside.
BoxMeasurePolicy¶
data class BoxMeasurePolicy(alignment: Alignment) : RowColumnMeasurePolicy
ColumnMeasurePolicy¶
data class ColumnMeasurePolicy(verticalArrangement: Arrangement.Vertical, horizontalAlignment: Alignment.Horizontal) : RowColumnMeasurePolicy
Dp¶
A density-independent pixel unit used throughout the layout system. Currently an alias for Int since GUI measurements map 1:1 to Minecraft GUI pixels (no separate density scaling).
IntCoordinates¶
@JvmInline
@Serializable
value class IntCoordinates(val pair: Long)
A 2D integer coordinate pair, packed into a single Long (x in the high 32 bits, y in the low 32 bits) to avoid boxing allocations. Also aliased as IntOffset when used to represent a relative displacement rather than an absolute position.
IntOffset¶
typealias IntOffset = IntCoordinates
An IntCoordinates used to represent a relative displacement rather than an absolute position.
IntRect¶
An axis-aligned integer rectangle described by its min/max bounds along each axis, rather than an origin and a size. Used for hit-testing and clip/overlap calculations (e.g. scissor regions).
IntSize¶
An integer width/height pair, packed into a single Long (width in the high 32 bits, height in the low 32 bits) to avoid boxing allocations.
LayoutDirection¶
enum LayoutDirection : Enum<LayoutDirection>
A class for defining layout directions.
LayoutNode¶
class LayoutNode(nodeName: String = "LayoutNode") : Measurable, Placeable, UINode, MeasureScope
The concrete node type that forms Archie's UI scene graph.
Measurable¶
interface Measurable
A node that can participate in a layout pass by returning a Placeable.
MeasurePolicy¶
@Stable
fun interface MeasurePolicy
Defines how a LayoutNode measures itself and its children.
MeasureResult¶
data class MeasureResult(
val width: Int,
val height: Int,
val placer: Placer
)
The result of a MeasurePolicy.measure call, containing the intrinsic dimensions of the node and a Placer that positions child nodes within those bounds.
MeasureScope¶
interface MeasureScope
Marker interface implemented by LayoutNode and passed as the first argument to MeasurePolicy.measure. Measure policies may cast this to LayoutNode to access node-level properties such as padding or margin modifiers during layout.
Placeable¶
interface Placeable
The result of measuring a node, which can subsequently be positioned via placeAt.
Placer¶
@Stable
fun interface Placer
A deferred child-placement action returned inside a MeasureResult.
Renderer¶
@Stable
interface Renderer
Defines the rendering behaviour of a LayoutNode.
RowColumnMeasurePolicy¶
abstract class RowColumnMeasurePolicy(
val sumWidth: Boolean = false,
val sumHeight: Boolean = false,
val arrangementSpacing: Int = 0
) : MeasurePolicy
Base MeasurePolicy for Row and Column layouts.
RowMeasurePolicy¶
data class RowMeasurePolicy(horizontalArrangement: Arrangement.Horizontal, verticalAlignment: Alignment.Vertical) : RowColumnMeasurePolicy
Size¶
An integer width/height pair. Unlike IntSize, this is a regular data class (not an inline value class), which makes it convenient where a boxed, nullable, or default-constructed size is needed, e.g. component configuration.
Properties¶
dp¶
Converts this Int to a Dp value. Provided so measurements read naturally at call sites, e.g. 16.dp, mirroring Compose's Dp API even though no unit conversion currently happens.
EmptyRenderer¶
val EmptyRenderer: Renderer
A Renderer that performs no drawing — the default for layout-only nodes.
Functions¶
Box¶
A layout composable that stacks its children on top of each other, aligned within its bounds.
Column¶
@Composable
fun Column(
modifier: Modifier = Modifier,
verticalArrangement: Arrangement.Vertical = Arrangement.Top,
horizontalAlignment: Alignment.Horizontal = Alignment.Start,
content: @Composable
() -> Unit
)
A layout composable that arranges its children in a vertical sequence from top to bottom.
Layout¶
The fundamental building block for creating custom Compose-based UI elements in Archie.
offset¶
pos¶
fun pos(x: Int, y: Int): IntCoordinates
Creates an IntCoordinates at the given x, y position.
Row¶
@Composable
fun Row(
modifier: Modifier = Modifier,
horizontalArrangement: Arrangement.Horizontal = Arrangement.Start,
verticalAlignment: Alignment.Vertical = Alignment.Top,
content: @Composable
() -> Unit
)
A layout composable that arranges its children in a horizontal sequence from left to right.