Struct Length
CSS3 has multiple possible 'modes' for a Length, the two most common being: PIXELS (px) and PERCENT (%); this wraps the mode with a float value, giving you e.g. "10 px", or eg "50 %".
Namespace: NinjaTools.FlexBuilder.CSS3
Assembly: cs.temp.dll.dll
Syntax
[Serializable]
public struct Length
Constructors
- (void) Length(LengthType)
- (void) Length(Boolean)
Failings in Microsoft's C# (not fixed until C# v8 or so) require a parameter here that does literally nothing
Parameters
Boolean | fakeArgument |
- (void) Length(Single)
- (void) Length(Single, LengthType)
Fields
- (LengthType) mode
Internal, do NOT modify directly - this is only public because C# doesnt have a 'package' keyword
- (Single) value
Internal, do NOT modify directly - this is only public because C# doesnt have a 'package' keyword
Properties
- (Boolean) hasNonRelativeValue
- (Boolean) hasRelativeValue
Checks if its a non-fixed (i.e. relative) value, e.g. a percent
- (Length) None
Shorthand for creating a new struct with NONE (i.e. initial, 0) value explicitly (C# doesn't fully support struct-constructors)
Methods
- (Boolean) Equals(Object)
- (Int32) GetHashCode()
- (Boolean) HasNonRelativeValue(out Single)
- (Boolean) HasResolvableValue(CSSAvailableLength, out BoxLength)
- (Boolean) HasResolvableValue(CSSAvailableLength, out Single)
Checks if this length can be 'resolved' ie turned into a pixel value, using only the supplied (possibly empty) InnerContentLength of its parent. If this is a px value it will always return true, if its a % value it will return true or false depending on the supplied (or missing) ContentLength
Parameters
CSSAvailableLength | parentSize | |
Single | resolvedValue |
Returns
Boolean |
- (Boolean) hasResolvableValue(ContentLength, out Single)
Checks if this length can be 'resolved' ie turned into a pixel value, using only the supplied (possibly empty) InnerContentLength of its parent. If this is a px value it will always return true, if its a % value it will return true or false depending on the supplied (or missing) ContentLength
Parameters
ContentLength | parentSize | |
Single | resolvedValue |
Returns
Boolean |
- (String) ToString()
- (Single) ValueNonRelative()
Requires the value to be non-relative, i.e. resolvable - and throws an exception if it is not e.g. a fixed value in pixels.
Returns
Single |
Exceptions
Exception |
- (Nullable<Single>) ValueOrNull(CSSAvailableLength)
Upgraded / preferred / future version of ValueOrNull(Nullable<Single>)
Parameters
CSSAvailableLength | containerLength |
Returns
Nullable<Single> |
- (Nullable<Single>)
ValueOrNull(Func<>>)
Resolves a value if possible without even calculating the parent-container's size (e.g. if this is a PIXEL length); if it needs the parent-container's size (e.g. if this is a PERCENT length) it will lazily invoke the supplied lambda; if that lambda fails to provide a value, this returns null (i.e. unresolvable), otherwise it gives the final value resolved into pixels.
Parameters
Func<Nullable<Single>> | lazilyGenerateDefiniteContainerSize |
Returns
Nullable<Single> |
- (Nullable<Single>)
ValueOrNull(Nullable)
This is the preferred method: all callers should upgrade to this or a variant. In future this will be further
converted to require a ContentLength or
Already has a variant for CSSAvailableLength -
Parameters
Nullable<Single> | containerLength |
Returns
Nullable<Single> | value if possible, or null if EITHER you requested a "percent of null", OR requested "none of (something)" |