Spinning Topp Logo BlackTopp Studios
inc
layoutstrategy.cpp
1 // © Copyright 2010 - 2016 BlackTopp Studios Inc.
2 /* This file is part of The Mezzanine Engine.
3 
4  The Mezzanine Engine is free software: you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation, either version 3 of the License, or
7  (at your option) any later version.
8 
9  The Mezzanine Engine is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with The Mezzanine Engine. If not, see <http://www.gnu.org/licenses/>.
16 */
17 /* The original authors have included a copy of the license specified above in the
18  'Docs' folder. See 'gpl.txt'
19 */
20 /* We welcome the use of the Mezzanine engine to anyone, including companies who wish to
21  Build professional software and charge for their product.
22 
23  However there are some practical restrictions, so if your project involves
24  any of the following you should contact us and we will try to work something
25  out:
26  - DRM or Copy Protection of any kind(except Copyrights)
27  - Software Patents You Do Not Wish to Freely License
28  - Any Kind of Linking to Non-GPL licensed Works
29  - Are Currently In Violation of Another Copyright Holder's GPL License
30  - If You want to change our code and not add a few hundred MB of stuff to
31  your distribution
32 
33  These and other limitations could cause serious legal problems if you ignore
34  them, so it is best to simply contact us or the Free Software Foundation, if
35  you have any questions.
36 
37  Joseph Toppi - toppij@gmail.com
38  John Blackwood - makoenergy02@gmail.com
39 */
40 #ifndef _uilayoutstrategy_cpp
41 #define _uilayoutstrategy_cpp
42 
43 #include "UI/layoutstrategy.h"
44 #include "UI/widget.h"
45 
46 #include "MathTools/mathtools.h"
47 #include "exception.h"
48 
49 #include <algorithm>
50 
51 namespace Mezzanine
52 {
53  namespace UI
54  {
55  ///////////////////////////////////////////////////////////////////////////////
56  // Construction and Destruction
57 
59  { }
60 
62  { }
63 
64  ///////////////////////////////////////////////////////////////////////////////
65  // Primary Methods
66 
67  void LayoutStrategy::Layout(const Rect& OldSelfRect, const Rect& NewSelfRect, const ChildContainer& ChildQuads)
68  {
69  Boole QuadPositionUpdated = (OldSelfRect.Position != NewSelfRect.Position);
70  Boole QuadSizeUpdated = (OldSelfRect.Size != NewSelfRect.Size);
71  for( ConstChildIterator ChildIt = ChildQuads.begin() ; ChildIt != ChildQuads.end() ; ++ChildIt )
72  {
73  QuadRenderable* Child = (*ChildIt);
74 
75  if( Child->GetManualTransformUpdates() )
76  continue;
77 
78  const Rect OldChildRect = Child->GetRect();
79  Rect NewChildRect = OldChildRect;
80  //NewChildRect.SetIdentity();
81 
82  if( QuadSizeUpdated ) {
83  NewChildRect.Size = this->HandleChildSizing(OldSelfRect,NewSelfRect,Child);
84  }
85 
86  if( QuadSizeUpdated || QuadPositionUpdated ) {
87  NewChildRect.Position = this->HandleChildPositioning(OldSelfRect,NewSelfRect,NewChildRect.Size,Child);
88  }
89 
90  Child->UpdateDimensions(OldChildRect,NewChildRect);
91  }// for each child
92  }
93 
94  ///////////////////////////////////////////////////////////////////////////////
95  // Sub-task Methods
96 
97  Vector2 LayoutStrategy::HandleChildPositioning(const Rect& OldSelfRect, const Rect& NewSelfRect, const Vector2& NewChildSize, QuadRenderable* Child)
98  {
99  Vector2 NewPosition;
100  //const PositioningInfo& ChildPositioning = Child->GetPositioningPolicy();
101 
102  // Resolve our position
103  NewPosition.X = MathTools::Floor( this->HandleChildHorizontalPositioning(OldSelfRect,NewSelfRect,NewChildSize,Child) );
104  NewPosition.Y = MathTools::Floor( this->HandleChildVerticalPositioning(OldSelfRect,NewSelfRect,NewChildSize,Child) );
105 
106  return NewPosition;
107  }
108 
109  Real LayoutStrategy::HandleChildHorizontalPositioning(const Rect& OldSelfRect, const Rect& NewSelfRect, const Vector2& NewChildSize, QuadRenderable* Child)
110  {
111  const Real OldXPos = Child->GetActualPosition().X;
112  const Real OldXSize = Child->GetActualSize().X;
113  const PositioningInfo& ChildPositioning = Child->GetPositioningPolicy();
114  // Rather than have a bunch of complicated checks to see what needs to be filled in, blindly assign Unified position
115  // to the new rect, and allow simpler targetted checks fill in the exceptions
116  Real Ret = NewSelfRect.Position.X + ChildPositioning.UPosition.X.CalculateActualDimension(NewSelfRect.Size.X);
117  // Create a variable to store the old axis offset (the number of pixels to the left, or right if negative) on the X axis.
118  Real Offset = 0;
119  // Do our checks
120  if( ChildPositioning.HorizontalRules & UI::PF_Anchor_Left && ChildPositioning.HorizontalRules & UI::PF_Anchor_Right ) { // Check if we're centered
121  // Update the offset if we're configured to.
122  if( ChildPositioning.HorizontalRules & UI::PF_Anchor_Prev_Offset ) {
123  // Get the old offset between the center of this quad and it's parent.
124  Offset = ( OldXPos + ( OldXSize * 0.5 ) ) - OldSelfRect.GetHorizontalCenter();
125  }else if( ChildPositioning.HorizontalRules & UI::PF_Anchor_SelfSize ) {
126  // Use the new child size on the horizontal sxis. Apply the Unified Dim on the X axis.
127  Offset = ChildPositioning.UPosition.X.CalculateActualDimension( NewChildSize.X );
128  }else if( ChildPositioning.HorizontalRules & UI::PF_Anchor_ParentSize ) {
129  // Use this quads new size on the horizontal sxis. Apply the Unified Dim on the X axis.
130  Offset = ChildPositioning.UPosition.X.CalculateActualDimension( NewSelfRect.Size.X );
131  }
132  // Then add that distance to the updated transform and then subtract the new half size.
133  Ret = ( NewSelfRect.GetHorizontalCenter() + Offset ) - ( NewChildSize.X * 0.5 );
134  }else if( ChildPositioning.HorizontalRules & UI::PF_Anchor_Left ) { // Check if we're anchored to the left
135  // Update the offset if we're configured to.
136  if( ChildPositioning.HorizontalRules & UI::PF_Anchor_Prev_Offset ) {
137  // Get the old offset between the left edge of this quad and it's parent.
138  // Note: If the child is within the bounds of it's parent, this Offset should always be >= 0.
139  Offset = ( OldXPos - OldSelfRect.GetLeftEdge() );
140  }else if( ChildPositioning.HorizontalRules & UI::PF_Anchor_SelfSize ) {
141  // Use the new child size on the horizontal sxis. Apply the Unified Dim on the X axis.
142  Offset = ChildPositioning.UPosition.X.CalculateActualDimension( NewChildSize.X );
143  }else if( ChildPositioning.HorizontalRules & UI::PF_Anchor_ParentSize ) {
144  // Use this quads new size on the horizontal sxis. Apply the Unified Dim on the X axis.
145  Offset = ChildPositioning.UPosition.X.CalculateActualDimension( NewSelfRect.Size.X );
146  }
147  // Then add that distance to the updated transform.
148  Ret = NewSelfRect.GetLeftEdge() + Offset;
149  }else if( ChildPositioning.HorizontalRules & UI::PF_Anchor_Right ) { // Check if we're anchored to the right
150  // Update the offset if we're configured to.
151  if( ChildPositioning.HorizontalRules & UI::PF_Anchor_Prev_Offset ) {
152  // Get the old offset between the right edge of this quad and it's parent.
153  // Note: If the child is within the bounds of it's parent, this Offset should always be <= 0.
154  Offset = ( ( OldXPos + OldXSize ) - OldSelfRect.GetRightEdge() );
155  }else if( ChildPositioning.HorizontalRules & UI::PF_Anchor_SelfSize ) {
156  // Use the new child size on the horizontal sxis. Apply the Unified Dim on the X axis.
157  Offset = ChildPositioning.UPosition.X.CalculateActualDimension( NewChildSize.X );
158  }else if( ChildPositioning.HorizontalRules & UI::PF_Anchor_ParentSize ) {
159  // Use this quads new size on the horizontal sxis. Apply the Unified Dim on the X axis.
160  Offset = ChildPositioning.UPosition.X.CalculateActualDimension( NewSelfRect.Size.X );
161  }
162  // Then add that distance to the updated transform.
163  Ret = ( NewSelfRect.GetRightEdge() + Offset ) - NewChildSize.X;
164  }
165  return Ret;
166  }
167 
168  Real LayoutStrategy::HandleChildVerticalPositioning(const Rect& OldSelfRect, const Rect& NewSelfRect, const Vector2& NewChildSize, QuadRenderable* Child)
169  {
170  const Real OldYPos = Child->GetActualPosition().Y;
171  const Real OldYSize = Child->GetActualSize().Y;
172  const PositioningInfo& ChildPositioning = Child->GetPositioningPolicy();
173  // Rather than have a bunch of complicated checks to see what needs to be filled in, blindly assign Unified position
174  // to the new rect, and allow simpler targetted checks fill in the exceptions
175  Real Ret = NewSelfRect.Position.Y + ChildPositioning.UPosition.Y.CalculateActualDimension(NewSelfRect.Size.Y);
176  // Create a variable to store the old axis offset (the number of pixels up, or down if negative) on the Y axis.
177  Real Offset = 0;
178  // Do our checks
179  if( ChildPositioning.VerticalRules & UI::PF_Anchor_Top && ChildPositioning.VerticalRules & UI::PF_Anchor_Bottom ) { // Check if we're centered
180  // Update the offset if we're configured to.
181  if( ChildPositioning.VerticalRules & UI::PF_Anchor_Prev_Offset ) {
182  // Get the old offset between the center of this quad and it's parent.
183  Offset = ( OldYPos + ( OldYSize * 0.5 ) ) - OldSelfRect.GetVerticalCenter();
184  }else if( ChildPositioning.VerticalRules & UI::PF_Anchor_SelfSize ) {
185  // Use the new child size on the vertical sxis. Apply the Unified Dim on the Y axis.
186  Offset = ChildPositioning.UPosition.Y.CalculateActualDimension( NewChildSize.Y );
187  }else if( ChildPositioning.VerticalRules & UI::PF_Anchor_ParentSize ) {
188  // Use this quads new size on the vertical sxis. Apply the Unified Dim on the Y axis.
189  Offset = ChildPositioning.UPosition.Y.CalculateActualDimension( NewSelfRect.Size.Y );
190  }
191  // Then add that distance to the updated transform and then subtract the new half size.
192  Ret = ( NewSelfRect.GetVerticalCenter() + Offset ) - ( NewChildSize.Y * 0.5 );
193  }else if( ChildPositioning.VerticalRules & UI::PF_Anchor_Top ) { // Check if we're anchored to the top
194  // Update the offset if we're configured to.
195  if( ChildPositioning.VerticalRules & UI::PF_Anchor_Prev_Offset ) {
196  // Get the old offset between the top edge of this quad and it's parent.
197  // Note: If the child is within the bounds of it's parent, this Offset should always be >= 0.
198  Offset = ( OldYPos - OldSelfRect.GetTopEdge() );
199  }else if( ChildPositioning.VerticalRules & UI::PF_Anchor_SelfSize ) {
200  // Use the new child size on the vertical sxis. Apply the Unified Dim on the X axis.
201  Offset = ChildPositioning.UPosition.Y.CalculateActualDimension( NewChildSize.Y );
202  }else if( ChildPositioning.VerticalRules & UI::PF_Anchor_ParentSize ) {
203  // Use this quads new size on the vertical sxis. Apply the Unified Dim on the Y axis.
204  Offset = ChildPositioning.UPosition.Y.CalculateActualDimension( NewSelfRect.Size.Y );
205  }
206  // Then add that distance to the updated transform.
207  Ret = NewSelfRect.GetTopEdge() + Offset;
208  }else if( ChildPositioning.VerticalRules & UI::PF_Anchor_Bottom ) { // Check if we're anchored to the bottom
209  // Update the offset if we're configured to.
210  if( ChildPositioning.VerticalRules & UI::PF_Anchor_Prev_Offset ) {
211  // Get the old offset between the bottom edge of this quad and it's parent.
212  // Note: If the child is within the bounds of it's parent, this Offset should always be <= 0.
213  Offset = ( ( OldYPos + OldYSize ) - OldSelfRect.GetBottomEdge() );
214  }else if( ChildPositioning.VerticalRules & UI::PF_Anchor_SelfSize ) {
215  // Use the new child size on the vertical sxis. Apply the Unified Dim on the Y axis.
216  Offset = ChildPositioning.UPosition.Y.CalculateActualDimension( NewChildSize.Y );
217  }else if( ChildPositioning.VerticalRules & UI::PF_Anchor_ParentSize ) {
218  // Use this quads new size on the vertical sxis. Apply the Unified Dim on the Y axis.
219  Offset = ChildPositioning.UPosition.Y.CalculateActualDimension( NewSelfRect.Size.Y );
220  }
221  // Then add that distance to the updated transform.
222  Ret = ( NewSelfRect.GetBottomEdge() + Offset ) - NewChildSize.Y;
223  }
224  return Ret;
225  }
226 
227  Vector2 LayoutStrategy::HandleChildSizing(const Rect& OldSelfRect, const Rect& NewSelfRect, QuadRenderable* Child)
228  {
229  Vector2 NewSize;
230  Vector2 OldSize = Child->GetActualSize();
231  const SizingInfo& ChildSizing = Child->GetSizingPolicy();
232 
233  // Check for configurations that are just not doable
236  { MEZZ_EXCEPTION(ExceptionBase::INVALID_STATE_EXCEPTION,"Both axes of a SizingPolicy cannot attempt to match the other axis. This creates a circular dependency."); }
237  if( ChildSizing.HorizontalRules == UI::SR_Match_Other_Axis && ChildSizing.VerticalRules == UI::SR_Size_For_Text )
238  { MEZZ_EXCEPTION(ExceptionBase::INVALID_STATE_EXCEPTION,"Cannot attempt to match vertical axis when it is sizing for text. This creates a circular dependency."); }
239  if( ChildSizing.HorizontalRules == UI::SR_Size_For_Text )
240  { MEZZ_EXCEPTION(ExceptionBase::INVALID_STATE_EXCEPTION,"Cannot size for text on the horizontal axis."); }
241 
242  // In general, process the vertical dimension first. This is because vertical resizing is likely to be less extreme compared to horizontal
243  // in the case of transitioning from widescreen to standard viewing formats. In general, horizontal is more likely to be the dependent axis.
244  // That is of course unless Vertical is explicitly declared otherwise. So check for that.
245  if( ChildSizing.VerticalRules != UI::SR_Match_Other_Axis ) {
246  // Vertical first
247  NewSize.Y = MathTools::Ceil( this->HandleChildVerticalSizing(OldSelfRect,NewSelfRect,0,Child) );
248  // Horizontal second
249  NewSize.X = MathTools::Ceil( this->HandleChildHorizontalSizing(OldSelfRect,NewSelfRect,NewSize.Y,Child) );
250  }else{
251  // Horizontal first
252  NewSize.X = MathTools::Ceil( this->HandleChildHorizontalSizing(OldSelfRect,NewSelfRect,0,Child) );
253  // Vertical second
254  NewSize.Y = MathTools::Ceil( this->HandleChildVerticalSizing(OldSelfRect,NewSelfRect,NewSize.X,Child) );
255  }
256 
257  // Preserve the aspect ratio if we need to
258  this->CheckChildAspectRatio(OldSize,NewSize,Child);
259 
260  // Clamp to our min and max sizes
261  this->ClampChildToMinSize(NewSelfRect,NewSize,Child);
262  this->ClampChildToMaxSize(NewSelfRect,NewSize,Child);
263 
264  return NewSize;
265  }
266 
267  Real LayoutStrategy::HandleChildHorizontalSizing(const Rect& OldSelfRect, const Rect& NewSelfRect, const Real PrevAxisResult, QuadRenderable* Child)
268  {
269  Real Ret = 0.0;
270  const SizingInfo& ChildSizing = Child->GetSizingPolicy();
271  Vector2 OldSize = Child->GetActualSize();
272  // Horizontal second
273  switch(ChildSizing.HorizontalRules)
274  {
275  case UI::SR_Unified_Dims:
276  { Ret = ChildSizing.USize.X.CalculateActualDimension(NewSelfRect.Size.X); break; }
278  { Ret = PrevAxisResult; break; }
280  { Ret = ChildSizing.USize.X.CalculateActualDimension(PrevAxisResult); break; }
281  case UI::SR_Fixed_Size:
282  default:
283  { Ret = OldSize.X; break; }
284  }
285  return std::max(Ret,Real(0.0));
286  }
287 
288  Real LayoutStrategy::HandleChildVerticalSizing(const Rect& OldSelfRect, const Rect& NewSelfRect, const Real PrevAxisResult, QuadRenderable* Child)
289  {
290  Real Ret = 0.0;
291  const SizingInfo& ChildSizing = Child->GetSizingPolicy();
292  Vector2 OldSize = Child->GetActualSize();
293  // Vertical first
294  switch(ChildSizing.VerticalRules)
295  {
296  case UI::SR_Unified_Dims:
297  { Ret = ChildSizing.USize.Y.CalculateActualDimension(NewSelfRect.Size.Y); break; }
299  { Ret = PrevAxisResult; break; }
301  { Ret = ChildSizing.USize.Y.CalculateActualDimension(PrevAxisResult); break; }
303  { Child->PopulateTextLinesInLayers(PrevAxisResult); Ret = Child->GetIdealHeightForText() + 2.0; break; }
304  case UI::SR_Fixed_Size:
305  default:
306  { Ret = OldSize.Y; break; }
307  }
308  return std::max(Ret,Real(0.0));
309  }
310 
311  void LayoutStrategy::CheckChildAspectRatio(const Vector2& OldChildSize, Vector2& NewChildSize, QuadRenderable* Child)
312  {
313  const SizingInfo& ChildSizing = Child->GetSizingPolicy();
314  // Do we care about aspect ratio?
315  // Did we used to have a size?
316  // And did the aspect ratio change?
317  if( ChildSizing.RatioLock != UI::ARL_Ratio_Unlocked &&
318  ( OldChildSize.X > 0.0 && OldChildSize.Y > 0.0) &&
319  !MathTools::WithinTolerance( NewChildSize.X / NewChildSize.Y, OldChildSize.X / OldChildSize.Y, 0.01 ) )
320  {
321  Real XChange = NewChildSize.X / OldChildSize.X;
322  Real YChange = NewChildSize.Y / OldChildSize.Y;
323 
324  if( ChildSizing.RatioLock != UI::ARL_Ratio_Y_Axis ) {
325  if( XChange > YChange ) {
326  if( ChildSizing.RatioLock == UI::ARL_Ratio_Locked_Expanding )
327  NewChildSize.Y = OldChildSize.Y * XChange;
328  else if( ChildSizing.RatioLock == UI::ARL_Ratio_Locked_Shrinking )
329  NewChildSize.X = OldChildSize.X * YChange;
330  }else if( YChange > XChange ) {
331  if( ChildSizing.RatioLock == UI::ARL_Ratio_Locked_Expanding )
332  NewChildSize.X = OldChildSize.X * YChange;
333  else if( ChildSizing.RatioLock == UI::ARL_Ratio_Locked_Shrinking )
334  NewChildSize.Y = OldChildSize.Y * XChange;
335  }
336  }else{
337  NewChildSize.X = OldChildSize.X * YChange;
338  }
339  }
340  }
341 
342  void LayoutStrategy::ClampChildToMinSize(const Rect& NewSelfRect, Vector2& NewChildSize, QuadRenderable* Child)
343  {
344  const SizingInfo& ChildSizing = Child->GetSizingPolicy();
345  if( ChildSizing.MinSize.X.Rel != 0 && ChildSizing.MinSize.X.Abs != 0 &&
346  ChildSizing.MinSize.Y.Rel != 0 && ChildSizing.MinSize.Y.Abs != 0 )
347  {
348  Vector2 TempVec = ChildSizing.MinSize.CalculateActualDimensions(NewSelfRect.Size);
349  NewChildSize.X = std::max(NewChildSize.X,TempVec.X);
350  NewChildSize.Y = std::max(NewChildSize.Y,TempVec.Y);
351  }
352  }
353 
354  void LayoutStrategy::ClampChildToMaxSize(const Rect& NewSelfRect, Vector2& NewChildSize, QuadRenderable* Child)
355  {
356  const SizingInfo& ChildSizing = Child->GetSizingPolicy();
357  if( ChildSizing.MaxSize.X.Rel != 0 && ChildSizing.MaxSize.X.Abs != 0 &&
358  ChildSizing.MaxSize.Y.Rel != 0 && ChildSizing.MaxSize.Y.Abs != 0 )
359  {
360  Vector2 TempVec = ChildSizing.MaxSize.CalculateActualDimensions(NewSelfRect.Size);
361  NewChildSize.X = std::min(NewChildSize.X,TempVec.X);
362  NewChildSize.Y = std::min(NewChildSize.Y,TempVec.Y);
363  }
364  }
365  }//UI
366 }//Mezzanine
367 
368 #endif
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.
Definition: unifieddim.h:313
bool Boole
Generally acts a single bit, true or false.
Definition: datatypes.h:173
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.
Definition: rect.h:180
Vector2 Size
Vector2 representing the width and height of the rect.
Definition: rect.h:71
Anchors to the bottom side of the quad.
Real GetTopEdge() const
Gets the value of the top edge of this rect.
Definition: rect.h:149
Real Rel
The relative value on this dimension.
Definition: unifieddim.h:63
#define MEZZ_EXCEPTION(num, desc)
An easy way to throw exceptions with rich information.
Definition: exception.h:3048
This is a helper class designed to describe the behaviors of a quad when it needs to be resized...
Definition: sizinginfo.h:56
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.
Definition: sizinginfo.h:73
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.
Definition: rect.h:174
This class represents a box shaped area on the screen.
Definition: rect.h:55
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.
Definition: unifieddim.h:65
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...
Definition: unifieddim.h:384
Whole VerticalRules
Rules for resizing on the Y axis.
Definition: sizinginfo.h:69
float Real
A Datatype used to represent a real floating point number.
Definition: datatypes.h:141
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.
Definition: vector2.h:69
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.
Definition: vector2.h:67
This is used to represent a point on a 2 dimentional area, such as a screen.
Definition: vector2.h:63
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.
Definition: rect.h:167
UnifiedDim Y
The dimension on the Y plane.
Definition: unifieddim.h:315
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.
Definition: exception.h:113
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.
Definition: actor.cpp:56
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.
Definition: sizinginfo.h:67
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.
Definition: sizinginfo.h:63
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.
Definition: rect.h:161
Real GetBottomEdge() const
Gets the value of the bottom edge of this rect.
Definition: rect.h:155
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.
Definition: rect.h:69
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.
Definition: sizinginfo.h:71
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...
Definition: unifieddim.h:109
UnifiedVec2 MaxSize
The maximum permitted size.
Definition: sizinginfo.h:65
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.