40 #ifndef _uilayoutstrategy_cpp
41 #define _uilayoutstrategy_cpp
43 #include "UI/layoutstrategy.h"
44 #include "UI/widget.h"
46 #include "MathTools/mathtools.h"
70 Boole QuadSizeUpdated = (OldSelfRect.
Size != NewSelfRect.
Size);
71 for(
ConstChildIterator ChildIt = ChildQuads.begin() ; ChildIt != ChildQuads.end() ; ++ChildIt )
79 Rect NewChildRect = OldChildRect;
82 if( QuadSizeUpdated ) {
86 if( QuadSizeUpdated || QuadPositionUpdated ) {
154 Offset = ( ( OldXPos + OldXSize ) - OldSelfRect.
GetRightEdge() );
163 Ret = ( NewSelfRect.
GetRightEdge() + Offset ) - NewChildSize.
X;
198 Offset = ( OldYPos - OldSelfRect.
GetTopEdge() );
213 Offset = ( ( OldYPos + OldYSize ) - OldSelfRect.
GetBottomEdge() );
278 { Ret = PrevAxisResult;
break; }
283 { Ret = OldSize.
X;
break; }
285 return std::max(Ret,
Real(0.0));
299 { Ret = PrevAxisResult;
break; }
306 { Ret = OldSize.
Y;
break; }
308 return std::max(Ret,
Real(0.0));
318 ( OldChildSize.
X > 0.0 && OldChildSize.
Y > 0.0) &&
319 !MathTools::WithinTolerance( NewChildSize.
X / NewChildSize.
Y, OldChildSize.
X / OldChildSize.
Y, 0.01 ) )
321 Real XChange = NewChildSize.
X / OldChildSize.
X;
322 Real YChange = NewChildSize.
Y / OldChildSize.
Y;
325 if( XChange > YChange ) {
327 NewChildSize.
Y = OldChildSize.
Y * XChange;
329 NewChildSize.
X = OldChildSize.
X * YChange;
330 }
else if( YChange > XChange ) {
332 NewChildSize.
X = OldChildSize.
X * YChange;
334 NewChildSize.
Y = OldChildSize.
Y * XChange;
337 NewChildSize.
X = OldChildSize.
X * YChange;
349 NewChildSize.
X = std::max(NewChildSize.
X,TempVec.
X);
350 NewChildSize.
Y = std::max(NewChildSize.
Y,TempVec.
Y);
361 NewChildSize.
X = std::min(NewChildSize.
X,TempVec.
X);
362 NewChildSize.
Y = std::min(NewChildSize.
Y,TempVec.
Y);
Uses the offset of the old transform to determine the offset for the new transform, preserving absolute distance between updates.
virtual Rect GetRect() const
Gets this QuadRenderables' Rect.
virtual const SizingInfo & GetSizingPolicy() const
Gets the current behavior this QuadRenderable will use when it is sized.
ChildContainer::const_iterator ConstChildIterator
Const Iterator type for QuadRenderable instances stored by this class.
UnifiedDim X
The dimension on the X plane.
bool Boole
Generally acts a single bit, true or false.
virtual Vector2 HandleChildSizing(const Rect &OldSelfRect, const Rect &NewSelfRect, QuadRenderable *Child)
Handles the sizing of a child that needs it's dimensions updated.
Whole VerticalRules
Rules for determining the position of a quad on the Y axis.
Real GetVerticalCenter() const
Gets the value of the vertical center of this rect.
Vector2 Size
Vector2 representing the width and height of the rect.
Anchors to the bottom side of the quad.
Real GetTopEdge() const
Gets the value of the top edge of this rect.
Real Rel
The relative value on this dimension.
#define MEZZ_EXCEPTION(num, desc)
An easy way to throw exceptions with rich information.
This is a helper class designed to describe the behaviors of a quad when it needs to be resized...
virtual Real HandleChildHorizontalSizing(const Rect &OldSelfRect, const Rect &NewSelfRect, const Real PrevAxisResult, QuadRenderable *Child)
Handles the sizing of a child on the X axis.
std::vector< Widget * > ChildContainer
Basic container type for QuadRenderable storage by this class.
Sizes the container so all text in layers will be visible. Only valid for Vertical sizing(exception w...
UI::AspectRatioLock RatioLock
Rule for determining aspect ratio lock.
virtual const PositioningInfo & GetPositioningPolicy() const
Gets the current behavior this QuadRenderable will use when it is positioned.
virtual void CheckChildAspectRatio(const Vector2 &OldChildSize, Vector2 &NewChildSize, QuadRenderable *Child)
Preserves a child's aspect ratio if it is configured to do so.
Real GetHorizontalCenter() const
Gets the value of the horizontal center of this rect.
This class represents a box shaped area on the screen.
virtual void PopulateTextLinesInLayers(const Real MaxWidth)
Populates all text lines in all text layers owned by this quad.
Blended Mode. This will do the same as "SR_Match_Other_Axis" and will also apply Unified Dim of the c...
Real Abs
The absolute value on this dimension.
This implements the exception hiearchy for Mezzanine.
Vector2 CalculateActualDimensions(const Vector2 &Actual) const
Calculates the actual values when a Vector2 with actual dimensions has this unified vector2 applied t...
Whole VerticalRules
Rules for resizing on the Y axis.
float Real
A Datatype used to represent a real floating point number.
The aspect ratio is locked. When multiple axes are resized the axis with less growth is used to deter...
The X axis is limited by the change to the Y axis. The Y axis can resize freely.
virtual Boole GetManualTransformUpdates() const
Gets whether or not this quad will be automatically updated when parent transforms are updated...
Resizing will use the provided unified dimensions with no further alterations. This is the default fo...
The calculated value for the perpendicular axis will be used as the final value for this axis...
Real Y
Coordinate on the Y vector.
virtual Real GetIdealHeightForText() const
Gets the height needed for this quadrenderable to be able to completely display text in it's child te...
Real X
Coordinate on the X vector.
This is used to represent a point on a 2 dimentional area, such as a screen.
LayoutStrategy()
Class constructor.
virtual Vector2 GetActualSize() const
Gets the pixel size of this widget.
Real GetRightEdge() const
Gets the value of the right edge of this rect.
UnifiedDim Y
The dimension on the Y plane.
Anchors to the left side of the quad.
The aspect ratio is locked. When multiple axes are resized the axis with more growth is used to deter...
virtual void Layout(const Rect &OldSelfRect, const Rect &NewSelfRect, const ChildContainer &ChildQuads)
Updates the dimensions of a collection of QuadRenderables.
Whole HorizontalRules
Rules for determining the position of a quad on the X axis.
Thrown when the available information should have worked but failed for unknown reasons.
Uses the its own updated size as the offset for the new transform, and applies the Unified Dim of the...
UnifiedVec2 UPosition
Unified dimensions to be used if the resize rules permits it.
The bulk of the engine components go in this namspace.
No resizing of any kind will take place.
Uses the parents updated size of as the offset for the new transform, and applies the Unified Dim of ...
virtual void ClampChildToMinSize(const Rect &NewSelfRect, Vector2 &NewChildSize, QuadRenderable *Child)
Clamps the updated size to the set minimum size for the child quad.
UnifiedVec2 MinSize
The minumum permitted size.
virtual Vector2 GetActualPosition() const
Gets the pixel position of this widget.
The aspect ratio is not locked and both dimensions can resize freely.
UnifiedVec2 USize
Unified dimensions to be used if the resize rules permits it.
virtual Vector2 HandleChildPositioning(const Rect &OldSelfRect, const Rect &NewSelfRect, const Vector2 &NewChildSize, QuadRenderable *Child)
Handles the positioning of a child that needs it's dimensions updated.
Anchors to the right side of the quad.
virtual Real HandleChildHorizontalPositioning(const Rect &OldSelfRect, const Rect &NewSelfRect, const Vector2 &NewChildSize, QuadRenderable *Child)
Handles the positioning of a child on the X axis.
Real GetLeftEdge() const
Gets the value of the left edge of this rect.
Real GetBottomEdge() const
Gets the value of the bottom edge of this rect.
This represents a nestable quad for an object in a GUI layout.
virtual void UpdateDimensions()
Updates the dimensions of this QuadRenderable based on the transform of it's parent.
Vector2 Position
Vector2 representing the top-left position of the rect.
virtual void ClampChildToMaxSize(const Rect &NewSelfRect, Vector2 &NewChildSize, QuadRenderable *Child)
Clamps the updated size to the set maximum size for the child quad.
Whole HorizontalRules
Rules for resizing on the X axis.
Anchors to the top side of the quad.
virtual ~LayoutStrategy()
Class destructor.
virtual Real HandleChildVerticalPositioning(const Rect &OldSelfRect, const Rect &NewSelfRect, const Vector2 &NewChildSize, QuadRenderable *Child)
Handles the positioning of a child on the Y axis.
Real CalculateActualDimension(const Real &Actual) const
Calculates the actual value when a Real in pixels has this unified dim applied to it...
UnifiedVec2 MaxSize
The maximum permitted size.
This is a helper class designed to describe the behaviors of a quad when it needs to be repositioned...
virtual Real HandleChildVerticalSizing(const Rect &OldSelfRect, const Rect &NewSelfRect, const Real PrevAxisResult, QuadRenderable *Child)
Handles the sizing of a child on the Y axis.