![]() |
Tempo
Tempo is an app that allows users to create and manage timers, stopwatches, and alarms.
|
The Display class manages the visual representation and interaction logic for timers, stopwatches, and alarms. More...
#include <Display.hpp>

Public Member Functions | |
| Display () | |
| Constructs a new Display object. More... | |
| void | tickTimerSetup (string to_print) |
| Updates the timer setup display, showing the current input with a blinking cursor. More... | |
| void | tickAlarmSetup (string to_print, bool isAM) |
| Updates the alarm setup display, showing the current input with a blinking cursor. More... | |
| void | tickTimer (Timer &timer) |
| Updates the display based on the state of the provided Timer object. More... | |
| void | tickStopwatch (Stopwatch &stopwatch) |
| Updates the display based on the state of the provided Stopwatch object. More... | |
| void | tickAlarm (Alarm &alarm) |
| Updates the display based on the state of the provided Alarm object. More... | |
| void | stageTimerDisplay (int hours, int minutes, int seconds, int tenths) |
| Stages the timer display with provided time values. More... | |
| void | stageAlarmDisplay (string time) |
| Converts the alarm time into an ASCII representation and stages it for display. More... | |
| void | stageArt (vector< string > art) |
| Stages the controls for the timer. More... | |
| void | stageTimerBar (double percentage) |
| Stages the progress bar for the timer. More... | |
| void | stageAlarmBar (double percentage) |
| Creates a visual progress bar for the alarm based on the percentage completed. More... | |
| void | stageStopwatchDisplay (int hours, int minutes, int seconds, int hundredths) |
| Stages the stopwatch display with provided time values. More... | |
| void | stageStopwatchSplits (vector< int > splits) |
| Stages the splits block to be displayed. More... | |
| void | stageAlarmDisplay () |
| Stages the display for the alarm. More... | |
| void | setSplash (string str) |
| Sets the splash screen text. More... | |
| void | clearSplash () |
| Clears the splash screen. More... | |
| void | printSplash (int splashIndex, string formatting) |
| Prints the splash screen to the terminal. More... | |
| void | printAscii (int asciiIndex, string formatting) |
| Prints ASCII art to the terminal. More... | |
| void | printArt (int controlIndex, string formatting) |
| Prints controls to the terminal. More... | |
| void | printBar (int barIndex, string formatting) |
| Prints the progress bar to the terminal. More... | |
| void | printSplits (int splitsIndex, string formatting) |
| Prints the stopwatch splits to the terminal. More... | |
| void | clearScreen () |
| Clears the terminal screen. More... | |
| void | setFormat (const string &code) |
| Sets the terminal text color. More... | |
| void | clearFormat () |
| Clears the terminal text color. More... | |
| void | setCursor (int x, int y) |
| Sets the cursor position in the terminal. More... | |
| void | clearLine (int lineIndex) |
| Clears a specific line in the terminal. More... | |
| void | setFont (int num) |
| Sets the font style for the terminal. More... | |
Static Public Member Functions | |
| template<typename char_type > | |
| static auto | fast_print (const basic_string< char_type > &sss) -> void |
| Efficiently prints a string to the terminal. More... | |
Static Public Attributes | |
| static const string | SELECTED = "\033[1;30;46m" |
| static const string | BOLD = "\033[1m" |
| static const string | BLACK = "\033[30m" |
| static const string | RED = "\033[31m" |
| static const string | GREEN = "\033[32m" |
| static const string | YELLOW = "\033[33m" |
| static const string | BLUE = "\033[34m" |
| static const string | MAGENTA = "\033[35m" |
| static const string | CYAN = "\033[36m" |
| static const string | WHITE = "\033[37m" |
| static const string | BOLD_BLACK = "\033[1;30m" |
| static const string | BOLD_RED = "\033[1;31m" |
| static const string | BOLD_GREEN = "\033[1;32m" |
| static const string | BOLD_YELLOW = "\033[1;33m" |
| static const string | BOLD_BLUE = "\033[1;34m" |
| static const string | BOLD_MAGENTA = "\033[1;35m" |
| static const string | BOLD_CYAN = "\033[1;36m" |
| static const string | BOLD_WHITE = "\033[1;37m" |
Private Attributes | |
| string | _asciiBuffer |
| Buffer for ASCII art. More... | |
| string | _barBuffer |
| Buffer for progress bar. More... | |
| string | _controlBuffer |
| Buffer for controls. More... | |
| string | _splitBuffer |
| Buffer for the splits block. More... | |
| string | _splash |
| String for splash screen. More... | |
| string | _oldAscii |
| Previous ASCII art for comparison. More... | |
| string | _oldControls |
| Previous controls for comparison. More... | |
| string | _oldBar |
| Previous progress bar for comparison. More... | |
| string | _oldSplash |
| Previous splash screen for comparison. More... | |
| string | _oldSplits |
| Previous splits for comparison. More... | |
| vector< vector< vector< string > > > | _fonts |
| List of font ascii. More... | |
| vector< int > | _fontHeights |
| List of font heights. More... | |
| vector< vector< string > > | _currFont |
| current font ascii More... | |
| int | ASCII_HEIGHT |
| string | PADDING |
| string | _formatting |
| string | _oldFormatting |
| int | _asciiWidth |
| Width of the ASCII art. More... | |
| vector< string > | _timerSetupControls |
| vector< string > | _alarmSetupControls |
| vector< string > | _alarmSetupAM |
| vector< string > | _alarmSetupPM |
| vector< string > | _alarmControls |
| vector< string > | _timerControls |
| vector< string > | _stopwatchControls |
The Display class manages the visual representation and interaction logic for timers, stopwatches, and alarms.
Handles the terminal display for a timer and stopwatch, including ASCII art and controls.
Definition at line 23 of file Display.hpp.
| Display::Display | ( | ) |
Constructs a new Display object.
Definition at line 39 of file Display.cpp.
References f1_ascii, f1_height, f2_ascii, f2_height, f3_ascii, f3_height, f4_ascii, and f4_height.
| void Display::clearFormat | ( | ) |
Clears the terminal text color.
Clears the formatting for the text to be displayed.
Definition at line 147 of file Display.cpp.
| void Display::clearLine | ( | int | row | ) |
Clears a specific line in the terminal.
| lineIndex | The index of the line to clear. |
| row | The row number to clear. |
Definition at line 111 of file Display.cpp.
| void Display::clearScreen | ( | ) |
Clears the terminal screen.
Clears the terminal screen and resets the old buffers.
Definition at line 67 of file Display.cpp.
| void Display::clearSplash | ( | ) |
Clears the splash screen.
Clears the splash text from the screen.
Definition at line 170 of file Display.cpp.
|
static |
Efficiently prints a string to the terminal.
Prints a string to the console efficiently using the Windows API.
| char_type | The character type of the string. |
| sss | The string to print. |
| char_type | The character type (either char or wchar_t). |
| sss | The string to print. |
Definition at line 124 of file Display.cpp.
| void Display::printArt | ( | int | row, |
| string | formatting | ||
| ) |
Prints controls to the terminal.
Prints the controls for the timer or stopwatch to the terminal.
| controlIndex | The index used for control display. |
| row | The row position to print. |
Definition at line 588 of file Display.cpp.
| void Display::printAscii | ( | int | row, |
| string | formatting | ||
| ) |
Prints ASCII art to the terminal.
Prints the ASCII art representation of the timer or stopwatch to the terminal.
| asciiIndex | The index used for ASCII control. |
| row | The row position to print. |
Definition at line 569 of file Display.cpp.
| void Display::printBar | ( | int | row, |
| string | formatting | ||
| ) |
Prints the progress bar to the terminal.
Prints the progress bar for the timer to the terminal.
| barIndex | The index used for bar control. |
| row | The row position to print. |
Definition at line 607 of file Display.cpp.
| void Display::printSplash | ( | int | row, |
| string | formatting | ||
| ) |
Prints the splash screen to the terminal.
Prints the splash text to the terminal.
| splashIndex | The index used for splash screen control. |
| row | The row position to print. |
Definition at line 626 of file Display.cpp.
| void Display::printSplits | ( | int | row, |
| string | formatting | ||
| ) |
Prints the stopwatch splits to the terminal.
| row | The row position to print. |
Definition at line 645 of file Display.cpp.
| void Display::setCursor | ( | int | row, |
| int | col | ||
| ) |
Sets the cursor position in the terminal.
| x | The x-coordinate (column) to move the cursor to. |
| y | The y-coordinate (row) to move the cursor to. |
| row | The row position. |
| col | The column position. |
Definition at line 101 of file Display.cpp.
| void Display::setFont | ( | int | num | ) |
Sets the font style for the terminal.
| num | The font style to set. |
Definition at line 79 of file Display.cpp.
| void Display::setFormat | ( | const string & | code | ) |
Sets the terminal text color.
Sets the formatting for the text to be displayed.
| color | The color to set the text to. |
| code | string& The formatting code. |
Definition at line 138 of file Display.cpp.
| void Display::setSplash | ( | string | str | ) |
Sets the splash screen text.
Sets the splash text to be displayed at the top or bottom of the screen.
| str | The string to display as the splash screen. |
| str | The splash text to display. |
Definition at line 162 of file Display.cpp.
| void Display::stageAlarmBar | ( | double | percentage | ) |
Creates a visual progress bar for the alarm based on the percentage completed.
| percentage | The percentage of completion. |
Definition at line 356 of file Display.cpp.
| void Display::stageAlarmDisplay | ( | string | time | ) |
Converts the alarm time into an ASCII representation and stages it for display.
| time | The alarm time string in "HH:MM" format. |
Definition at line 247 of file Display.cpp.
| void Display::stageAlarmDisplay | ( | ) |
Stages the display for the alarm.
| void Display::stageArt | ( | vector< string > | art | ) |
Stages the controls for the timer.
Stages vector<string> ascii art to be displayed in the terminal.
Definition at line 396 of file Display.cpp.
| void Display::stageStopwatchDisplay | ( | int | hours, |
| int | minutes, | ||
| int | seconds, | ||
| int | hundredths | ||
| ) |
Stages the stopwatch display with provided time values.
Converts the stopwatch values into an ASCII representation and stages it for display.
| hours | Hours to display. |
| minutes | Minutes to display. |
| seconds | Seconds to display. |
| hundredths | Hundredths of a second to display. |
| hours | The number of hours. |
| minutes | The number of minutes. |
| seconds | The number of seconds. |
| hundredths | The number of hundredths of a second. |
Definition at line 414 of file Display.cpp.
| void Display::stageStopwatchSplits | ( | vector< int > | splits | ) |
| void Display::stageTimerBar | ( | double | percentage | ) |
Stages the progress bar for the timer.
Creates a visual progress bar for the timer based on the percentage completed.
| percentage | The percentage of the timer's progress to display. |
| percentage | The percentage of completion. |
Definition at line 316 of file Display.cpp.
| void Display::stageTimerDisplay | ( | int | hours, |
| int | minutes, | ||
| int | seconds, | ||
| int | tenths | ||
| ) |
Stages the timer display with provided time values.
Converts the timer values into an ASCII representation and stages it for display.
| hours | Hours to display. |
| minutes | Minutes to display. |
| seconds | Seconds to display. |
| tenths | Tenths of a second to display. |
| hours | The number of hours. |
| minutes | The number of minutes. |
| seconds | The number of seconds. |
| tenths | The number of tenths of a second. |
Definition at line 186 of file Display.cpp.
| void Display::tickAlarm | ( | Alarm & | alarm | ) |
Updates the display based on the state of the provided Alarm object.
Updates the alarm display on each tick, showing the alarm time and progress bar.
| alarm | Reference to the Alarm object. |
| alarm | The Alarm object to get the alarm time and progress from. |
Definition at line 899 of file Display.cpp.
References Alarm::getEndTime(), Alarm::isDone(), Alarm::percentElapsed(), and Alarm::timeToString().

