Simple SFML GUI  0.2a
PanelModelGrid.hpp
1 /*
2  * PanelModelGrid.hpp
3  *
4  * Created on: 02.06.2017
5  * Author: jakub
6  */
7 
8 #ifndef SSG_PANELMODELGRID_HPP_
9 #define SSG_PANELMODELGRID_HPP_
10 
11 #include "MarginModelBase.hpp"
12 
14 public:
16  size_t cols=2,
17  size_t rows=1,
18  float margin=0.f,
19  MarginMode marginMode = MarginMode::Full,
20  MarginUnit marginUnit = MarginUnit::Absolute
21  );
22 
23  inline static auto create(
24  size_t cols=2,
25  size_t rows=1,
26  float margin=0.f,
27  MarginMode marginMode = MarginMode::Full,
28  MarginUnit marginUnit = MarginUnit::Absolute
29  ) {
30  return std::make_shared<PanelModelGrid>(cols, rows, margin, marginMode, marginUnit);
31  }
32 
33  virtual void init(const Panel& panel) override;
34  virtual void handleElement(const Panel& panel, Element& element, size_t order) override;
35 
36  void setCols(size_t cols);
37  void setRows(size_t rows);
38 
39 private:
40  size_t cols = 1;
41  size_t rows = 1;
42 
43  float sum = 0.f;
44  float lastSum = -1.f;
45 
46  sf::FloatRect computeArea(size_t x, size_t y, const sf::FloatRect& panelArea);
47 };
48 
49 typedef std::shared_ptr<PanelModelGrid> PanelModelGridPtr;
50 
51 #endif /* SSG_PANELMODELGRID_HPP_ */
Definition: Panel.hpp:29
Definition: PanelModelGrid.hpp:13
Definition: Element.hpp:22
Definition: MarginModelBase.hpp:7