Struct ViewportPlacement
Namespace: ReadyM.Cef
Assembly: ReadyM.Cef.dll
Where a viewport sits and how big it is: a normalized anchor rect in the parent, plus an offset per edge.
public struct ViewportPlacement : IEquatable<ViewportPlacement>
Implements
Inherited Members
object.GetType(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()
Examples
On a 1920x1080 screen, every layout anyone actually wants:
full screen anchors 0,0 -> 1,1 edges 0, 0, 0, 0 1920x1080 at 0,0
full screen inset 40 anchors 0,0 -> 1,1 edges 40, 40, -40, -40 1840x1000 at 40,40
top-right 400x300 anchors 1,0 -> 1,0 edges -420, 20, -20, 320 400x300 at 1500,20
centered 800x600 anchors .5,.5 -> .5,.5 edges -400,-300, 400, 300 800x600 at 560,240
right sidebar, 400 wide anchors 1,0 -> 1,1 edges -400, 0, 0, 0 400x1080 at 1520,0
Remarks
Per axis: equal anchor min and max pins that axis to one line, and its two offsets are a position and a size; different values stretch between two lines, and the offsets are insets.
OFFSETS ARE POSITIVE TOWARD +X AND +Y, so a positive **Right** moves the right edge further right and insetting from the right is negative. It reads backwards the first time. The named cases below hide it for the common layouts.
Fields
AnchorMaxX
public float AnchorMaxX
Field Value
AnchorMaxY
public float AnchorMaxY
Field Value
AnchorMinX
A normalized rect in the parent. Equal min and max on an axis pins it; different values stretch it. 0,0 to 1,1 fills, which is how full screen is said.
public float AnchorMinX
Field Value
AnchorMinY
public float AnchorMinY
Field Value
Bottom
public float Bottom
Field Value
Left
Per edge, measured from the anchor that edge belongs to, positive toward +x and +y.
public float Left
Field Value
Right
public float Right
Field Value
Top
public float Top
Field Value
Properties
FullScreen
The whole frame. Both axes stretched, every edge on its anchor. What a viewport starts as.
public static ViewportPlacement FullScreen { get; }
Property Value
Methods
Centered(float, float)
A fixed size in the middle. Single) at Center on both axes.
public static ViewportPlacement Centered(float width, float height)
Parameters
width float
height float
Returns
Equals(ViewportPlacement)
public bool Equals(ViewportPlacement other)
Parameters
other ViewportPlacement
Returns
Equals(object?)
public override bool Equals(object? obj)
Parameters
obj object?
Returns
GetHashCode()
public override int GetHashCode()
Returns
HorizontalBar(ViewportAlign, float)
A full-width bar along the top or bottom. Stretched across, pinned down.
public static ViewportPlacement HorizontalBar(ViewportAlign side, float height)
Parameters
side ViewportAlign
Start is the top edge, End the bottom. Center is a centered band.
height float
How tall the bar is, in screen pixels.
Returns
Pinned(ViewportAlign, ViewportAlign, float, float, float)
A fixed size, pinned to a corner, an edge midpoint or the center, inset by a margin.
public static ViewportPlacement Pinned(ViewportAlign horizontal, ViewportAlign vertical, float width, float height, float margin = 0)
Parameters
horizontal ViewportAlign
vertical ViewportAlign
width float
height float
margin float
Returns
Remarks
The alignment picks the anchor per axis: Start is 0, Center is 0.5, End is 1. The margin is always INWARD, and at Center it does nothing, because there is no edge to be away from.
Stretch(float, float, float, float)
The whole frame, inset. Positive is INWARD on every side, unlike the raw fields.
public static ViewportPlacement Stretch(float left, float top, float right, float bottom)
Parameters
left float
top float
right float
bottom float
Returns
ToString()
public override string ToString()
Returns
VerticalBar(ViewportAlign, float)
A full-height bar down one side. Pinned across, stretched down.
public static ViewportPlacement VerticalBar(ViewportAlign side, float width)
Parameters
side ViewportAlign
Start is the left edge, End the right. Center is a centered column.
width float
How wide the bar is, in screen pixels.
Returns
Operators
operator ==(ViewportPlacement, ViewportPlacement)
public static bool operator ==(ViewportPlacement left, ViewportPlacement right)
Parameters
left ViewportPlacement
right ViewportPlacement
Returns
operator !=(ViewportPlacement, ViewportPlacement)
public static bool operator !=(ViewportPlacement left, ViewportPlacement right)
Parameters
left ViewportPlacement
right ViewportPlacement