Detailed Description

This represents a parsed value of a css property.

Public Member Functions

 Value ()
 Creates a new empty value. More...
 
 Value (string text)
 Creates a new value from the given value text and guesses what type it is. More...
 
 Value (string text, ValueType type)
 Creates a new value from the given value as text and a type of the value represented in the text. More...
 
bool IsAuto ()
 Checks if this is 'auto' More...
 
bool IsAbsolute ()
 Checks if this is an absolute value and is not a percentage/em/ rectangle containing percents. More...
 
bool Equals (Value value)
 Checks if two values are equal. More...
 
void MakeAbsolute (CssProperty property, Element element)
 Converts this relative value (such as a percentage or em) into a fixed one. More...
 
void InheritFrom (Value parent)
 Inherits from the given parent value by copying them. More...
 
void BakePX (int size)
 Converts the percentage held by this value into a fixed pixel number. More...
 
Value Copy ()
 Duplicates this value. More...
 
void SetFloat (float value)
 Sets the given floating point number as the value. More...
 
float ToFloat ()
 Converts this value to a floating point number. More...
 
Color ToColor ()
 Converts this value to a Unity colour. More...
 
override string ToString ()
 Converts this value to a css useable string. More...
 
void Reset ()
 Empties this value. More...
 
void Set (string valueText)
 Sets the value and guesses it's type. More...
 
void Set (string valueText, ValueType type)
 Sets the value which is of a known given type. More...
 
int GetMixed (int dimension)
 Resolves a mixed pixel and % value. More...
 
void SetPercent (float percent)
 
void Offset (Value by)
 Offsets this percentage value by a given percentage or pixel value. More...
 
bool AllSameValues ()
 Are all entries in this rectangle the same? More...
 
string GetText (int index)
 Gets the numbered inner values text. More...
 
float GetRadians (int index)
 Gets the numbered inner values floating point number in radians. More...
 
float GetFloat (int index)
 Gets the numbered inner values floating point number. More...
 
int GetPX (int index)
 Gets the numbered inner value as pixels. More...
 
Color GetColor (int index)
 Gets the numbered inner value as a colour. More...
 
string ToHex ()
 Converts this value into a hex string that is 2 characters long. More...
 
void SetInnerValues (int count)
 Sets defaults for the given number of inner values. More...
 
void SetInnerValues (string valueText, int count)
 Sets the given fixed number of inner values of this to the given css text string. More...
 

Static Public Member Functions

static Color GetColour (string valueText)
 Gets a colour from a hex HTML string. More...
 
static void GetColour (string valueText, out float r, out float g, out float b, out float a)
 
static int GetInnerIndex (ref string property)
 
static ValueType TypeOf (CssProperty property, ref string value)
 
static bool IsSingle (string valueText)
 
static ValueType TypeOf (string valueText)
 

Public Attributes

int PX
 If this is a pixel integer, the raw pixel value. More...
 
string Text
 If this is a text value, e.g. "auto", the raw text value. More...
 
float Single
 If this is a decimal, the raw decimal value. More...
 
bool Boolean
 If this is a boolean, the raw bool value. More...
 
bool Important
 True if this value is important. More...
 
Value[] InnerValues
 The set of internal values, such as each individual value of padding. More...
 
Calculation Calculation
 A calculation if this value is calc(..). More...
 
ValueType Type =ValueType.Null
 The type of value this is. More...
 

Properties

Value this[int index] [get, set]
 Gets or sets the numbered inner value. Used if this is a rectangle/ colour etc. More...
 

Private Member Functions

int ParentFontSize (ComputedStyle style)
 Gets the fontsize for the given computed style. More...
 
string InnerValueString ()
 

Static Private Member Functions

static int DoubleNibble (int nibble)
 Duplicates the given nibble (4 bit number) and places the result alongside in the same byte. E.g. c in hex becomes cc. More...
 

Constructor & Destructor Documentation

PowerUI.Css.Value.Value ( )
inline

Creates a new empty value.

PowerUI.Css.Value.Value ( string  text)
inline

Creates a new value from the given value text and guesses what type it is.

Parameters
textThe value to set, e.g. "auto" or "14.9".
PowerUI.Css.Value.Value ( string  text,
ValueType  type 
)
inline

Creates a new value from the given value as text and a type of the value represented in the text.

Parameters
textThe value to set, e.g. "auto" or "14.9".
typeThe type of the value, e.g. percentage.

Member Function Documentation

bool PowerUI.Css.Value.AllSameValues ( )
inline

Are all entries in this rectangle the same?

void PowerUI.Css.Value.BakePX ( int  size)
inline

Converts the percentage held by this value into a fixed pixel number.

Parameters
sizeThe number that represents 100%.
Value PowerUI.Css.Value.Copy ( )
inline

Duplicates this value.

Returns
A duplicated copy of this value. Note that if this value has inner values, they are copied too.
static int PowerUI.Css.Value.DoubleNibble ( int  nibble)
inlinestaticprivate

Duplicates the given nibble (4 bit number) and places the result alongside in the same byte. E.g. c in hex becomes cc.

Parameters
nibbleThe nibble to duplicate.
bool PowerUI.Css.Value.Equals ( Value  value)
inline

Checks if two values are equal.

Parameters
valueThe value to check for equality with this. Always returns false if null.
Returns
True if this and the given value are equal; false otherwise.
Color PowerUI.Css.Value.GetColor ( int  index)
inline

Gets the numbered inner value as a colour.

Parameters
indexThe number of the inner value.
Returns
The colour from the numbered inner value, if it's available. Clear otherwise.
static Color PowerUI.Css.Value.GetColour ( string  valueText)
inlinestatic

