Spinning Topp Logo BlackTopp Studios
inc
layoutcontainer.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 _uilayoutcontainer_cpp
41 #define _uilayoutcontainer_cpp
42 
43 #include "UI/layoutcontainer.h"
44 #include "UI/screen.h"
45 
46 namespace Mezzanine
47 {
48  namespace UI
49  {
50  const String LayoutContainer::TypeName = "LayoutContainer";
51 
53  Widget(Parent)
54  { }
55 
56  LayoutContainer::LayoutContainer(const String& RendName, Screen* Parent) :
57  Widget(RendName,Parent)
58  { }
59 
60  LayoutContainer::LayoutContainer(const String& RendName, const UnifiedRect& RendRect, Screen* Parent) :
61  Widget(RendName,RendRect,Parent)
62  { }
63 
65  { }
66 
67  ///////////////////////////////////////////////////////////////////////////////
68  // Utility
69 
70  void LayoutContainer::UpdateDimensions(const Rect& OldSelfRect, const Rect& NewSelfRect)
71  {
72  // Update the personal data first
73  this->ActDims = NewSelfRect;
74 
75  // Perform the container specific update logic
76  this->UpdateContainerDimensionsImpl(OldSelfRect,NewSelfRect);
77 
78  /*// Update the children, if any
79  if( this->VisibleChildren.empty() == false )
80  this->LayoutStrat->Layout(OldSelfRect,NewSelfRect,this->VisibleChildren);// */
81 
82  // We done got icky
83  this->_MarkAllLayersDirty();
84  }
85 
86  ///////////////////////////////////////////////////////////////////////////////
87  // Child Management
88 
89  ///////////////////////////////////////////////////////////////////////////////
90  // Serialization
91 
93  {
94  this->Widget::ProtoSerializeProperties(SelfRoot);
95  }
96 
98  {
99  this->Widget::ProtoDeSerializeProperties(SelfRoot);
100  }
101 
103  {
105  }
106 
107  ///////////////////////////////////////////////////////////////////////////////
108  // Internal Methods
109 
111  {
112  // Update the children based on page positions and the container size so we can grab the proper vertices.
113  if(this->VertexCache) {
114  if( this->Dirty || this->AllLayersDirty ) {
115  this->VertexCache->Clear();
117  for( VisibleChildIterator ChildIt = this->VisibleChildren.begin() ; ChildIt != this->VisibleChildren.end() ; ++ChildIt )
118  { (*ChildIt)->_AppendRenderDataCascading(*VertexCache); }
119  }
120  RenderData.Append(*VertexCache);
121  }else{
122  this->_AppendRenderData(RenderData);
123  for( VisibleChildIterator It = this->VisibleChildren.begin() ; It != this->VisibleChildren.end() ; ++It )
124  { (*It)->_AppendRenderDataCascading(RenderData); }
125  }
126  }
127  }//UI
128 }//Mezzanine
129 
130 #endif
virtual void ProtoDeSerializeProperties(const XML::Node &SelfRoot)
Take the data stored in an XML Node and overwrite the properties of this object with it...
void Clear()
Clears all Vertex vectors.
Definition: screen.cpp:176
virtual void UpdateContainerDimensionsImpl(const Rect &OldSelfRect, const Rect &NewSelfRect)=0
The container specific logic for updating it's dimensions.
virtual void _MarkAllLayersDirty()
Tells this QuadRenderable that all of it's layers are dirty.
virtual void ProtoSerializeProperties(XML::Node &SelfRoot) const
Convert the properties of this class to an XML::Node ready for serialization.
LayoutContainer(Screen *Parent)
Blank constructor.
VisibleChildContainer::iterator VisibleChildIterator
Iterator type for Visible QuadRenderable instances stored by this class.
virtual ~LayoutContainer()
Class destructor.
void Append(ScreenRenderData &OtherData)
Appends the contents of another ScreenRenderData to the end of this.
Definition: screen.cpp:182
virtual void ProtoSerializeProperties(XML::Node &SelfRoot) const
Convert the properties of this class to an XML::Node ready for serialization.
Definition: widget.cpp:278
This class represents a box shaped area on the screen.
Definition: rect.h:55
static String GetSerializableName()
Get the name of the the XML tag the Renderable class will leave behind as its instances are serialize...
virtual void _AppendRenderDataCascading(ScreenRenderData &RenderData)
Appends the vertices of this renderable to another vector, and then does the same for this renderable...
Boole AllLayersDirty
Determines whether or not this Quad needs all of it's layers refreshed. Usually after a transform upd...
VisibleChildContainer VisibleChildren
A container of children that meet the criteria for rendering in this container.
Rect ActDims
The actual (pixel) position and size of this Quad on the screen it belongs to.
virtual void _AppendRenderData(ScreenRenderData &RenderData)
Appends the vertices of this renderable to another vector.
This class represents a 2D rect which can express the size and position of a renderable on screen...
Definition: unifieddim.h:661
A light-weight handle for manipulating nodes in DOM tree.
Definition: node.h:89
This is the base class for all widgets.
Definition: widget.h:126
static const String TypeName
String containing the type name for this class: "LayoutContainer".
ScreenRenderData * VertexCache
This is a pointer to the optional cache of vertex's belonging to this Quad and all of it's children...
The bulk of the engine components go in this namspace.
Definition: actor.cpp:56
This class stores all vertices pertaining to a layer sorted by their priority for rendering...
Definition: screen.h:115
Boole Dirty
Stores whether this Renderables vertices need to be regenerated.
Definition: renderable.h:78
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: widget.cpp:337
virtual void UpdateDimensions()
Updates the dimensions of this QuadRenderable based on the transform of it's parent.
This class is a helper class for creating UI's. It is responsible for storing and keeping track of al...
Definition: screen.h:142
std::string String
A datatype used to a series of characters.
Definition: datatypes.h:159