display

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

element.hpp (1006B)


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