Spinning Topp Logo BlackTopp Studios
inc
screen.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 #ifndef _uiscreen_h
41 #define _uiscreen_h
42 
43 #include "matrix4x4.h"
44 #include "UI/glyph.h"
45 #include "UI/vertex.h"
46 #include "UI/quadrenderable.h"
47 #include "UI/widget.h"
48 #include "UI/widgetfactory.h"
49 
50 namespace Mezzanine
51 {
52  namespace Graphics
53  {
54  class Viewport;
55  class SceneManager;
56  }
57  namespace UI
58  {
59  class Button;
60  class CheckBox;
61  class DropDownList;
62  class EditBox;
63  class GridContainer;
64  class HorizontalContainer;
65  class HorizontalScrollbar;
66  class LineList;
67  class ListBox;
68  class MenuEntry;
69  class RadioButton;
70  class Scrollbar;
71  class Spinner;
72  class StackButton;
73  class TabSet;
74  class VerticalContainer;
75  class VerticalScrollbar;
76  class Widget;
77  class Window;
78 
79  class Sprite;
80  class TextureAtlas;
81  class MouseHoverStrategy;
82  class MarkupParser;
83  class UIManager;
84  struct ScreenInternalData;
85  ///////////////////////////////////////////////////////////////////////////////
86  /// @brief This class stores how the calls to Render are to be done.
87  /// @details
88  ///////////////////////////////////////
90  {
91  /// @brief The name of the atlas to be rendered with.
93  /// @brief The number of vertices to be rendered.
95  /// @brief The index of the first verticy to be rendered.
97  /// @brief The index of the last verticy to be rendered.
99 
100  /// @brief Blank constructor.
102  RenderCount(0), RenderStart(0), RenderEnd(0)
103  { }
104  /// @brief Atlas constructor.
105  /// @param AtlasName The name of the atlas the specified vertices will use to render.
106  AtlasAndPosition(const String& AtlasName) :
107  Atlas(AtlasName), RenderCount(0), RenderStart(0), RenderEnd(0)
108  { }
109  };//AtlasAndPosition
110 
111  ///////////////////////////////////////////////////////////////////////////////
112  /// @brief This class stores all vertices pertaining to a layer sorted by their priority for rendering.
113  /// @details
114  ///////////////////////////////////////
116  {
117  public:
118  /// @brief Container storing all of the vertices to be rendered.
119  std::vector<VertexData> Vertices;
120 
121  /// @brief Clears all Vertex vectors.
122  void Clear();
123  /// @brief Gets the combined size of all Vertex vectors.
124  Whole Size();
125  /// @brief Appends the contents of another ScreenRenderData to the end of this.
126  /// @param OtherData The other ScreenRenderData to append.
127  void Append(ScreenRenderData& OtherData);
128  /// @brief Array access operator spanning all 3 Vertex vectors.
129  /// @param Index The index to access.
130  /// @return Returns a reference to the VertexData at the specified index.
131  VertexData& operator[](const Whole& Index);
132  };//ScreenRenderData
133 
134  ///////////////////////////////////////////////////////////////////////////////
135  /// @class Screen
136  /// @headerfile screen.h
137  /// @brief This class is a helper class for creating UI's. It is responsible for storing and keeping
138  /// track of all the elements of a single UI screen.
139  /// @details UI's can optionally be divided up into Screens. Each screen is batched together
140  /// for rendering, so keeping the amount of screens to a minimum will improve performance.
141  ///////////////////////////////////////
143  {
144  public:
145  /// @brief Basic container type for @ref Widget storage by this class.
146  typedef std::map<String,Widget*> WidgetContainer;
147  /// @brief Iterator type for @ref Widget instances stored by this class.
148  typedef WidgetContainer::iterator WidgetIterator;
149  /// @brief Const Iterator type for @ref Widget instances stored by this class.
150  typedef WidgetContainer::const_iterator ConstWidgetIterator;
151  /// @brief Basic container type for @ref Widget storage by this class.
152  typedef std::map<String,WidgetFactory*> WidgetFactoryContainer;
153  /// @brief Iterator type for @ref Widget instances stored by this class.
154  typedef WidgetFactoryContainer::iterator WidgetFactoryIterator;
155  /// @brief Const Iterator type for @ref Widget instances stored by this class.
156  typedef WidgetFactoryContainer::const_iterator ConstWidgetFactoryIterator;
157  /// @brief Basic container type for the storage of render data on this screen.
158  typedef std::vector<AtlasAndPosition> TextureVertexContainer;
159  /// @brief Callback type for child processing.
160  typedef Boole (ChildCallback)(QuadRenderable* Quad);
161  protected:
162  friend class Mezzanine::UI::UIManager;
163 
164  /// @internal
165  /// @brief A container storing a mapping of the textures needed to render each section of vertices.
166  TextureVertexContainer TextureByVertex;
167  /// @internal
168  /// @brief A container storing the actual vertices to be rendered.
170  /// @internal
171  /// @brief A container storing all the factories for the widgets supported by this screen.
172  WidgetFactoryContainer WidgetFactories;
173  /// @internal
174  /// @brief A container storing all the created Widgets owned by this screen.
175  WidgetContainer Widgets;
176 
177  /// @internal
178  /// @brief The transformation matrix used to update vertex transforms if needed.
180  /// @internal
181  /// @brief The name of the this screens primary atlas for texture lookups.
183  /// @internal
184  /// @brief The scaling to be applied to all vertices that are generated by this screen.
185  /// @note This member is set once and barely used, could be replaced with individual constructions where used.
187  /// @internal
188  /// @brief The pixel position on this screen where the mouse clicked on a Widget.
190  /// @internal
191  /// @brief The inverse size (1/size) of the viewport this screen is bound to in pixels.
193 
194  /// @internal
195  /// @brief A pointer to the class storing all sensative internal data THAT IS NOT FOR YOUR EYES!
196  ScreenInternalData* SID;
197  /// @internal
198  /// @brief A pointer to the UIManager that owns this screen.
200  /// @internal
201  /// @brief A pointer to the viewport this screen is bound to.
203  /// @internal
204  /// @brief A pointer to the strategy to be used when detecting the hovered widget.
206 
207  /// @internal
208  /// @brief The current orientation mode of this screen.
210 
211  /// @internal
212  /// @brief Gets a pointer to the SceneManager connected to this screens viewport.
213  /// @return Returns a pointer to the SceneManager that will be rendering this screen.
214  virtual Graphics::SceneManager* GetSceneManager() const;
215  /// @internal
216  /// @brief Gets a registered WidgetFactory that creates the specified type of widget.
217  /// @exception If a widget factor of the specified widget type isn't registered then a II_IDENTITY_NOT_FOUND_EXCEPTION will be thrown.
218  /// @param WidgetTypeName The name of the widget type to retrieve the factory for.
219  /// @return Returns a pointer to the specified factory. This pointer will always be valid if an exception isn't thrown.
220  virtual WidgetFactory* GetWidgetFactoryExcept(const String& WidgetTypeName);
221  /// @internal
222  /// @brief Verifies uniqueness of a widget and inserts it if it is.
223  /// @exception If a widget with the same name already exists in this Screen, a II_DUPLICATE_IDENTITY_EXCEPTION will be thrown.
224  /// @param ToInsert The widget to be verified and inserted.
225  /// @return Returns a pointer to the same widget that was passed into this method.
226  virtual Widget* CheckAndInsertExcept(Widget* ToInsert);
227 
228  /// @internal
229  /// @brief Sets up all the necessary projection and world matrices for UI rendering.
230  virtual void PrepareRenderSystem();
231  /// @internal
232  /// @brief Creates a new Vertex Buffer for vertices generated by the UI system.
233  /// @param InitialSize The amount of space to allocate for the initial buffer, in number of vertices.
234  virtual void CreateVertexBuffer(const Whole& InitialSize);
235  /// @internal
236  /// @brief Destroys the Vertex Buffer storing all the UI vertices generated by this screen.
237  virtual void DestroyVertexBuffer();
238  /// @internal
239  /// @brief Resizes the Vertex Buffer.
240  /// @note The Vertex Buffer will not shrink, only grow. Passing in a smaller size will do nothing.
241  /// @param RequestedSize The new size for the existing buffer.
242  virtual void ResizeVertexBuffer(const Whole& RequestedSize);
243  //public:
244  /// @brief Internal constructor.
245  /// @param RendName The name of this screen.
246  /// @param Atlas The name of the primary atlas to be assigned to this screen.
247  /// This can be overridden later, even by individual UI elements.
248  /// @param WindowViewport The Viewport to which this screen belongs.
249  /// @param Manager A pointer to the UI manager creating this screen.
250  Screen(const String& RendName, const String& Atlas, Graphics::Viewport* WindowViewport, UIManager* Manager);
251  /// @brief XML constructor.
252  /// @param XMLNode The node of the xml document to construct from.
253  /// @param Manager A pointer to the UI manager creating this screen.
254  Screen(const XML::Node& XMLNode, UIManager* Manager);
255  /// @brief Class destructor.
256  virtual ~Screen();
257  public:
258  ///////////////////////////////////////////////////////////////////////////////
259  // Utility and Visibility Methods
260 
261  /// @copydoc Renderable::SetVisible(Boole)
262  virtual void SetVisible(Boole CanSee);
263  /// @copydoc Renderable::GetVisible() const
264  virtual Boole GetVisible() const;
265  /// @copydoc Renderable::IsVisible() const
266  virtual Boole IsVisible() const;
267  /// @copydoc Renderable::Show()
268  virtual void Show();
269  /// @copydoc Renderable::Hide()
270  virtual void Hide();
271 
272  /// @copydoc Renderable::GetRenderableType() const
273  virtual RenderableType GetRenderableType() const;
274 
275  /// @brief Gets the current viewport dimensions.
276  /// @return Returns a Vector2 representing the current viewport dimensions.
277  virtual const Vector2& GetViewportDimensions() const;
278  /// @brief Checks to see if the viewport has changed in size. If so it updates all the UI elements on the screen.
279  virtual void CheckViewportSize();
280  /// @brief Gets the Viewport this screen is currently rendering to.
281  /// @return Returns a pointer to the Viewport this screen is applied to.
282  virtual Graphics::Viewport* GetViewport() const;
283  /// @brief Gets the UIManager this screen belongs to.
284  /// @return Returns a pointer to the UI manager that owns this screen.
285  virtual UIManager* GetManager() const;
286 
287  ///////////////////////////////////////////////////////////////////////////////
288  // Mouse Hover Methods
289 
290  /// @brief Sets the strategy to use when detect which object the mouse is hovered over.
291  /// @note This method will replace whatever method is currently set if one is set.
292  /// @param Strategy A pointer to the strategy to use.
293  virtual void SetMouseHoverStrategy(MouseHoverStrategy* Strategy);
294  /// @brief Gets the MouseHoverStrategy currently being used by this screen.
295  /// @return Returns a pointer to the currently set MouseHoverStrategy.
296  virtual MouseHoverStrategy* GetMouseHoverStrategy() const;
297  /// @brief Gets the quad the mouse is over if any.
298  /// @param MousePos The current mouse position.
299  /// @return Returns the Widget the mouse is over, or NULL if there are none.
300  virtual Widget* FindHoveredWidget(const Vector2& MousePos);
301  /// @brief Gets the mouse position from the last call to "FindHoveredQuad(const Vector2&).
302  /// @note Screens have a 1:1 ratio to viewports, not windows. The returned coordinates is in viewport space.
303  /// @warning This will not perform any additional checks. Only returns the result of the last check.
304  /// Verify the screen this is being called on is the one with the mouse over if prior to calling or you may get outdated information.
305  /// @return Returns a valid point on this screen if the last check was valid, or (-1,-1) if the check failed.
306  virtual const Vector2& GetMouseHitPosition() const;
307 
308  ///////////////////////////////////////////////////////////////////////////////
309  // WidgetFactory Management
310 
311  /// @brief Adds/registers a widget factory with this Screen, allowing it to be constructed through this API.
312  /// @param ToBeAdded The widget factory to be added.
313  void AddWidgetFactory(WidgetFactory* ToBeAdded);
314  /// @brief Removes a widget factory from this Screen.
315  /// @param ToBeRemoved A pointer to the widget factory that is to be removed.
316  void RemoveWidgetFactory(WidgetFactory* ToBeRemoved);
317  /// @brief Removes a widget factory from this Screen.
318  /// @param ImplName The name of the widget implementation created by the factory to be removed.
319  void RemoveWidgetFactory(const String& ImplName);
320  /// @brief Removes and destroys a widget factory in this Screen.
321  /// @param ToBeDestroyed A pointer to the widget factory that is to be removed and destroyed.
322  void DestroyWidgetFactory(WidgetFactory* ToBeDestroyed);
323  /// @brief Removes and destroys a widget factory in this Screen.
324  /// @param ImplName The name of the widget implementation created by the factory to be removed and destroyed.
325  void DestroyWidgetFactory(const String& ImplName);
326  /// @brief Destroys all widget factories in this Screen.
327  /// @warning The destruction of widget factories should only be done after the corresponding managers have been destroyed, otherwise this will cause an exception.
328  void DestroyAllWidgetFactories();
329  /// @brief Adds all the default widget factories provided by the engine to the Screen.
330  void AddAllDefaultWidgetFactories();
331 
332  ///////////////////////////////////////////////////////////////////////////////
333  // Widget Management
334 
335  /// @brief Creates a widget from an XML::Node.
336  /// @note This IS a polymorphic create method, and can create a widget of any type that has it's factory registered.
337  /// @exception This method will throw an exception if the WidgetNode is not named after a known widget.
338  /// @param WidgetNode The XML node populated with data needed to construct a widget.
339  /// @return Returns a pointer to the created widget.
340  virtual Widget* CreateWidget(const XML::Node& WidgetNode);
341  /// @brief Creates a widget based on the provided typename.
342  /// @note This IS a polymorphic create method, and can create a widget of any type that has it's factory registered.
343  /// @param TypeName The class name of the widget to be created.
344  /// @param RendName The unique instance name to be given to the widget.
345  /// @param Params A NameValuePairMap containing the params to be applied during construction.
346  /// @return Returns a pointer to the created widget.
347  virtual Widget* CreateWidget(const String& TypeName, const String& RendName, const NameValuePairMap& Params);
348  /// @brief Creates a widget based on the provided typename.
349  /// @note This IS a polymorphic create method, and can create a widget of any type that has it's factory registered.
350  /// @param TypeName The class name of the widget to be created.
351  /// @param RendName The unique instance name to be given to the widget.
352  /// @param RendRect The dimensions that will be assigned to the created Widget.
353  /// @param Params A NameValuePairMap containing the params to be applied during construction.
354  /// @return Returns a pointer to the created widget.
355  virtual Widget* CreateWidget(const String& TypeName, const String& RendName, const UnifiedRect& RendRect, const NameValuePairMap& Params);
356 
357  /// @brief Gets a widget in this screen by name.
358  /// @param Name The name of the widget to get.
359  /// @return Returns a pointer to the widget of the specified name.
360  virtual Widget* GetWidget(const String& Name);
361  /// @brief Gets the number of widgets being used in this screen.
362  /// @return Returns the number of widgets this screen is storing.
363  virtual Whole GetNumWidgets();
364 
365  /// @brief Destroys a widget.
366  /// @param ToBeDestroyed Pointer to the widget you want destroyed.
367  virtual void DestroyWidget(Widget* ToBeDestroyed);
368  /// @brief Destroys all widgets being stored by this screen.
369  virtual void DestroyAllWidgets();
370 
371  ///////////////////////////////////////////////////////////////////////////////
372  // Convenience Widget Creation Methods
373 
374  /// @brief Creates a generic widget.
375  /// @note This IS NOT a polymorphic create method. It will case an instance of the widget base class.
376  /// @param RendName The name to be given to this Widget.
377  /// @return Returns a pointer to the created Widget.
378  virtual Widget* CreateWidget(const String& RendName);
379  /// @brief Creates a generic widget.
380  /// @note This IS NOT a polymorphic create method. It will case an instance of the widget base class.
381  /// @param RendName The name to be given to this Widget.
382  /// @param RendRect The rect describing this Widget's transform relative to it's parent.
383  /// @return Returns a pointer to the created Widget.
384  virtual Widget* CreateWidget(const String& RendName, const UnifiedRect& RendRect);
385  /// @brief Creates a Button.
386  /// @param RendName The name to be given to this Button.
387  /// @return Returns a pointer to the created Button.
388  virtual Button* CreateButton(const String& RendName);
389  /// @brief Creates a Button.
390  /// @param RendName The name to be given to this Button.
391  /// @param RendRect The rect describing this Button's transform relative to it's parent.
392  /// @return Returns a pointer to the created Button.
393  virtual Button* CreateButton(const String& RendName, const UnifiedRect& RendRect);
394  /// @brief Creates a StackButton.
395  /// @param RendName The name to be given to this StackButton.
396  /// @return Returns a pointer to the created StackButton.
397  virtual StackButton* CreateStackButton(const String& RendName);
398  /// @brief Creates a MenuButton.
399  /// @param RendName The name to be given to this StackButton.
400  /// @param RendRect The rect describing this StackButton's transform relative to it's parent.
401  /// @return Returns a pointer to the created StackButton.
402  virtual StackButton* CreateStackButton(const String& RendName, const UnifiedRect& RendRect);
403  /// @brief Creates a RadioButton.
404  /// @param RendName The name to be given to this RadioButton.
405  /// @return Returns a pointer to the created RadioButton.
406  virtual RadioButton* CreateRadioButton(const String& RendName);
407  /// @brief Creates a RadioButton.
408  /// @param RendName The name to be given to this RadioButton.
409  /// @param RendRect The rect describing this RadioButton's transform relative to it's parent.
410  /// @return Returns a pointer to the created RadioButton.
411  virtual RadioButton* CreateRadioButton(const String& RendName, const UnifiedRect& RendRect);
412  /// @brief Creates a CheckBox.
413  /// @param RendName The name of the CheckBox.
414  /// @return Returns a pointer to the created CheckBox.
415  virtual CheckBox* CreateCheckBox(const String& RendName);
416  /// @brief Creates a CheckBox.
417  /// @param RendName The name of the CheckBox.
418  /// @param RendRect The Rect representing the position and size of the CheckBox.
419  /// @return Returns a pointer to the created CheckBox.
420  virtual CheckBox* CreateCheckBox(const String& RendName, const UnifiedRect& RendRect);
421  /// @brief Creates a EditBox.
422  /// @param RendName The name of the EditBox.
423  /// @param EditLayerType The type of text layer to be auto-created for editing.
424  /// @param EditFont A pointer to the font to be used by the edit layer.
425  /// @return Returns a pointer to the created EditBox.
426  virtual EditBox* CreateEditBox(const String& RendName, const RenderLayerType EditLayerType, FontData* EditFont);
427  /// @brief Creates a EditBox.
428  /// @param RendName The name of the EditBox.
429  /// @param EditLayerType The type of text layer to be auto-created for editing.
430  /// @param EditFontName The name of the font to be used by the edit layer.
431  /// @return Returns a pointer to the created EditBox.
432  virtual EditBox* CreateEditBox(const String& RendName, const RenderLayerType EditLayerType, const String& EditFontName);
433  /// @brief Creates a EditBox.
434  /// @param RendName The name of the EditBox.
435  /// @param RendRect The Rect representing the position and size of the EditBox.
436  /// @param EditLayerType The type of text layer to be auto-created for editing.
437  /// @param EditFont A pointer to the font to be used by the edit layer.
438  /// @return Returns a pointer to the created EditBox.
439  virtual EditBox* CreateEditBox(const String& RendName, const UnifiedRect& RendRect, const RenderLayerType EditLayerType, FontData* EditFont);
440  /// @brief Creates a EditBox.
441  /// @param RendName The name of the EditBox.
442  /// @param RendRect The Rect representing the position and size of the EditBox.
443  /// @param EditLayerType The type of text layer to be auto-created for editing.
444  /// @param EditFontName The name of the font to be used by the edit layer.
445  /// @return Returns a pointer to the created EditBox.
446  virtual EditBox* CreateEditBox(const String& RendName, const UnifiedRect& RendRect, const RenderLayerType EditLayerType, const String& EditFontName);
447 
448  /// @brief Creates a Scrollbar aligned on the X axis.
449  /// @param RendName The name of the HorizontalScrollbar.
450  /// @param Style The style of scrollbar you want to create, see Scrollbar documentation for more details.
451  /// @return Returns a pointer to the created HorizontalScrollbar.
452  virtual HorizontalScrollbar* CreateHorizontalScrollbar(const String& RendName, const UI::ScrollbarStyle Style);
453  /// @brief Creates a Scrollbar aligned on the X axis.
454  /// @param RendName The name of the HorizontalScrollbar.
455  /// @param RendRect The Rect representing the position and size of the HorizontalScrollbar.
456  /// @param Style The style of scrollbar you want to create, see Scrollbar documentation for more details.
457  /// @return Returns a pointer to the created HorizontalScrollbar.
458  virtual HorizontalScrollbar* CreateHorizontalScrollbar(const String& RendName, const UnifiedRect& RendRect, const UI::ScrollbarStyle Style);
459  /// @brief Creates a Scrollbar aligned on the Y axis.
460  /// @param RendName The name of the VerticalScrollbar.
461  /// @param Style The style of scrollbar you want to create, see Scrollbar documentation for more details.
462  /// @return Returns a pointer to the created VerticalScrollbar.
463  virtual VerticalScrollbar* CreateVerticalScrollbar(const String& RendName, const UI::ScrollbarStyle Style);
464  /// @brief Creates a Scrollbar aligned on the Y axis.
465  /// @param RendName The name of the VerticalScrollbar.
466  /// @param RendRect The Rect representing the position and size of the VerticalScrollbar.
467  /// @param Style The style of scrollbar you want to create, see Scrollbar documentation for more details.
468  /// @return Returns a pointer to the created VerticalScrollbar.
469  virtual VerticalScrollbar* CreateVerticalScrollbar(const String& RendName, const UnifiedRect& RendRect, const UI::ScrollbarStyle Style);
470  /// @brief Creates a Spinner.
471  /// @param RendName The name of the Spinner.
472  /// @param SpinStyle The layout of buttons this Spinner will have.
473  /// @param EditFont A pointer to the font to be used by the edit layer.
474  /// @return Returns a pointer to the created Spinner.
475  virtual Spinner* CreateSpinner(const String& RendName, const SpinnerStyle SpinStyle, FontData* EditFont);
476  /// @brief Creates a Spinner.
477  /// @param RendName The name of the Spinner.
478  /// @param SpinStyle The layout of buttons this Spinner will have.
479  /// @param EditFontName The name of the font to be used by the edit layer.
480  /// @return Returns a pointer to the created Spinner.
481  virtual Spinner* CreateSpinner(const String& RendName, const SpinnerStyle SpinStyle, const String& EditFontName);
482  /// @brief Creates a Spinner.
483  /// @param RendName The name of the Spinner.
484  /// @param RendRect The Rect representing the position and size of the Spinner.
485  /// @param SpinStyle The layout of buttons this Spinner will have.
486  /// @param EditFont A pointer to the font to be used by the edit layer.
487  /// @return Returns a pointer to the created Spinner.
488  virtual Spinner* CreateSpinner(const String& RendName, const UnifiedRect& RendRect, const SpinnerStyle SpinStyle, FontData* EditFont);
489  /// @brief Creates a Spinner.
490  /// @param RendName The name of the Spinner.
491  /// @param RendRect The Rect representing the position and size of the Spinner.
492  /// @param SpinStyle The layout of buttons this Spinner will have.
493  /// @param EditFontName The name of the font to be used by the edit layer.
494  /// @return Returns a pointer to the created Spinner.
495  virtual Spinner* CreateSpinner(const String& RendName, const UnifiedRect& RendRect, const SpinnerStyle SpinStyle, const String& EditFontName);
496 
497  /// @brief Creates a MenuEntry.
498  /// @param RendName The name to be given to this MenuEntry.
499  /// @return Returns a pointer to the created MenuEntry.
500  virtual MenuEntry* CreateMenuEntry(const String& RendName);
501  /// @brief Creates a MenuEntry.
502  /// @param RendName The name to be given to this MenuEntry.
503  /// @param RendRect The rect describing this MenuEntry's transform relative to it's parent.
504  /// @return Returns a pointer to the created MenuEntry.
505  virtual MenuEntry* CreateMenuEntry(const String& RendName, const UnifiedRect& RendRect);
506  /// @brief Creates a TabSet.
507  /// @param RendName The name to be given to this TabSet.
508  /// @return Returns a pointer to the created TabSet.
509  virtual TabSet* CreateTabSet(const String& RendName);
510  /// @brief Creates a TabSet.
511  /// @param RendName The name to be given to this TabSet.
512  /// @param RendRect The rect describing this TabSet's transform relative to it's parent.
513  /// @return Returns a pointer to the created TabSet.
514  virtual TabSet* CreateTabSet(const String& RendName, const UnifiedRect& RendRect);
515  /// @brief Creates a ListBox.
516  /// @param RendName The name to be given to this ListBox.
517  /// @param Style The style of scrollbar you want to create, see Scrollbar documentation for more details.
518  /// @return Returns a pointer to the created ListBox.
519  virtual ListBox* CreateListBox(const String& RendName, const UI::ScrollbarStyle Style);
520  /// @brief Creates a ListBox.
521  /// @param RendName The name to be given to this ListBox.
522  /// @param RendRect The rect describing this ListBox's transform relative to it's parent.
523  /// @param Style The style of scrollbar you want to create, see Scrollbar documentation for more details.
524  /// @return Returns a pointer to the created ListBox.
525  virtual ListBox* CreateListBox(const String& RendName, const UnifiedRect& RendRect, const UI::ScrollbarStyle Style);
526  /// @brief Creates a DropDownList.
527  /// @param RendName The name to be given to this DropDownList.
528  /// @param Style An enum value representing how the scrollbar child of the ListBox will be constructed. See @ref UI::ScrollbarStyle enum for more info.
529  /// @return Returns a pointer to the created DropDownList.
530  virtual DropDownList* CreateDropDownList(const String& RendName, const UI::ScrollbarStyle Style);
531  /// @brief Creates a DropDownList.
532  /// @param RendName The name to be given to this DropDownList.
533  /// @param RendRect The rect describing this DropDownList's transform relative to it's parent.
534  /// @param Style An enum value representing how the scrollbar child of the ListBox will be constructed. See @ref UI::ScrollbarStyle enum for more info.
535  /// @return Returns a pointer to the created DropDownList.
536  virtual DropDownList* CreateDropDownList(const String& RendName, const UnifiedRect& RendRect, const UI::ScrollbarStyle Style);
537 
538  /// @brief Creates a widget container aligned on the X axis.
539  /// @param RendName The name to be given to this renderable.
540  /// @return Returns a pointer to the created HorizontalContainer.
541  virtual HorizontalContainer* CreateHorizontalContainer(const String& RendName);
542  /// @brief Creates a widget container aligned on the X axis.
543  /// @param RendName The name to be given to this renderable.
544  /// @param RendRect The rect describing this widget's transform relative to it's parent.
545  /// @return Returns a pointer to the created HorizontalContainer.
546  virtual HorizontalContainer* CreateHorizontalContainer(const String& RendName, const UnifiedRect& RendRect);
547  /// @brief Creates a widget container aligned on the Y axis.
548  /// @param RendName The name to be given to this renderable.
549  /// @return Returns a pointer to the created VerticalContainer.
550  virtual VerticalContainer* CreateVerticalContainer(const String& RendName);
551  /// @brief Creates a widget container aligned on the Y axis.
552  /// @param RendName The name to be given to this renderable.
553  /// @param RendRect The rect describing this widget's transform relative to it's parent.
554  /// @return Returns a pointer to the created VerticalContainer.
555  virtual VerticalContainer* CreateVerticalContainer(const String& RendName, const UnifiedRect& RendRect);
556  /// @brief Creates a widget container for the placement of widgets on a 2D grid.
557  /// @param RendName The name to be given to this renderable.
558  /// @return Returns a pointer to the created GridContainer.
559  virtual GridContainer* CreateGridContainer(const String& RendName);
560  /// @brief Creates a widget container for the placement of widgets on a 2D grid.
561  /// @param RendName The name to be given to this renderable.
562  /// @param RendRect The rect describing this widget's transform relative to it's parent.
563  /// @return Returns a pointer to the created GridContainer.
564  virtual GridContainer* CreateGridContainer(const String& RendName, const UnifiedRect& RendRect);
565 
566  /*/// @brief Creates a Window.
567  /// @return Returns a pointer to the created Window.
568  /// @param Name The name of the Window.
569  /// @param RendRect The Rect representing the position and size of the Window.
570  virtual Window* CreateWidgetWindow(ConstString& Name, const Rect& RendRect);// */
571 
572  ///////////////////////////////////////////////////////////////////////////////
573  // Atlas Query
574 
575  /// @brief Sets the Atlas to be assumed when one isn't provided for atlas related tasks.
576  /// @param Atlas The name of the atlas to be used.
577  virtual void SetPrimaryAtlas(const String& Atlas);
578  /// @brief Gets the currently set primary atlas.
579  /// @return Returns a string containing the name of the primary atlas that is set.
580  virtual String GetPrimaryAtlas();
581  /// @brief Gets the position of the white pixel from an Atlas.
582  /// @param Atlas The name of the Atlas to get the white pixel from.
583  /// @return Returns a Vector2 with the location of white pixel on the Atlas.
584  Vector2 GetWhitePixel(const String& Atlas) const;
585  /// @brief Gets a sprite from an Atlas.
586  /// @param SpriteName The name of the sprite to retrieve.
587  /// @param Atlas The name of the Atlas to get the sprite from.
588  /// @return Returns a pointer to the requested Sprite.
589  Sprite* GetSprite(const String& SpriteName, const String& Atlas) const;
590  /// @brief Gets the specified FontData from an Atlas.
591  /// @param FontName The name of the Font to retrieve.
592  /// @param Atlas The name of the atlas to check the specified FontData for.
593  /// @return Returns a pointer to the requested FontData.
594  FontData* GetFont(const String& FontName, const String& Atlas) const;
595  /// @brief Gets the texture size of the specified Atlas.
596  /// @param Atlas The name of the atlas to get the texture size of.
597  /// @return Returns a Vector2 containing the size of the requested Atlas.
598  Vector2 GetTextureSize(const String& Atlas) const;
599  /// @brief Gets an atlas that has been loaded.
600  /// @param Atlas The name of the Atlas to retrieve, usually stored as a filename.
601  /// @return Returns a pointer to the requested Texture Atlas.
602  TextureAtlas* GetAtlas(const String& Atlas) const;
603  /// @brief Gets the X axis Texel Offset for the current rendersystem.
604  /// @return Retruns a real containing the texel offset to be applied to renderables on this screen.
605  Real GetTexelOffsetX() const;
606  /// @brief Gets the Y axis Texel Offset for the current rendersystem.
607  /// @return Retruns a real containing the texel offset to be applied to renderables on this screen.
608  Real GetTexelOffsetY() const;
609 
610  ///////////////////////////////////////////////////////////////////////////////
611  // Other Query
612 
613  /// @brief Checks to see if a MarkupParser has already been registsered under a specific name.
614  /// @param ParserName The name of the MarkupParser to check for.
615  /// @return Returns true if a MarkupParser is registered under the specified name.
616  bool IsMarkupParserRegistered(const String& ParserName) const;
617  /// @brief Gets a MarkupParser by it's registered name.
618  /// @param ParserName The name of the MarkupParser to retrieve.
619  /// @return Returns a pointer to the requested MarkupParser, or NULL if none are registered under the specified name.
620  UI::MarkupParser* GetMarkupParser(const String& ParserName) const;
621 
622  ///////////////////////////////////////////////////////////////////////////////
623  // Serialization
624 
625  /// @copydoc Renderable::ProtoSerializeProperties(XML::Node&) const
626  virtual void ProtoSerializeProperties(XML::Node& SelfRoot) const;
627  /// @copydoc Renderable::ProtoDeSerializeProperties(const XML::Node&)
628  virtual void ProtoDeSerializeProperties(const XML::Node& SelfRoot);
629 
630  /// @copydoc Renderable::GetDerivedSerializableName() const
631  virtual String GetDerivedSerializableName() const;
632  /// @copydoc Renderable::GetSerializableName()
633  static String GetSerializableName();
634 
635  ///////////////////////////////////////////////////////////////////////////////
636  // Internal Functions
637 
638  /// @copydoc Renderable::_MarkDirty()
639  void _MarkDirty();
640  /// @copydoc QuadRenderable::_MarkAllLayersDirty()
641  virtual void _MarkAllLayersDirty();
642  /// @internal
643  /// @brief Manually calls the UI system to render this screen.
644  void _RenderScreen();
645  /// @internal
646  /// @brief Forces an orientation mode change for this screen.
647  /// @param Mode The orientation mode to be applied to the UI on this screen.
648  void _SetOrientation(const Mezzanine::OrientationMode& Mode);
649  /// @internal
650  /// @brief Updates the vertex positions so they are in front of the camera in world space.
651  /// @param RenderData Vector of the vertices to be transformed.
652  /// @param Begin The first Vertex to transform in the range.
653  /// @param End The last Vertex to transform in the range.
654  void _Transform(ScreenRenderData& RenderData, const Whole& Begin, const Whole& End);
655  /// @internal
656  /// @brief Prepares all vertices for rendering to the screen.
657  /// @param Force Whether or not to force preparation regardless of if they need it.
658  void _RenderVertices(bool Force = false);
659 
660  /// @internal
661  /// @brief Processes all children of this screen by their zorder.
662  /// @param CB The callback implementing how the children are to be processed.
663  /// @return Returns the result of the callback, and exits early if true.
664  template<typename Callback>
666  {
667  for( ChildIterator ChildIt = this->ChildrenBegin() ; ChildIt != this->ChildrenEnd() ; ++ChildIt )
668  {
669  if( Screen::_ProcessAllChildren((*ChildIt),CB) )
670  return true;
671  }
672  return false;
673  }
674  /// @internal
675  /// @brief Processes all children of this screen in reverse zorder.
676  /// @param CB The callback implementing how the children are to be processed.
677  /// @return Returns the result of the callback, and exits early if true.
678  template<typename Callback>
680  {
681  for( ReverseChildIterator RChildIt = this->RChildrenBegin() ; RChildIt != this->RChildrenEnd() ; ++RChildIt )
682  {
683  if( Screen::_ReverseProcessAllChildren((*RChildIt),CB) )
684  return true;
685  }
686  return false;
687  }
688  /// @internal
689  /// @brief Processes all children of this screen by their zorder.
690  /// @param Wid The Widget whose children need to be processed.
691  /// @param CB The callback implementing how the children are to be processed.
692  /// @return Returns the result of the callback, and exits early if true.
693  template<typename Callback>
694  static Boole _ProcessAllChildren(Widget* Wid, Callback* CB)
695  {
696  if( (*CB)(Wid) )
697  return true;
698  for( ChildIterator ChildIt = Wid->ChildrenBegin() ; ChildIt != Wid->ChildrenEnd() ; ++ChildIt )
699  {
700  if( Screen::_ProcessAllChildren((*ChildIt),CB) )
701  return true;
702  }
703  return false;
704  }
705  /// @internal
706  /// @brief Processes all children of this screen in reverse zorder.
707  /// @param Wid The Widget whose children need to be processed.
708  /// @param CB The callback implementing how the children are to be processed.
709  /// @return Returns the result of the callback, and exits early if true.
710  template<typename Callback>
711  static Boole _ReverseProcessAllChildren(Widget* Wid, Callback* CB)
712  {
713  for( ReverseChildIterator RChildIt = Wid->RChildrenBegin() ; RChildIt != Wid->RChildrenEnd() ; ++RChildIt )
714  {
715  if( Screen::_ReverseProcessAllChildren((*RChildIt),CB) )
716  return true;
717  }
718  if( (*CB)(Wid) )
719  return true;
720 
721  return false;
722  }
723  };//uiscreen
724  }//ui
725 }//Mezzanine
726 
727 #endif
This class represents a collection of Glyphs in a common visual style.
Definition: font.h:55
void Clear()
Clears all Vertex vectors.
Definition: screen.cpp:176
TextureAtlas * GetAtlas(const String &AtlasName)
Gets a loaded Atlas being stored in this manager.
Definition: uimanager.cpp:286
Matrix4x4 VertexTransform
The transformation matrix used to update vertex transforms if needed.
Definition: screen.h:179
Boole IsMarkupParserRegistered(const String &ParserName) const
Checks to see if a MarkupParser has already been registsered under a specific name.
Definition: uimanager.cpp:484
std::vector< VertexData > Vertices
Container storing all of the vertices to be rendered.
Definition: screen.h:119
Graphics::Viewport * GameViewport
A pointer to the viewport this screen is bound to.
Definition: screen.h:202
bool Boole
Generally acts a single bit, true or false.
Definition: datatypes.h:173
String Atlas
The name of the atlas to be rendered with.
Definition: screen.h:92
ChildContainer::reverse_iterator ReverseChildIterator
Reverse Iterator type for Widget instances stored by this class.
This class contains utilities and functions to allow the manipulation of the Graphical scene...
Definition: scenemanager.h:85
AtlasAndPosition(const String &AtlasName)
Atlas constructor.
Definition: screen.h:106
This is a container class for placing child objects on a 2 dimensional grid.
SpinnerStyle
Used by the spinner class to determine what styling should be used for the spinner.
ChildIterator ChildrenEnd()
Gets an iterator to one passed the last child Widget.
std::vector< AtlasAndPosition > TextureVertexContainer
Basic container type for the storage of render data on this screen.
Definition: screen.h:158
Whole Size()
Gets the combined size of all Vertex vectors.
Definition: screen.cpp:179
UIManager * UIMan
A pointer to the UIManager that owns this screen.
Definition: screen.h:199
WidgetContainer::const_iterator ConstWidgetIterator
Const Iterator type for Widget instances stored by this class.
Definition: screen.h:150
void Append(ScreenRenderData &OtherData)
Appends the contents of another ScreenRenderData to the end of this.
Definition: screen.cpp:182
This class stores how the calls to Render are to be done.
Definition: screen.h:89
This is a button with additional data used to track the binding to a StackedContainer which can be se...
Definition: stackbutton.h:54
Vector3 Scale
The scaling to be applied to all vertices that are generated by this screen.
Definition: screen.h:186
A 4x4 matrix math class for the representation of full transforms.
Definition: matrix4x4.h:59
Boole _ReverseProcessAllChildren(Callback *CB)
Processes all children of this screen in reverse zorder.
Definition: screen.h:679
This is a collection of smaller textures packed into a larger texture, intended to increase UI perfor...
Definition: textureatlas.h:71
WidgetContainer::iterator WidgetIterator
Iterator type for Widget instances stored by this class.
Definition: screen.h:148
Whole RenderCount
The number of vertices to be rendered.
Definition: screen.h:94
AtlasAndPosition()
Blank constructor.
Definition: screen.h:101
ScrollbarStyle
Used by the scrollbar class to determine what styling should be used for the scrollbar.
This is a widget that stores sets of renderables but only displays one at a time. ...
Definition: tabset.h:54
static Boole _ProcessAllChildren(Widget *Wid, Callback *CB)
Processes all children of this screen by their zorder.
Definition: screen.h:694
This is a simple widget for a numeric variable in a box.
Definition: spinner.h:130
Boole _ProcessAllChildren(Callback *CB)
Processes all children of this screen by their zorder.
Definition: screen.h:665
float Real
A Datatype used to represent a real floating point number.
Definition: datatypes.h:141
String PrimaryAtlas
The name of the this screens primary atlas for texture lookups.
Definition: screen.h:182
This class represents a 2D rect which can express the size and position of a renderable on screen...
Definition: unifieddim.h:661
std::map< String, Widget * > WidgetContainer
Basic container type for Widget storage by this class.
Definition: screen.h:146
This class is for creating and managing viewports within a game window.
Definition: viewport.h:65
This is the base class for a method of finding which quad the mouse is hovered over.
A light-weight handle for manipulating nodes in DOM tree.
Definition: node.h:89
Whole RenderEnd
The index of the last verticy to be rendered.
Definition: screen.h:98
Vector2 MouseHitPosition
The pixel position on this screen where the mouse clicked on a Widget.
Definition: screen.h:189
This is used to represent a point on a 2 dimentional area, such as a screen.
Definition: vector2.h:63
This is the base class for all widgets.
Definition: widget.h:126
VertexData & operator[](const Whole &Index)
Array access operator spanning all 3 Vertex vectors.
Definition: screen.cpp:185
WidgetFactoryContainer::const_iterator ConstWidgetFactoryIterator
Const Iterator type for Widget instances stored by this class.
Definition: screen.h:156
ScreenInternalData * SID
A pointer to the class storing all sensative internal data THAT IS NOT FOR YOUR EYES! ...
Definition: screen.h:196
static Boole _ReverseProcessAllChildren(Widget *Wid, Callback *CB)
Processes all children of this screen in reverse zorder.
Definition: screen.h:711
A layout container that aligns it's children along a common Y axis.
This is a scrollbar class aligned on the X axis.
This class is an entry for a single window/widget in a menu.
Definition: menuentry.h:57
std::map< String, WidgetFactory * > WidgetFactoryContainer
Basic container type for Widget storage by this class.
Definition: screen.h:152
MouseHoverStrategy * MouseStrat
A pointer to the strategy to be used when detecting the hovered widget.
Definition: screen.h:205
WidgetFactoryContainer WidgetFactories
A container storing all the factories for the widgets supported by this screen.
Definition: screen.h:172
Basic class describing a vertex in the UI to be rendered.
Definition: vertex.h:65
RenderLayerType
This enum describes the type of RenderLayer this is for use in casting.
This is used to represent a point in space, or a vector through space.
Definition: vector3.h:77
ReverseChildIterator RChildrenBegin()
Gets an iterator to the last Widget.
This class is responsible for any and all user interactions with the User interface/HUD.
Definition: uimanager.h:114
#define MEZZ_LIB
Some platforms require special decorations to denote what is exported/imported in a share library...
ScreenRenderData VertexCache
A container storing the actual vertices to be rendered.
Definition: screen.h:169
MarkupParser * GetMarkupParser(const String &ParserName) const
Gets a MarkupParser by it's registered name.
Definition: uimanager.cpp:490
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
OrientationMode
Simple enum for communicating the orientation the UI and Camera have relative to the world it is rend...
Definition: enumerations.h:66
unsigned long Whole
Whole is an unsigned integer, it will be at least 32bits in size.
Definition: datatypes.h:151
A layout container that aligns it's children along a common X axis.
WidgetContainer Widgets
A container storing all the created Widgets owned by this screen.
Definition: screen.h:175
ChildContainer::iterator ChildIterator
Iterator type for Widget instances stored by this class.
This class is a helper class, specifically for use as a button.
Definition: button.h:66
ReverseChildIterator RChildrenEnd()
Gets an iterator to one before the first child Widget.
This is a base class for the parsing of markup texts contained in text layers.
Definition: markupparser.h:126
This is a simple widget for storing a bool value.
Definition: checkbox.h:55
Mezzanine::OrientationMode Orientation
The current orientation mode of this screen.
Definition: screen.h:209
This is a scrollbar class aligned on the Y axis.
Whole RenderStart
The index of the first verticy to be rendered.
Definition: screen.h:96
This represents a nestable quad for an object in a GUI layout.
This is a simple widget where only one of it's selections can be selected at a time.
Definition: radiobutton.h:130
ChildIterator ChildrenBegin()
Gets an iterator to the first child Widget.
TextureVertexContainer TextureByVertex
A container storing a mapping of the textures needed to render each section of vertices.
Definition: screen.h:166
std::map< String, String > NameValuePairMap
This is a datatype mostly used for describing settings or parameters that can't be declared in advanc...
Definition: datatypes.h:209
WidgetFactoryContainer::iterator WidgetFactoryIterator
Iterator type for Widget instances stored by this class.
Definition: screen.h:154
This class is a helper class for creating UI's. It is responsible for storing and keeping track of al...
Definition: screen.h:142
Basic class used to describe a portion of a texture to be applied to a Quad.
Definition: sprite.h:55
std::string String
A datatype used to a series of characters.
Definition: datatypes.h:159
RenderableType
A small enum to describe the type of renderable this is.
Definition: renderable.h:62
This is a base class for factories that construct the widgets available to the UI subsystem...
Definition: widgetfactory.h:61
Vector2 InverseSize
The inverse size (1/size) of the viewport this screen is bound to in pixels.
Definition: screen.h:192
This is a widget that displays one selection from a list that can have it's visibility toggled...
Definition: dropdownlist.h:59
This is a widget for displaying a list of captions in a box.
Definition: listbox.h:63
Widget for handling the input and manipulation of text.
Definition: editbox.h:60