Spinning Topp Logo BlackTopp Studios
inc
quadrenderable.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 _uiquadrenderable_cpp
41 #define _uiquadrenderable_cpp
42 
43 #include "UI/quadrenderable.h"
44 
45 #include "UI/renderlayergroup.h"
46 #include "UI/layoutstrategy.h"
47 #include "UI/widget.h"
48 #include "UI/screen.h"
49 
50 #include "UI/multiimagelayer.h"
51 #include "UI/singleimagelayer.h"
52 #include "UI/multilinetextlayer.h"
53 #include "UI/singlelinetextlayer.h"
54 
55 #include "stringtool.h"
56 #include "serialization.h"
57 
58 #include <algorithm>
59 
60 namespace Mezzanine
61 {
62  namespace UI
63  {
64  ///////////////////////////////////////////////////////////////////////////////
65  // QuadRenderable Methods
66 
68  Renderable(Parent),
69  ParentQuad(NULL),
70  ActiveGroup(NULL),
71  LayoutStrat(NULL),
72  VertexCache(NULL),
73  ZOrder(0),
74  MousePassthrough(false),
75  ManualTransformUpdates(false),
76  AllLayersDirty(false)
77  { this->ActDims.SetIdentity(); }
78 
79  QuadRenderable::QuadRenderable(const String& RendName, Screen* Parent) :
80  Renderable(RendName,Parent),
81  ParentQuad(NULL),
82  ActiveGroup(NULL),
83  LayoutStrat(NULL),
84  VertexCache(NULL),
85  ZOrder(0),
86  MousePassthrough(false),
87  ManualTransformUpdates(false),
88  AllLayersDirty(false)
89  { this->ActDims.SetIdentity(); }
90 
91  QuadRenderable::QuadRenderable(const String& RendName, const UnifiedRect& RendRect, Screen* Parent) :
92  Renderable(RendName,Parent),
93  ParentQuad(NULL),
94  ActiveGroup(NULL),
95  LayoutStrat(NULL),
96  VertexCache(NULL),
97  ZOrder(0),
98  MousePassthrough(false),
99  ManualTransformUpdates(false),
100  AllLayersDirty(false)
101  {
102  this->ActDims.SetIdentity();
103 
104  this->PositioningPolicy.UPosition = RendRect.Position;
105  this->SizingPolicy.USize = RendRect.Size;
106  }
107 
109  {
110  for( ChildIterator ChildIt = this->ChildWidgets.begin() ; ChildIt != this->ChildWidgets.end() ; ++ChildIt )
111  { this->ParentScreen->DestroyWidget( (*ChildIt) ); }
112  this->ChildWidgets.clear();
114  this->DestroyAllRenderLayers();
115  this->SetLocalVertexCaching(false);
116  if( this->LayoutStrat != NULL ) {
117  delete this->LayoutStrat;
118  this->LayoutStrat = NULL;
119  }
120  }
121 
123  {
124  this->ProtoSerializeProperties(SelfRoot);
125  this->ProtoSerializeRenderLayers(SelfRoot);
126  this->ProtoSerializeRenderLayerGroups(SelfRoot);
127  }
128 
130  {
131  // Get the render layers first in this case as our properties partially depend on them (ActiveGroup)
132  this->ProtoDeSerializeRenderLayers(SelfRoot);
133  this->ProtoDeSerializeRenderLayerGroups(SelfRoot);
134  this->ProtoDeSerializeProperties(SelfRoot);
135  }
136 
137  void QuadRenderable::AppendLayerVertices(std::vector<VertexData>& Vertices)
138  {
139  if( this->ActiveGroup != NULL ) {
141  { (*It).second->_AppendVertices(Vertices); }
142  }
143  }
144 
146  {
147  if( NewSize > this->RenderLayers.size() ) {
148  Whole Pow2 = 1;
149  while( Pow2 < NewSize )
150  Pow2 <<= 1;
151 
152  this->RenderLayers.resize(Pow2,NULL);
153  }
154  }
155 
157  {
158  RenderLayerGroup* NewGroup = new RenderLayerGroup(ID,this);
159  if( this->RenderLayerGroups.empty() && this->ActiveGroup == NULL ) {
160  this->SetActiveGroup( NewGroup );
161  }
162  this->RenderLayerGroups.push_back( NewGroup );
163  return NewGroup;
164  }
165 
166  ///////////////////////////////////////////////////////////////////////////////
167  // Utility Methods
168 
170  { return this->ZOrder; }
171 
173  { return ( this->ChildWidgets.empty() ? 0 : this->ChildWidgets.back()->GetZOrder() ); }
174 
176  { return ( this->ChildWidgets.empty() ? 0 : this->ChildWidgets.front()->GetZOrder() ); }
177 
179  {
180  ChildContainer TempContainer;
181  this->ChildWidgets.swap(TempContainer);
182  for( ChildIterator TempIt = TempContainer.begin() ; TempIt != TempContainer.end() ; ++TempIt )
183  {
184  UInt16 Zorder = (*TempIt)->GetZOrder();
185  for( ChildIterator ChildIt = this->ChildWidgets.begin() ; ChildIt != this->ChildWidgets.end() ; ++ChildIt )
186  {
187  if( (*ChildIt)->GetZOrder() > Zorder ) {
188  this->ChildWidgets.insert(ChildIt,(*TempIt));
189  (*TempIt)->_MarkAllChildrenDirty();
190  return;
191  }
192  }
193  this->ChildWidgets.push_back(*TempIt);
194  (*TempIt)->_MarkAllChildrenDirty();
195  }
196  }
197 
199  { return this->GetRect().CheckOverlap(Quad->GetRect()); }
200 
202  { return this->GetRect().IsInside(Point); }
203 
205  { return (this->ParentScreen == this->ParentQuad); }
206 
208  {
209  for( RenderLayerIterator LayerIt = this->RenderLayers.begin() ; LayerIt != this->RenderLayers.end() ; ++LayerIt )
210  {
211  UI::RenderLayerType LayerType = (*LayerIt)->GetLayerType();
212  if( LayerType == UI::RLT_MultiLineText || LayerType == UI::RLT_SingleLineText ) {
213  static_cast<TextLayer*>( *LayerIt )->PopulateTextLines(MaxWidth * (*LayerIt)->GetScale().X);
214  }
215  }
216  }
217 
219  {
220  Real Ret = 0;
221  for( ConstRenderLayerIterator LayerIt = this->RenderLayers.begin() ; LayerIt != this->RenderLayers.end() ; ++LayerIt )
222  {
223  UI::RenderLayerType LayerType = (*LayerIt)->GetLayerType();
224  if( LayerType == UI::RLT_MultiLineText || LayerType == UI::RLT_SingleLineText ) {
225  Real LayerHeight = static_cast<TextLayer*>( *LayerIt )->GetTotalHeight();
226  if( LayerHeight > Ret )
227  Ret = LayerHeight;
228  }
229  }
230  return Ret;
231  }
232 
234  {
235  if( this->ParentQuad ) {
236  Rect ParentRect = this->ParentQuad->GetRect();
237  this->ParentQuad->UpdateDimensions(ParentRect,ParentRect);
238  }
239  }
240 
242  {
243  Rect TempRect = this->GetRect();
244  this->UpdateDimensions(TempRect,TempRect);
245  }
246 
247  void QuadRenderable::UpdateDimensions(const Rect& OldSelfRect, const Rect& NewSelfRect)
248  {
249  // Update the personal data first
250  this->ActDims = NewSelfRect;
251 
252  // Update the children, if we have a layout strat and the chidlren exist
253  if( this->LayoutStrat != NULL && this->ChildWidgets.empty() == false )
254  this->LayoutStrat->Layout(OldSelfRect,NewSelfRect,this->ChildWidgets);
255 
256  // We done got icky
257  this->_MarkAllLayersDirty();
258  }
259 
261  { this->MousePassthrough = Enable; }
262 
264  { return this->MousePassthrough; }
265 
267  { this->ManualTransformUpdates = Enable; }
268 
270  { return this->ManualTransformUpdates; }
271 
272  ///////////////////////////////////////////////////////////////////////////////
273  // Transform Policy Methods
274 
276  {
277  if( this->PositioningPolicy != Policy ) {
278  this->PositioningPolicy = Policy;
279  }
280  }
281 
283  {
284  return this->PositioningPolicy;
285  }
286 
288  {
289  if( this->SizingPolicy != Policy ) {
290  this->SizingPolicy = Policy;
291  }
292  }
293 
295  {
296  return this->SizingPolicy;
297  }
298 
300  {
301  if( this->PositioningPolicy.HorizontalRules != Rules ) {
302  this->PositioningPolicy.HorizontalRules = Rules;
303  }
304  }
305 
307  {
308  return this->PositioningPolicy.HorizontalRules;
309  }
310 
312  {
313  if( this->PositioningPolicy.VerticalRules != Rules ) {
314  this->PositioningPolicy.VerticalRules = Rules;
315  }
316  }
317 
319  {
320  return this->PositioningPolicy.VerticalRules;
321  }
322 
324  {
325  if( this->SizingPolicy.HorizontalRules != Rules ) {
326  this->SizingPolicy.HorizontalRules = Rules;
327  }
328  }
329 
331  {
332  return this->SizingPolicy.HorizontalRules;
333  }
334 
336  {
337  if( this->SizingPolicy.VerticalRules != Rules ) {
338  this->SizingPolicy.VerticalRules = Rules;
339  }
340  }
341 
343  {
344  return this->SizingPolicy.VerticalRules;
345  }
346 
348  {
349  if( this->SizingPolicy.RatioLock != Lock ) {
350  this->SizingPolicy.RatioLock = Lock;
351  }
352  }
353 
355  {
356  return this->SizingPolicy.RatioLock;
357  }
358 
360  {
361  if( this->SizingPolicy.MinSize != Min ) {
362  this->SizingPolicy.MinSize = Min;
363  }
364  }
365 
367  {
368  return this->SizingPolicy.MinSize;
369  }
370 
372  {
373  if( this->SizingPolicy.MaxSize != Max ) {
374  this->SizingPolicy.MaxSize = Max;
375  }
376  }
377 
379  {
380  return this->SizingPolicy.MaxSize;
381  }
382 
383  ///////////////////////////////////////////////////////////////////////////////
384  // RenderLayer Management
385 
387  {
388  SingleImageLayer* NewLayer = new SingleImageLayer(this);
389  NewLayer->_UpdateIndex(this->RenderLayers.size());
390  this->RenderLayers.push_back(NewLayer);
391  this->_MarkDirty();
392  return NewLayer;
393  }
394 
396  {
397  SingleImageLayer* NewLayer = this->CreateSingleImageLayer();
398  this->AddLayerToExistingGroup(NewLayer,NormalZ,Widget::WG_Normal);
399  this->AddLayerToExistingGroup(NewLayer,HoveredZ,Widget::WG_Hovered);
400  return NewLayer;
401  }
402 
404  {
405  SingleImageLayer* NewLayer = this->CreateSingleImageLayer();
406  this->AddLayerToGroup(NewLayer,GroupAndZ);
407  return NewLayer;
408  }
409 
411  {
412  SingleImageLayer* NewLayer = this->CreateSingleImageLayer();
413  NewLayer->SetSprite(SpriteName);
414  return NewLayer;
415  }
416 
417  SingleImageLayer* QuadRenderable::CreateSingleImageLayer(const String& SpriteName, const UInt16 NormalZ, const UInt16 HoveredZ)
418  {
419  SingleImageLayer* NewLayer = this->CreateSingleImageLayer(SpriteName);
420  this->AddLayerToExistingGroup(NewLayer,NormalZ,Widget::WG_Normal);
421  this->AddLayerToExistingGroup(NewLayer,HoveredZ,Widget::WG_Hovered);
422  return NewLayer;
423  }
424 
426  {
427  SingleImageLayer* NewLayer = this->CreateSingleImageLayer(GroupAndZ);
428  NewLayer->SetSprite(SpriteName);
429  return NewLayer;
430  }
431 
433  {
434  MultiImageLayer* NewLayer = new MultiImageLayer(this);
435  NewLayer->_UpdateIndex(this->RenderLayers.size());
436  this->RenderLayers.push_back(NewLayer);
437  this->_MarkDirty();
438  return NewLayer;
439  }
440 
442  {
443  MultiImageLayer* NewLayer = this->CreateMultiImageLayer();
444  this->AddLayerToExistingGroup(NewLayer,NormalZ,Widget::WG_Normal);
445  this->AddLayerToExistingGroup(NewLayer,HoveredZ,Widget::WG_Hovered);
446  return NewLayer;
447  }
448 
450  {
451  MultiImageLayer* NewLayer = this->CreateMultiImageLayer();
452  this->AddLayerToGroup(NewLayer,GroupAndZ);
453  return NewLayer;
454  }
455 
457  {
458  SingleLineTextLayer* NewLayer = new SingleLineTextLayer(this);
459  NewLayer->_UpdateIndex(this->RenderLayers.size());
460  this->RenderLayers.push_back(NewLayer);
461  this->_MarkDirty();
462  return NewLayer;
463  }
464 
466  {
468  this->AddLayerToExistingGroup(NewLayer,NormalZ,Widget::WG_Normal);
469  this->AddLayerToExistingGroup(NewLayer,HoveredZ,Widget::WG_Hovered);
470  return NewLayer;
471  }
472 
474  {
476  this->AddLayerToGroup(NewLayer,GroupAndZ);
477  return NewLayer;
478  }
479 
481  {
482  SingleLineTextLayer* NewLayer = new SingleLineTextLayer(FontName,this);
483  NewLayer->_UpdateIndex(this->RenderLayers.size());
484  this->RenderLayers.push_back(NewLayer);
485  this->_MarkDirty();
486  return NewLayer;
487  }
488 
489  SingleLineTextLayer* QuadRenderable::CreateSingleLineTextLayer(const String& FontName, const UInt16 NormalZ, const UInt16 HoveredZ)
490  {
491  SingleLineTextLayer* NewLayer = this->CreateSingleLineTextLayer(FontName);
492  this->AddLayerToExistingGroup(NewLayer,NormalZ,Widget::WG_Normal);
493  this->AddLayerToExistingGroup(NewLayer,HoveredZ,Widget::WG_Hovered);
494  return NewLayer;
495  }
496 
498  {
499  SingleLineTextLayer* NewLayer = this->CreateSingleLineTextLayer(FontName);
500  this->AddLayerToGroup(NewLayer,GroupAndZ);
501  return NewLayer;
502  }
503 
505  {
506  MultiLineTextLayer* NewLayer = new MultiLineTextLayer(this);
507  NewLayer->_UpdateIndex(this->RenderLayers.size());
508  this->RenderLayers.push_back(NewLayer);
509  this->_MarkDirty();
510  return NewLayer;
511  }
512 
514  {
515  MultiLineTextLayer* NewLayer = this->CreateMultiLineTextLayer();
516  this->AddLayerToExistingGroup(NewLayer,NormalZ,Widget::WG_Normal);
517  this->AddLayerToExistingGroup(NewLayer,HoveredZ,Widget::WG_Hovered);
518  return NewLayer;
519  }
520 
522  {
523  MultiLineTextLayer* NewLayer = this->CreateMultiLineTextLayer();
524  this->AddLayerToGroup(NewLayer,GroupAndZ);
525  return NewLayer;
526  }
527 
529  {
530  MultiLineTextLayer* NewLayer = new MultiLineTextLayer(FontName,this);
531  NewLayer->_UpdateIndex(this->RenderLayers.size());
532  this->RenderLayers.push_back(NewLayer);
533  this->_MarkDirty();
534  return NewLayer;
535  }
536 
537  MultiLineTextLayer* QuadRenderable::CreateMultiLineTextLayer(const String& FontName, const UInt16 NormalZ, const UInt16 HoveredZ)
538  {
539  MultiLineTextLayer* NewLayer = this->CreateMultiLineTextLayer(FontName);
540  this->AddLayerToExistingGroup(NewLayer,NormalZ,Widget::WG_Normal);
541  this->AddLayerToExistingGroup(NewLayer,HoveredZ,Widget::WG_Hovered);
542  return NewLayer;
543  }
544 
546  {
547  MultiLineTextLayer* NewLayer = this->CreateMultiLineTextLayer(FontName);
548  this->AddLayerToGroup(NewLayer,GroupAndZ);
549  return NewLayer;
550  }
551 
553  { return this->RenderLayers.at(Index); }
554 
556  {
557  Whole Num = 0;
558  for( RenderLayerIterator RendIt = this->RenderLayers.begin() ; RendIt != this->RenderLayers.end() ; ++RendIt )
559  {
560  if( (*RendIt)->GetLayerType() == Type ) {
561  if( Num == Which ) {
562  return (*RendIt);
563  }
564  ++Num;
565  }
566  }
567  return NULL;
568  }
569 
571  { return this->RenderLayers.size(); }
572 
574  { return ( this->ActiveGroup != NULL ? this->ActiveGroup->GetNumRenderLayers() : 0 ); }
575 
577  {
578  for( RenderLayerGroupIterator GroupIt = this->RenderLayerGroups.begin() ; GroupIt != this->RenderLayerGroups.end() ; ++GroupIt )
579  {
580  (*GroupIt)->RemoveLayer(ToBeDestroyed);
581  }
582  for( Whole Index = 0 ; Index < this->RenderLayers.size() ; ++Index )
583  {
584  if( ToBeDestroyed == this->RenderLayers[Index] ) {
585  if( Index != this->RenderLayers.size() - 1 ) {
586  // swap...
587  std::swap(this->RenderLayers[Index],this->RenderLayers[this->RenderLayers.size()-1]);
588  this->RenderLayers[Index]->_UpdateIndex(Index);
589  }
590  // ...and pop
591  this->RenderLayers.pop_back();
592  break;
593  }
594  }
595  delete ToBeDestroyed;
596  }
597 
599  {
600  for( RenderLayerGroupIterator GroupIt = this->RenderLayerGroups.begin() ; GroupIt != this->RenderLayerGroups.end() ; ++GroupIt )
601  {
602  (*GroupIt)->RemoveAllLayers();
603  }
604  for( RenderLayerIterator It = this->RenderLayers.begin() ; It != this->RenderLayers.end() ; ++It )
605  {
606  delete (*It);
607  }
608  this->RenderLayers.clear();
609  }
610 
612  { return this->RenderLayers.begin(); }
613 
615  { return this->RenderLayers.end(); }
616 
618  { return this->RenderLayers.begin(); }
619 
621  { return this->RenderLayers.end(); }
622 
623  ///////////////////////////////////////////////////////////////////////////////
624  // RenderLayerGroup Management
625 
627  {
628  RenderLayerGroup* ToSet = this->GetRenderLayerGroup(GroupID);
629  if( ToSet != NULL ) {
630  this->SetActiveGroup( ToSet );
631  }else{
632  MEZZ_EXCEPTION(ExceptionBase::II_IDENTITY_NOT_FOUND_EXCEPTION,"RenderLayerGroup named \"" + Name + "\" does not exist in QuadRenderable: \"" + this->GetName() + "\"." );
633  }
634  }
635 
637  {
638  if( this->ActiveGroup != Group ) {
639  // Out with the old
640  if( this->ActiveGroup != NULL ) {
641  this->ActiveGroup->NotifyInactive();
642  }
643  // In with the new
644  this->ActiveGroup = Group;
645  if( this->ActiveGroup != NULL ) {
646  this->ActiveGroup->NotifyActive();
647  }
648  this->_MarkDirty();
649  }
650  }
651 
653  { return this->ActiveGroup; }
654 
656  { return ( this->GetRenderLayerGroup(GroupID) != NULL ); }
657 
659  { return this->RenderLayerGroups.size(); }
660 
661  void QuadRenderable::AddLayerToGroup(RenderLayer* Layer, const UInt16 LayerZOrder, const UInt16 GroupID)
662  { this->CreateOrRetrieveRenderLayerGroup(GroupID)->AddLayer(Layer,LayerZOrder); }
663 
665  { this->AddLayerToGroup(Layer,GroupAndZ.LayerZOrder,GroupAndZ.GroupID); }
666 
667  void QuadRenderable::AddLayerToExistingGroup(RenderLayer* Layer, const UInt16 LayerZOrder, const UInt16 GroupID)
668  {
669  RenderLayerGroup* ExistingGroup = this->GetRenderLayerGroup(GroupID);
670  if( ExistingGroup != NULL ) {
671  ExistingGroup->AddLayer(Layer,LayerZOrder);
672  }
673  }
674 
676  {
677  for( GroupOrderEntryVector::const_iterator It = Entrys.begin() ; It != Entrys.end() ; ++It )
678  { this->CreateOrRetrieveRenderLayerGroup( (*It).GroupID )->AddLayer( Layer, (*It).LayerZOrder ); }
679  }
680 
682  {
683  RenderLayerGroup* GroupCheck = this->GetRenderLayerGroup(GroupID);
684  if( GroupCheck != NULL ) {
685  GroupCheck->RemoveLayer(Layer);
686  }
687  }
688 
690  {
691  for( RenderLayerGroupIterator GroupIt = this->RenderLayerGroups.begin() ; GroupIt != this->RenderLayerGroups.end() ; ++GroupIt )
692  { (*GroupIt)->RemoveLayer(Layer); }
693  }
694 
696  {
697  RenderLayerGroup* GroupCheck = this->GetRenderLayerGroup(GroupID);
698  if( GroupCheck == NULL ) {
699  return this->CreateRenderLayerGroupNoCheck(GroupID);
700  }else{
701  MEZZ_EXCEPTION(ExceptionBase::II_DUPLICATE_IDENTITY_EXCEPTION,"RenderLayerGroup named \"" + Name + "\" already exists in QuadRenderable: \"" + this->GetName() + "\"." );
702  }
703  return NULL;//This should never happen, but compilation warnings are annoying.
704  }
705 
707  {
708  RenderLayerGroup* Ret = this->GetRenderLayerGroup(GroupID);
709  if( Ret == NULL ) {
710  Ret = this->CreateRenderLayerGroupNoCheck(GroupID);
711  }
712  return Ret;
713  }
714 
716  {
717  for( ConstRenderLayerGroupIterator GroupIt = this->RenderLayerGroups.begin() ; GroupIt != this->RenderLayerGroups.end() ; ++GroupIt )
718  {
719  if( (*GroupIt)->GetGroupID() == GroupID ) {
720  return (*GroupIt);
721  }
722  }
723  return NULL;
724  }
725 
727  {
728  for( RenderLayerGroupIterator GroupIt = this->RenderLayerGroups.begin() ; GroupIt != this->RenderLayerGroups.end() ; ++GroupIt )
729  {
730  if( (*GroupIt)->GetGroupID() == GroupID ) {
731  delete (*GroupIt);
732  this->RenderLayerGroups.erase(GroupIt);
733  return;
734  }
735  }
736  }
737 
739  {
740  this->DestroyRenderLayerGroup(ToBeDestroyed->GetGroupID());
741  }
742 
744  {
745  for( RenderLayerGroupIterator GroupIt = this->RenderLayerGroups.begin() ; GroupIt != this->RenderLayerGroups.end() ; ++GroupIt )
746  { delete (*GroupIt); }
747  this->RenderLayerGroups.clear();
748  }
749 
751  { return this->RenderLayerGroups.begin(); }
752 
754  { return this->RenderLayerGroups.end(); }
755 
757  { return this->RenderLayerGroups.begin(); }
758 
760  { return this->RenderLayerGroups.end(); }
761 
762  ///////////////////////////////////////////////////////////////////////////////
763  // Child Management
764 
766  {
767  if( this->GetRenderableType() == Renderable::RT_Screen ) {
768  // If this is the screen adding a direct child, enable vertex caching
769  Child->SetLocalVertexCaching(true);
770  }
771 
772  UInt16 Zorder = Child->GetZOrder();
773  for( ChildIterator It = this->ChildWidgets.begin() ; It != this->ChildWidgets.end() ; ++It )
774  {
775  if( (*It)->GetZOrder() > Zorder ) {
776  this->ChildWidgets.insert(It,Child);
777  Child->SetVisible( this->GetVisible() );
778  Child->_NotifyParenthood(this);
779  Child->_MarkAllChildrenDirty();
780  this->_MarkDirty();
781  return;
782  }
783  }
784  this->ChildWidgets.push_back(Child);
785  Child->SetVisible( this->GetVisible() );
786  Child->_NotifyParenthood(this);
787  Child->_MarkAllChildrenDirty();
788  this->_MarkDirty();
789  }
790 
791  void QuadRenderable::AddChild(Widget* Child, const UInt16 ZOrder)
792  {
793  Child->_SetZOrder(ZOrder);
794  this->AddChild(Child);
795  }
796 
798  {
799  for( ConstChildIterator ChildIt = this->ChildWidgets.begin() ; ChildIt != this->ChildWidgets.end() ; ++ChildIt )
800  {
801  if( Zorder == (*ChildIt)->GetZOrder() )
802  return (*ChildIt);
803  }
804  return NULL;
805  }
806 
807  Widget* QuadRenderable::GetChild(const String& RendName) const
808  {
809  for( ConstChildIterator ChildIt = this->ChildWidgets.begin() ; ChildIt != this->ChildWidgets.end() ; ++ChildIt )
810  {
811  if( RendName == (*ChildIt)->GetName() )
812  return (*ChildIt);
813  }
814  return NULL;
815  }
816 
818  {
819  return this->ChildWidgets.size();
820  }
821 
823  {
824  for( ChildIterator It = this->ChildWidgets.begin() ; It != this->ChildWidgets.end() ; ++It )
825  {
826  if( Child == (*It) ) {
827  Child->_NotifyParenthood(NULL);
828  this->ChildWidgets.erase(It);
829  this->_MarkDirty();
830  return;
831  }
832  }
833  }
834 
836  {
837  for( ChildIterator It = this->ChildWidgets.begin() ; It != this->ChildWidgets.end() ; ++It )
838  {
839  (*It)->_NotifyParenthood(NULL);
840  }
841  this->ChildWidgets.clear();
842  this->_MarkDirty();
843  }
844 
846  {
847  for( ChildIterator It = this->ChildWidgets.begin() ; It != this->ChildWidgets.end() ; ++It )
848  {
849  if( ToBeDestroyed == (*It) ) {
850  ToBeDestroyed->_NotifyParenthood(NULL);
851  this->ChildWidgets.erase(It);
852  this->ParentScreen->DestroyWidget(ToBeDestroyed);
853  this->_MarkDirty();
854  return;
855  }
856  }
857  }
858 
860  {
861  for( ChildIterator It = this->ChildWidgets.begin() ; It != this->ChildWidgets.end() ; ++It )
862  {
863  (*It)->_NotifyParenthood(NULL);
864  this->ParentScreen->DestroyWidget( (*It) );
865  }
866  this->ChildWidgets.clear();
867  this->_MarkDirty();
868  }
869 
871  { return this->ChildWidgets.begin(); }
872 
874  { return this->ChildWidgets.end(); }
875 
877  { return this->ChildWidgets.begin(); }
878 
880  { return this->ChildWidgets.end(); }
881 
883  { return this->ChildWidgets.rbegin(); }
884 
886  { return this->ChildWidgets.rend(); }
887 
889  { return this->ChildWidgets.rbegin(); }
890 
892  { return this->ChildWidgets.rend(); }
893 
894  ///////////////////////////////////////////////////////////////////////////////
895  // Transform Methods
896 
898  {
899  if( this->PositioningPolicy.UPosition != Position ) {
900  this->PositioningPolicy.UPosition = Position;
901  }
902  }
903 
905  {
906  if( this->SizingPolicy.USize != Size ) {
907  this->SizingPolicy.USize = Size;
908  }
909  }
910 
912  { return this->PositioningPolicy.UPosition; }
913 
915  { return this->SizingPolicy.USize; }
916 
918  { return UnifiedRect(this->PositioningPolicy.UPosition,this->SizingPolicy.USize); }
919 
921  { return this->ActDims.Position; }
922 
924  { return this->ActDims.Size; }
925 
927  { return this->ActDims; }
928 
929  ///////////////////////////////////////////////////////////////////////////////
930  // Fetch Methods
931 
933  { return this->ParentQuad; }
934 
936  {
937  if( this->ParentQuad ) {
938  ConstChildIterator ParentEnd = this->ParentQuad->ChildrenEnd();
939  ConstChildIterator ParentBegin = this->ParentQuad->ChildrenBegin();
940  for( ConstChildIterator ChildIt = ParentBegin ; ChildIt != ParentEnd ; ++ChildIt )
941  {
942  if( this == (*ChildIt) ) {
943  if( ParentEnd != (++ChildIt) ) return (*ChildIt);
944  else return ( Wrap ? (*ParentBegin) : this );
945  }
946  }
947  }
948  return NULL;
949  }
950 
952  {
953  if( this->ParentQuad ) {
954  ConstChildIterator ParentEnd = this->ParentQuad->ChildrenEnd();
955  ConstChildIterator ParentBegin = this->ParentQuad->ChildrenBegin();
956  for( ConstChildIterator ChildIt = ParentBegin ; ChildIt != ParentEnd ; ++ChildIt )
957  {
958  if( this == (*ChildIt) ) {
959  if( ParentBegin != (--ChildIt) ) return (*ChildIt);
960  else return ( Wrap ? (*ParentEnd) : this );
961  }
962  }
963  }
964  return NULL;
965  }
966 
968  {
969  if( this->IsChildOfScreen() ) {
970  return this;
971  }else{
972  return (this->ParentQuad ? this->ParentQuad->GetTopMostQuad() : this );
973  }
974  }
975 
977  {
978  if( Child != NULL ) {
979  QuadRenderable* RetTest = Child;
980  while( RetTest->GetParent() != NULL && RetTest->GetParent() != this )
981  { RetTest = RetTest->GetParent(); }
982  // By this point the return value will either be NULL or a widget
983  // since it'll hit the ceiling (screen) or find this.
984  // So a blind cast should be safe.
985  return static_cast<Widget*>( RetTest );
986  }
987  return NULL;
988  }
989 
990  ///////////////////////////////////////////////////////////////////////////////
991  // VertexCaching Methods
992 
994  {
995  if(Enable && !VertexCache) {
996  this->VertexCache = new ScreenRenderData();
997  }else if(!Enable && VertexCache) {
998  this->VertexCache->Clear();
999  delete this->VertexCache;
1000  this->VertexCache = NULL;
1001  }
1002  }
1003 
1005  {
1006  return this->VertexCache != NULL;
1007  }
1008 
1009  ///////////////////////////////////////////////////////////////////////////////
1010  // Serialization
1011 
1013  {
1014  XML::Node SelfRoot = ParentNode.AppendChild(this->GetDerivedSerializableName());
1015 
1016  this->ProtoSerializeImpl(SelfRoot);
1017 
1018  // Child quads always get serialized last
1019  this->ProtoSerializeChildQuads(SelfRoot);
1020  }
1021 
1023  {
1024  this->Renderable::ProtoSerializeProperties(SelfRoot);
1025  XML::Node PropertiesNode = SelfRoot.AppendChild( QuadRenderable::GetSerializableName() + "Properties" );
1026 
1027  if( PropertiesNode.AppendAttribute("Version").SetValue("1") &&
1028  PropertiesNode.AppendAttribute("MousePassthrough").SetValue( this->MousePassthrough ? "true" : "false" ) &&
1029  PropertiesNode.AppendAttribute("ManualTransformUpdates").SetValue( this->ManualTransformUpdates ? "true" : "false" ) &&
1030  PropertiesNode.AppendAttribute("ZOrder").SetValue(this->ZOrder) &&
1031  PropertiesNode.AppendAttribute("VertexCache").SetValue( this->IsVertexCachingEnabled() ? "true" : "false" ) )
1032  {
1033  if( this->ActiveGroup != NULL ) {
1034  PropertiesNode.AppendAttribute("ActiveGroup").SetValue( ActiveGroup->GetGroupID() );
1035  }
1036 
1037  XML::Node ActDimsNode = PropertiesNode.AppendChild("Dimensions");
1038  this->ActDims.ProtoSerialize( ActDimsNode );
1039  XML::Node PositioningPolicyNode = PropertiesNode.AppendChild("PositioningPolicy");
1040  this->PositioningPolicy.ProtoSerialize( PositioningPolicyNode );
1041  XML::Node SizingPolicyNode = PropertiesNode.AppendChild("SizingPolicy");
1042  this->SizingPolicy.ProtoSerialize( SizingPolicyNode );
1043 
1044  return;
1045  }else{
1046  SerializeError("Create XML Attribute Values",QuadRenderable::GetSerializableName() + "Properties",true);
1047  }
1048  }
1049 
1051  {
1052  XML::Node LayersNode = SelfRoot.AppendChild( "RenderLayers" );
1053  if( LayersNode.AppendAttribute("Version").SetValue("1") == false ) {
1054  SerializeError("Create XML Version Attribute","RenderLayers",true);
1055  }
1056 
1057  for( ConstRenderLayerIterator LayerIt = this->RenderLayers.begin() ; LayerIt != this->RenderLayers.end() ; ++LayerIt )
1058  {
1059  (*LayerIt)->ProtoSerialize(LayersNode);
1060  }
1061  }
1062 
1064  {
1065  XML::Node GroupsNode = SelfRoot.AppendChild( "RenderLayerGroups" );
1066  if( GroupsNode.AppendAttribute("Version").SetValue("1") == false ) {
1067  SerializeError("Create XML Version Attribute","RenderLayerGroups",true);
1068  }
1069 
1070  for( ConstRenderLayerGroupIterator GroupIt = this->RenderLayerGroups.begin() ; GroupIt != this->RenderLayerGroups.end() ; ++GroupIt )
1071  {
1072  XML::Node CurrGroupNode = GroupsNode.AppendChild( "RenderLayerGroup" );
1073  if( CurrGroupNode.AppendAttribute( "GroupID" ).SetValue( (*GroupIt)->GetGroupID() ) ) {
1074  for( RenderLayerGroup::RenderLayerIterator LayerIt = (*GroupIt)->RenderLayerBegin() ; LayerIt != (*GroupIt)->RenderLayerEnd() ; ++LayerIt )
1075  {
1076  XML::Node CurrLayerNode = CurrGroupNode.AppendChild( "RenderLayer" );
1077 
1078  if( CurrLayerNode.AppendAttribute( "Index" ).SetValue( (*LayerIt).second->GetIndex() ) == false ) {
1079  SerializeError("Create XML Attribute Values","Index",true);
1080  }
1081  if( CurrLayerNode.AppendAttribute( "ZOrder" ).SetValue( (*LayerIt).first ) == false ) {
1082  SerializeError("Create XML Attribute Values","ZOrder",true);
1083  }
1084  }
1085  }else{
1086  SerializeError("Create XML Attribute Values","GroupID",true);
1087  }
1088  }
1089  }
1090 
1092  {
1093  XML::Node ChildrenNode = SelfRoot.AppendChild( "Children" );
1094  if( ChildrenNode.AppendAttribute("Version").SetValue("1") ) {
1095  for( ConstChildIterator ChildIt = this->ChildWidgets.begin() ; ChildIt != this->ChildWidgets.end() ; ++ChildIt )
1096  {
1097  (*ChildIt)->ProtoSerialize(ChildrenNode);
1098  }
1099  }else{
1100  SerializeError("Create XML Version Attribute","Children",true);
1101  }
1102  }
1103 
1105  {
1106  this->ProtoDeSerializeImpl(SelfRoot);
1107 
1108  // Child quads update is always last
1109  this->ProtoDeSerializeChildQuads(SelfRoot);
1110  }
1111 
1113  {
1115 
1116  XML::Attribute CurrAttrib;
1117  XML::Node PropertiesNode = SelfRoot.GetChild( QuadRenderable::GetSerializableName() + "Properties" );
1118 
1119  if( !PropertiesNode.Empty() ) {
1120  if(PropertiesNode.GetAttribute("Version").AsInt() == 1) {
1121  // Get the single data type properties
1122  CurrAttrib = PropertiesNode.GetAttribute("MousePassthrough");
1123  if( !CurrAttrib.Empty() )
1124  this->MousePassthrough = StringTools::ConvertToBool( CurrAttrib.AsString() );
1125 
1126  CurrAttrib = PropertiesNode.GetAttribute("ManualTransformUpdates");
1127  if( !CurrAttrib.Empty() )
1129 
1130  CurrAttrib = PropertiesNode.GetAttribute("ZOrder");
1131  if( !CurrAttrib.Empty() )
1132  this->ZOrder = CurrAttrib.AsWhole();
1133 
1134  CurrAttrib = PropertiesNode.GetAttribute("VertexCache");
1135  if( !CurrAttrib.Empty() )
1137 
1138  CurrAttrib = PropertiesNode.GetAttribute("ActiveGroupName");
1139  if( !CurrAttrib.Empty() )
1140  this->SetActiveGroup( CurrAttrib.AsUint() );
1141 
1142  // Get the properties that need their own nodes
1143  XML::Node DimsNode = PropertiesNode.GetChild("Dimensions").GetFirstChild();
1144  if( !DimsNode.Empty() )
1145  this->ActDims.ProtoDeSerialize(DimsNode);
1146 
1147  XML::Node PositioningNode = PropertiesNode.GetChild("PositioningPolicy").GetFirstChild();
1148  if( !PositioningNode.Empty() )
1149  this->PositioningPolicy.ProtoDeSerialize(PositioningNode);
1150 
1151  XML::Node SizingNode = PropertiesNode.GetChild("SizingPolicy").GetFirstChild();
1152  if( !SizingNode.Empty() )
1153  this->SizingPolicy.ProtoDeSerialize(SizingNode);
1154  }else{
1155  MEZZ_EXCEPTION(ExceptionBase::INVALID_VERSION_EXCEPTION,"Incompatible XML Version for " + (QuadRenderable::GetSerializableName() + "Properties") + ": Not Version 1.");
1156  }
1157  }else{
1158  MEZZ_EXCEPTION(ExceptionBase::II_IDENTITY_NOT_FOUND_EXCEPTION,QuadRenderable::GetSerializableName() + "Properties" + " was not found in the provided XML node, which was expected.");
1159  }
1160  }
1161 
1163  {
1165  this->DestroyAllRenderLayers();
1166  XML::Attribute CurrAttrib;
1167  XML::Node LayersNode = SelfRoot.GetChild( "RenderLayers" );
1168 
1169  if( !LayersNode.Empty() ) {
1170  if(LayersNode.GetAttribute("Version").AsInt() == 1) {
1171  for( XML::NodeIterator LayerNodeIt = LayersNode.begin() ; LayerNodeIt != LayersNode.end() ; ++LayerNodeIt )
1172  {
1173  RenderLayer* CurrLayer = NULL;
1174 
1175  if( (*LayerNodeIt).Name() == String("SingleImageLayer") ) {
1176  CurrLayer = new SingleImageLayer(this);
1177  CurrLayer->ProtoDeSerialize( (*LayerNodeIt) );
1178  this->ResizeLayers( CurrLayer->GetIndex() );
1179  this->RenderLayers[ CurrLayer->GetIndex() ] = CurrLayer;
1180  }else if( (*LayerNodeIt).Name() == String("MultiImageLayer") ) {
1181  CurrLayer = new MultiImageLayer(this);
1182  CurrLayer->ProtoDeSerialize( (*LayerNodeIt) );
1183  this->ResizeLayers( CurrLayer->GetIndex() );
1184  this->RenderLayers[ CurrLayer->GetIndex() ] = CurrLayer;
1185  }else if( (*LayerNodeIt).Name() == String("SingleLineTextLayer") ) {
1186  CurrLayer = new SingleLineTextLayer(this);
1187  CurrLayer->ProtoDeSerialize( (*LayerNodeIt) );
1188  this->ResizeLayers( CurrLayer->GetIndex() );
1189  this->RenderLayers[ CurrLayer->GetIndex() ] = CurrLayer;
1190  }else if( (*LayerNodeIt).Name() == String("MultiLineTextLayer") ) {
1191  CurrLayer = new MultiLineTextLayer(this);
1192  CurrLayer->ProtoDeSerialize( (*LayerNodeIt) );
1193  this->ResizeLayers( CurrLayer->GetIndex() );
1194  this->RenderLayers[ CurrLayer->GetIndex() ] = CurrLayer;
1195  }else{
1196  MEZZ_EXCEPTION(ExceptionBase::II_IDENTITY_INVALID_EXCEPTION,"Unknown render layer name provided when deserializing.");
1197  }
1198  }
1199  }else{
1200  MEZZ_EXCEPTION(ExceptionBase::INVALID_VERSION_EXCEPTION,"Incompatible XML Version for RenderLayers: Not Version 1.");
1201  }
1202  }
1203  }
1204 
1206  {
1208  XML::Attribute CurrAttrib;
1209  XML::Node GroupsNode = SelfRoot.GetChild( "RenderLayerGroups" );
1210 
1211  if( !GroupsNode.Empty() ) {
1212  if(GroupsNode.GetAttribute("Version").AsInt() == 1) {
1213  for( XML::NodeIterator GroupNodeIt = GroupsNode.begin() ; GroupNodeIt != GroupsNode.end() ; ++GroupNodeIt )
1214  {
1215  RenderLayerGroup* CurrGroup = NULL;
1216 
1217  CurrAttrib = (*GroupNodeIt).GetAttribute("GroupID");
1218  if( !CurrAttrib.Empty() )
1219  CurrGroup = this->CreateRenderLayerGroup( CurrAttrib.AsUint() );
1220 
1221  if( CurrGroup ) {
1222  for( XML::NodeIterator LayerNodeIt = (*GroupNodeIt).begin() ; LayerNodeIt != (*GroupNodeIt).end() ; ++LayerNodeIt )
1223  {
1224  XML::Attribute IndexAttrib = (*LayerNodeIt).GetAttribute("Index");
1225  XML::Attribute ZOrderAttrib = (*LayerNodeIt).GetAttribute("ZOrder");
1226 
1227  if( IndexAttrib && ZOrderAttrib ) {
1228  CurrGroup->AddLayer( this->GetRenderLayer( IndexAttrib.AsWhole() ), ZOrderAttrib.AsWhole() );
1229  }else{
1230  MEZZ_EXCEPTION(ExceptionBase::II_IDENTITY_NOT_FOUND_EXCEPTION,"Index and/or ZOrder attributes were not found in the provided XML node, which was expected.");
1231  }
1232  }
1233  }
1234  }
1235  }else{
1236  MEZZ_EXCEPTION(ExceptionBase::INVALID_VERSION_EXCEPTION,"Incompatible XML Version for RenderLayerGroups: Not Version 1.");
1237  }
1238  }
1239  }
1240 
1242  {
1243  XML::Node ChildrenNode = SelfRoot.GetChild( "Children" );
1244  if( !ChildrenNode.Empty() ) {
1245  if( ChildrenNode.GetAttribute("Version").AsInt() == 1 ) {
1246  for( XML::NodeIterator ChildNodeIt = ChildrenNode.begin() ; ChildNodeIt != ChildrenNode.end() ; ++ChildNodeIt )
1247  {
1248  this->AddChild( this->ParentScreen->CreateWidget( (*ChildNodeIt) ) );
1249  }
1250  }else{
1251  MEZZ_EXCEPTION(ExceptionBase::INVALID_VERSION_EXCEPTION,"Incompatible XML Version for Children: Not Version 1.");
1252  }
1253  }
1254  }
1255 
1258 
1260  { return "QuadRenderable"; }
1261 
1262  ///////////////////////////////////////////////////////////////////////////////
1263  // Internal Methods
1264 
1266  { this->ZOrder = Zorder; }
1267 
1269  { this->ParentQuad = NewParent; }
1270 
1272  {
1273  if( this->LayoutStrat != NULL ) {
1274  delete this->LayoutStrat;
1275  }
1276  this->LayoutStrat = ToSet;
1277  }
1278 
1280  {
1281  if( this->Dirty || this->AllLayersDirty ) {
1282  for( RenderLayerIterator LayerIt = this->RenderLayers.begin() ; LayerIt != this->RenderLayers.end() ; ++LayerIt )
1283  { (*LayerIt)->_Redraw(this->AllLayersDirty); }
1284 
1285  this->Dirty = this->AllLayersDirty = false;
1286  }
1287  }
1288 
1290  {
1291  if( this->Dirty )
1292  return;
1293 
1294  this->Dirty = true;
1295  if( this->ParentQuad )
1296  this->ParentQuad->_MarkDirty();
1297  }
1298 
1300  {
1301  this->_MarkDirty();
1302  for( ChildIterator It = this->ChildWidgets.begin() ; It != this->ChildWidgets.end() ; ++It )
1303  { (*It)->_MarkAllChildrenDirty(); }
1304  }
1305 
1307  {
1308  if( this->Dirty && this->AllLayersDirty )
1309  return;
1310 
1311  this->Dirty = true;
1312  this->AllLayersDirty = true;
1313  this->ParentQuad->_MarkDirty();
1314  }
1315 
1317  {
1318  this->_Clean();
1319  if( this->GetVisible() ) {
1320  this->AppendLayerVertices(RenderData.Vertices);
1321  }
1322  }
1323 
1325  {
1326  if( this->VertexCache ) {
1327  if( this->Dirty || this->AllLayersDirty ) {
1328  this->VertexCache->Clear();
1330  for( ChildIterator ChildIt = this->ChildWidgets.begin() ; ChildIt != this->ChildWidgets.end() ; ++ChildIt )
1331  { (*ChildIt)->_AppendRenderDataCascading(*VertexCache); }
1332  }
1333  RenderData.Append(*VertexCache);
1334  }else{
1335  this->_AppendRenderData(RenderData);
1336  for( ChildIterator ChildIt = this->ChildWidgets.begin() ; ChildIt != this->ChildWidgets.end() ; ++ChildIt )
1337  { (*ChildIt)->_AppendRenderDataCascading(RenderData); }
1338  }
1339  }
1340  }//UI
1341 }//Mezzanine
1342 
1343 #endif
This is a render layer specializing in single-line text.
RenderLayerContainer::iterator RenderLayerIterator
Iterator type for RenderLayer instances stored by this class.
virtual void ProtoSerializeChildQuads(XML::Node &SelfRoot) const
Convert the child quads of this class to an XML::Node ready for serialization.
virtual Boole GetVisible() const =0
Gets the visibility setting of this renderable.
void RemoveLayerFromGroup(RenderLayer *Layer, const UInt16 GroupID)
Removes a single RenderLayer from a specified RenderLayerGroup.
void DestroyRenderLayerGroup(const UInt16 GroupID)
Destroy's a RenderLayerGroup by ID.
virtual void ProtoSerializeRenderLayers(XML::Node &SelfRoot) const
Convert the RenderLayers of this class to an XML::Node ready for serialization.
void SetLocalVertexCaching(Boole Enable)
Enables or disables caching of vertex's belonging to this and all child renderables.
Attribute AppendAttribute(const Char8 *Name)
Creates an Attribute and puts it at the end of this Nodes attributes.
virtual void ProtoDeSerialize(const XML::Node &SelfRoot)
Take the data stored in an XML Node and overwrite this object with it.
RenderLayerGroupContainer::iterator RenderLayerGroupIterator
Iterator type for RenderLayerGroup instances stored by this class.
Thrown when duplicates of teh same identity string exist.
Definition: exception.h:95
virtual Rect GetRect() const
Gets this QuadRenderables' Rect.
void SetIdentity()
Sets all the values of this rect to zero.
Definition: rect.h:141
const String & GetName() const
Gets the name of this renderable.
Definition: renderable.cpp:77
void Clear()
Clears all Vertex vectors.
Definition: screen.cpp:176
void NotifyActive()
Notifies this RenderLayerGroup that it has become the active group.
A light-weight handle for manipulating attributes in DOM tree.
Definition: attribute.h:74
virtual const SizingInfo & GetSizingPolicy() const
Gets the current behavior this QuadRenderable will use when it is sized.
This is a base class for the algorithms used by QuadRenderables to determine how they should update t...
Basic class for all structures that get inserted into the rendering hierarchy.
Definition: renderable.h:58
std::vector< VertexData > Vertices
Container storing all of the vertices to be rendered.
Definition: screen.h:119
bool Boole
Generally acts a single bit, true or false.
Definition: datatypes.h:173
RenderLayerGroup * ActiveGroup
This is a pointer to the group of RenderLayers currently being used for rendering.
UnifiedVec2 Size
The width and height of this rect.
Definition: unifieddim.h:670
ChildContainer::reverse_iterator ReverseChildIterator
Reverse Iterator type for Widget instances stored by this class.
virtual String GetDerivedSerializableName() const
Gets the most derived serializable name of this Renderable.
PositioningInfo PositioningPolicy
This stores all the information needed to determine the specific behaviors this Quad should have when...
virtual void _MarkAllChildrenDirty()
Tells this QuadRenderable to mark each of it's children (and their children) as dirty.
Whole VerticalRules
Rules for determining the position of a quad on the Y axis.
std::vector< Widget * > ChildContainer
Basic container type for Widget storage by this class.
virtual void _MarkAllLayersDirty()
Tells this QuadRenderable that all of it's layers are dirty.
virtual void DestroyChild(Widget *ToBeDestroyed)
Destroys a child Widget currently inside this QuadRenderable.
virtual UnifiedVec2 GetMaxSize() const
Gets the currently set maximum size for this quad.
virtual Boole GetMousePassthrough() const
Gets whether or not Mouse Passthrough is enabled.
virtual Whole GetVerticalPositioningRules() const
Gets the current behavior this quad will follow when it is positioned automatically on the Y axis...
virtual Real GetTotalHeight() const
Gets the combined height of all the text lines in this layer.
Definition: textlayer.cpp:363
void DestroyAllRenderLayers()
Destroys all RenderLayers being stored by this renderable.
Vector2 Size
Vector2 representing the width and height of the rect.
Definition: rect.h:71
SizingInfo SizingPolicy
This stores all the information needed to determine the specific behaviors this Quad should have when...
ChildContainer::const_iterator ConstChildIterator
Const Iterator type for Widget instances stored by this class.
UInt16 ZOrder
This is the ZOrder of this Quad in relation to all other Quads in it's parent.
virtual void ProtoDeSerializeProperties(const XML::Node &SelfRoot)
Take the data stored in an XML Node and overwrite the properties of this object with it...
virtual Whole GetHorizontalSizingRules() const
Gets the current behavior this quad will follow for the X axis when it is resized.
SingleImageLayer * CreateSingleImageLayer()
Creates a SingleImageLayer for this renderable.
ChildIterator ChildrenEnd()
Gets an iterator to one passed the last child Widget.
virtual void _Clean()
Refreshes the render data of this renderable.
virtual Whole GetIndex() const
Gets the index position of this RenderLayer in it's parent.
Thrown when the requested identity could not be found.
Definition: exception.h:94
Node GetFirstChild() const
Get the first child Node of this Node.
void RemoveLayerFromAllGroups(RenderLayer *Layer)
Removes a single RenderLayer from all RenderLayerGroups owned by this QuadRenderable.
#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
void Append(ScreenRenderData &OtherData)
Appends the contents of another ScreenRenderData to the end of this.
Definition: screen.cpp:182
virtual void SetMousePassthrough(Boole Enable)
Sets whether or not this quad should be skipped when determining if the mouse is hovered over this qu...
virtual void ProtoSerializeRenderLayerGroups(XML::Node &SelfRoot) const
Convert the RenderLayerGroups of this class to an XML::Node ready for seriailization.
virtual void SetHorizontalPositioningRules(const Whole Rules)
Sets the behavior this quad will have when it is positioned automatically on the X axis...
virtual UnifiedVec2 GetUnifiedSize() const
Gets the size of this QuadRenderable as a Unified Vector2.
This is a render layer specializing in multi-line text.
Thrown when a version is accessed/parsed/required and it cannot work correctly or is missing...
Definition: exception.h:112
virtual UnifiedVec2 GetMinSize() const
Gets the currently set minimum size for this quad.
Value representing a SingleLineTextLayer.
UI::AspectRatioLock RatioLock
Rule for determining aspect ratio lock.
Definition: sizinginfo.h:73
QuadRenderable * GetTopMostQuad()
Gets the QuadRenderable that is both an ancestor of this quad, and a direct child of the screen...
virtual const PositioningInfo & GetPositioningPolicy() const
Gets the current behavior this QuadRenderable will use when it is positioned.
const Char8 * AsString(const Char8 *def="") const
Attempts to convert the value of the attribute to a String and returns the results.
virtual void _UpdateIndex(const Whole Index)
Notifies this RenderLayer that it's index in the parent QuadRenderable has been updated.
virtual void ProtoDeSerializeImpl(const XML::Node &SelfRoot)
Implementation method for deseriailizing additional sets of data.
virtual void ProtoSerializeProperties(XML::Node &SelfRoot) const
Convert the properties of this class to an XML::Node ready for serialization.
Boole CheckOverlap(const Rect &OtherRect) const
Checks to see if another Rect is overlapping with this one.
Definition: rect.h:194
virtual void SetUnifiedSize(const UnifiedVec2 &Size)
Sets the size this QuadRenderable will have within it's parent.
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...
QuadRenderable(Screen *Parent)
Blank constructor.
void RemoveLayer(RenderLayer *RL)
Removes a layer from this group.
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.
RenderLayerGroup * CreateRenderLayerGroup(const UInt16 GroupID)
Creates a new RenderLayerGroup that can have. function will throw an exception if a group already exi...
RenderLayerContainer::const_iterator ConstRenderLayerIterator
Const Iterator type for RenderLayer instances stored by this class.
virtual void SetMinSize(const UnifiedVec2 &Min)
Sets the minimum size this quad is allowed to have.
QuadRenderable * GetPrevSibling(Boole Wrap=true)
Gets the QuadRenderable before this one among the QuadRenderables owned by it's parent.
virtual void SetMaxSize(const UnifiedVec2 &Max)
Sets the maximum size this quad is allowed to have.
virtual void ProtoSerializeProperties(XML::Node &SelfRoot) const
Convert the properties of this class to an XML::Node ready for serialization.
Definition: renderable.cpp:99
virtual void ProtoSerializeImpl(XML::Node &SelfRoot) const
Implementation method for serializing additional sets of data.
bool Empty() const
Is this storing anything at all?
virtual void ProtoSerialize(XML::Node &ParentNode) const
Convert this class to an XML::Node ready for serialization.
RenderLayerContainer RenderLayers
This is a container storing all the RenderLayer instances created by and belonging to this Quad...
virtual void PopulateTextLines(const Real MaxWidth)
Populates text lines in this layer with parsed characters.
Definition: textlayer.cpp:701
virtual RenderableType GetRenderableType() const =0
Gets the type of renderable this is.
void ProtoDeSerialize(const XML::Node &SelfRoot)
Take the data stored in an XML Node and overwrite this object with it.
Definition: rect.h:298
virtual Widget * GetChild(const UInt16 Zorder) const
Gets a child by it's ZOrder.
Boole AllLayersDirty
Determines whether or not this Quad needs all of it's layers refreshed. Usually after a transform upd...
ChildContainer ChildWidgets
This is a container storing all the children that belong to this Quad.
virtual UnifiedRect GetUnifiedRect() const
Gets the Unified positiona nd size of this QuadRenderable as a unified rect.
Whole VerticalRules
Rules for resizing on the Y axis.
Definition: sizinginfo.h:69
UInt16 GetGroupID() const
Gets the ID of this RenderLayerGroup.
Rect ActDims
The actual (pixel) position and size of this Quad on the screen it belongs to.
Value representing a MultiLineTextLayer.
void AddLayerToExistingGroup(RenderLayer *Layer, const UInt16 LayerZOrder, const UInt16 GroupID)
Adds a RenderLayer to the specified group.
virtual void _AppendRenderData(ScreenRenderData &RenderData)
Appends the vertices of this renderable to another vector.
RenderLayerGroupContainer::const_iterator ConstRenderLayerGroupIterator
Const Iterator type for RenderLayerGroup instances stored by this class.
float Real
A Datatype used to represent a real floating point number.
Definition: datatypes.h:141
The interface for serialization.
virtual const UInt16 & GetZOrder() const
Gets the currently set ZOrder of this QuadRenderable with it's parent.
RenderLayerIterator RenderLayerBegin()
Gets an iterator to the first RenderLayer.
bool SetValue(const Char8 *rhs)
Set the value of this.
virtual Boole GetManualTransformUpdates() const
Gets whether or not this quad will be automatically updated when parent transforms are updated...
This class represents a 2D rect which can express the size and position of a renderable on screen...
Definition: unifieddim.h:661
virtual Whole GetHorizontalPositioningRules() const
Gets the current behavior this quad will follow when it is positioned automatically on the X axis...
AspectRatioLock
Used by sizing behavior classes to determine how resizes that preserve aspect ratio should behave...
uint16_t UInt16
An 16-bit unsigned integer.
Definition: datatypes.h:122
Whole AsWhole(Whole def=0) const
Attempts to convert the value of the attribute to a Whole and returns the results.
virtual void RemoveChild(Widget *ToBeRemoved)
Removes a child Widget from this quadrenderable.
Boole ConvertToBool(const String &ToConvert, const Boole Default)
Converts a string into a Boole.
Definition: stringtool.cpp:379
virtual void DestroyWidget(Widget *ToBeDestroyed)
Destroys a widget.
Definition: screen.cpp:585
Child node iterator (a bidirectional iterator over a collection of Node)
Definition: nodeiterator.h:77
void NotifyInactive()
Notifies this RenderLayerGroup that it is no longer the active group.
A light-weight handle for manipulating nodes in DOM tree.
Definition: node.h:89
iterator begin() const
Get a Child node iterator that references the first child Node.
void ProtoDeSerialize(const XML::Node &SelfRoot)
Take the data stored in an XML Node and overwrite this object with it.
virtual Real GetIdealHeightForText() const
Gets the height needed for this quadrenderable to be able to completely display text in it's child te...
virtual UInt16 GetHighestChildZOrder() const
Gets the highest ZOrder among the children of this QuadRenderable.
unsigned int AsUint(unsigned int def=0) const
Attempts to convert the value of the attribute to an unsigned int and returns the results...
virtual Boole IsInside(const Vector2 &Point) const
Checks to see if a point in 2D space is inside this quad.
UnifiedVec2 Position
The top left position of this rect.
Definition: unifieddim.h:668
int AsInt(int def=0) const
Attempts to convert the value of the attribute to an int and returns the results. ...
uint32_t UInt32
An 32-bit unsigned integer.
Definition: datatypes.h:126
void ResizeLayers(const Whole NewSize)
Resizes the container for RenderLayers in this QuadRenderable.
virtual UI::AspectRatioLock GetAspectRationLock() const
Gets how (and if) the aspect ratio of this quad is locked.
RenderLayerContainer::iterator RenderLayerIterator
Iterator type for RenderLayerPair instances stored by this class.
virtual void SetManualTransformUpdates(Boole Enable)
Sets whether or not this quad has specific behaviors for it's transform updates and they should not b...
Boole RenderLayerGroupExists(const UInt16 GroupID) const
Checks to see if a RenderLayerGroup exists.
This is used to represent a point on a 2 dimentional area, such as a screen.
Definition: vector2.h:63
iterator end() const
Get a Child node iterator that references one past the last child Node.
ChildContainer::const_reverse_iterator ConstReverseChildIterator
Const Reverse Iterator type for Widget instances stored by this class.
virtual void ProtoDeSerializeRenderLayers(const XML::Node &SelfRoot)
Take the data stored in an XML Node and overwrite the RenderLayers of this object with it...
bool Empty() const
Is this storing anything at all?
RenderLayerIterator RenderLayerEnd()
Gets an iterator to one passed the last RenderLayer.
UInt32 GetNumRenderLayers() const
Gets the number of RenderLayers created for this renderable.
This is the base class for all widgets.
Definition: widget.h:126
virtual void SetHorizontalSizingRules(const Whole Rules)
Sets the behavior this quad will have on the X axis when it is resized.
Boole ManualTransformUpdates
Controls whether or not this Quad and it's children will recieve automatic transform updates...
virtual void SetAspectRatioLock(const UI::AspectRatioLock Lock)
Sets how (and if) the aspect ratio of this quad is locked.
virtual Vector2 GetActualSize() const
Gets the pixel size of this widget.
RenderLayerIterator RenderLayerBegin()
Gets an iterator to the first RenderLayer.
RenderLayerGroupIterator RenderLayerGroupEnd()
Gets an iterator to one passed the last RenderLayerGroup.
RenderLayerIterator RenderLayerEnd()
Gets an iterator to one passed the last RenderLayer.
virtual void DestroyAllChildren()
Destroys all child Widgets currently inside this QuadRenderable.
void ProtoSerialize(XML::Node &ParentNode) const
Convert this class to an XML::Node ready for serialization.
Definition: sizinginfo.h:153
virtual void ProtoDeSerializeRenderLayerGroups(const XML::Node &SelfRoot)
Take the data stored in an XML Node and overwrite the RenderLayerGroups of this object with it...
virtual ~QuadRenderable()
Class destructor.
virtual void UpdateChildDimensions()
Updates the dimensions of the children in this QuadRenderable.
This is a small convenience class used to store a RenderLayerGroup ID and a ZOrder on that RenderLaye...
ScreenRenderData * VertexCache
This is a pointer to the optional cache of vertex's belonging to this Quad and all of it's children...
virtual void RemoveAllChildren()
Removes all child Widgets from this QuadRenderable.
RenderLayerGroupIterator RenderLayerGroupBegin()
Gets an iterator to the first RenderLayerGroup.
RenderLayerGroup * GetActiveGroup() const
Gets the current RenderLayerGroup used for rendering.
void AddLayerToGroup(RenderLayer *Layer, const UInt16 LayerZOrder, const UInt16 GroupID)
Adds a RenderLayer to the specified group.
virtual void Layout(const Rect &OldSelfRect, const Rect &NewSelfRect, const ChildContainer &ChildQuads)
Updates the dimensions of a collection of QuadRenderables.
void AppendLayerVertices(std::vector< VertexData > &Vertices)
Adds all the vertices belonging to all the layers of this renderable to the provided vector...
String Name
The unique name of this Renderable.
Definition: renderable.h:81
Whole HorizontalRules
Rules for determining the position of a quad on the X axis.
virtual Boole CheckOverlap(const QuadRenderable *Quad) const
Checks to see if another Quad is overlapping with this one.
virtual Boole IsChildOfScreen() const
Gets whether or not this QuadRenderable is a direct child of it's screen.
std::vector< GroupOrderEntry > GroupOrderEntryVector
Convenience container type for GroupOrderEntry storage.
virtual void ProtoDeSerializeProperties(const XML::Node &SelfRoot)
Take the data stored in an XML Node and overwrite the properties of this object with it...
Definition: renderable.cpp:118
virtual void AddChild(Widget *Child)
Adds a Widget to this as a child of this quad.
virtual void _SetZOrder(const UInt16 &Zorder)
Ssts the ZOrder value for this renderable.
virtual void _AppendRenderDataCascading(ScreenRenderData &RenderData)
Appends the vertices of this renderable to another vector, and then does the same for this renderable...
UInt32 GetNumRenderLayerGroups() const
Gets the number of RenderLayerGroup's created for this renderable.
virtual void _SetLayoutStrat(LayoutStrategy *ToSet)
Sets a new LayoutStrategy for this quad to use.
virtual void SetSprite(Sprite *NewSprite)
Sets the fill image(if provided in the atlas) of the layer.
RenderLayerGroup * CreateRenderLayerGroupNoCheck(const UInt16 ID)
Creates a new RenderLayerGroup with the provided ID, without checking if it is unique.
virtual void UpdateChildOrder()
Updates the order of children in this QuadRenderable based on the ZOrder set on each child...
This class stores a group of render layers that can be set to be rendered.
UInt32 GetNumVisibleRenderLayers() const
Gets the number of RenderLayers that are visible in this renderable.
RenderLayerGroupContainer RenderLayerGroups
This is a container storing all the RenderLayerGroup instances created by and belonging to this Quad...
virtual void SetSizingPolicy(const SizingInfo &Policy)
Sets the behavior to be used when this QuadRenderable is sized.
UnifiedVec2 UPosition
Unified dimensions to be used if the resize rules permits it.
Thrown when the identity string wasn't valid at all.
Definition: exception.h:93
RenderLayerType
This enum describes the type of RenderLayer this is for use in casting.
void AddLayerToGroups(RenderLayer *Layer, const GroupOrderEntryVector &Entrys)
Adds a RenderLayer to multiple groups.
void DestroyAllRenderLayerGroups()
Destroy's all RenderLayerGroups being stored/managed by this QuadRenderable.
ReverseChildIterator RChildrenBegin()
Gets an iterator to the last Widget.
Widget * GetClosestChild(Widget *Child)
Gets a pointer to the child of this QuadRenderable that is storing a child, or another quad that is...
UInt16 GroupID
The ID of the RenderLayerGroup this entry is referring to.
UInt16 LayerZOrder
The ZOrder within the specified RenderLayerGroup to modify.
The bulk of the engine components go in this namspace.
Definition: actor.cpp:56
MultiLineTextLayer * CreateMultiLineTextLayer()
Creats a MultiLineTextLayer for this renderable.
This class stores all vertices pertaining to a layer sorted by their priority for rendering...
Definition: screen.h:115
QuadRenderable * GetParent() const
Gets the parent of this quad.
unsigned long Whole
Whole is an unsigned integer, it will be at least 32bits in size.
Definition: datatypes.h:151
virtual void SetVerticalSizingRules(const Whole Rules)
Sets the behavior this quad will have on the Y axis when it is resized.
void ProtoDeSerialize(const XML::Node &SelfRoot)
Take the data stored in an XML Node and overwrite this object with it.
Definition: sizinginfo.h:178
UnifiedVec2 MinSize
The minumum permitted size.
Definition: sizinginfo.h:67
RenderLayerGroup * CreateOrRetrieveRenderLayerGroup(const UInt16 GroupID)
Gets the named RenderLayerGroup or creates one with the specified ID if it does not exist...
virtual Whole GetNumChildren() const
Gets the number of children in this QuadRenderable.
ChildContainer::iterator ChildIterator
Iterator type for Widget instances stored by this class.
virtual Vector2 GetActualPosition() const
Gets the pixel position of this widget.
RenderLayer * GetRenderLayer(const UInt32 &Index) const
Gets a RenderLayer belonging to this QuadRenderable by index.
UnifiedVec2 USize
Unified dimensions to be used if the resize rules permits it.
Definition: sizinginfo.h:63
virtual void SetVisible(Boole CanSee)
Sets the visibility of this renderable.
Definition: widget.cpp:229
Boole IsVertexCachingEnabled() const
Gets whether or not vertex caching is enabled for this Quad.
This class represents a point in 2D space using UnifiedDim's.
Definition: unifieddim.h:306
virtual UnifiedVec2 GetUnifiedPosition() const
Gets the position of this QuadRenderable as a Unified Vector2.
virtual void ProtoDeSerialize(const XML::Node &SelfRoot)
Take the data stored in an XML Node and overwrite this object with it.
ReverseChildIterator RChildrenEnd()
Gets an iterator to one before the first child Widget.
Boole Dirty
Stores whether this Renderables vertices need to be regenerated.
Definition: renderable.h:78
virtual void SetUnifiedPosition(const UnifiedVec2 &Position)
Sets the position this QuadRenderable will have within it's parent.
void DestroyRenderLayer(RenderLayer *ToBeDestroyed)
Destroys a RenderLayer being stored by this renderable.
Boole IsInside(const Vector2 &Point) const
Checks to see if a point in 2D space is inside this rect.
Definition: rect.h:207
virtual void SetPositioningPolicy(const PositioningInfo &Policy)
Sets the behavior to be used when this QuadRenderable is positioned.
virtual void SetVerticalPositioningRules(const Whole Rules)
Sets the behavior this quad will have when it is positioned automatically on the Y axis...
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.
SingleLineTextLayer * CreateSingleLineTextLayer()
Creats a SingleLineTextLayer for this renderable.
QuadRenderable * GetNextSibling(Boole Wrap=true)
Gets the QuadRenderable after this one among the QuadRenderables owned by it's parent.
Vector2 Position
Vector2 representing the top-left position of the rect.
Definition: rect.h:69
ChildIterator ChildrenBegin()
Gets an iterator to the first child Widget.
virtual void _MarkDirty()
Marks this renderable as dirty, and informs other renderables if needed.
void ProtoSerialize(XML::Node &ParentNode) const
Convert this class to an XML::Node ready for serialization.
Definition: rect.h:281
Whole HorizontalRules
Rules for resizing on the X axis.
Definition: sizinginfo.h:71
void SerializeError(const String &FailedTo, const String &ClassName, Boole SOrD)
Simply does some string concatenation, then throws an Exception.
This is an image layer that supports rendering only a single image/sprite.
Boole MousePassthrough
Controls whether or not this Quad will be considered for mouse hover checks.
UInt32 GetNumRenderLayers() const
Gets the number of RenderLayers assigned to this group.
RenderLayerGroup * GetRenderLayerGroup(const UInt16 GroupID) const
Gets a RenderLayerGroup by ID.
void AddLayer(RenderLayer *RL, const UInt16 ZOrder)
Adds a layer to this group by it's ZOrder.
Node AppendChild(NodeType Type=NodeElement)
Creates a Node and makes it a child of this one.
virtual void ProtoDeSerializeChildQuads(const XML::Node &SelfRoot)
Take the data stored in an XML Node and overwrite the ChildQuads of this object with it...
This class is a helper class for creating UI's. It is responsible for storing and keeping track of al...
Definition: screen.h:142
MultiImageLayer * CreateMultiImageLayer()
Creates an MultiImageLayer for this renderable.
LayoutStrategy * LayoutStrat
This is a pointer to the strategy being used by this Quad to determine the positions and sizes of chi...
std::string String
A datatype used to a series of characters.
Definition: datatypes.h:159
This is a base class for render layers that render text.
Definition: textlayer.h:64
QuadRenderable * ParentQuad
This is a pointer to the Quad that owns this Quad and is responsible for transform updates applied to...
UnifiedVec2 MaxSize
The maximum permitted size.
Definition: sizinginfo.h:65
This is an image layer that supports rendering of multiple images within it's space.
Attribute GetAttribute(const Char8 *Name) const
Attempt to get an Attribute on this Node with a given name.
virtual Whole GetVerticalSizingRules() const
Gets the current behavior this quad will follow for the Y axis when it is resized.
This is the base class for the types of layers that can be added to a renderable. ...
Definition: renderlayer.h:58
This is a helper class designed to describe the behaviors of a quad when it needs to be repositioned...
Node GetChild(const Char8 *Name) const
Attempt to get a child Node with a given name.
virtual UInt16 GetLowestChildZOrder() const
Gets the lowest ZOrder among the children of this QuadRenderable.
Screen * ParentScreen
A pointer to the Screen that created this Renderable.
Definition: renderable.h:72
virtual void _NotifyParenthood(QuadRenderable *NewParent)
Notifies this QuadRenderable that it has been added to another QuadRenderable.
virtual Widget * CreateWidget(const XML::Node &WidgetNode)
Creates a widget from an XML::Node.
Definition: screen.cpp:542
void SetActiveGroup(const UInt16 GroupID)
Sets the RenderLayerGroup that will be used to render this renderable.