TurtleBrains  0.3.5
High quality, portable, C++ framework for rapid 2D game development.
tbx_interface_screen.hpp
1 
9 #ifndef TurtleBrainsExpress_InterfaceScreen_hpp
10 #define TurtleBrainsExpress_InterfaceScreen_hpp
11 
12 #include <turtle_brains/express/interface/tbx_interface_element.hpp>
13 #include <turtle_brains/express/interface/tbx_interface_controller.hpp>
14 
15 #include <memory>
16 
17 namespace TurtleBrainsExpress
18 {
19  namespace Interface
20  {
21  namespace Unstable
22  {
23  typedef std::unique_ptr<Element> ElementPtr;
24 
25  class Screen : public Element
26  {
27  public:
28  Screen(void);
29  virtual ~Screen(void);
30 
34  void AddElement(Element& element, const Point& position);
35  void AddElement(ElementPtr& element, const Point& position);
36  void RemoveElement(Element* element);
37 
38  void Update(Controller& controller);
39 
40  protected:
41  virtual void OnRender(void) const override;
42 
43  virtual bool ContainsPointer(const Point& pointerPosition) const override;
44  virtual bool CanLinkWithNeighbor(const NavigationDirection& direction) const override;
45 
46  virtual void OnHandleUserEvent(const UserEvent& userEvent) override;
47 
48  private:
49  typedef std::pair<Element*, ElementPtr> ElementPtrPair;
50  typedef std::list<ElementPtrPair> ElementContainer;
51  ElementContainer mElements;
52  };
53 
54  class SingleColumnScreen : public Screen
55  {
56  public:
57  SingleColumnScreen(tbGraphics::PixelSpace padding = 20, Point offset = Point(0, 0));
58  virtual ~SingleColumnScreen(void);
59 
63  void AddElement(Element& element);
64  void AddElement(ElementPtr& element);
65 
66  protected:
67  virtual void OnStateChange(const State& newState) override;
68 
69  private:
70  void AddElement(Element& element, const Point& position);
71  void AddElement(ElementPtr& element, const Point& position);
72  void CreateLinks(Element& element);
73 
74  Point mPlacement;
75  tbGraphics::PixelSpace mPadding;
76  Element* mFirstElement;
77  Element* mLastElement;
78  };
79 
85  class DoubleColumnScreen : public Screen
86  {
87  public:
88  DoubleColumnScreen(tbGraphics::PixelSpace padding = 20, Point offset = Point(0, 0));
89  virtual ~DoubleColumnScreen(void);
90 
94  void AddElement(Element& left, Element& right);
95  void AddElement(ElementPtr& leftElement, ElementPtr& rightElement);
96  void AddElement(Element& leftElement, ElementPtr& rightElement);
97  void AddElement(ElementPtr& leftElement, Element& rightElement);
98 
99  protected:
100  virtual void OnStateChange(const State& newState) override;
101 
102  private:
103  void AddElement(Element& element, const Point& position);
104  void AddElement(ElementPtr& element, const Point& position);
105  void CreateLinks(Element& element);
106 
107  Point mPlacement;
108  Point mPadding;
109  Element* mFirstElement;
110  Element* mLastElement;
111  };
112 
113 
114  }; /* namespace Interface */
115  };
116 }; /* namespace TurtleBrainsExpress */
117 
119 
120 #endif /* TurtleBrainsExpress_InterfaceScreen_hpp */
A collection of objects and functions to express games quickly.
Definition: tbx_interface.hpp:18
Definition: tbx_interface.hpp:58
Definition: tbx_interface_controller.hpp:34
tbCore::uint16 PixelSpace
Definition: tb_texture_manager.hpp:36
Definition: tbx_interface_element.hpp:28
Definition: tbx_interface_screen.hpp:25
void AddElement(Element &element, const Point &position)