Simple SFML GUI  0.2a
Panel.hpp
1 /*
2  * Panel.hpp
3  *
4  * Created on: 25.05.2017
5  * Author: jakub
6  */
7 
8 #ifndef SSG_PANEL_HPP_
9 #define SSG_PANEL_HPP_
10 
11 #include <SFML/Graphics.hpp>
12 #include <functional>
13 #include <memory>
14 #include <map>
15 #include <vector>
16 #include "Element.hpp"
17 #include "HaveBackground.hpp"
18 #include "HaveContextMenu.hpp"
19 #include "HaveEnabled.hpp"
20 #include "PanelModel.hpp"
21 #include "ColorAccess.hpp"
22 
23 namespace ActionType {
24  namespace Update {
25  const char* const Area = "areaupdate";
26  }
27 }
28 
29 class Panel :
30  public HaveContextMenu,
31  public HaveEnabled,
32  public HaveBackground,
33  public SetColorAccess,
34  public GetColorAccess {
35 public:
36  Panel(const Element* parent = nullptr);
37  virtual ~Panel() = default;
38  virtual void draw(sf::RenderTarget& target, sf::RenderStates states) override;
39  virtual bool update(sf::Vector2f mp, bool pressLeft, bool pressRight, bool aboveHover) override;
40  virtual void updateArea() override;
41 
42  const std::shared_ptr<PanelModel>& getModel() const;
43  void setModel(const std::shared_ptr<PanelModel>& model);
44  void add(const ElementPtr& element, const Element* stop);
45  void add(const ElementPtr& element);
46  void add(const std::vector<ElementPtr>& elements);
47  void add(const std::vector<ElementPtr>&& elements);
48  const ElementPtr get(const sf::String& name);
49  const ElementPtr getFront();
50  const std::vector<ElementPtr>& getElements();
51  const std::vector<ElementPtr>& getElements() const;
52 
53  bool remove(const Element* ptr);
54  bool remove(int index);
55  bool removeFirst(const sf::String& name);
56  bool removeAll();
57  virtual void refreshModel(bool* wasTwice = nullptr);
58 
59 protected:
60  std::vector<std::shared_ptr<Element>> elements;
61  std::vector<std::pair<bool,std::shared_ptr<Element>>> elementsQueue;
62  std::shared_ptr<PanelModel> model;
63  bool updateRenderTexture;
64 
65  void refreshModelLoop();
66  void updateElements();
67 };
68 
69 typedef std::shared_ptr<Panel> PanelPtr;
70 
71 #endif /* SSG_PANEL_HPP_ */
Definition: Panel.hpp:29
Definition: HaveBackground.hpp:28
Definition: Checkbox.hpp:13
Definition: ColorAccess.hpp:17
Definition: HaveEnabled.hpp:15
Definition: HaveContextMenu.hpp:13
Definition: ColorAccess.hpp:26
Definition: Element.hpp:22