Detailed Description

This helps 'render' elements from the DOM into a set of 3D meshes. It also performs things such as alignment and line packing.

Public Member Functions

 Renderman (WorldUI worldUI)
 Creates a new renderer for rendering in the world. More...
 
 Renderman ()
 Creates a new renderer and a new document. More...
 
 Renderman (bool aot)
 Creates a renderman for use in the Editor with AOT compiling Nitro. More...
 
void SetInputMode (InputMode mode)
 Called when the physics input mode changes. Ensures all batches in this renderer are on the correct new input mode. More...
 
void RelocateCollider ()
 Figures out where the box collider should be if we're in physics mode. More...
 
void IncreaseDepth ()
 Increases the current depth value. More...
 
void Clear ()
 Clears all batches from this renderer. More...
 
void Destroy ()
 Destroys this renderman when it's no longer needed. More...
 
void SetupBatch (DisplayableProperty property, TextureAtlas graphics, TextureAtlas font)
 Sets up the current batch based on the isolation settings requested by a property. More...
 
void AddBatch (UIBatch batch)
 Adds the given batch to the main linked list for processing. More...
 
void BeginLinePack (Element element)
 Sets up this renderer so that it's ready to start packing child elements of a given element into lines. More...
 
void HorizontalAlign (Element element)
 Aligns all elements that have been packed so far based on the alignment settings in a given parent element. More...
 
void EndLinePack (Element element)
 Lets the renderer know that the given parent element has finished packing all of its kids. This allows alignment to occur next. More...
 
void CompleteLine (ComputedStyle parentStyle)
 Lets the renderer know the current line doesn't fit anymore elements and has been finished. More...
 
void PackOnLine (Element element)
 Puts the given element onto the current line. More...
 
bool IsInvisible (int left, int top, int width, int height)
 Checks if the given box coordinates are outside the current clipping boundary. If they are, the box is considered invisible. More...
 
void SetBoundary (ComputedStyle style)
 Sets the clipping boundary from the given computed style. More...
 
void ResetBoundary ()
 Resets the clipping boundary back to the whole screen. More...
 
void Reset ()
 Resets all values in the renderer. Called before each layout. More...
 
void RenderWithCamera (int id)
 Puts all batches of this renderer into the given unity layer. More...
 
void RequestLayout ()
 Asks the renderer to perform a layout next update. More...
 
void RequestPaint (Css.ElementStyle style)
 Asks the renderer to perform a paint on the given style object next update. More...
 
void Update ()
 Update causes all changes to be applied and layouts to occur. More...
 
void Layout ()
 Relocates all DOM elements by calculating their onscreen position. Each element may allocate sections of the 3D mesh (blocks) which are then flushed out into the unity mesh and onto the screen. More...
 
Vector3 PixelToWorldUnit (float px, float py, float depth)
 Converts the given screen coordinate to world coordinates. More...
 

Public Attributes

int PenX
 The current x location of the renderer in screen pixels from the left. More...
 
int PenY
 The current y location of the renderer in screen pixels from the top. More...
 
int LineHeight
 The height of the current line being processed. More...
 
float Depth =0f
 The current depth the rendering is occuring at. More...
 
float MaxDepth =0f
 The deepest element rendered so far. More...
 
bool DepthUsed
 Set to true when an element has been placed in the depth buffer. More...
 
TransformationStack Transformations =new TransformationStack()
 A stack of transformations to apply to elements. Updated during a layout event. More...
 
ComputedStyle LastOnLine
 A linked list of elements on a line are kept. This is the last element on the current line. More...
 
ComputedStyle FirstOnLine
 A linked list of elements on a line are kept. This is the first element on the current line. More...
 
bool GoingLeftwards
 True if the rendering direction is left. This originates from the direction: css property. More...
 
UIBatch CurrentBatch
 The batch that we are currently rendering to. More...
 
ComputedStyle LastPacked
 The last child element of an element to be packed onto any line. Tracked for valign. More...
 
ComputedStyle FirstPacked
 The first child element of an element to be packed onto any line. Tracked for valign. More...
 
BoxRegion ClippingBoundary
 The active clipping boundary. Usually the bounds of the parent element. More...
 
int BatchDepth
 Essentially counts how many batches were issued. Used to define the render order. More...
 
