TouchCPLib  1.0.0
A touch-enabled GUI interface based on SDL and libTS. It provides a simple desktop-free UI for your embedded Raspberry projects.
GraphicsScene.h
Go to the documentation of this file.
1 #pragma once
2 
13 #include <vector>
14 #include <algorithm>
15 #include <random>
16 
17 #include "GraphicsObject.h"
18 
19 class SceneManager;
20 
28 {
29 public:
30  GraphicsScene();
31  GraphicsScene(const GraphicsScene &copy) = delete;
32  GraphicsScene(const GraphicsScene &&move) = delete;
33  GraphicsScene operator=(const GraphicsScene &copy) = delete;
34  virtual ~GraphicsScene();
35  const std::vector<GraphicsObject *> getObjects() const;
41  void addObject(GraphicsObject *object);
47  void addObjects(GraphicsObject **toadd, size_t number);
52  void addObjects(const std::vector<GraphicsObject *> &toadd);
58  void removeObject(GraphicsObject *toremove);
63  void removeObject(int index);
67  void clearObjects();
68  void draw(uint32_t time) override;
69  void show();
70 
71 private:
72  static std::string unsafeRandomHash(size_t length);
73  const std::string classHash = GraphicsScene::unsafeRandomHash(32);
74  std::vector<GraphicsObject *> objects;
75 };
void addObject(GraphicsObject *object)
Add an object to the scene. *** Once added, the object is bound to the scene and it will take care of...
Definition: GraphicsScene.cpp:23
void show()
Definition: GraphicsScene.cpp:62
A simple interface for all the graphic objects that are supposed to be drawn.
Definition: GraphicsObject.h:17
The GraphicsObject base class.
virtual ~GraphicsScene()
Definition: GraphicsScene.cpp:9
const std::vector< GraphicsObject * > getObjects() const
Definition: GraphicsScene.cpp:18
void removeObject(GraphicsObject *toremove)
Removes an object from the scene. *** You take ownership of the object back, so the scene won&#39;t delet...
Definition: GraphicsScene.cpp:38
void clearObjects()
Removes all the objects from the scene, taking ownership back on them.
Definition: GraphicsScene.cpp:48
The scene manager controls which scene is currently displayed, in addition to enumerating the scenes ...
Definition: SceneManager.h:22
GraphicsScene operator=(const GraphicsScene &copy)=delete
void addObjects(GraphicsObject **toadd, size_t number)
Add an array of objects to the scene.
Definition: GraphicsScene.cpp:28
void draw(uint32_t time) override
The draw method. It will be called once per frame for each object in a scene.
Definition: GraphicsScene.cpp:53
The Scene object is a base class to construct a Scene upon. The scene is basically a view that can be...
Definition: GraphicsScene.h:27
GraphicsScene()
Definition: GraphicsScene.cpp:4