API ReferenceSandbox.UI

Lengthclass

A variable unit based length. ie, could be a percentage or a pixel length. This is commonly used to express the size of things in UI space, usually coming from style sheets.

object→Length
Namespace
Sandbox.UI
Assembly
Sandbox.System
Declaration
public sealed struct Sandbox.UI.Length

Methods13

Showing 13 methods

public static System.Nullable`1<Sandbox.UI.Length> Calc(string expression)PUBLICSTATIC

Create a length based on a css calc expression

ParameterTypeDescription
expressionstring—
Returns:Nullable<Length>—

public static Sandbox.UI.Length Em(float value)PUBLICSTATIC

Create a length based on the font size of the current element.

ParameterTypeDescription
valuefloatValue in em
Returns:LengthA new length

public static System.Nullable`1<Sandbox.UI.Length> Fraction(float fraction)PUBLICSTATIC

Create a length in percents

ParameterTypeDescription
fractionfloatThe fraction of a percent (0 = 0%, 1 = 100%)
Returns:Nullable<Length>A new length

public static System.Nullable`1<Sandbox.UI.Length> Parse(string value)PUBLICSTATIC

Parse a length. This is used by the stylesheet parsing system.

ParameterTypeDescription
valuestringA length represented by a string
Returns:Nullable<Length>—

Example

Built-in examples define the default contract and should be read first.

public static System.Nullable`1<Sandbox.UI.Length> Percent(float percent)PUBLICSTATIC

Create a length in percents

ParameterTypeDescription
percentfloatThe amount of percent for this (0-100)
Returns:Nullable<Length>A new length

public static System.Nullable`1<Sandbox.UI.Length> Pixels(float pixels)PUBLICSTATIC

Create a length in pixels

ParameterTypeDescription
pixelsfloatThe amount of pixels for this length
Returns:Nullable<Length>A new length

public static Sandbox.UI.Length Rem(float value)PUBLICSTATIC

Create a length based on the font size of the root element.

ParameterTypeDescription
valuefloatValue in rem
Returns:LengthA new length

public static System.Nullable`1<Sandbox.UI.Length> ViewHeight(float percentage)PUBLICSTATIC

Create a length based on the view height

ParameterTypeDescription
percentagefloatThe amount of percent for this (0-100)
Returns:Nullable<Length>A new length

public static System.Nullable`1<Sandbox.UI.Length> ViewMax(float percentage)PUBLICSTATIC

Create a length based on the longest edge of the screen size

ParameterTypeDescription
percentagefloatThe amount of percent for this (0-100)
Returns:Nullable<Length>A new length

public static System.Nullable`1<Sandbox.UI.Length> ViewMin(float percentage)PUBLICSTATIC

Create a length based on the shortest edge of the screen size

ParameterTypeDescription
percentagefloatThe amount of percent for this (0-100)
Returns:Nullable<Length>A new length

public static System.Nullable`1<Sandbox.UI.Length> ViewWidth(float percentage)PUBLICSTATIC

Create a length based on the view width

ParameterTypeDescription
percentagefloatThe amount of percent for this (0-100)
Returns:Nullable<Length>A new length

Properties4

Showing 4 properties

public static Sandbox.UI.Length Sandbox.UI.Length.Auto { get; set; }PUBLICSTATICGETSET

Quickly create a Length with Unit set to LengthUnit.Auto

Returns:Length—

public static Sandbox.UI.Length Sandbox.UI.Length.Contain { get; set; }PUBLICSTATICGETSET

Quickly create a Length with Unit set to LengthUnit.Contain

Returns:Length—

public static Sandbox.UI.Length Sandbox.UI.Length.Cover { get; set; }PUBLICSTATICGETSET

Quickly create a Length with Unit set to LengthUnit.Cover

Returns:Length—

On this page