TurtleBrains  0.3.5
High quality, portable, C++ framework for rapid 2D game development.
tb_graphic_list.hpp
1 
9 #ifndef TurtleBrains_GraphicList_hpp
10 #define TurtleBrains_GraphicList_hpp
11 
12 #include <turtle_brains/graphics/tb_graphic.hpp>
13 
14 #include <list>
15 
16 namespace TurtleBrains
17 {
18  namespace Graphics
19  {
20 
27  class GraphicList : public Graphic
28  {
29  public:
34  GraphicList(void);
35 
40  virtual ~GraphicList(void);
41 
46  void ClearGraphics(void);
47 
53  void AddGraphic(Graphic* graphic);
54 
60  void AddGraphic(Graphic& graphic);
61 
67  void RemoveGraphic(Graphic* graphic);
68 
72  virtual void SetColor(const tbGraphics::Color& newColor) override;
73 
74  virtual PixelSpace GetPixelWidth(void) const { return mPixelWidth; }
75  virtual PixelSpace GetPixelHeight(void) const { return mPixelHeight; }
76 
77  void RecalculateWidthAndHeight(void);
78 
79  protected:
84  virtual void OnUpdate(const float deltaTime) override;
85 
94  virtual void OnRender(void) const override;
95 
96  private:
97  void ReallyAddGraphic(Graphic* graphic, const bool managed);
98 
99  //These are all disabled from GraphicList, maybe they shouldn't be in the base Graphic
100  //TODO: TIM: Refactor: Remove this from base Graphic and create a Transform or some other class.
101  void SetOrigin(const AnchorLocation& anchor) { Graphic::SetOrigin(anchor); }
102  void SetOrigin(const float originX, const float originY) { Graphic::SetOrigin(originX, originY); }
103 
104  void SetScroll(const float scroll) { SetScroll(scroll, scroll); }
105  void SetScroll(const float scrollX, const float scrollY)
106  {
107  for (Graphic* graphic : mGraphics)
108  {
109  graphic->SetScroll(scrollX, scrollY);
110  }
111  Graphic::SetScroll(0.0f, 0.0f);
112  }
113 
114  typedef std::list<Graphic*> GraphicContainer;
115  GraphicContainer mGraphics;
116  GraphicContainer mManagedGraphics;
117  PixelSpace mPixelWidth;
118  PixelSpace mPixelHeight;
119  };
120 
121  }; /* namespace Graphics */
122 }; /* namespace TurtleBrains */
123 
125 
126 #endif /* TurtleBrains_Graphic_hpp */
Definition: tb_graphic.hpp:61
Definition: tb_graphic_list.hpp:27
AnchorLocation
Definition: tb_graphic.hpp:44
virtual PixelSpace GetPixelWidth(void) const
Definition: tb_graphic_list.hpp:74
Give the GameScene and Entities something to display, Text, Sprites and AnimatedSprites help bring th...
void RemoveGraphic(Graphic *graphic)
virtual void OnUpdate(const float deltaTime) override
void AddGraphic(Graphic *graphic)
virtual void SetColor(const tbGraphics::Color &newColor) override
Here is some information about the primary namespace.
Definition: tb_application_dialog.hpp:21
Definition: tb_color.hpp:24
void SetScroll(const float scroll)
Definition: tb_graphic.hpp:245
virtual PixelSpace GetPixelHeight(void) const
Definition: tb_graphic_list.hpp:75
tbCore::uint16 PixelSpace
Definition: tb_texture_manager.hpp:36
void SetOrigin(const AnchorLocation &anchor, const tbMath::Vector2 &offset=tbMath::Vector2::Zero())
virtual void OnRender(void) const override