int LineStart =0
 The point at which lines begin at. More...
 
int MaxX
 The x value that must not be exceeded by elements on a line. Used if the parent has fixed width. More...
 
int Baseline
 The position of the text baseline. More...
 
int LargestLineWidth
 The length of the longest line so far. More...
 
int RenderLayer
 The unity layer that all meshes should go into. More...
 
bool LayoutOccuring
 A flag which notes if the vital parts of a layout are occuring. During this, the DOM delays updates. More...
 
UIBatch LastBatch
 The tail of the batch linked list. More...
 
UIBatch FirstBatch
 The head of the batch linked list. More...
 
Document RootDocument
 The base document being rendered. More...
 
float DepthResolution =0.05f
 How far apart along z elements are placed on the UI. More...
 
bool DoLayout
 True if a layout event was requested. More...
 
Shader CustomShader
 The current shader override, if there is one. More...
 
ElementStyle StylesToPaint
 The start of a linked list of styles that need to be painted. This linked list helps prevent layouts occuring as many updates only affect the appearance. More...
 
ElementStyle StylesToRecompute
 The start of a linked list of styles that need to be recomputed. More...
 
GameObject Node
 An optional gameobject to parent all content to. More...
 
bool ScreenClip =true
 True if the screen should clip this renderer. More...
 
WorldUI InWorldUI
 Used if this renderer is generating a UI in the game world (e.g. on a billboard). More...
 
Transform PhysicsModeCollider
 The transform of a gameobject containing a cube collider. More...
 

Properties

bool RenderingInWorld [get]
 Is this a renderer for a WorldUI? More...
 
GameObject Parent [get]
 Gets the parent gameobject for this renderman, if there is one. More...
 
RenderMode RenderMode [get, set]
 How this renderman renders images; either on an atlas or with them 'as is'. More...
 
FilterMode FilterMode [get, set]
 The image filter mode. If you're using lots of WorldUI's or animations its best to have this on bilinear. More...
 
FilterMode TextFilterMode [get, set]
 The text filter mode. If you're using lots of WorldUI's its best to have this on Bilinear. More...
 
int Layer [get, set]
 The layer to put this Renderer in. Simply an alias for RenderWithCamera. More...
 

Private Member Functions

void AlignLine (ComputedStyle first, ComputedStyle last, int lineSpace, int elementCount, int lineLength, ComputedStyle parent)
 Horizontally aligns a line based on alignment settings in the given computed style. More...
 
void AddToLine (ComputedStyle style, Element parentNode)
 Adds the given style to the current line. More...
 

Private Attributes

List< ComputedStyleActiveFloats
 The set of active floated elements for the current line being rendered. More...
 
FilterMode ImageFilterMode =FilterMode.Point
 The default filtering mode used by all images of this renderer. More...
 

Static Private Attributes

static RenderMode UIRenderMode =RenderMode.Atlas
 How this renderman renders images; either on an atlas or with them 'as is'. More...
 

Constructor & Destructor Documentation

PowerUI.Renderman.Renderman ( WorldUI  worldUI)
inline

Creates a new renderer for rendering in the world.

PowerUI.Renderman.Renderman ( )
inline

Creates a new renderer and a new document.

PowerUI.Renderman.Renderman ( bool  aot)
inline

Creates a renderman for use in the Editor with AOT compiling Nitro.

Member Function Documentation

void PowerUI.Renderman.AddBatch ( UIBatch  batch)
inline

Adds the given batch to the main linked list for processing.

void PowerUI.Renderman.AddToLine ( ComputedStyle  style,
Element  parentNode 
)
inlineprivate

Adds the given style to the current line.

Parameters
styleThe style to add.
void PowerUI.Renderman.AlignLine ( ComputedStyle  first,
ComputedStyle  last,
int  lineSpace,
int  elementCount,
int  lineLength,
ComputedStyle  parent 
)
inlineprivate

Horizontally aligns a line based on alignment settings in the given computed style.

Parameters
firstThe style of the first element on the line.
lastThe style of the last element on the line.
lineSpaceThe amount of space available to the line.
elementCountThe number of elements on this line.
lineLengthThe width of the line in pixels.
parentThe style which defines the alignment.
void PowerUI.Renderman.BeginLinePack ( Element  element)
inline

