layout-system.md 2.5 KB

Layout system

Intermediate Programmer Designer

The Stride UI layout system is similar to Windows Presentation Foundation (WPF). For more information about the WPF layout system, see the MSDN documentation. Much of the WPF documentation also applies to the Stride layout system.

Every @'Stride.UI.UIElement' in the Stride UI system has a surrounding rectangle used in layouts. Stride computes layouts according to the @'Stride.UI.UIElement' requirement, available screen space, constraints, margins, padding, and the special behavior of @'Stride.UI.Panels.Panel' elements (which arrange children in specific ways).

Processing this data recursively, the layout system computes a position and size for every @'Stride.UI.UIElement' in the UI system.

Measure and arrange

Stride performs the layout process recursively in two passes: Measure and Arrange.

Measure

In the Measure pass, each element recursively computes its DesiredSize according to the properties you set, such as @'Stride.UI.UIElement.Width', @'Stride.UI.UIElement.Height', and @'Stride.UI.UIElement.Margin'.

Some @'Stride.UI.Panels.Panel' elements call Measure recursively to determine the DesiredSize of their children, and act accordingly.

Arrange

The Arrange pass arranges the elements, taking into account:

  • @'Stride.UI.UIElement.Margin'
  • @'Stride.UI.UIElement.Width'
  • @'Stride.UI.UIElement.Height'
  • @'Stride.UI.UIElement.HorizontalAlignment'
  • @'Stride.UI.UIElement.VerticalAlignment'
  • @'Stride.UI.Panels.Panel'
  • specific Arrange rules

See also