MezzanineEngine 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
linearcontainer.h
1 //© Copyright 2010 - 2012 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 
41 #ifndef _uilinearcontainer_h
42 #define _uilinearcontainer_h
43 
44 #include "UI/pagedcontainer.h"
45 
46 namespace Mezzanine
47 {
48  namespace UI
49  {
50  class LinearContainerLayoutStrategy;
51  ///////////////////////////////////////////////////////////////////////////////
52  /// @brief This is a container class for placing child objects in succession on a single axis.
53  /// @details
54  ///////////////////////////////////////
56  {
57  public:
58  /// @enum SizeEnforcement
59  /// @brief This enum is used to determine if and when a child should be forced to a specific size for this container.
61  {
62  SE_None = 0, ///< No sizing enforcement of any kind is to occur to the children of this container.
63  SE_OnAdd = 1, ///< The preset size for children of this container will only be applied when they are added to this container, ensuring the same start size for all children.
64  SE_OnUpdate = 2 ///< The preset size for children of this container will be enforced constantly on each update, preventing children from being rendered at any other size.
65  };
66  protected:
67  /// @internal
68  /// @brief The size given to children layed out by this container.
70  /// @internal
71  /// @brief The amount of space to add to both sides of a child object on the relevant axis.
73  /// @internal
74  /// @brief The current enforcement for child size in this container.
76  /// @internal
77  /// @brief The alignment to be given to the sequence of children visible in this container.
79 
80  /// @internal
81  /// @brief Updates a child that hasn't been selected to be visible.
82  /// @param OldSelfRect The previous dimensions of this quad prior to it's dimensions being updated.
83  /// @param NewSelfRect The updated and current dimensions of this quad.
84  /// @param InvisibleChild The child to be updated.
85  virtual void UpdateInvisibleChild(const Rect& OldSelfRect, const Rect& NewSelfRect, QuadRenderable* InvisibleChild);
86  public:
87  /// @brief Blank constructor.
88  /// @param Parent The parent Screen that created this widget.
89  LinearContainer(Screen* Parent);
90  /// @brief Standard initialization constructor.
91  /// @param RendName The name to be given to this renderable.
92  /// @param Parent The parent Screen that created this widget.
93  LinearContainer(const String& RendName, Screen* Parent);
94  /// @brief Rect constructor.
95  /// @param RendName The name to be given to this renderable.
96  /// @param RendRect The rect describing this widget's transform relative to it's parent.
97  /// @param Parent The parent screen that created this renderable.
98  LinearContainer(const String& RendName, const UnifiedRect& RendRect, Screen* Parent);
99  /// @brief Class destructor.
100  virtual ~LinearContainer();
101 
102  ///////////////////////////////////////////////////////////////////////////////
103  // Utility
104 
105  /// @brief Sets both the size and enforcement rules for forced child sizing in this container.
106  /// @note The sizing provided here works just like any other normal child sizing does, with the relative parts being based on the the parent container (this).
107  /// @param ForcedSize A SizingInfo describing how all children should size themselves on dimension updates.
108  /// @param Enforcement A bitmask containing when the child sizing will be enforced by this container. See SizeEnforcement enum for more details.
109  virtual void SetChildSizing(const SizingInfo& ForcedSize, const Whole Enforcement);
110  /// @brief Sets the size to be given to children processed by this container if forced sizing is enabled.
111  /// @note The sizing provided here works just like any other normal child sizing does, with the relative parts being based on the the parent container (this).
112  /// @param ForcedSize A SizingInfo describing how all children should size themselves on dimension updates.
113  virtual void SetChildSize(const SizingInfo& ForcedSize);
114  /// @brief Gets the size to be given to children processed by this container if forced sizing is enabled.
115  /// @return Returns a const SizeInfo reference to the sizing given to children processed by this container if forced sizing is enabled.
116  virtual const SizingInfo& GetChildSize() const;
117  /// @brief Sets when the set child sizing will be applied to any given child.
118  /// @param Enforcement A bitmask containing when the child sizing will be enforced by this container. See SizeEnforcement enum for more details.
119  virtual void SetChildSizeEnforcement(const Whole Enforcement);
120  /// @brief Gets when the set child sizing will be applied to any given child.
121  /// @return Returns a bitmask describing when the child sizing will be enforced by this container. See SizeEnforcement enum for more details.
122  virtual Whole GetChildSizeEnforcement() const;
123 
124  /// @brief Sets the spacing to be split between both sides of each child quad on the relevant axis.
125  /// @note The unified dimension passed in is relative to the parent of this container, just like this containers
126  /// dimensions and the work area dimensions.
127  /// @param Padding The amount of space to apply on both sides of each child.
128  virtual void SetPadding(const UnifiedDim& Padding);
129  /// @brief Gets the spacing being split between both sides of each child quad on the relevant axis.
130  /// @return Returns a const UnifiedDim reference representing the amount of space to apply on both sides of each child.
131  virtual const UnifiedDim& GetPadding() const;
132 
133  /// @brief Sets the alignment for visible children of this container when they don't take up all the visible space provided by the container.
134  /// @param ChildAlign The alignment to be given to visible children of this linear container.
135  virtual void SetVisibleChildAlignment(const UI::LinearAlignment ChildAlign);
136  /// @brief Gets the alignment for visible children of this container when they don't take up all the visible space provided by the container.
137  /// @return Returns a LinearAlignment value representing the alignment of visible children of this linear container.
138  virtual UI::LinearAlignment GetVisibleChildAlignment() const;
139 
140  ///////////////////////////////////////////////////////////////////////////////
141  // Child Management
142 
143  /// @copydoc QuadRenderable::AddChild(Widget*)
144  virtual void AddChild(Widget* Child);
145 
146  ///////////////////////////////////////////////////////////////////////////////
147  // Serialization
148 
149  /// @copydoc Renderable::ProtoSerializeProperties(XML::Node&) const
150  virtual void ProtoSerializeProperties(XML::Node& SelfRoot) const;
151  /// @copydoc Renderable::ProtoDeSerializeProperties(const XML::Node&)
152  virtual void ProtoDeSerializeProperties(const XML::Node& SelfRoot);
153 
154  /// @copydoc Renderable::GetSerializableName()
155  static String GetSerializableName();
156 
157  ///////////////////////////////////////////////////////////////////////////////
158  // Internal Methods
159  };//LinearContainer
160  }//UI
161 }//Mezzanine
162 
163 #endif