Sets up this renderer so that it's ready to start packing child elements of a given element into lines.

Parameters
elementThe parent element whose children will be packed.
void PowerUI.Renderman.Clear ( )
inline

Clears all batches from this renderer.

void PowerUI.Renderman.CompleteLine ( ComputedStyle  parentStyle)
inline

Lets the renderer know the current line doesn't fit anymore elements and has been finished.

Parameters
parentStyleThe computed style of the element holding this line.
void PowerUI.Renderman.Destroy ( )
inline

Destroys this renderman when it's no longer needed.

void PowerUI.Renderman.EndLinePack ( Element  element)
inline

Lets the renderer know that the given parent element has finished packing all of its kids. This allows alignment to occur next.

Parameters
elementThe element that is done packing.
void PowerUI.Renderman.HorizontalAlign ( Element  element)
inline

Aligns all elements that have been packed so far based on the alignment settings in a given parent element.

Parameters
elementThe element that defines the alignment.
void PowerUI.Renderman.IncreaseDepth ( )
inline

Increases the current depth value.

bool PowerUI.Renderman.IsInvisible ( int  left,
int  top,
int  width,
int  height 
)
inline

Checks if the given box coordinates are outside the current clipping boundary. If they are, the box is considered invisible.

Parameters
leftThe x coordinate of the left edge of the box in pixels from the left of the screen.
topThe y coordinate of the top edge of the box in pixels from the top edge of the screen.
widthThe width of the box.
heightThe height of the box (extends down the screen).
Returns
True if the box was outside the current clipping boundary.
void PowerUI.Renderman.Layout ( )
inline

Relocates all DOM elements by calculating their onscreen position. Each element may allocate sections of the 3D mesh (blocks) which are then flushed out into the unity mesh and onto the screen.

void PowerUI.Renderman.PackOnLine ( Element  element)
inline

Puts the given element onto the current line.

Parameters
elementThe element to pack.
Vector3 PowerUI.Renderman.PixelToWorldUnit ( float  px,
float  py,
float  depth 
)
inline

Converts the given screen coordinate to world coordinates.

Parameters
pxThe screen x coordinate in pixels from the left.
pyThe screen y coordinate in pixels from the top.
depthThe z depth.
void PowerUI.Renderman.RelocateCollider ( )
inline

Figures out where the box collider should be if we're in physics mode.

void PowerUI.Renderman.RenderWithCamera ( int  id)
inline

Puts all batches of this renderer into the given unity layer.

Parameters
idThe ID of the unity layer.
void PowerUI.Renderman.RequestLayout ( )
inline

Asks the renderer to perform a layout next update.

void PowerUI.Renderman.RequestPaint ( Css.ElementStyle  style)
inline

Asks the renderer to perform a paint on the given style object next update.

Parameters
styleThe style to paint.
void PowerUI.Renderman.Reset ( )
inline

Resets all values in the renderer. Called before each layout.

void PowerUI.Renderman.ResetBoundary ( )
inline

Resets the clipping boundary back to the whole screen.

void PowerUI.Renderman.SetBoundary ( ComputedStyle  style)
inline

Sets the clipping boundary from the given computed style.

Parameters
styleThe computed style to find the clipping boundary from.
void PowerUI.Renderman.SetInputMode ( InputMode  mode)
inline

Called when the physics input mode changes. Ensures all batches in this renderer are on the correct new input mode.

Parameters
modeThe new input mode to use.
void PowerUI.Renderman.SetupBatch ( DisplayableProperty  property,
TextureAtlas  graphics,
TextureAtlas  font 
)
inline

Sets up the current batch based on the isolation settings requested by a property.

Parameters
propertyThe displayable property which wants the batch.
fontTextureThe font texture to use with this batch.
void PowerUI.Renderman.Update ( )
inline

Update causes all changes to be applied and layouts to occur.

Member Data Documentation

List<ComputedStyle> PowerUI.Renderman.ActiveFloats
private

The set of active floated elements for the current line being rendered.

int PowerUI.Renderman.Baseline

The position of the text baseline.

int PowerUI.Renderman.BatchDepth

Essentially counts how many batches were issued. Used to define the render order.

BoxRegion PowerUI.Renderman.ClippingBoundary

