Rose
Manager.h
Go to the documentation of this file.
1 
8 #pragma once
9 
10 #include "Visual.h"
11 #include "Layout.h"
12 
13 namespace rose {
14 
15  class LinearLayout : public LayoutManager {
16  protected:
17  Orientation mOrientation{Orientation::Horizontal};
18  int mInternalSpacing{0};
19 
20  public:
21  LinearLayout() = default;
22 
23  ~LinearLayout() override = default;
24 
25  explicit LinearLayout(Orientation orientation, int internalSpace = 0) : LinearLayout() {
26  mOrientation = orientation;
27  mInternalSpacing = internalSpace;
28  }
29 
31  Rectangle layoutContent(gm::Context &context, const Rectangle &screenRect, LayoutManager::Itr first,
32  LayoutManager::Itr last) override;
33  };
34 
35  class GridLayout : public LayoutManager {
36  protected:
37  Orientation mOrientation{Orientation::Horizontal};
38  Size mInternalSpacing{0};
39  int mStride{0};
40 
41  public:
42  GridLayout() = default;
43 
44  ~GridLayout() override = default;
45 
46  explicit GridLayout(Orientation orientation, int horizontalSpace = 0, int verticalSpace = 0, int stride = 0)
47  : GridLayout() {
48  mOrientation = orientation;
49  mInternalSpacing.w = horizontalSpace;
50  mInternalSpacing.h = verticalSpace;
51  mStride = stride;
52  }
53 
55  Rectangle layoutContent(gm::Context &context, const Rectangle &screenRect, LayoutManager::Itr first,
56  LayoutManager::Itr last) override;
57  };
58 
59  class Row : public Manager {
60  protected:
61 
62  public:
63  Row() : Manager() {
64  setLayoutManager(std::make_unique<LinearLayout>(Orientation::Horizontal));
65  }
66 
67  static constexpr std::string_view id = "Row";
68  std::string_view nodeId() const noexcept override {
69  return id;
70  }
71  };
72 
73  class Column : public Manager {
74  protected:
75 
76  public:
77  Column() : Manager() {
78  setLayoutManager(std::make_unique<LinearLayout>(Orientation::Vertical));
79  }
80 
81  static constexpr std::string_view id = "Column";
82 
83  std::string_view nodeId() const noexcept override {
84  return id;
85  }
86  };
87 
88  class Grid : public Manager {
89  protected:
90 
91  public:
92  Grid() : Manager() {
93  setLayoutManager(std::make_unique<GridLayout>(Orientation::Horizontal, 2, 2, 0));
94  }
95 
96  ~Grid() override = default;
97 
98  explicit Grid(int stride) : Manager() {
99  setLayoutManager(std::make_unique<GridLayout>(Orientation::Horizontal, 2, 2, stride));
100  }
101 
102  static constexpr std::string_view id = "Grid";
103 
104  std::string_view nodeId() const noexcept override {
105  return id;
106  }
107 
108  void draw(gm::Context &context, const Position<int> &containerPosition) override {
109  Manager::draw(context, containerPosition);
110  }
111  };
112 
118  class Overlay : public LayoutManager {
119  public:
120  Overlay() = default;
121 
122  ~Overlay() override = default;
123 
125  Rectangle layoutContent(gm::Context &context, const Rectangle &screenRect, LayoutManager::Itr first,
126  LayoutManager::Itr last) override;
127  };
128 }
Definition: Manager.h:15
A pure virtual base class for layout managers.
Definition: Visual.h:392
Definition: Manager.h:88
A Widget which manages contained Widgets.
Definition: Visual.h:697
void draw(gm::Context &context, const Position< int > &containerPosition) override
Draw the manager and contents.
Definition: Visual.cpp:217
void draw(gm::Context &context, const Position< int > &containerPosition) override
Draw the visual.
Definition: Manager.h:108
Definition: Manager.h:73
Context
Definition: GraphicsModel.h:76
A layout manager for to create overlays on the Container.
Definition: Manager.h:118
Orientation
Possible values for Widget orientation.
Definition: Types.h:41
A composite of a Position and a Size.
Definition: Types.h:307
A size in integer dimensions.
Definition: Types.h:230
ToDo: There is an issue that the initial scroll interaction is lost if the click/press lands on a Wid...
Definition: CelestialOverlay.cpp:13
Definition: Manager.h:35
Definition: Manager.h:59
Rectangle layoutContent(gm::Context &context, const Rectangle &screenRect, LayoutManager::Itr first, LayoutManager::Itr last) override
Layout the contents of the associated manager.
Definition: Manager.cpp:13
User Interface Visual types.