DUDS
Distributed Update of Data from Something
Panel.hpp
Go to the documentation of this file.
1 /*
2  * This file is part of the DUDS project. It is subject to the BSD-style
3  * license terms in the LICENSE file found in the top-level directory of this
4  * distribution and at https://github.com/jjackowski/duds/blob/master/LICENSE.
5  * No part of DUDS, including this file, may be copied, modified, propagated,
6  * or distributed except according to the terms contained in the LICENSE file.
7  *
8  * Copyright (C) 2020 Jeff Jackowski
9  */
10 #ifndef PANEL_HPP
11 #define PANEL_HPP
12 
14 
15 namespace duds { namespace ui { namespace graphics {
16 
17 class PriorityGridLayout;
18 
23 struct PanelMargins {
27  std::uint16_t l;
31  std::uint16_t r;
35  std::uint16_t t;
39  std::uint16_t b;
40 };
41 
52 class Panel {
53 public:
64  virtual void added(PriorityGridLayout *pgl, unsigned int pri);
74  virtual void removing(PriorityGridLayout *pgl, unsigned int pri);
96  virtual const BppImage *render(
97  ImageLocation &offset,
98  ImageDimensions &dim,
99  PanelMargins &margin,
100  int sizeStep
101  ) = 0;
102 };
103 
107 typedef std::shared_ptr<Panel> PanelSptr;
108 
117 class EmptyPanel : public Panel {
118  struct Token { };
119 public:
127  static std::shared_ptr<EmptyPanel> make() {
128  return std::make_shared<EmptyPanel>(Token());
129  }
133  virtual const BppImage *render(
134  ImageLocation &,
135  ImageDimensions &,
136  PanelMargins &,
137  int
138  );
139 };
140 
141 
142 
143 /*
144  * A Panel that provides an image based on the size-step selected by the
145  * layout.
146  * @todo Implement.
147  * /
148 class SteppedImagePanel : public Panel {
149 protected:
150  std::vector<ConstBppImageSptr> images;
151 public:
152  virtual const BppImage *render(
153  ImageLocation &,
154  ImageDimensions &,
155  PanelMargins &,
156  int sizeStep
157  ) {
158  return images[sizeStep];
159  }
160 };
161 */
162 
163 } } }
164 
165 #endif // #ifndef PANEL_HPP
Stores a location within an image.
Definition: BppImage.hpp:33
std::uint16_t l
Left margin size.
Definition: Panel.hpp:27
std::uint16_t r
Right margin size.
Definition: Panel.hpp:31
Represents something being drawn in a rectangular region defined by a PriorityGridLayout object...
Definition: Panel.hpp:52
std::uint16_t b
Bottom margin size.
Definition: Panel.hpp:39
A way to place Panel objects dynamically with a priority mechanism to allow panels to be resized and ...
Stores the dimensions of an image.
Definition: BppImage.hpp:125
std::uint16_t t
Top margin size.
Definition: Panel.hpp:35
static std::shared_ptr< EmptyPanel > make()
Returns a shared pointer to a new empty panel.
Definition: Panel.hpp:127
General graphics related code.
Definition: HD44780.hpp:15
std::shared_ptr< Panel > PanelSptr
A shared pointer to a Panel.
Definition: Panel.hpp:107
An empty panel; useful for taking up space according to a layout configuration.
Definition: Panel.hpp:117
Defines the size of a margin bordering a panel; the size of the margin is included in computations fo...
Definition: Panel.hpp:23
An image that uses a single bit to represent the state of each pixel; a black or white picture...
Definition: BppImage.hpp:321