Table of Contents

Class ElementBounds

Namespace
Vintagestory.API.Client
Assembly
VintagestoryAPI.dll

Box sizing model comparable to the box sizing model of cascading style sheets using "position:relative;" Each element has a position, size, padding and margin Padding is counted towards the size of the box, whereas margin is not

public class ElementBounds
Inheritance
ElementBounds
Inherited Members

Constructors

ElementBounds()

public ElementBounds()

Fields

Alignment

public EnumDialogArea Alignment

Field Value

EnumDialogArea

ChildBounds

public List<ElementBounds> ChildBounds

Field Value

List<ElementBounds>

Code

For debugging purposes only

public string Code

Field Value

string

Initialized

public bool Initialized

Field Value

bool

IsDrawingSurface

If set, bgDrawX/Y will be relative, instead of absolute

public bool IsDrawingSurface

Field Value

bool

IsWindowBounds

protected bool IsWindowBounds

Field Value

bool

LeftOfBounds

public ElementBounds LeftOfBounds

Field Value

ElementBounds

Name

public string Name

Field Value

string

ParentBounds

public ElementBounds ParentBounds

Field Value

ElementBounds

absFixedX

public double absFixedX

Field Value

double

absFixedY

public double absFixedY

Field Value

double

absInnerHeight

public double absInnerHeight

Field Value

double

absInnerWidth

public double absInnerWidth

Field Value

double

absMarginX

public double absMarginX

Field Value

double

absMarginY

public double absMarginY

Field Value

double

absOffsetX

public double absOffsetX

Field Value

double

absOffsetY

public double absOffsetY

Field Value

double

absPaddingX

public double absPaddingX

Field Value

double

absPaddingY

public double absPaddingY

Field Value

double

fixedHeight

public double fixedHeight

Field Value

double

fixedMarginX

public double fixedMarginX

Field Value

double

fixedMarginY

public double fixedMarginY

Field Value

double

fixedOffsetX

public double fixedOffsetX

Field Value

double

fixedOffsetY

public double fixedOffsetY

Field Value

double

fixedPaddingX

public double fixedPaddingX

Field Value

double

fixedPaddingY

public double fixedPaddingY

Field Value

double

fixedWidth

public double fixedWidth

Field Value

double

fixedX

public double fixedX

Field Value

double

fixedY

public double fixedY

Field Value

double

horizontalSizing

public ElementSizing horizontalSizing

Field Value

ElementSizing

percentHeight

public double percentHeight

Field Value

double

percentPaddingX

public double percentPaddingX

Field Value

double

percentPaddingY

public double percentPaddingY

Field Value

double

percentWidth

public double percentWidth

Field Value

double

percentX

public double percentX

Field Value

double

percentY

public double percentY

Field Value

double

renderOffsetX

public double renderOffsetX

Field Value

double

renderOffsetY

public double renderOffsetY

Field Value

double

verticalSizing

public ElementSizing verticalSizing

Field Value

ElementSizing

Properties

BothSizing

Set the vertical and horizontal sizing, see also ElementSizing. Setting this is equal to calling WithSizing(ElementSizing)

public ElementSizing BothSizing { set; }

Property Value

ElementSizing

Empty

Create a special instance of type ElementEmptyBounds whose position is 0 and size 1. It's often used for other bounds that need a static, unchanging parent bounds

public static ElementBounds Empty { get; }

Property Value

ElementBounds

Fill

Quick Method to create a new ElementBounds instance that fills 100% of its parent bounds. Useful for backgrounds.

public static ElementBounds Fill { get; }

Property Value

ElementBounds

InnerHeight

public virtual double InnerHeight { get; }

Property Value

double

InnerWidth

public virtual double InnerWidth { get; }

Property Value

double

OuterHeight

Height including padding

public virtual double OuterHeight { get; }

Property Value

double

OuterHeightInt

public virtual int OuterHeightInt { get; }

Property Value

int

OuterWidth

Width including padding

public virtual double OuterWidth { get; }

Property Value

double

OuterWidthInt

public virtual int OuterWidthInt { get; }

Property Value

int

RequiresRecalculation

public virtual bool RequiresRecalculation { get; }

Property Value

bool

absX

Absolute position of the element plus margin. Same as renderX but without padding

public virtual double absX { get; }

Property Value

double

absY

public virtual double absY { get; }

Property Value

double

bgDrawX

Position where the background has to be drawn, this encompasses the elements padding

public virtual double bgDrawX { get; }

Property Value

double

bgDrawY

public virtual double bgDrawY { get; }