| void Display::tickAlarmSetup | ( | string | to_print, |
| bool | isAM | ||
| ) |
Updates the alarm setup display, showing the current input with a blinking cursor.
| to_print | The current alarm setup input string. |
Definition at line 705 of file Display.cpp.
| void Display::tickStopwatch | ( | Stopwatch & | stopwatch | ) |
Updates the display based on the state of the provided Stopwatch object.
Updates the stopwatch display on each tick, converting time into ASCII and updating the terminal.
| stopwatch | Reference to the Stopwatch object. |
| stopwatch | The Stopwatch object to get the current time from. |
Definition at line 856 of file Display.cpp.
References Stopwatch::currentMilliseconds(), Stopwatch::getSplits(), and Stopwatch::isRunning().

| void Display::tickTimer | ( | Timer & | timer | ) |
Updates the display based on the state of the provided Timer object.
Updates the timer display on each tick, converting time into ASCII and updating the terminal.
| timer | Reference to the Timer object. |
| timer | The Timer object to get the remaining time from. |
Definition at line 812 of file Display.cpp.
References Timer::isDone(), Timer::isRunning(), Timer::percentElapsed(), and Timer::remainingMilliseconds().

| void Display::tickTimerSetup | ( | string | to_print | ) |
Updates the timer setup display, showing the current input with a blinking cursor.
| to_print | The current timer setup input string. |
Definition at line 663 of file Display.cpp.
|
private |
Definition at line 256 of file Display.hpp.
|
private |
Definition at line 241 of file Display.hpp.
|
private |
Definition at line 235 of file Display.hpp.
|
private |
Definition at line 249 of file Display.hpp.
|
private |
Buffer for ASCII art.
Definition at line 205 of file Display.hpp.
|
private |
Width of the ASCII art.
Definition at line 227 of file Display.hpp.
|
private |
Buffer for progress bar.
Definition at line 206 of file Display.hpp.
|
private |
Buffer for controls.
Definition at line 207 of file Display.hpp.
|
private |
current font ascii
Definition at line 219 of file Display.hpp.
|
private |
List of font heights.
Definition at line 218 of file Display.hpp.
|
private |
List of font ascii.
Definition at line 217 of file Display.hpp.
|
private |
Definition at line 224 of file Display.hpp.
|
private |
Previous ASCII art for comparison.
Definition at line 211 of file Display.hpp.
|
private |
Previous progress bar for comparison.
Definition at line 213 of file Display.hpp.
|
private |
Previous controls for comparison.
Definition at line 212 of file Display.hpp.
|
private |
Definition at line 225 of file Display.hpp.
|
private |
Previous splash screen for comparison.
Definition at line 214 of file Display.hpp.
|
private |
Previous splits for comparison.
Definition at line 215 of file Display.hpp.
|
private |
String for splash screen.
Definition at line 209 of file Display.hpp.
|
private |
Buffer for the splits block.
Definition at line 208 of file Display.hpp.
|
private |
Definition at line 268 of file Display.hpp.
|
private |
Definition at line 262 of file Display.hpp.
|
private |
Definition at line 229 of file Display.hpp.
|
private |
Definition at line 221 of file Display.hpp.
|
static |
Definition at line 31 of file Display.hpp.
|
static |
Definition at line 35 of file Display.hpp.
|
static |
Definition at line 29 of file Display.hpp.
|
static |
Definition at line 40 of file Display.hpp.
|
static |
Definition at line 44 of file Display.hpp.
|
static |
Definition at line 46 of file Display.hpp.
Referenced by Menu::credits(), Menu::mainMenu(), and Menu::settingsMenu().
|
static |
Definition at line 42 of file Display.hpp.
|
static |
Definition at line 45 of file Display.hpp.
|
static |
Definition at line 41 of file Display.hpp.
|
static |
Definition at line 47 of file Display.hpp.
Referenced by Menu::mainMenu(), Menu::Menu(), and Menu::settingsMenu().
|
static |
Definition at line 43 of file Display.hpp.
|
static |
Definition at line 37 of file Display.hpp.
|
static |
Definition at line 33 of file Display.hpp.
|
static |
Definition at line 36 of file Display.hpp.
|
private |
Definition at line 222 of file Display.hpp.
|
static |
Definition at line 32 of file Display.hpp.
|
static |
Definition at line 27 of file Display.hpp.
Referenced by Menu::mainMenu(), and Menu::settingsMenu().
|
static |
Definition at line 38 of file Display.hpp.
Referenced by Menu::credits().
|
static |
Definition at line 34 of file Display.hpp.
1.8.13