That Terminal
A terminal emulator designed for video making purposes.
ui.hh
Go to the documentation of this file.
1 #ifndef bqtTermUI_HH
2 #define bqtTermUI_HH
7 #include <string_view>
8 #include <cstdint>
9 #include <utility>
10 #include <variant>
11 
12 #include "keysym.hh"
13 
15 class UI
16 {
17  // Font geometry in pixels
18  unsigned VidCellWidth = 8;
19  unsigned VidCellHeight = 16;
20  // Window geometry in cells
21  unsigned WindowWidth = 80;
22  unsigned WindowHeight = 25;
24  bool Headless = false;
25 
28  bool Allow_Windows_Bigger_Than_Desktop = false;
29 public:
31  UI();
33  ~UI();
34 
36  std::pair<unsigned,unsigned> GetCellSize() const
37  {
38  return {VidCellWidth,VidCellHeight};
39  }
41  std::pair<unsigned,unsigned> GetWindowSize() const
42  {
43  return {WindowWidth,WindowHeight};
44  }
46  bool IsHeadless() const
47  {
48  return Headless;
49  }
50 
57  void ResizeTo(unsigned cellx,unsigned celly, unsigned width,unsigned height);
58 
60  void SetWindowTitle(std::string_view str);
62  void SetIconName(std::string_view str);
64  void BeepOn();
65 
69  void PresentGraphics(const std::uint32_t* pixels);
70 
72  enum resizetype { cellx,celly,winx,winy };
73 
81  using EventType = std::pair<
82  std::string,
83  std::variant<
84  std::pair<int,int>,
85  std::pair<int, resizetype>,
86  bool
87  >>;
88 
92  EventType HandleEvents(bool permit_text_input);
93 
95  void SetHeadless(bool state) { Headless = state; }
96 
97 private:
98  // Delete copies
99  UI(const UI&) = delete;
100  UI(UI&&) = delete;
101  UI& operator=(const UI&) = delete;
102  UI& operator=(UI&&) = delete;
103 };
104 
106 extern UI ui;
107 
108 #endif
Definition: ui.hh:16
void PresentGraphics(const std::uint32_t *pixels)
Definition: ui.cc:163
~UI()
Definition: ui.cc:305
void SetHeadless(bool state)
Definition: ui.hh:95
void ResizeTo(unsigned cellx, unsigned celly, unsigned width, unsigned height)
Definition: ui.cc:154
UI()
Definition: ui.cc:301
std::pair< std::string, std::variant< std::pair< int, int >, std::pair< int, resizetype >, bool > > EventType
Definition: ui.hh:87
void BeepOn()
Definition: ui.cc:107
EventType HandleEvents(bool permit_text_input)
Definition: ui.cc:211
std::pair< unsigned, unsigned > GetWindowSize() const
Definition: ui.hh:41
resizetype
Definition: ui.hh:72
bool IsHeadless() const
Definition: ui.hh:46
void SetIconName(std::string_view str)
Definition: ui.cc:149
std::pair< unsigned, unsigned > GetCellSize() const
Definition: ui.hh:36
void SetWindowTitle(std::string_view str)
Definition: ui.cc:143
Defines InterpretInput()
UI ui
Definition: ui.cc:310