Property Value

double

drawX

Position where the element has to be drawn. This is a position relative to it's parent element plus margin plus padding.

public virtual double drawX { get; }

Property Value

double

drawY

public virtual double drawY { get; }

Property Value

double

relX

Position relative to it's parent element plus margin

public virtual double relX { get; }

Property Value

double

relY

public virtual double relY { get; }

Property Value

double

renderX

public virtual double renderX { get; }

Property Value

double

renderY

public virtual double renderY { get; }

Property Value

double

Methods

BelowCopy(double, double, double, double)

Makes a copy of the current bounds but leaves the position and padding at 0. Sets the same parent as the current one.

public ElementBounds BelowCopy(double fixedDeltaX = 0, double fixedDeltaY = 0, double fixedDeltaWidth = 0, double fixedDeltaHeight = 0)

Parameters

fixedDeltaX double
fixedDeltaY double
fixedDeltaWidth double
fixedDeltaHeight double

Returns

ElementBounds

CalcWorldBounds()

public virtual void CalcWorldBounds()

CopyOffsetedSibling(double, double, double, double)

Makes a copy of the current bounds but leaves the position and padding at 0. Sets the same parent as the current one.

public ElementBounds CopyOffsetedSibling(double fixedDeltaX = 0, double fixedDeltaY = 0, double fixedDeltaWidth = 0, double fixedDeltaHeight = 0)

Parameters

fixedDeltaX double
fixedDeltaY double
fixedDeltaWidth double
fixedDeltaHeight double

Returns

ElementBounds

CopyOnlySize()

Makes a copy of the current bounds but leaves the position and 0. Sets the parent to the calling bounds

public ElementBounds CopyOnlySize()

Returns

ElementBounds

Fixed(double, double, double, double)

Quick method to create new ElementsBounds instance that uses fixed element sizing.

public static ElementBounds Fixed(double fixedX, double fixedY, double fixedWidth, double fixedHeight)

Parameters

fixedX double
fixedY double
fixedWidth double
fixedHeight double

Returns

ElementBounds

Fixed(int, int)

Create a new ElementBounds instance with given fixed x/y position and width/height 0

public static ElementBounds Fixed(int fixedX, int fixedY)

Parameters

fixedX int
fixedY int

Returns

ElementBounds

Fixed(EnumDialogArea, double, double, double, double)

Quick method to create new ElementsBounds instance that uses fixed element sizing.

public static ElementBounds Fixed(EnumDialogArea alignment, double fixedX, double fixedY, double fixedWidth, double fixedHeight)

Parameters

alignment EnumDialogArea
fixedX double
fixedY double
fixedWidth double
fixedHeight double

Returns

ElementBounds

FixedGrow(double)

Grows the current width/height by a fixed value

public ElementBounds FixedGrow(double amount)

Parameters

amount double

Returns

ElementBounds

FixedGrow(double, double)

Grows the current width/height by a fixed value

public ElementBounds FixedGrow(double width, double height)

Parameters

width double
height double

Returns

ElementBounds

FixedLeftOf(ElementBounds, double)

Set the fixed x-position to "refBounds.fixedX - fixedWith - rightSpacing" so that the element will be left of reference bounds

public ElementBounds FixedLeftOf(ElementBounds refBounds, double rightSpacing = 0)

Parameters

refBounds ElementBounds
rightSpacing double

Returns

ElementBounds

FixedOffseted(EnumDialogArea, double, double, double, double)

Quick method to create new ElementsBounds instance that uses fixed element sizing.

public static ElementBounds FixedOffseted(EnumDialogArea alignment, double fixedOffsetX, double fixedOffsetY, double fixedWidth, double fixedHeight)

Parameters

alignment EnumDialogArea
fixedOffsetX double
fixedOffsetY double
fixedWidth double
fixedHeight double

Returns

ElementBounds

FixedPos(EnumDialogArea, double, double)

public static ElementBounds FixedPos(EnumDialogArea alignment, double fixedX, double fixedY)

Parameters

alignment EnumDialogArea
fixedX double
fixedY double

Returns

ElementBounds

FixedRightOf(ElementBounds, double)

Set the fixed x-position to "refBounds.fixedX + refBounds.fixedWidth + leftSpacing" so that the bounds will be right of reference bounds

public ElementBounds FixedRightOf(ElementBounds refBounds, double leftSpacing = 0)

Parameters

refBounds ElementBounds
leftSpacing double

Returns

ElementBounds

FixedShrink(double)

Shrinks the current width/height by a fixed value

