Tempo
Tempo is an app that allows users to create and manage timers, stopwatches, and alarms.
Display.hpp
Go to the documentation of this file.
1 #ifndef DISPLAY_HPP
2 #define DISPLAY_HPP
3 
4 #include "Timer.hpp"
5 #include "Stopwatch.hpp"
6 #include "Alarm.hpp"
7 
8 #include "../fonts/font1.hpp"
9 #include "../fonts/font2.hpp"
10 #include "../fonts/font3.hpp"
11 #include "../fonts/font4.hpp"
12 
13 #include <cstring>
14 #include <iostream>
15 #include <vector>
16 
17 using namespace std;
18 
23 class Display
24 {
25 public:
26 
27  static const string SELECTED;
28 
29  static const string BOLD;
30 
31  static const string BLACK;
32  static const string RED;
33  static const string GREEN;
34  static const string YELLOW;
35  static const string BLUE;
36  static const string MAGENTA;
37  static const string CYAN;
38  static const string WHITE;
39 
40  static const string BOLD_BLACK;
41  static const string BOLD_RED;
42  static const string BOLD_GREEN;
43  static const string BOLD_YELLOW;
44  static const string BOLD_BLUE;
45  static const string BOLD_MAGENTA;
46  static const string BOLD_CYAN;
47  static const string BOLD_WHITE;
48 
49 
53  Display();
54 
55  void tickTimerSetup(string to_print);
56 
57  void tickAlarmSetup(string to_print, bool isAM);
58 
63  void tickTimer(Timer &timer);
64 
69  void tickStopwatch(Stopwatch &stopwatch);
70 
75  void tickAlarm(Alarm &alarm);
76 
84  void stageTimerDisplay(int hours, int minutes, int seconds, int tenths);
85 
86  void stageAlarmDisplay(string time);
87 
91  void stageArt(vector<string> art);
92 
97  void stageTimerBar(double percentage);
98 
99  void stageAlarmBar(double percentage);
100 
108  void stageStopwatchDisplay(int hours, int minutes, int seconds, int hundredths);
109 
113  void stageStopwatchSplits(vector<int> splits);
114 
118  void stageAlarmDisplay();
119 
124  void setSplash(string str);
125 
129  void clearSplash();
130 
135  void printSplash(int splashIndex, string formatting);
136 
141  void printAscii(int asciiIndex, string formatting);
142 
147  void printArt(int controlIndex, string formatting);
148 
153  void printBar(int barIndex, string formatting);
154 
158  void printSplits(int splitsIndex, string formatting);
159 
163  void clearScreen();
164 
169  void setFormat(const string& code);
170 
174  void clearFormat();
175 
181  void setCursor(int x, int y);
182 
187  void clearLine(int lineIndex);
188 
193  void setFont(int num);
194 
195 
201  template <typename char_type>
202  static auto fast_print(const basic_string<char_type> &sss) -> void;
203 
204 private:
205  string _asciiBuffer;
206  string _barBuffer;
207  string _controlBuffer;
208  string _splitBuffer;
209  string _splash;
210 
211  string _oldAscii;
212  string _oldControls;
213  string _oldBar;
214  string _oldSplash;
215  string _oldSplits;
216 
217  vector<vector<vector<string>>> _fonts;
218  vector<int> _fontHeights;
219  vector<vector<string>> _currFont;
220 
222  string PADDING;
223 
224  string _formatting;
226 
228 
229  vector<string> _timerSetupControls = {
230  " _ ___ _ _ ___ ___ _ _ _ __ ___ ",
231  " |_ |\\ | | |_ |_) | | |\\/| |_ |_) | |_ |\\ | /__ | |_| o ",
232  " |_ | \\| | |_ | \\ | _|_ | | |_ | \\ |_ |_ | \\| \\_| | | | o ",
233  };
234 
235  vector<string> _alarmSetupControls = {
236  " _ ___ _ _ _ ___ ___ _ ",
237  "|_ |\\ | | |_ |_) /\\ | /\\ |_) |\\/| | | |\\/| |_ o ",
238  "|_ | \\| | |_ | \\ /--\\ |_ /--\\ | \\ | | | _|_ | | |_ o ",
239  };
240 
241  vector<string> _alarmSetupAM = {
242  " ",
243  " /\\ |\\/| ",
244  " /--\\ | | ",
245  " ",
246  };
247 
248 
249  vector<string> _alarmSetupPM = {
250  " _ ",
251  " |_) |\\/| ",
252  " | | | ",
253  " ",
254  };
255 
256  vector<string> _alarmControls = {
257  "",
258  "A: New Alarm | Q: Main Menu",
259  "",
260  };
261 
262  vector<string> _timerControls = {
263  "",
264  "S: Start/Stop | R: Reset | A: New Timer | Q: Main Menu",
265  "",
266  };
267 
268  vector<string> _stopwatchControls = {
269  "",
270  "S: Start/Stop | R: Reset | A: Add Split | Q: Main Menu",
271  "",
272  };
273 
274 };
275 
276 #endif // DISPLAY_HPP
string _oldFormatting
Definition: Display.hpp:225
A class to manage alarms with time-based triggers.
Definition: Alarm.hpp:13
string _oldAscii
Previous ASCII art for comparison.
Definition: Display.hpp:211
The Timer class provides a countdown timer with start, pause, resume, reset, and time adjustment func...
Definition: Timer.hpp:12
string _formatting
Definition: Display.hpp:224
static const string BOLD
Definition: Display.hpp:29
The Stopwatch class provides a simple timer with start, pause, resume, and reset functionalities.
Definition: Stopwatch.hpp:13
static const string RED
Definition: Display.hpp:32
int _asciiWidth
Width of the ASCII art.
Definition: Display.hpp:227
static const string BOLD_YELLOW
Definition: Display.hpp:43
static const string BLACK
Definition: Display.hpp:31
string _splitBuffer
Buffer for the splits block.
Definition: Display.hpp:208
static const string BLUE
Definition: Display.hpp:35
string _asciiBuffer
Buffer for ASCII art.
Definition: Display.hpp:205
static const string BOLD_WHITE
Definition: Display.hpp:47
STL namespace.
string _splash
String for splash screen.
Definition: Display.hpp:209
string _oldSplits
Previous splits for comparison.
Definition: Display.hpp:215
static const string BOLD_BLACK
Definition: Display.hpp:40
static const string SELECTED
Definition: Display.hpp:27
int ASCII_HEIGHT
Definition: Display.hpp:221
static const string BOLD_RED
Definition: Display.hpp:41
static const string WHITE
Definition: Display.hpp:38
static const string YELLOW
Definition: Display.hpp:34
vector< int > _fontHeights
List of font heights.
Definition: Display.hpp:218
string _barBuffer
Buffer for progress bar.
Definition: Display.hpp:206
static const string BOLD_GREEN
Definition: Display.hpp:42
vector< vector< string > > _currFont
current font ascii
Definition: Display.hpp:219
string _oldSplash
Previous splash screen for comparison.
Definition: Display.hpp:214
vector< vector< vector< string > > > _fonts
List of font ascii.
Definition: Display.hpp:217
static const string CYAN
Definition: Display.hpp:37
static const string MAGENTA
Definition: Display.hpp:36
static const string BOLD_CYAN
Definition: Display.hpp:46
static const string BOLD_BLUE
Definition: Display.hpp:44
string _oldBar
Previous progress bar for comparison.
Definition: Display.hpp:213
string _oldControls
Previous controls for comparison.
Definition: Display.hpp:212
string _controlBuffer
Buffer for controls.
Definition: Display.hpp:207
static const string BOLD_MAGENTA
Definition: Display.hpp:45
string PADDING
Definition: Display.hpp:222
static const string GREEN
Definition: Display.hpp:33
The Display class manages the visual representation and interaction logic for timers, stopwatches, and alarms.
Definition: Display.hpp:23