MezzanineEngine 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
screen.h
1 // © Copyright 2010 - 2014 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 MenuButton;
69  class MenuEntry;
70  class RadioButton;
71  class Scrollbar;
72  class Spinner;
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  /// @class AtlasAndPosition
87  /// @headerfile screen.h
88  /// @brief This class stores how the calls to Render are to be done.
89  /// @details
90  ///////////////////////////////////////
92  {
93  String Atlas;
94  Whole RenderCount;
95  Whole RenderStart;
96  Whole RenderEnd;
97 
98  AtlasAndPosition() : RenderCount(0), RenderStart(0), RenderEnd(0) {};
99  AtlasAndPosition(const String& AtlasName) : Atlas(AtlasName), RenderCount(0), RenderStart(0), RenderEnd(0) {};
100  };//AtlasAndPosition
101 
102  ///////////////////////////////////////////////////////////////////////////////
103  /// @class ScreenRenderData
104  /// @headerfile screen.h
105  /// @brief This class stores all vertices pertaining to a layer sorted by their priority for rendering.
106  /// @details
107  ///////////////////////////////////////
109  {
110  public:
111  std::vector<VertexData> LowVertices;
112  std::vector<VertexData> MediumVertices;
113  std::vector<VertexData> HighVertices;
114 
115  /// @brief Clears all Vertex vectors.
116  void Clear();
117  /// @brief Gets the combined size of all Vertex vectors.
118  Whole Size();
119  /// @brief Appends the contents of another ScreenRenderData to the end of this.
120  /// @param OtherData The other ScreenRenderData to append.
121  void Append(ScreenRenderData& OtherData);
122  /// @brief Array access operator spanning all 3 Vertex vectors.
123  /// @param Index The index to access.
124  VertexData& operator[](const Whole& Index);
125  };//ScreenRenderData
126 
127  ///////////////////////////////////////////////////////////////////////////////
128  /// @class Screen
129  /// @headerfile screen.h
130  /// @brief This class is a helper class for creating UI's. It is responsible for storing and keeping
131  /// track of all the elements of a single UI screen.
132  /// @details UI's can optionally be divided up into Screens. Each screen is batched together
133  /// for rendering, so keeping the amount of screens to a minimum will improve performance.
134  ///////////////////////////////////////
136  {
137  public:
138  /// @brief Basic container type for @ref Widget storage by this class.
139  typedef std::map<String,Widget*> WidgetContainer;
140  /// @brief Iterator type for @ref Widget instances stored by this class.
141  typedef WidgetContainer::iterator WidgetIterator;
142  /// @brief Const Iterator type for @ref Widget instances stored by this class.
143  typedef WidgetContainer::const_iterator ConstWidgetIterator;
144  /// @brief Basic container type for @ref Widget storage by this class.
145  typedef std::map<String,WidgetFactory*> WidgetFactoryContainer;
146  /// @brief Iterator type for @ref Widget instances stored by this class.
147  typedef WidgetFactoryContainer::iterator WidgetFactoryIterator;
148  /// @brief Const Iterator type for @ref Widget instances stored by this class.
149  typedef WidgetFactoryContainer::const_iterator ConstWidgetFactoryIterator;
150  /// @brief Basic container type for the storage of render data on this screen.
151  typedef std::vector<AtlasAndPosition> TextureVertexContainer;
152  /// @brief Callback type for child processing.
153  typedef bool (ChildCallback)(QuadRenderable* Quad);
154  protected:
155  friend class Mezzanine::UI::UIManager;
156 
157  /// @internal
158  /// @brief A container storing a mapping of the textures needed to render each section of vertices.
160  /// @internal
161  /// @brief A container storing the actual vertices to be rendered.
163  /// @internal
164  /// @brief A container storing all the factories for the widgets supported by this screen.
166  /// @internal
167  /// @brief A container storing all the created Widgets owned by this screen.
169 
170  /// @internal
171  /// @brief The transformation matrix used to update vertex transforms if needed.
173  /// @internal
174  /// @brief The name of the this screens primary atlas for texture lookups.
176  /// @internal
177  /// @brief The scaling to be applied to all vertices that are generated by this screen.
178  /// @note This member is set once and barely used, could be replaced with individual constructions where used.
180  /// @internal
181  /// @brief The pixel position on this screen where the mouse clicked on a Widget.
183  /// @internal
184  /// @brief The inverse size (1/size) of the viewport this screen is bound to in pixels.
186 
187  /// @internal
188  /// @brief A pointer to the class storing all sensative internal data THAT IS NOT FOR YOUR EYES!
190  /// @internal
191  /// @brief A pointer to the UIManager that owns this screen.
193  /// @internal
194  /// @brief A pointer to the viewport this screen is bound to.
196  /// @internal
197  /// @brief A pointer to the strategy to be used when detecting the hovered widget.
199 
200  /// @internal
201  /// @brief The current orientation mode of this screen.
203 
204  /// @internal
205  /// @brief Gets a pointer to the SceneManager connected to this screens viewport.
206  /// @return Returns a pointer to the SceneManager that will be rendering this screen.
207  virtual Graphics::SceneManager* GetSceneManager() const;
208  /// @internal
209  /// @brief Gets a registered WidgetFactory that creates the specified type of widget.
210  /// @exception If a widget factor of the specified widget type isn't registered then a II_IDENTITY_NOT_FOUND_EXCEPTION will be thrown.
211  /// @param WidgetTypeName The name of the widget type to retrieve the factory for.
212  /// @return Returns a pointer to the specified factory. This pointer will always be valid if an exception isn't thrown.
213  virtual WidgetFactory* GetWidgetFactoryExcept(const String& WidgetTypeName);
214  /// @internal
215  /// @brief Verifies uniqueness of a widget and inserts it if it is.
216  /// @exception If a widget with the same name already exists in this Screen, a II_DUPLICATE_IDENTITY_EXCEPTION will be thrown.
217  /// @param ToInsert The widget to be verified and inserted.
218  /// @return Returns a pointer to the same widget that was passed into this method.
219  virtual Widget* CheckAndInsertExcept(Widget* ToInsert);
220 
221  /// @internal
222  /// @brief Sets up all the necessary projection and world matrices for UI rendering.
223  virtual void PrepareRenderSystem();
224  /// @internal
225  /// @brief Creates a new Vertex Buffer for vertices generated by the UI system.
226  /// @param InitialSize The amount of space to allocate for the initial buffer, in number of vertices.
227  virtual void CreateVertexBuffer(const Whole& InitialSize);
228  /// @internal
229  /// @brief Destroys the Vertex Buffer storing all the UI vertices generated by this screen.
230  virtual void DestroyVertexBuffer();
231  /// @internal
232  /// @brief Resizes the Vertex Buffer.
233  /// @note The Vertex Buffer will not shrink, only grow. Passing in a smaller size will do nothing.
234  /// @param RequestedSize The new size for the existing buffer.
235  virtual void ResizeVertexBuffer(const Whole& RequestedSize);
236  //public:
237  /// @brief Internal constructor.
238  /// @param RendName The name of this screen.
239  /// @param Atlas The name of the primary atlas to be assigned to this screen.
240  /// This can be overridden later, even by individual UI elements.
241  /// @param WindowViewport The Viewport to which this screen belongs.
242  /// @param Manager A pointer to the UI manager creating this screen.
243  Screen(const String& RendName, const String& Atlas, Graphics::Viewport* WindowViewport, UIManager* Manager);
244  /// @brief XML constructor.
245  /// @param XMLNode The node of the xml document to construct from.
246  /// @param Manager A pointer to the UI manager creating this screen.
247  Screen(const XML::Node& XMLNode, UIManager* Manager);
248  /// @brief Class destructor.
249  virtual ~Screen();
250  public:
251  ///////////////////////////////////////////////////////////////////////////////
252  // Utility and Visibility Methods
253 
254  /// @copydoc Renderable::SetVisible(Bool)
255  virtual void SetVisible(Boolean CanSee);
256  /// @copydoc Renderable::GetVisible() const
257  virtual Boolean GetVisible() const;
258  /// @copydoc Renderable::IsVisible() const
259  virtual Boolean IsVisible() const;
260  /// @copydoc Renderable::Show()
261  virtual void Show();
262  /// @copydoc Renderable::Hide()
263  virtual void Hide();
264 
265  /// @copydoc Renderable::GetRenderableType() const
266  virtual RenderableType GetRenderableType() const;
267 
268  /// @brief Gets the current viewport dimensions.
269  /// @return Returns a Vector2 representing the current viewport dimensions.
270  virtual const Vector2& GetViewportDimensions() const;
271  /// @brief Checks to see if the viewport has changed in size. If so it updates all the UI elements on the screen.
272  virtual void CheckViewportSize();
273  /// @brief Gets the Viewport this screen is currently rendering to.
274  /// @return Returns a pointer to the Viewport this screen is applied to.
275  virtual Graphics::Viewport* GetViewport() const;
276  /// @brief Gets the UIManager this screen belongs to.
277  /// @return Returns a pointer to the UI manager that owns this screen.
278  virtual UIManager* GetManager() const;
279 
280  ///////////////////////////////////////////////////////////////////////////////
281  // Mouse Hover Methods
282 
283  /// @brief Sets the strategy to use when detect which object the mouse is hovered over.
284  /// @note This method will replace whatever method is currently set if one is set.
285  /// @param Strategy A pointer to the strategy to use.
286  virtual void SetMouseHoverStrategy(MouseHoverStrategy* Strategy);
287  /// @brief Gets the MouseHoverStrategy currently being used by this screen.
288  /// @return Returns a pointer to the currently set MouseHoverStrategy.
289  virtual MouseHoverStrategy* GetMouseHoverStrategy() const;
290  /// @brief Gets the quad the mouse is over if any.
291  /// @param MousePos The current mouse position.
292  /// @return Returns the Widget the mouse is over, or NULL if there are none.
293  virtual Widget* FindHoveredWidget(const Vector2& MousePos);
294  /// @brief Gets the mouse position from the last call to "FindHoveredQuad(const Vector2&).
295  /// @note Screens have a 1:1 ratio to viewports, not windows. The returned coordinates is in viewport space.
296  /// @warning This will not perform any additional checks. Only returns the result of the last check.
297  /// 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.
298  /// @return Returns a valid point on this screen if the last check was valid, or (-1,-1) if the check failed.
299  virtual const Vector2& GetMouseHitPosition() const;
300 
301  ///////////////////////////////////////////////////////////////////////////////
302  // WidgetFactory Management
303 
304  /// @brief Adds/registers a widget factory with this Screen, allowing it to be constructed through this API.
305  /// @param ToBeAdded The widget factory to be added.
306  void AddWidgetFactory(WidgetFactory* ToBeAdded);
307  /// @brief Removes a widget factory from this Screen.
308  /// @param ToBeRemoved A pointer to the widget factory that is to be removed.
309  void RemoveWidgetFactory(WidgetFactory* ToBeRemoved);
310  /// @brief Removes a widget factory from this Screen.
311  /// @param ImplName The name of the widget implementation created by the factory to be removed.
312  void RemoveWidgetFactory(const String& ImplName);
313  /// @brief Removes and destroys a widget factory in this Screen.
314  /// @param ToBeDestroyed A pointer to the widget factory that is to be removed and destroyed.
315  void DestroyWidgetFactory(WidgetFactory* ToBeDestroyed);
316  /// @brief Removes and destroys a widget factory in this Screen.
317  /// @param ImplName The name of the widget implementation created by the factory to be removed and destroyed.
318  void DestroyWidgetFactory(const String& ImplName);
319  /// @brief Destroys all widget factories in this Screen.
320  /// @warning The destruction of widget factories should only be done after the corresponding managers have been destroyed, otherwise this will cause an exception.
321  void DestroyAllWidgetFactories();
322  /// @brief Adds all the default widget factories provided by the engine to the Screen.
323  void AddAllDefaultWidgetFactories();
324 
325  ///////////////////////////////////////////////////////////////////////////////
326  // Widget Management
327 
328  /// @brief Creates a widget from an XML::Node.
329  /// @exception This method will throw an exception if the WidgetNode is not named after a known widget.
330  /// @param WidgetNode The XML node populated with data needed to construct a widget.
331  /// @return Returns a pointer to the created widget.
332  virtual Widget* CreateWidget(const XML::Node& WidgetNode);
333 
334  /// @brief Gets a widget in this screen by name.
335  /// @param Name The name of the widget to get.
336  /// @return Returns a pointer to the widget of the specified name.
337  virtual Widget* GetWidget(const String& Name);
338  /// @brief Gets the number of widgets being used in this screen.
339  /// @return Returns the number of widgets this screen is storing.
340  virtual Whole GetNumWidgets();
341 
342  /// @brief Destroys a widget.
343  /// @param ToBeDestroyed Pointer to the widget you want destroyed.
344  virtual void DestroyWidget(Widget* ToBeDestroyed);
345  /// @brief Destroys all widgets being stored by this screen.
346  virtual void DestroyAllWidgets();
347 
348  ///////////////////////////////////////////////////////////////////////////////
349  // Convenience Widget Creation Methods
350 
351  /// @brief Creates a generic widget.
352  /// @note This is not a polymorphic create method. It will case an instance of the widget base class.
353  /// @param Name The name to be given to this Widget.
354  /// @return Returns a pointer to the created Widget.
355  virtual Widget* CreateWidget(const String& Name);
356  /// @brief Creates a generic widget.
357  /// @note This is not a polymorphic create method. It will case an instance of the widget base class.
358  /// @param Name The name to be given to this Widget.
359  /// @param RendRect The rect describing this Widget's transform relative to it's parent.
360  /// @return Returns a pointer to the created Widget.
361  virtual Widget* CreateWidget(const String& Name, const UnifiedRect& RendRect);
362  /// @brief Creates a Button.
363  /// @param Name The name to be given to this Button.
364  /// @return Returns a pointer to the created Button.
365  virtual Button* CreateButton(const String& Name);
366  /// @brief Creates a Button.
367  /// @param Name The name to be given to this Button.
368  /// @param RendRect The rect describing this Button's transform relative to it's parent.
369  /// @return Returns a pointer to the created Button.
370  virtual Button* CreateButton(const String& Name, const UnifiedRect& RendRect);
371  /// @brief Creates a MenuButton.
372  /// @param Name The name to be given to this MenuButton.
373  /// @return Returns a pointer to the created MenuButton.
374  virtual MenuButton* CreateMenuButton(const String& Name);
375  /// @brief Creates a MenuButton.
376  /// @param Name The name to be given to this MenuButton.
377  /// @param RendRect The rect describing this MenuButton's transform relative to it's parent.
378  /// @return Returns a pointer to the created MenuButton.
379  virtual MenuButton* CreateMenuButton(const String& Name, const UnifiedRect& RendRect);
380  /// @brief Creates a RadioButton.
381  /// @param Name The name to be given to this RadioButton.
382  /// @return Returns a pointer to the created RadioButton.
383  virtual RadioButton* CreateRadioButton(const String& Name);
384  /// @brief Creates a RadioButton.
385  /// @param Name The name to be given to this RadioButton.
386  /// @param RendRect The rect describing this RadioButton's transform relative to it's parent.
387  /// @return Returns a pointer to the created RadioButton.
388  virtual RadioButton* CreateRadioButton(const String& Name, const UnifiedRect& RendRect);
389  /// @brief Creates a CheckBox.
390  /// @param Name The name of the CheckBox.
391  /// @return Returns a pointer to the created CheckBox.
392  virtual CheckBox* CreateCheckBox(const String& Name);
393  /// @brief Creates a CheckBox.
394  /// @param Name The name of the CheckBox.
395  /// @param RendRect The Rect representing the position and size of the CheckBox.
396  /// @return Returns a pointer to the created CheckBox.
397  virtual CheckBox* CreateCheckBox(const String& Name, const UnifiedRect& RendRect);
398  /// @brief Creates a Scrollbar aligned on the X axis.
399  /// @param Name The name of the HorizontalScrollbar.
400  /// @param Style The style of scrollbar you want to create, see Scrollbar documentation for more details.
401  /// @return Returns a pointer to the created HorizontalScrollbar.
402  virtual HorizontalScrollbar* CreateHorizontalScrollbar(const String& Name, const UI::ScrollbarStyle Style);
403  /// @brief Creates a Scrollbar aligned on the X axis.
404  /// @param Name The name of the HorizontalScrollbar.
405  /// @param RendRect The Rect representing the position and size of the HorizontalScrollbar.
406  /// @param Style The style of scrollbar you want to create, see Scrollbar documentation for more details.
407  /// @return Returns a pointer to the created HorizontalScrollbar.
408  virtual HorizontalScrollbar* CreateHorizontalScrollbar(const String& Name, const UnifiedRect& RendRect, const UI::ScrollbarStyle Style);
409  /// @brief Creates a Scrollbar aligned on the Y axis.
410  /// @param Name The name of the VerticalScrollbar.
411  /// @param Style The style of scrollbar you want to create, see Scrollbar documentation for more details.
412  /// @return Returns a pointer to the created VerticalScrollbar.
413  virtual VerticalScrollbar* CreateVerticalScrollbar(const String& Name, const UI::ScrollbarStyle Style);
414  /// @brief Creates a Scrollbar aligned on the Y axis.
415  /// @param Name The name of the VerticalScrollbar.
416  /// @param RendRect The Rect representing the position and size of the VerticalScrollbar.
417  /// @param Style The style of scrollbar you want to create, see Scrollbar documentation for more details.
418  /// @return Returns a pointer to the created VerticalScrollbar.
419  virtual VerticalScrollbar* CreateVerticalScrollbar(const String& Name, const UnifiedRect& RendRect, const UI::ScrollbarStyle Style);
420 
421  /// @brief Creates a MenuEntry.
422  /// @param Name The name to be given to this MenuEntry.
423  /// @return Returns a pointer to the created MenuEntry.
424  virtual MenuEntry* CreateMenuEntry(const String& Name);
425  /// @brief Creates a MenuEntry.
426  /// @param Name The name to be given to this MenuEntry.
427  /// @param RendRect The rect describing this MenuEntry's transform relative to it's parent.
428  /// @return Returns a pointer to the created MenuEntry.
429  virtual MenuEntry* CreateMenuEntry(const String& Name, const UnifiedRect& RendRect);
430 
431  /// @brief Creates a widget container aligned on the X axis.
432  /// @param RendName The name to be given to this renderable.
433  /// @return Returns a pointer to the created HorizontalContainer.
434  virtual HorizontalContainer* CreateHorizontalContainer(const String& RendName);
435  /// @brief Creates a widget container aligned on the X axis.
436  /// @param RendName The name to be given to this renderable.
437  /// @param RendRect The rect describing this widget's transform relative to it's parent.
438  /// @return Returns a pointer to the created HorizontalContainer.
439  virtual HorizontalContainer* CreateHorizontalContainer(const String& RendName, const UnifiedRect& RendRect);
440  /// @brief Creates a widget container aligned on the Y axis.
441  /// @param RendName The name to be given to this renderable.
442  /// @return Returns a pointer to the created VerticalContainer.
443  virtual VerticalContainer* CreateVerticalContainer(const String& RendName);
444  /// @brief Creates a widget container aligned on the Y axis.
445  /// @param RendName The name to be given to this renderable.
446  /// @param RendRect The rect describing this widget's transform relative to it's parent.
447  /// @return Returns a pointer to the created VerticalContainer.
448  virtual VerticalContainer* CreateVerticalContainer(const String& RendName, const UnifiedRect& RendRect);
449 
450  /*/// @brief Creates a List Box.
451  /// @return Returns a pointer to the created List Box.
452  /// @param Name The name of the List Box.
453  /// @param RendRect The Rect representing the position and size of the List Box.
454  /// @param ScrollStyle The style of scrollbar you want to create, see Scrollbar documentation for more details.
455  virtual ListBox* CreateListBox(ConstString& Name, const Rect& RendRect, const UI::ScrollbarStyle& ScrollStyle);
456  /// @brief Creates a Spinner.
457  /// @return Returns a pointer to the created Spinner.
458  /// @param Name The Name for the Widget.
459  /// @param RendRect The Rect representing the position and size of the Spinner.
460  /// @param SStyle The layout of buttons this widget will have. See SpinnerStyle enum or class description for more details.
461  /// @param GlyphHeight The desired relative height of the text you want.
462  virtual Spinner* CreateSpinner(ConstString& Name, const Rect& RendRect, const UI::SpinnerStyle& SStyle, const Real& GlyphHeight);
463  /// @brief Creates a scrolled cell grid.
464  /// @return Returns a pointer to the created ScrolledCellGrid.
465  /// @param Name The name of the widget.
466  /// @param RendRect The Rect representing the position and size of the ScrolledCellGrid.
467  /// @param Thickness The width of the vertical scrollbar in relative units. The same amount of actual pixels is used
468  /// to determine the height of the horizontal scrollbar.
469  /// @param Style An enum value representing how you want your scrollbar constructed. See class details for more info.
470  virtual ScrolledCellGrid* CreateScrolledCellGrid(ConstString& Name, const Rect& RendRect, const Real& Thickness, const UI::ScrollbarStyle& Style);
471  /// @brief Creates a paged cell grid.
472  /// @return Returns a pointer to the created PagedCellGrid.
473  /// @param Name The name of the widget.
474  /// @param RendRect The Rect representing the position and size of the PagedCellGrid.
475  /// @param SpnRect The Rect representing the position and size of the Spinner.
476  /// @param SStyle The style of spinner to create.
477  /// @param GlyphHeight The desired lineheight of the glyphs to be used with the spinner.
478  virtual PagedCellGrid* CreatePagedCellGrid(ConstString& Name, const Rect& RendRect, const Rect& SpnRect, const UI::SpinnerStyle& SStyle, const Real& GlyphHeight);
479  /// @brief Creates a drop down list.
480  /// @return Returns a pointer to the created DropDownList.
481  /// @param Name The Name for the Widget.
482  /// @param RendRect The renderable rect representing the position and size of this widget.
483  /// @param LineHeight The lineheight you want the text to have. If the Rect passed in is relative, this will expect LineHeight to be relative as well.
484  /// @param ScrollStyle The style of the scrollbar you want for this List Box. See Scrollbar class for more information.
485  virtual DropDownList* CreateDropDownList(ConstString& Name, const Rect& RendRect, const Real& LineHeight, const UI::ScrollbarStyle& ScrollStyle);
486  /// @brief Creates a tabset.
487  /// @return Returns a pointer to the created tabset.
488  /// @param Name The Name for the Widget.
489  /// @param SetRect The Rect representing the position and size of all the Renderable Sets generated by the tabset.
490  virtual TabSet* CreateTabSet(ConstString& Name, const Rect& SetRect);
491 
492  /// @brief Creates a Window.
493  /// @return Returns a pointer to the created Window.
494  /// @param Name The name of the Window.
495  /// @param RendRect The Rect representing the position and size of the Window.
496  virtual Window* CreateWidgetWindow(ConstString& Name, const Rect& RendRect);//*/
497 
498  ///////////////////////////////////////////////////////////////////////////////
499  // Atlas Query
500 
501  /// @brief Sets the Atlas to be assumed when one isn't provided for atlas related tasks.
502  /// @param Atlas The name of the atlas to be used.
503  virtual void SetPrimaryAtlas(const String& Atlas);
504  /// @brief Gets the currently set primary atlas.
505  /// @return Returns a string containing the name of the primary atlas that is set.
506  virtual String GetPrimaryAtlas();
507  /// @brief Gets the position of the white pixel from an Atlas.
508  /// @param Atlas The name of the Atlas to get the white pixel from.
509  /// @return Returns a Vector2 with the location of white pixel on the Atlas.
510  Vector2 GetWhitePixel(const String& Atlas) const;
511  /// @brief Gets a sprite from an Atlas.
512  /// @param SpriteName The name of the sprite to retrieve.
513  /// @param Atlas The name of the Atlas to get the sprite from.
514  /// @return Returns a pointer to the requested Sprite.
515  Sprite* GetSprite(const String& SpriteName, const String& Atlas) const;
516  /// @brief Gets the specified FontData from an Atlas.
517  /// @param FontName The name of the Font to retrieve.
518  /// @param Atlas The name of the atlas to check the specified FontData for.
519  /// @return Returns a pointer to the requested FontData.
520  FontData* GetFont(const String& FontName, const String& Atlas) const;
521  /// @brief Gets the texture size of the specified Atlas.
522  /// @param Atlas The name of the atlas to get the texture size of.
523  /// @return Returns a Vector2 containing the size of the requested Atlas.
524  Vector2 GetTextureSize(const String& Atlas) const;
525  /// @brief Gets an atlas that has been loaded.
526  /// @param Atlas The name of the Atlas to retrieve, usually stored as a filename.
527  /// @return Returns a pointer to the requested Texture Atlas.
528  TextureAtlas* GetAtlas(const String& Atlas) const;
529  /// @brief Gets the X axis Texel Offset for the current rendersystem.
530  /// @return Retruns a real containing the texel offset to be applied to renderables on this screen.
531  Real GetTexelOffsetX() const;
532  /// @brief Gets the Y axis Texel Offset for the current rendersystem.
533  /// @return Retruns a real containing the texel offset to be applied to renderables on this screen.
534  Real GetTexelOffsetY() const;
535 
536  ///////////////////////////////////////////////////////////////////////////////
537  // Other Query
538 
539  /// @brief Checks to see if a MarkupParser has already been registsered under a specific name.
540  /// @param ParserName The name of the MarkupParser to check for.
541  /// @return Returns true if a MarkupParser is registered under the specified name.
542  bool IsMarkupParserRegistered(const String& ParserName) const;
543  /// @brief Gets a MarkupParser by it's registered name.
544  /// @param ParserName The name of the MarkupParser to retrieve.
545  /// @return Returns a pointer to the requested MarkupParser, or NULL if none are registered under the specified name.
546  UI::MarkupParser* GetMarkupParser(const String& ParserName) const;
547 
548  ///////////////////////////////////////////////////////////////////////////////
549  // Serialization
550 
551  /// @copydoc Renderable::ProtoSerializeProperties(XML::Node&) const
552  virtual void ProtoSerializeProperties(XML::Node& SelfRoot) const;
553  /// @copydoc Renderable::ProtoDeSerializeProperties(const XML::Node&)
554  virtual void ProtoDeSerializeProperties(const XML::Node& SelfRoot);
555 
556  /// @copydoc Renderable::GetDerivedSerializableName() const
557  virtual String GetDerivedSerializableName() const;
558  /// @copydoc Renderable::GetSerializableName()
559  static String GetSerializableName();
560 
561  ///////////////////////////////////////////////////////////////////////////////
562  // Internal Functions
563 
564  /// @copydoc Renderable::_MarkDirty()
565  void _MarkDirty();
566  /// @copydoc QuadRenderable::_MarkAllLayersDirty()
567  virtual void _MarkAllLayersDirty();
568  /// @internal
569  /// @brief Manually calls the UI system to render this screen.
570  void _RenderScreen();
571  /// @internal
572  /// @brief Forces an orientation mode change for this screen.
573  /// @param Mode The orientation mode to be applied to the UI on this screen.
574  void _SetOrientation(const Mezzanine::OrientationMode& Mode);
575  /// @internal
576  /// @brief Updates the vertex positions so they are in front of the camera in world space.
577  /// @param RenderData Vector of the vertices to be transformed.
578  /// @param Begin The first Vertex to transform in the range.
579  /// @param End The last Vertex to transform in the range.
580  void _Transform(ScreenRenderData& RenderData, const Whole& Begin, const Whole& End);
581  /// @internal
582  /// @brief Prepares all vertices for rendering to the screen.
583  /// @param Force Whether or not to force preparation regardless of if they need it.
584  void _RenderVertices(bool Force = false);
585 
586  /// @internal
587  /// @brief Processes all children of this screen by their zorder.
588  /// @param CB The callback implementing how the children are to be processed.
589  /// @return Returns the result of the callback, and exits early if true.
590  template<typename Callback>
591  Boolean _ProcessAllChildren(Callback* CB)
592  {
593  for( ChildIterator ChildIt = this->ChildrenBegin() ; ChildIt != this->ChildrenEnd() ; ++ChildIt )
594  {
595  if( Screen::_ProcessAllChildren((*ChildIt),CB) )
596  return true;
597  }
598  return false;
599  }
600  /// @internal
601  /// @brief Processes all children of this screen in reverse zorder.
602  /// @param CB The callback implementing how the children are to be processed.
603  /// @return Returns the result of the callback, and exits early if true.
604  template<typename Callback>
605  Boolean _ReverseProcessAllChildren(Callback* CB)
606  {
607  for( ReverseChildIterator RChildIt = this->RChildrenBegin() ; RChildIt != this->RChildrenEnd() ; ++RChildIt )
608  {
609  if( Screen::_ReverseProcessAllChildren((*RChildIt),CB) )
610  return true;
611  }
612  return false;
613  }
614  /// @internal
615  /// @brief Processes all children of this screen by their zorder.
616  /// @param Wid The Widget whose children need to be processed.
617  /// @param CB The callback implementing how the children are to be processed.
618  /// @return Returns the result of the callback, and exits early if true.
619  template<typename Callback>
620  static Boolean _ProcessAllChildren(Widget* Wid, Callback* CB)
621  {
622  if( (*CB)(Wid) )
623  return true;
624  for( ChildIterator ChildIt = Wid->ChildrenBegin() ; ChildIt != Wid->ChildrenEnd() ; ++ChildIt )
625  {
626  if( Screen::_ProcessAllChildren((*ChildIt),CB) )
627  return true;
628  }
629  return false;
630  }
631  /// @internal
632  /// @brief Processes all children of this screen in reverse zorder.
633  /// @param Wid The Widget whose children need to be processed.
634  /// @param CB The callback implementing how the children are to be processed.
635  /// @return Returns the result of the callback, and exits early if true.
636  template<typename Callback>
637  static Boolean _ReverseProcessAllChildren(Widget* Wid, Callback* CB)
638  {
639  for( ReverseChildIterator RChildIt = Wid->RChildrenBegin() ; RChildIt != Wid->RChildrenEnd() ; ++RChildIt )
640  {
641  if( Screen::_ReverseProcessAllChildren((*RChildIt),CB) )
642  return true;
643  }
644  if( (*CB)(Wid) )
645  return true;
646 
647  return false;
648  }
649  };//uiscreen
650  }//ui
651 }//Mezzanine
652 
653 #endif