public ElementBounds FixedShrink(double amount)

Parameters

amount double

Returns

ElementBounds

FixedSize(double, double)

Quick method to create a new ElementBounds instance that uses fixed element sizing. The X/Y Coordinates are left at 0.

public static ElementBounds FixedSize(double fixedWidth, double fixedHeight)

Parameters

fixedWidth double
fixedHeight double

Returns

ElementBounds

FixedSize(EnumDialogArea, double, double)

Quick method to create a new ElementBounds instance that uses fixed element sizing. The X/Y Coordinates are left at 0.

public static ElementBounds FixedSize(EnumDialogArea alignment, double fixedWidth, double fixedHeight)

Parameters

alignment EnumDialogArea
fixedWidth double
fixedHeight double

Returns

ElementBounds

FixedUnder(ElementBounds, double)

Set the fixed y-position to "refBounds.fixedY + refBounds.fixedHeight + spacing" so that the bounds will be under the reference bounds

public ElementBounds FixedUnder(ElementBounds refBounds, double spacing = 0)

Parameters

refBounds ElementBounds
spacing double

Returns

ElementBounds

FlatCopy()

Creates a clone of the bounds but without child elements

public ElementBounds FlatCopy()

Returns

ElementBounds

ForkBoundingParent(double, double, double, double)

Creates a new elements bounds which acts as the parent bounds of the current bounds. It will also arrange the fixedX/Y and Width/Height coords of both bounds so that the parent bounds surrounds the child bounds with given spacings. Uses fixed coords only!

public ElementBounds ForkBoundingParent(double leftSpacing = 0, double topSpacing = 0, double rightSpacing = 0, double bottomSpacing = 0)

Parameters

leftSpacing double
topSpacing double
rightSpacing double
bottomSpacing double

Returns

ElementBounds

ForkChild()

public ElementBounds ForkChild()

Returns

ElementBounds

ForkChildOffseted(double, double, double, double)

public ElementBounds ForkChildOffseted(double fixedDeltaX = 0, double fixedDeltaY = 0, double fixedDeltaWidth = 0, double fixedDeltaHeight = 0)

Parameters

fixedDeltaX double
fixedDeltaY double
fixedDeltaWidth double
fixedDeltaHeight double

Returns

ElementBounds

ForkContainingChild(double, double, double, double)

Creates a new elements bounds which acts as the child bounds of the current bounds. It will also arrange the fixedX/Y and Width/Height coords of both bounds so that the parent bounds surrounds the child bounds with given spacings. Uses fixed coords only!

public ElementBounds ForkContainingChild(double leftSpacing = 0, double topSpacing = 0, double rightSpacing = 0, double bottomSpacing = 0)

Parameters

leftSpacing double
topSpacing double
rightSpacing double
bottomSpacing double

Returns

ElementBounds

MarkDirtyRecursive()

public void MarkDirtyRecursive()

PartiallyInside(ElementBounds)

Checks if the bounds is at least partially inside it's parent bounds by checking if any of the 4 corner points is inside

public bool PartiallyInside(ElementBounds boundingBounds)

Parameters

boundingBounds ElementBounds

Returns

bool

Percentual(double, double, double, double)

Quick method to create new ElementsBounds instance that uses percentual element sizing, e.g. setting percentWidth to 0.5 will set the width of the bounds to 50% of its parent width

public static ElementBounds Percentual(double percentX, double percentY, double percentWidth, double percentHeight)

Parameters

percentX double
percentY double
percentWidth double
percentHeight double

Returns

ElementBounds

Percentual(EnumDialogArea, double, double)

Quick method to create new ElementsBounds instance that uses percentual element sizing, e.g. setting percentWidth to 0.5 will set the width of the bounds to 50% of its parent width

public static ElementBounds Percentual(EnumDialogArea alignment, double percentWidth, double percentHeight)

Parameters

alignment EnumDialogArea
percentWidth double
percentHeight double

Returns

ElementBounds

PointInside(double, double)

Returns true if supplied coordinate is inside the bounds

public bool PointInside(double absPointX, double absPointY)

Parameters

absPointX double
absPointY double

Returns

bool

PointInside(int, int)

Returns true if supplied coordinate is inside the bounds

public bool PointInside(int absPointX, int absPointY)

Parameters

absPointX int
absPointY int

Returns

bool

PositionInside(int, int)

Returns the relative coordinate if supplied coordinate is inside the bounds, otherwise null

public Vec2d PositionInside(int absPointX, int absPointY)

Parameters

absPointX int
absPointY int

