Table of Contents

Class CanvasLayout

Namespace
MagicUI.Elements
Assembly
MagicUI.dll

A layout that places elements absolutely in screen space.

public class CanvasLayout : Layout, ILayoutParent
Inheritance
CanvasLayout
Implements
Inherited Members
Extension Methods

Remarks

Usually this is not a very idiomatic way to use MagicUI, but is helpful in the rare cases where you just need to move things around by hand. One particularly good use case for this is to ease migrations for people who have existing CanvasUtil UIs and want to migrate to create more complex layouts.

This layout has some unusual properties to be aware of compared to other elements:

  • Because this layout will request to fill the entire screen, it may create unexpected results if it is set as the child of another element, and changing its alignment and padding may result in children being placed off-screen
  • The alignment of children will not have any effect, as it will be arranged at its offset with exactly its effective size
  • The right and bottom paddings of children will not have any effect. It's recommended to use XOffset and YOffset attached properties instead of padding to position children.

Constructors

CanvasLayout(LayoutRoot, string)

Creates a canvas layout

public CanvasLayout(LayoutRoot onLayout, string name = "New CanvasLayout")

Parameters

onLayout LayoutRoot

The layout root to draw the stack layout on

name string

The name of the stack layout

Fields

XOffset

The child's X offset in the canvas

public static AttachedProperty<float> XOffset

Field Value

AttachedProperty<float>

YOffset

The child's Y offset in the canvas

public static AttachedProperty<float> YOffset

Field Value

AttachedProperty<float>

Methods

ArrangeOverride(Vector2)

Internal implementation to position the object within the allocated space.

protected override void ArrangeOverride(Vector2 alignedTopLeftCorner)

Parameters

alignedTopLeftCorner Vector2

The space available for the element.

DestroyOverride()

Internal implementation to perform any additional cleanup when the element is destroyed

protected override void DestroyOverride()

MeasureOverride()

Internal implementation to calculate desired size.

protected override Vector2 MeasureOverride()

Returns

Vector2