The active clipping boundary. Usually the bounds of the parent element.

UIBatch PowerUI.Renderman.CurrentBatch

The batch that we are currently rendering to.

Shader PowerUI.Renderman.CustomShader

The current shader override, if there is one.

float PowerUI.Renderman.Depth =0f

The current depth the rendering is occuring at.

float PowerUI.Renderman.DepthResolution =0.05f

How far apart along z elements are placed on the UI.

bool PowerUI.Renderman.DepthUsed

Set to true when an element has been placed in the depth buffer.

bool PowerUI.Renderman.DoLayout

True if a layout event was requested.

UIBatch PowerUI.Renderman.FirstBatch

The head of the batch linked list.

ComputedStyle PowerUI.Renderman.FirstOnLine

A linked list of elements on a line are kept. This is the first element on the current line.

ComputedStyle PowerUI.Renderman.FirstPacked

The first child element of an element to be packed onto any line. Tracked for valign.

bool PowerUI.Renderman.GoingLeftwards

True if the rendering direction is left. This originates from the direction: css property.

FilterMode PowerUI.Renderman.ImageFilterMode =FilterMode.Point
private

The default filtering mode used by all images of this renderer.

WorldUI PowerUI.Renderman.InWorldUI

Used if this renderer is generating a UI in the game world (e.g. on a billboard).

int PowerUI.Renderman.LargestLineWidth

The length of the longest line so far.

UIBatch PowerUI.Renderman.LastBatch

The tail of the batch linked list.

ComputedStyle PowerUI.Renderman.LastOnLine

A linked list of elements on a line are kept. This is the last element on the current line.

ComputedStyle PowerUI.Renderman.LastPacked

The last child element of an element to be packed onto any line. Tracked for valign.

bool PowerUI.Renderman.LayoutOccuring

A flag which notes if the vital parts of a layout are occuring. During this, the DOM delays updates.

int PowerUI.Renderman.LineHeight

The height of the current line being processed.

int PowerUI.Renderman.LineStart =0

The point at which lines begin at.

float PowerUI.Renderman.MaxDepth =0f

The deepest element rendered so far.

int PowerUI.Renderman.MaxX

The x value that must not be exceeded by elements on a line. Used if the parent has fixed width.

GameObject PowerUI.Renderman.Node

An optional gameobject to parent all content to.

int PowerUI.Renderman.PenX

The current x location of the renderer in screen pixels from the left.

int PowerUI.Renderman.PenY

The current y location of the renderer in screen pixels from the top.

Transform PowerUI.Renderman.PhysicsModeCollider

The transform of a gameobject containing a cube collider.

int PowerUI.Renderman.RenderLayer

The unity layer that all meshes should go into.

Document PowerUI.Renderman.RootDocument

The base document being rendered.

bool PowerUI.Renderman.ScreenClip =true

True if the screen should clip this renderer.

ElementStyle PowerUI.Renderman.StylesToPaint

The start of a linked list of styles that need to be painted. This linked list helps prevent layouts occuring as many updates only affect the appearance.

ElementStyle PowerUI.Renderman.StylesToRecompute

The start of a linked list of styles that need to be recomputed.

TransformationStack PowerUI.Renderman.Transformations =new TransformationStack()

A stack of transformations to apply to elements. Updated during a layout event.

RenderMode PowerUI.Renderman.UIRenderMode =RenderMode.Atlas
staticprivate

How this renderman renders images; either on an atlas or with them 'as is'.

Property Documentation

FilterMode PowerUI.Renderman.FilterMode
getset

The image filter mode. If you're using lots of WorldUI's or animations its best to have this on bilinear.

int PowerUI.Renderman.Layer
getset

The layer to put this Renderer in. Simply an alias for RenderWithCamera.

GameObject PowerUI.Renderman.Parent
get

Gets the parent gameobject for this renderman, if there is one.

bool PowerUI.Renderman.RenderingInWorld
get

Is this a renderer for a WorldUI?

RenderMode PowerUI.Renderman.RenderMode
getset

How this renderman renders images; either on an atlas or with them 'as is'.

FilterMode PowerUI.Renderman.TextFilterMode
getset

The text filter mode. If you're using lots of WorldUI's its best to have this on Bilinear.