Returns

Vec2d

RightCopy(double, double, double, double)

Create a flat copy of the element with a fixed position offset that causes it to be right of the original element

public ElementBounds RightCopy(double fixedDeltaX = 0, double fixedDeltaY = 0, double fixedDeltaWidth = 0, double fixedDeltaHeight = 0)

Parameters

fixedDeltaX double
fixedDeltaY double
fixedDeltaWidth double
fixedDeltaHeight double

Returns

ElementBounds

RightOf(ElementBounds, double)

public ElementBounds RightOf(ElementBounds leftBounds, double leftMargin = 0)

Parameters

leftBounds ElementBounds
leftMargin double

Returns

ElementBounds

ToString()

Returns a string that represents the current object.

public override string ToString()

Returns

string

A string that represents the current object.

WithAlignment(EnumDialogArea)

Set the alignment property

public ElementBounds WithAlignment(EnumDialogArea alignment)

Parameters

alignment EnumDialogArea

Returns

ElementBounds

WithChild(ElementBounds)

public ElementBounds WithChild(ElementBounds bounds)

Parameters

bounds ElementBounds

Returns

ElementBounds

WithChildren(params ElementBounds[])

public ElementBounds WithChildren(params ElementBounds[] bounds)

Parameters

bounds ElementBounds[]

Returns

ElementBounds

WithEmptyParent()

Creates a new bounds using FitToChildren and sets that as bound parent. This is usefull if you want to draw elements that are not part of the dialog

public ElementBounds WithEmptyParent()

Returns

ElementBounds

WithFixedAlignmentOffset(double, double)

Sets a new fixed offset that is applied after element alignment. So you could i.e. horizontally center an element and then offset in x direction from there using this method.

public ElementBounds WithFixedAlignmentOffset(double x, double y)

Parameters

x double
y double

Returns

ElementBounds

WithFixedHeight(double)

Set the height property

public ElementBounds WithFixedHeight(double height)

Parameters

height double

Returns

ElementBounds

WithFixedMargin(double)

Sets a new fixed margin (pad = top/right/down/left margin)

public ElementBounds WithFixedMargin(double pad)

Parameters

pad double

Returns

ElementBounds

WithFixedMargin(double, double)

Sets a new fixed margin (pad = top/right/down/left margin)

public ElementBounds WithFixedMargin(double padH, double padV)

Parameters

padH double
padV double

Returns

ElementBounds

WithFixedOffset(double, double)

Sets a new fixed offset that is used during element alignment.

public ElementBounds WithFixedOffset(double offx, double offy)

Parameters

offx double
offy double

Returns

ElementBounds

WithFixedPadding(double)

Sets a new fixed padding (pad = top/right/down/left padding)

public ElementBounds WithFixedPadding(double pad)

Parameters

pad double

Returns

ElementBounds

WithFixedPadding(double, double)

Sets a new fixed padding (x = left/right, y = top/down padding)

public ElementBounds WithFixedPadding(double leftRight, double upDown)

Parameters

leftRight double
upDown double

Returns

ElementBounds

WithFixedPosition(double, double)

Sets a new fixed offset that is used during element alignment.

public ElementBounds WithFixedPosition(double x, double y)

Parameters

x double
y double

Returns

ElementBounds

WithFixedSize(double, double)

Set the fixed width and fixed height values

public ElementBounds WithFixedSize(double width, double height)

Parameters

width double
height double

Returns

ElementBounds

WithFixedWidth(double)

Set the width property

public ElementBounds WithFixedWidth(double width)

Parameters

width double

Returns

ElementBounds

WithParent(ElementBounds)

Sets the parent of the bounds

public ElementBounds WithParent(ElementBounds bounds)

Parameters

bounds ElementBounds

Returns

ElementBounds

WithScale(double)

public ElementBounds WithScale(double factor)

Parameters

factor double

Returns

ElementBounds

WithSizing(ElementSizing)

Set the vertical and horizontal sizing property to the same value. See also ElementSizing.

public ElementBounds WithSizing(ElementSizing sizing)

Parameters

sizing ElementSizing

Returns

ElementBounds

WithSizing(ElementSizing, ElementSizing)

Set the vertical and horizontal sizing properties individually. See also ElementSizing.

public ElementBounds WithSizing(ElementSizing horizontalSizing, ElementSizing verticalSizing)

Parameters

horizontalSizing ElementSizing
verticalSizing ElementSizing

Returns

ElementBounds

scaled(double)

public static double scaled(double value)

Parameters

value double

Returns

double