Spinning Topp Logo BlackTopp Studios
inc
linearcontainer.h
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 
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  /// @brief This enum is used to determine if and when a child should be forced to a specific size for this container.
60  {
61  SE_None = 0, ///< No sizing enforcement of any kind is to occur to the children of this container.
62  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.
63  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.
64  };
65  protected:
66  /// @internal
67  /// @brief The size given to children layed out by this container.
69  /// @internal
70  /// @brief The amount of space to add to both sides of a child object on the relevant axis.
72  /// @internal
73  /// @brief The current enforcement for child size in this container.
75  /// @internal
76  /// @brief The alignment to be given to the sequence of children visible in this container.
78  public:
79  /// @brief Blank constructor.
80  /// @param Parent The parent Screen that created this widget.
81  LinearContainer(Screen* Parent);
82  /// @brief Standard initialization constructor.
83  /// @param RendName The name to be given to this renderable.
84  /// @param Parent The parent Screen that created this widget.
85  LinearContainer(const String& RendName, Screen* Parent);
86  /// @brief Rect constructor.
87  /// @param RendName The name to be given to this renderable.
88  /// @param RendRect The rect describing this widget's transform relative to it's parent.
89  /// @param Parent The parent screen that created this renderable.
90  LinearContainer(const String& RendName, const UnifiedRect& RendRect, Screen* Parent);
91  /// @brief Class destructor.
92  virtual ~LinearContainer();
93 
94  ///////////////////////////////////////////////////////////////////////////////
95  // Utility
96 
97  /// @brief Sets both the size and enforcement rules for forced child sizing in this container.
98  /// @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).
99  /// @param ForcedSize A SizingInfo describing how all children should size themselves on dimension updates.
100  /// @param Enforcement A bitmask containing when the child sizing will be enforced by this container. See SizeEnforcement enum for more details.
101  virtual void SetChildSizing(const SizingInfo& ForcedSize, const Whole Enforcement);
102  /// @brief Sets the size to be given to children processed by this container if forced sizing is enabled.
103  /// @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).
104  /// @param ForcedSize A SizingInfo describing how all children should size themselves on dimension updates.
105  virtual void SetChildSize(const SizingInfo& ForcedSize);
106  /// @brief Gets the size to be given to children processed by this container if forced sizing is enabled.
107  /// @return Returns a const SizeInfo reference to the sizing given to children processed by this container if forced sizing is enabled.
108  virtual const SizingInfo& GetChildSize() const;
109  /// @brief Sets when the set child sizing will be applied to any given child.
110  /// @param Enforcement A bitmask containing when the child sizing will be enforced by this container. See SizeEnforcement enum for more details.
111  virtual void SetChildSizeEnforcement(const Whole Enforcement);
112  /// @brief Gets when the set child sizing will be applied to any given child.
113  /// @return Returns a bitmask describing when the child sizing will be enforced by this container. See SizeEnforcement enum for more details.
114  virtual Whole GetChildSizeEnforcement() const;
115 
116  /// @brief Sets the spacing to be split between both sides of each child quad on the relevant axis.
117  /// @note The unified dimension passed in is relative to the parent container(this)
118  /// @param Padding The amount of space to apply on both sides of each child.
119  virtual void SetPadding(const UnifiedDim& Padding);
120  /// @brief Gets the spacing being split between both sides of each child quad on the relevant axis.
121  /// @return Returns a const UnifiedDim reference representing the amount of space to apply on both sides of each child.
122  virtual const UnifiedDim& GetPadding() const;
123 
124  /// @brief Sets the alignment for visible children of this container when they don't take up all the visible space provided by the container.
125  /// @param ChildAlign The alignment to be given to visible children of this linear container.
126  virtual void SetVisibleChildAlignment(const UI::LinearAlignment ChildAlign);
127  /// @brief Gets the alignment for visible children of this container when they don't take up all the visible space provided by the container.
128  /// @return Returns a LinearAlignment value representing the alignment of visible children of this linear container.
129  virtual UI::LinearAlignment GetVisibleChildAlignment() const;
130 
131  ///////////////////////////////////////////////////////////////////////////////
132  // Child Management
133 
134  /// @copydoc QuadRenderable::AddChild(Widget*)
135  virtual void AddChild(Widget* Child);
136  /// @copydoc QuadRenderable::AddChild(Widget*,const UInt16)
137  virtual void AddChild(Widget* Child, const UInt16 ZOrder);
138 
139  ///////////////////////////////////////////////////////////////////////////////
140  // Serialization
141 
142  /// @copydoc Renderable::ProtoSerializeProperties(XML::Node&) const
143  virtual void ProtoSerializeProperties(XML::Node& SelfRoot) const;
144  /// @copydoc Renderable::ProtoDeSerializeProperties(const XML::Node&)
145  virtual void ProtoDeSerializeProperties(const XML::Node& SelfRoot);
146 
147  /// @copydoc Renderable::GetSerializableName()
148  static String GetSerializableName();
149 
150  ///////////////////////////////////////////////////////////////////////////////
151  // Internal Methods
152  };//LinearContainer
153  }//UI
154 }//Mezzanine
155 
156 #endif
This is the base class for containers that have a render area and work area of different sizes...
UnifiedDim LinearPadding
The amount of space to add to both sides of a child object on the relevant axis.
SizeEnforcement
This enum is used to determine if and when a child should be forced to a specific size for this conta...
This is a helper class designed to describe the behaviors of a quad when it needs to be resized...
Definition: sizinginfo.h:56
LinearAlignment
Used by various UI classes to determine the alignment of their child objects, such as text in text li...
This class represents a 2D rect which can express the size and position of a renderable on screen...
Definition: unifieddim.h:661
uint16_t UInt16
An 16-bit unsigned integer.
Definition: datatypes.h:122
A light-weight handle for manipulating nodes in DOM tree.
Definition: node.h:89
Whole ForcedSizingRules
The current enforcement for child size in this container.
This is the base class for all widgets.
Definition: widget.h:126
SizingInfo ChildSizing
The size given to children layed out by this container.
This class represents both the relative and absolute values that can be expressed for the values on o...
Definition: unifieddim.h:56
#define MEZZ_LIB
Some platforms require special decorations to denote what is exported/imported in a share library...
The bulk of the engine components go in this namspace.
Definition: actor.cpp:56
unsigned long Whole
Whole is an unsigned integer, it will be at least 32bits in size.
Definition: datatypes.h:151
UI::LinearAlignment VisibleChildAlign
The alignment to be given to the sequence of children visible in this container.
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
This is a container class for placing child objects in succession on a single axis.