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
- Extension Methods
Constructors
ElementBounds()
public ElementBounds()
Fields
Alignment
public EnumDialogArea Alignment
Field Value
AllowNoChildren
public bool AllowNoChildren
Field Value
ChildBounds
public List<ElementBounds> ChildBounds
Field Value
Code
For debugging purposes only
public string Code
Field Value
Initialized
public bool Initialized
Field Value
IsDrawingSurface
If set, bgDrawX/Y will be relative, instead of absolute
public bool IsDrawingSurface
Field Value
IsWindowBounds
protected bool IsWindowBounds
Field Value
LeftOfBounds
public ElementBounds LeftOfBounds
Field Value
Name
public string Name
Field Value
ParentBounds
public ElementBounds ParentBounds
Field Value
absFixedX
public double absFixedX
Field Value
absFixedY
public double absFixedY
Field Value
absInnerHeight
public double absInnerHeight
Field Value
absInnerWidth
public double absInnerWidth
Field Value
absMarginX
public double absMarginX
Field Value
absMarginY
public double absMarginY
Field Value
absOffsetX
public double absOffsetX
Field Value
absOffsetY
public double absOffsetY
Field Value
absPaddingX
public double absPaddingX
Field Value
absPaddingY
public double absPaddingY
Field Value
fixedHeight
public double fixedHeight
Field Value
fixedMarginX
public double fixedMarginX
Field Value
fixedMarginY
public double fixedMarginY
Field Value
fixedOffsetX
public double fixedOffsetX
Field Value
fixedOffsetY
public double fixedOffsetY
Field Value
fixedPaddingX
public double fixedPaddingX
Field Value
fixedPaddingY
public double fixedPaddingY
Field Value
fixedWidth
public double fixedWidth
Field Value
fixedX
public double fixedX
Field Value
fixedY
public double fixedY
Field Value
horizontalSizing
public ElementSizing horizontalSizing
Field Value
percentHeight
public double percentHeight
Field Value
percentPaddingX
public double percentPaddingX
Field Value
percentPaddingY
public double percentPaddingY
Field Value
percentWidth
public double percentWidth
Field Value
percentX
public double percentX
Field Value
percentY
public double percentY
Field Value
renderOffsetX
public double renderOffsetX
Field Value
renderOffsetY
public double renderOffsetY
Field Value
verticalSizing
public ElementSizing verticalSizing
Field Value
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
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
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
InnerHeight
public virtual double InnerHeight { get; }
Property Value
InnerWidth
public virtual double InnerWidth { get; }
Property Value
OuterHeight
Height including padding
public virtual double OuterHeight { get; }
Property Value
OuterHeightInt
public virtual int OuterHeightInt { get; }
Property Value
OuterWidth
Width including padding
public virtual double OuterWidth { get; }
Property Value
OuterWidthInt
public virtual int OuterWidthInt { get; }
Property Value
RequiresRecalculation
public virtual bool RequiresRecalculation { get; }
Property Value
absX
Absolute position of the element plus margin. Same as renderX but without padding
public virtual double absX { get; }
Property Value
absY
public virtual double absY { get; }
Property Value
bgDrawX
Position where the background has to be drawn, this encompasses the elements padding
public virtual double bgDrawX { get; }
Property Value
bgDrawY
public virtual double bgDrawY { get; }
Property Value
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
drawY
public virtual double drawY { get; }
Property Value
relX
Position relative to it's parent element plus margin
public virtual double relX { get; }
Property Value
relY
public virtual double relY { get; }
Property Value
renderX
public virtual double renderX { get; }
Property Value
renderY
public virtual double renderY { get; }
Property Value
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
Returns
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
Returns
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
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
Returns
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
Returns
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
EnumDialogAreafixedX
doublefixedY
doublefixedWidth
doublefixedHeight
double
Returns
FixedGrow(double)
Grows the current width/height by a fixed value
public ElementBounds FixedGrow(double amount)
Parameters
amount
double
Returns
FixedGrow(double, double)
Grows the current width/height by a fixed value
public ElementBounds FixedGrow(double width, double height)
Parameters
Returns
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
ElementBoundsrightSpacing
double
Returns
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
EnumDialogAreafixedOffsetX
doublefixedOffsetY
doublefixedWidth
doublefixedHeight
double
Returns
FixedPos(EnumDialogArea, double, double)
public static ElementBounds FixedPos(EnumDialogArea alignment, double fixedX, double fixedY)
Parameters
alignment
EnumDialogAreafixedX
doublefixedY
double
Returns
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
ElementBoundsleftSpacing
double
Returns
FixedShrink(double)
Shrinks the current width/height by a fixed value
public ElementBounds FixedShrink(double amount)
Parameters
amount
double
Returns
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
Returns
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
EnumDialogAreafixedWidth
doublefixedHeight
double
Returns
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
ElementBoundsspacing
double
Returns
FlatCopy()
Creates a clone of the bounds but without child elements
public ElementBounds FlatCopy()
Returns
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
Returns
ForkChild()
public ElementBounds ForkChild()
Returns
ForkChildOffseted(double, double, double, double)
public ElementBounds ForkChildOffseted(double fixedDeltaX = 0, double fixedDeltaY = 0, double fixedDeltaWidth = 0, double fixedDeltaHeight = 0)
Parameters
Returns
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
Returns
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
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
Returns
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
EnumDialogAreapercentWidth
doublepercentHeight
double
Returns
PointInside(double, double)
Returns true if supplied coordinate is inside the bounds
public bool PointInside(double absPointX, double absPointY)
Parameters
Returns
PointInside(int, int)
Returns true if supplied coordinate is inside the bounds
public bool PointInside(int absPointX, int absPointY)
Parameters
Returns
PositionInside(int, int)
Returns the relative coordinate if supplied coordinate is inside the bounds, otherwise null
public Vec2d PositionInside(int absPointX, int absPointY)
Parameters
Returns
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
Returns
RightOf(ElementBounds, double)
public ElementBounds RightOf(ElementBounds leftBounds, double leftMargin = 0)
Parameters
leftBounds
ElementBoundsleftMargin
double
Returns
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
WithChild(ElementBounds)
public ElementBounds WithChild(ElementBounds bounds)
Parameters
bounds
ElementBounds
Returns
WithChildren(params ElementBounds[])
public ElementBounds WithChildren(params ElementBounds[] bounds)
Parameters
bounds
ElementBounds[]
Returns
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
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
Returns
WithFixedHeight(double)
Set the height property
public ElementBounds WithFixedHeight(double height)
Parameters
height
double
Returns
WithFixedMargin(double)
Sets a new fixed margin (pad = top/right/down/left margin)
public ElementBounds WithFixedMargin(double pad)
Parameters
pad
double
Returns
WithFixedMargin(double, double)
Sets a new fixed margin (pad = top/right/down/left margin)
public ElementBounds WithFixedMargin(double padH, double padV)
Parameters
Returns
WithFixedOffset(double, double)
Sets a new fixed offset that is used during element alignment.
public ElementBounds WithFixedOffset(double offx, double offy)
Parameters
Returns
WithFixedPadding(double)
Sets a new fixed padding (pad = top/right/down/left padding)
public ElementBounds WithFixedPadding(double pad)
Parameters
pad
double
Returns
WithFixedPadding(double, double)
Sets a new fixed padding (x = left/right, y = top/down padding)
public ElementBounds WithFixedPadding(double leftRight, double upDown)
Parameters
Returns
WithFixedPosition(double, double)
Sets a new fixed offset that is used during element alignment.
public ElementBounds WithFixedPosition(double x, double y)
Parameters
Returns
WithFixedSize(double, double)
Set the fixed width and fixed height values
public ElementBounds WithFixedSize(double width, double height)
Parameters
Returns
WithFixedWidth(double)
Set the width property
public ElementBounds WithFixedWidth(double width)
Parameters
width
double
Returns
WithParent(ElementBounds)
Sets the parent of the bounds
public ElementBounds WithParent(ElementBounds bounds)
Parameters
bounds
ElementBounds
Returns
WithScale(double)
public ElementBounds WithScale(double factor)
Parameters
factor
double
Returns
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
WithSizing(ElementSizing, ElementSizing)
Set the vertical and horizontal sizing properties individually. See also ElementSizing.
public ElementBounds WithSizing(ElementSizing horizontalSizing, ElementSizing verticalSizing)
Parameters
horizontalSizing
ElementSizingverticalSizing
ElementSizing
Returns
scaled(double)
public static double scaled(double value)
Parameters
value
double