Gets a colour from a hex HTML string.

static void PowerUI.Css.Value.GetColour ( string  valueText,
out float  r,
out float  g,
out float  b,
out float  a 
)
inlinestatic
float PowerUI.Css.Value.GetFloat ( int  index)
inline

Gets the numbered inner values floating point number.

Parameters
indexThe number of the inner value.
Returns
The floating point number of the numbered inner value, if it's available. 0 otherwise.
static int PowerUI.Css.Value.GetInnerIndex ( ref string  property)
inlinestatic
int PowerUI.Css.Value.GetMixed ( int  dimension)
inline

Resolves a mixed pixel and % value.

int PowerUI.Css.Value.GetPX ( int  index)
inline

Gets the numbered inner value as pixels.

Parameters
indexThe number of the inner value.
Returns
The pixels from the numbered inner value, if it's available. 0 otherwise.
float PowerUI.Css.Value.GetRadians ( int  index)
inline

Gets the numbered inner values floating point number in radians.

Parameters
indexThe number of the inner value.
Returns
The floating point number of the numbered inner value, if it's available. 0 otherwise.
string PowerUI.Css.Value.GetText ( int  index)
inline

Gets the numbered inner values text.

Parameters
indexThe number of the inner value.
Returns
The text of the numbered inner value, if it's available. Null otherwise.
void PowerUI.Css.Value.InheritFrom ( Value  parent)
inline

Inherits from the given parent value by copying them.

Parameters
parentThe value to inherit from.
string PowerUI.Css.Value.InnerValueString ( )
inlineprivate
bool PowerUI.Css.Value.IsAbsolute ( )
inline

Checks if this is an absolute value and is not a percentage/em/ rectangle containing percents.

Returns
True if this value is absolute; false if it is relative.
bool PowerUI.Css.Value.IsAuto ( )
inline

Checks if this is 'auto'

Returns
True if this value is 'auto'
static bool PowerUI.Css.Value.IsSingle ( string  valueText)
inlinestatic
void PowerUI.Css.Value.MakeAbsolute ( CssProperty  property,
Element  element 
)
inline

Converts this relative value (such as a percentage or em) into a fixed one.

Parameters
propertyThe property that this value represents and is being made absolute.
elementThe element holding all the values that represent 100%.
void PowerUI.Css.Value.Offset ( Value  by)
inline

Offsets this percentage value by a given percentage or pixel value.

int PowerUI.Css.Value.ParentFontSize ( ComputedStyle  style)
inlineprivate

Gets the fontsize for the given computed style.

Parameters
parentStyleThe style to get the fontsize from. Used for em calculations.
void PowerUI.Css.Value.Reset ( )
inline

Empties this value.

void PowerUI.Css.Value.Set ( string  valueText)
inline

Sets the value and guesses it's type.

Parameters
valueTextThe value to set, e.g. "auto" or "14.9".
void PowerUI.Css.Value.Set ( string  valueText,
ValueType  type 
)
inline

Sets the value which is of a known given type.

Parameters
textThe value to set, e.g. "auto" or "14.9".
typeThe type of the value, e.g. percentage.
void PowerUI.Css.Value.SetFloat ( float  value)
inline

Sets the given floating point number as the value.

Parameters
valueThe value to set.
void PowerUI.Css.Value.SetInnerValues ( int  count)
inline

Sets defaults for the given number of inner values.

Parameters
countThe number of inner values to setup.
void PowerUI.Css.Value.SetInnerValues ( string  valueText,
int  count 
)
inline

Sets the given fixed number of inner values of this to the given css text string.

Parameters
valueTextThe value to use for the inner values separated by spaces. E.g. "50% 50%"
countThe number of inner values this value should have. If the value text does not have enough chunks to fit in this number of inner values, the value text is repeated so they do. For example, "10 40" to fit in 4 inner values becomes "10 40 10 40"; "1 2 3" to fit in 4 becomes "1 2 3 1" etc.
void PowerUI.Css.Value.SetPercent ( float  percent)
inline
Color PowerUI.Css.Value.ToColor ( )
inline

Converts this value to a Unity colour.

Returns
The unity colour represented by this value.
float PowerUI.Css.Value.ToFloat ( )
inline

Converts this value to a floating point number.

Returns
The floating point represented by this value if possible. 0 otherwise.
string PowerUI.Css.Value.ToHex ( )
inline

Converts this value into a hex string that is 2 characters long.

override string PowerUI.Css.Value.ToString ( )
inline

Converts this value to a css useable string.

Returns
A css formatted string.
static ValueType PowerUI.Css.Value.TypeOf ( CssProperty  property,
ref string  value 
)
inlinestatic
static ValueType PowerUI.Css.Value.TypeOf ( string  valueText)
inlinestatic

Member Data Documentation

bool PowerUI.Css.Value.Boolean

If this is a boolean, the raw bool value.

Calculation PowerUI.Css.Value.Calculation

A calculation if this value is calc(..).

bool PowerUI.Css.Value.Important

True if this value is important.

Value [] PowerUI.Css.Value.InnerValues

The set of internal values, such as each individual value of padding.

int PowerUI.Css.Value.PX

If this is a pixel integer, the raw pixel value.

float PowerUI.Css.Value.Single

If this is a decimal, the raw decimal value.

string PowerUI.Css.Value.Text

If this is a text value, e.g. "auto", the raw text value.

ValueType PowerUI.Css.Value.Type =ValueType.Null

The type of value this is.

Property Documentation

Value PowerUI.Css.Value.this[int index]
getset

Gets or sets the numbered inner value. Used if this is a rectangle/ colour etc.

Parameters
indexThe number of the inner value.