display

Layout and Rendering TUI library
git clone git://git.dimitrijedobrota.com/display.git
Log | Files | Refs | README | LICENSE | HACKING | CONTRIBUTING | CODE_OF_CONDUCT | BUILDING

element.hpp (1104B)


0 #pragma once
2 #include "display/types.hpp"
4 namespace display
5 {
6 class Element
7 {
8 public:
9 explicit Element(plc_t aplc)
10 : m_aplc(aplc)
11 {
12 }
14 Element(const Element&) = delete;
15 Element& operator=(const Element&) = delete;
17 Element(Element&&) = default;
18 Element& operator=(Element&&) = default;
20 virtual ~Element() = default;
22 virtual void resize(plc_t aplc) { m_aplc = aplc; }
23 virtual void render() const = 0;
24 virtual void clear() const = 0;
25 virtual void input(event& evnt) = 0;
27 static std::ostream& set_cursor(xpos_t xpos, ypos_t ypos);
28 static std::ostream& set_cursor(pos_t pos);
30 void render_border() const;
32 [[nodiscard]] plc_t aplc() const { return m_aplc; }
33 [[nodiscard]] pos_t apos() const { return aplc().pos; }
34 [[nodiscard]] dim_t adim() const { return aplc().dim; }
35 [[nodiscard]] xpos_t axpos() const { return apos().x; }
36 [[nodiscard]] ypos_t aypos() const { return apos().y; }
37 [[nodiscard]] wth_t awth() const { return adim().width; }
38 [[nodiscard]] hgt_t ahgt() const { return adim().height; }
40 private:
41 plc_t m_aplc;
42 };
44 } // namespace display