41 #ifndef _uiunifieddim_h
42 #define _uiunifieddim_h
75 : Rel(Relative), Abs(0) {}
80 : Rel(Relative), Abs(Absolute) {}
84 : Rel(Other.Rel), Abs(Other.Abs) {}
111 return ( (this->Rel * Actual) + this->Abs );
144 Other.
Abs == 0.0f ? 0.0f : this->Abs / Other.
Abs);
152 this->Rel += Other.
Rel;
153 this->Abs += Other.
Abs;
161 this->Rel -= Other.
Rel;
162 this->Abs -= Other.
Abs;
170 this->Rel *= Other.
Rel;
171 this->Abs *= Other.
Abs;
179 this->Rel = (Other.
Rel == 0.0f ? 0.0f : this->Rel / Other.
Rel);
180 this->Abs = (Other.
Abs == 0.0f ? 0.0f : this->Abs / Other.
Abs);
192 return UnifiedDim( this->Rel * Other, this->Abs * Other );
199 return UnifiedDim( ( Other == 0 ? 0.0 : this->Rel / Other ),
200 ( Other == 0 ? 0.0 : this->Abs / Other ) );
230 return this->Rel == Other.
Rel && this->Abs == Other.
Abs;
237 return this->Rel != Other.
Rel || this->Abs != Other.
Abs;
248 this->Rel = Other.
Rel;
249 this->Abs = Other.
Abs;
279 if( !CurrAttrib.
Empty() )
280 this->Rel = CurrAttrib.
AsReal();
283 if( !CurrAttrib.
Empty() )
284 this->Abs = CurrAttrib.
AsReal();
349 : X(Other.X), Y(Other.Y) {}
455 this->X = this->X / Other.
X;
456 this->Y = this->Y / Other.
Y;
468 return UnifiedVec2(this->X + Other, this->Y + Other);
475 return UnifiedVec2(this->X - Other, this->Y - Other);
482 return UnifiedVec2(this->X * Other, this->Y * Other);
525 this->X = this->X / Other;
526 this->Y = this->Y / Other;
538 return UnifiedVec2( this->X * Other, this->Y * Other );
545 return UnifiedVec2( this->X / Other, this->Y / Other );
575 return this->X == Other.
X && this->Y == Other.
Y;
582 return this->X != Other.
X || this->Y != Other.
Y;
626 if( !CurrAttrib.
Empty() )
630 if( !CurrAttrib.
Empty() )
634 if( !CurrAttrib.
Empty() )
638 if( !CurrAttrib.
Empty() )
651 return "UnifiedVec2";
685 : Position(Pos), Size(Area) {}
693 this->Position.
SetValues(PositionX,PositionY);
703 this->Position.
SetValues(PositionXrel,PositionYrel,0.0,0.0);
704 this->Size.
SetValues(SizeXrel,SizeYrel,0.0,0.0);
716 const Real& PositionXabs,
const Real& PositionYabs,
const Real& SizeXabs,
const Real& SizeYabs)
718 this->Position.
SetValues(PositionXrel,PositionYrel,PositionXabs,PositionYabs);
719 this->Size.
SetValues(SizeXrel,SizeYrel,SizeXabs,SizeYabs);
732 this->Position = Pos;
742 this->Position.
SetValues(PositionX,PositionY);
755 const Real& PositionXabs,
const Real& PositionYabs,
const Real& SizeXabs,
const Real& SizeYabs)
757 this->Position.
SetValues(PositionXrel,PositionYrel,PositionXabs,PositionYabs);
758 this->Size.
SetValues(SizeXrel,SizeYrel,SizeXabs,SizeYabs);
774 Vector2 Size = this->Size.CalculateActualDimensions(Actual.
Size);
775 return Rect( ( AsChild ? Pos + Actual.
Position : Pos ), Size );
786 return this->Position == Other.
Position && this->Size == Other.
Size;
793 return this->Position != Other.
Position || this->Size != Other.
Size;
805 this->Size = Other.
Size;
841 if( !CurrAttrib.
Empty() )
845 if( !CurrAttrib.
Empty() )
849 if( !CurrAttrib.
Empty() )
853 if( !CurrAttrib.
Empty() )
857 if( !CurrAttrib.
Empty() )
861 if( !CurrAttrib.
Empty() )
865 if( !CurrAttrib.
Empty() )
869 if( !CurrAttrib.
Empty() )
882 return "UnifiedRect";
UnifiedRect(const Real &PositionXrel, const Real &PositionYrel, const Real &SizeXrel, const Real &SizeYrel)
Relative Real constructor.
UnifiedDim(const Real &Relative)
Relative constructor.
UnifiedVec2 operator-(const UnifiedVec2 &Other) const
Subtraction operator.
Attribute AppendAttribute(const Char8 *Name)
Creates an Attribute and puts it at the end of this Nodes attributes.
A light-weight handle for manipulating attributes in DOM tree.
void SetValues(const UnifiedVec2 &Pos, const UnifiedVec2 &Area)
Sets all data members of this unified rect explicitly.
static String GetSerializableName()
Get the name of the the XML tag the Renderable class will leave behind as its instances are serialize...
UnifiedVec2 & operator*=(const Real &Other)
Multiplication assignment with Real operator.
UnifiedVec2 operator/(const Real &Other)
Division with Real operator.
UnifiedVec2 operator/(const UnifiedVec2 &Other) const
Division operator.
UnifiedDim X
The dimension on the X plane.
UnifiedDim & operator-=(const UnifiedDim &Other)
Subtraction assignment operator.
Boole operator!=(const UnifiedRect &Other) const
Inequality comparison operator.
bool Boole
Generally acts a single bit, true or false.
UnifiedVec2 Size
The width and height of this rect.
void ProtoSerialize(XML::Node &ParentNode) const
Convert this class to an XML::Node ready for serialization.
UnifiedDim & operator/=(const Real &Other)
Division assignment with Real operator.
UnifiedVec2 & operator-=(const UnifiedDim &Other)
Subtraction assignment with UnifiedDim operator.
Vector2 Size
Vector2 representing the width and height of the rect.
Real Rel
The relative value on this dimension.
UnifiedRect(const UnifiedVec2 &Pos, const UnifiedVec2 &Area)
UnifiedVec2 constructor.
Thrown when the requested identity could not be found.
#define MEZZ_EXCEPTION(num, desc)
An easy way to throw exceptions with rich information.
void SetIdentity()
Sets all values of this dimension to zero.
void ProtoDeSerialize(const XML::Node &SelfRoot)
Take the data stored in an XML Node and overwrite this object with it.
UnifiedDim operator/(const Real &Other)
Division with Real operator.
UnifiedVec2 & operator*=(const UnifiedVec2 &Other)
Multiplication assignment operator.
UnifiedVec2 & operator+=(const UnifiedDim &Other)
Addition assignment with UnifiedDim operator.
Thrown when a version is accessed/parsed/required and it cannot work correctly or is missing...
UnifiedDim operator-(const UnifiedDim &Other) const
Subtraction operator.
Boole operator!=(const UnifiedDim &Other) const
Inequality comparison operator.
UnifiedDim & operator+=(const UnifiedDim &Other)
Addition assignment operator.
void ProtoSerialize(XML::Node &ParentNode) const
Convert this class to an XML::Node ready for serialization.
static String GetSerializableName()
Get the name of the the XML tag the Renderable class will leave behind as its instances are serialize...
UnifiedVec2(const Real &Xrel, const Real &Yrel, const Real &Xabs, const Real &Yabs)
Real constructor.
This class represents a box shaped area on the screen.
UnifiedDim(const UnifiedDim &Other)
Copy constructor.
UnifiedDim operator*(const UnifiedDim &Other) const
Multiplication operator.
UnifiedRect(const Real &PositionXrel, const Real &PositionYrel, const Real &SizeXrel, const Real &SizeYrel, const Real &PositionXabs, const Real &PositionYabs, const Real &SizeXabs, const Real &SizeYabs)
Real constructor.
UnifiedVec2 & operator-=(const UnifiedVec2 &Other)
Subtraction assignment operator.
Real Abs
The absolute value on this dimension.
Vector2 CalculateActualDimensions(const Vector2 &Actual) const
Calculates the actual values when a Vector2 with actual dimensions has this unified vector2 applied t...
UnifiedVec2(const UnifiedVec2 &Other)
Copy constructor.
static String GetSerializableName()
Get the name of the the XML tag the Renderable class will leave behind as its instances are serialize...
UnifiedVec2(const Real &x, const Real &y)
Real constructor.
float Real
A Datatype used to represent a real floating point number.
UnifiedVec2 & operator/=(const UnifiedDim &Other)
Division assignment with UnifiedDim operator.
UnifiedVec2 operator*(const UnifiedDim &Other) const
Multiplication with UnifiedDim operator.
bool SetValue(const Char8 *rhs)
Set the value of this.
This class represents a 2D rect which can express the size and position of a renderable on screen...
UnifiedVec2 operator+(const UnifiedDim &Other) const
Addition with UnifiedDim operator.
UnifiedVec2 & operator=(const UnifiedVec2 &Other)
Assignment operator.
Real Y
Coordinate on the Y vector.
Boole operator==(const UnifiedRect &Other) const
Equality comparison operator.
UnifiedDim()
Class constructor.
UnifiedDim(const Real &Relative, const Real &Absolute)
Descriptive constructor.
A light-weight handle for manipulating nodes in DOM tree.
Real X
Coordinate on the X vector.
UnifiedVec2 Position
The top left position of this rect.
int AsInt(int def=0) const
Attempts to convert the value of the attribute to an int and returns the results. ...
void ProtoSerialize(XML::Node &ParentNode) const
Convert this class to an XML::Node ready for serialization.
UnifiedVec2 & operator+=(const UnifiedVec2 &Other)
Addition assignment operator.
This is used to represent a point on a 2 dimentional area, such as a screen.
bool Empty() const
Is this storing anything at all?
UnifiedVec2 operator*(const Real &Other)
Multiplication with Real operator.
Boole operator!=(const UnifiedVec2 &Other) const
Inequality comparison operator.
void SetValues(const Real &Relative, const Real &Absolute)
Sets the values of this dimension.
UnifiedDim & operator*=(const Real &Other)
Multiplication assignment with Real operator.
UnifiedDim & operator/=(const UnifiedDim &Other)
Division assignment operator.
UnifiedDim Y
The dimension on the Y plane.
UnifiedDim operator+(const UnifiedDim &Other) const
Addition operator.
UnifiedVec2 & operator/=(const UnifiedVec2 &Other)
Division assignment operator.
Real AsReal(Real def=0) const
Attempts to convert the value of the attribute to a Real and returns the results. ...
UnifiedVec2 & operator/=(const Real &Other)
Division assignment with Real operator.
UnifiedDim & operator=(const UnifiedDim &Other)
Assignment operator.
UnifiedVec2 operator+(const UnifiedVec2 &Other) const
Addition operator.
UnifiedDim operator*(const Real &Other)
Multiplication with Real operator.
void SetIdentity()
Sets all members of this unified vector to zero.
void SetValues(const Real &PositionXrel, const Real &PositionYrel, const Real &SizeXrel, const Real &SizeYrel, const Real &PositionXabs, const Real &PositionYabs, const Real &SizeXabs, const Real &SizeYabs)
Sets all data members of this unified rect explicitly.
Boole operator==(const UnifiedVec2 &Other) const
Equality comparison operator.
~UnifiedDim()
Class destructor.
This class represents both the relative and absolute values that can be expressed for the values on o...
UnifiedVec2()
Class constructor.
UnifiedVec2 & operator*=(const UnifiedDim &Other)
Multiplication assignment with UnifiedDim operator.
void ProtoDeSerialize(const XML::Node &SelfRoot)
Take the data stored in an XML Node and overwrite this object with it.
UnifiedRect & operator=(const UnifiedRect &Other)
Assignment operator.
The bulk of the engine components go in this namspace.
~UnifiedVec2()
Class destructor.
Rect CalculateActualDimensions(const Rect &Actual, Boole AsChild=true) const
Calculates the actual values when a Rect with actual dimensions has this unified rect applied to it...
UnifiedDim & operator*=(const UnifiedDim &Other)
Multiplication assignment operator.
This class represents a point in 2D space using UnifiedDim's.
UnifiedVec2 operator-(const UnifiedDim &Other) const
Subtraction with UnifiedDim operator.
UnifiedRect(const UnifiedDim &PositionX, const UnifiedDim &PositionY, const UnifiedDim &SizeX, const UnifiedDim &SizeY)
UnifiedDim constructor.
void SetValues(const Real &Xrel, const Real &Yrel, const Real &Xabs, const Real &Yabs)
Sets all data members of this unified vector explicitly.
UnifiedVec2 operator*(const UnifiedVec2 &Other) const
Multiplication operator.
const Char8 * Name() const
ptrdiff_tGet the name of this Node.
Boole operator==(const UnifiedDim &Other) const
Equality comparison operator.
void SetValues(const UnifiedDim &x, const UnifiedDim &y)
Sets all data members of this unified vector explicitly.
Vector2 Position
Vector2 representing the top-left position of the rect.
void SerializeError(const String &FailedTo, const String &ClassName, Boole SOrD)
Simply does some string concatenation, then throws an Exception.
UnifiedRect()
Class constructor.
Node AppendChild(NodeType Type=NodeElement)
Creates a Node and makes it a child of this one.
std::string String
A datatype used to a series of characters.
~UnifiedRect()
Class destructor.
Real CalculateActualDimension(const Real &Actual) const
Calculates the actual value when a Real in pixels has this unified dim applied to it...
Attribute GetAttribute(const Char8 *Name) const
Attempt to get an Attribute on this Node with a given name.
void SetIdentity()
Sets all members of this unified rect to zero.
UnifiedDim operator/(const UnifiedDim &Other) const
Division operator.
void SetValues(const UnifiedDim &PositionX, const UnifiedDim &PositionY, const UnifiedDim &SizeX, const UnifiedDim &SizeY)
Sets all data members of this unified rect explicitly.
void ProtoDeSerialize(const XML::Node &SelfRoot)
Take the data stored in an XML Node and overwrite this object with it.
UnifiedVec2(const UnifiedDim &x, const UnifiedDim &y)
UnifiedDim constructor.
UnifiedVec2 operator/(const UnifiedDim &Other) const
Division with UnifiedDim operator.