Table of Contents

Class LayoutMath

Namespace
Icy.Design.Editor.Placement
Assembly
IcyUI.Design.dll

Margin and size arithmetic that follows how IcyUI arranges an element inside its slot.

public static class LayoutMath
Inheritance
LayoutMath
Inherited Members

Remarks

  • Left/Top: positioned at the start margin.
  • Right/Bottom: positioned against the end margin.
  • Center, and Stretch with an explicit size: centered in the slack, then offset by the start margin; the end margin is ignored.
  • Stretch with no size: fills the slot between both margins.

Methods

Kind(HorizontalAlignment, float)

Classifies an axis from its alignment and explicit size.

public static AxisKind Kind(HorizontalAlignment alignment, float size)

Parameters

alignment HorizontalAlignment

The horizontal alignment.

size float

The explicit width, or NaN.

Returns

AxisKind

The axis kind.

Kind(VerticalAlignment, float)

Classifies an axis from its alignment and explicit size.

public static AxisKind Kind(VerticalAlignment alignment, float size)

Parameters

alignment VerticalAlignment

The vertical alignment.

size float

The explicit height, or NaN.

Returns

AxisKind

The axis kind.

Move(UIElement, Thickness, int, int)

Gets the margin that moves element by (dx, dy) without changing its size.

public static Thickness Move(UIElement element, Thickness start, int dx, int dy)

Parameters

element UIElement

The element, for its alignment and explicit size.

start Thickness

The margin to move from.

dx int

The horizontal offset.

dy int

The vertical offset.

Returns

Thickness

The new margin.

ResizeAxis(AxisKind, int, int, int, int, bool, bool, bool)

Resizes one axis of an element by dragging its start or end edge.

public static AxisResize ResizeAxis(AxisKind kind, int startSize, int startMarginStart, int startMarginEnd, int delta, bool isStartEdge, bool anchored, bool sizeStretched = false)

Parameters

kind AxisKind

How the element is aligned on this axis.

startSize int

The element's size on this axis when the gesture started.

startMarginStart int

The start margin (left or top) when the gesture started.

startMarginEnd int

The end margin (right or bottom) when the gesture started.

delta int

How far the dragged edge moved, positive towards the end.

isStartEdge bool

Whether the start edge (left or top) is dragged.

anchored bool

true when the container anchors the element on this axis (a stack's stacking direction), so only the size changes, whatever the alignment.

sizeStretched bool

true when the container sizes its slot to the element on this axis (a stack's cross axis), so a Stretched element gets an explicit size instead of a margin: a margin can't grow a slot that follows the element.

Returns

AxisResize

The new size (null when the size isn't written) and margins.