![]() |
Tempo
Tempo is an app that allows users to create and manage timers, stopwatches, and alarms.
|
The Menu class manages the main menu and user input for the Timer Stopwatch and Alarm. More...
#include <Menu.hpp>

Public Member Functions | |
| Menu (bool testing) | |
| Constructs a Menu object. More... | |
| char | getMenuInput (int &selected) |
| Waits for the user to press a valid key (1 2 3 or Q) for menu selection. More... | |
| char | getSettingsInput (int &selected) |
| Waits for the user to press a valid key (1 2 3 4 or Q) for settings selection. More... | |
| void | wait (double seconds) |
| Waits for a specific duration using busy-waiting. More... | |
| void | waitForInput () |
| Waits for any key press from the user. More... | |
| void | checkTimerInput (Timer &timer, bool &run) |
| Checks and handles user input for the Timer. More... | |
| void | checkStopwatchInput (Stopwatch &stopwatch, bool &run) |
| Checks and handles user input for the Stopwatch. More... | |
| void | checkAlarmInput (Alarm &alarm, bool &run) |
| Checks and handles user input for the Alarm. More... | |
| void | mainMenu (int selected) |
| Starts the main menu loop allowing the user to choose between Timer Stopwatch and Alarm. More... | |
| void | settingsMenu (int selected) |
| Starts the settings menu loop allowing the user to change the notification and font settings. More... | |
| void | loadSettings () |
| Loads the notification and font settings from a file. More... | |
| void | saveSettings () |
| Saves the notification and font settings to a file. More... | |
| void | credits () |
| Displays the credits for the Timer Stopwatch and Alarm. More... | |
| void | timerSequence () |
| Displays the help menu for the Timer Stopwatch and Alarm. More... | |
| void | stopwatchSequence () |
| Displays the help menu for the Timer Stopwatch and Alarm. More... | |
| void | alarmSequence () |
| Displays the help menu for the Timer Stopwatch and Alarm. More... | |
| Timer | createTimer (bool &run) |
| Creates a Timer object with user input for the duration. More... | |
| Alarm | createAlarm (bool &run) |
| Creates a Alarm object with user input for the duration. More... | |
| void | printTimerInput (int, int, int) |
| Prints the Timer's input duration to the console. More... | |
| void | printArt (vector< string > art, string formatting) |
| Prints the Alarm's input duration to the console. More... | |
Private Attributes | |
| Display | _display |
| Instance of Display to manage the visual representation. More... | |
| bool | _run |
| Boolean to control the main loop execution. More... | |
| bool | _testing |
| vector< string > | _menuFormats |
| vector< string > | _settingsFormats |
| bool | _notiSetting |
| int | _fontSetting |
| vector< string > | _logoArt |
| vector< string > | _credits |
| vector< string > | _menuArt |
| vector< string > | _menuTimer |
| vector< string > | _menuStopwatch |
| vector< string > | _menuAlarm |
| vector< string > | _menuSettings |
| vector< string > | _menuQuit |
| vector< string > | _menuBlank |
| vector< string > | _settingsArt |
| vector< string > | _settingsFont1 |
| vector< string > | _settingsFont2 |
| vector< string > | _settingsFont3 |
| vector< string > | _settingsFont4 |
| vector< string > | _settingsNotiOn |
| vector< string > | _settingsNotiOff |
| vector< string > | _settingsCredits |
| vector< string > | _settingsBack |
| vector< string > | _settingsBlank |
| vector< string > | _stopMessages |
| Menu::Menu | ( | bool | testing | ) |
Constructs a Menu object.
Constructs a Menu object and initializes its state.
Definition at line 16 of file Menu.cpp.
References Display::BOLD_WHITE.
| void Menu::alarmSequence | ( | ) |
Displays the help menu for the Timer Stopwatch and Alarm.
Runs the alarm sequence, allowing the user to set and interact with an alarm.
Definition at line 349 of file Menu.cpp.
References Alarm::isDone(), and LOOPTIME.

| void Menu::checkAlarmInput | ( | Alarm & | alarm, |
| bool & | run | ||
| ) |
Checks and handles user input for the Alarm.
This function processes user input to control the Alarm. It updates the Alarm's state based on the key pressed.
| alarm | The Alarm object to control. |
| run | A boolean reference that determines whether to continue the loop. |
Definition at line 701 of file Menu.cpp.
| void Menu::checkStopwatchInput | ( | Stopwatch & | stopwatch, |
| bool & | run | ||
| ) |
Checks and handles user input for the Stopwatch.
This function processes user input to control the Stopwatch. It updates the Stopwatch's state based on the key pressed.
| stopwatch | The Stopwatch object to control. |
| run | A boolean reference that determines whether to continue the loop. |
Definition at line 647 of file Menu.cpp.
References Stopwatch::addSplit(), Stopwatch::currentMilliseconds(), Stopwatch::isRunning(), Stopwatch::pause(), Stopwatch::reset(), and Stopwatch::resume().

| void Menu::checkTimerInput | ( | Timer & | timer, |
| bool & | run | ||
| ) |
Checks and handles user input for the Timer.
This function processes user input to control the Timer. It updates the Timer's state based on the key pressed.
| timer | The Timer object to control. |
| run | A boolean reference that determines whether to continue the loop. |
Definition at line 599 of file Menu.cpp.
References Timer::isRunning(), Timer::pause(), Timer::remainingMilliseconds(), Timer::reset(), and Timer::resume().

| Alarm Menu::createAlarm | ( | bool & | run | ) |
Creates a Alarm object with user input for the duration.
Creates a new Alarm object based on user input.
This function prompts the user to enter the hours minutes and seconds for the Alarm. It then creates a Alarm object with the specified duration and returns it.
| run | A boolean reference that determines whether to continue the loop. |
| run | A reference to a boolean flag indicating whether to continue running the sequence. |
Definition at line 453 of file Menu.cpp.
References LOOPTIME.
| Timer Menu::createTimer | ( | bool & | run | ) |
Creates a Timer object with user input for the duration.
Creates a new Timer object based on user input.
This function prompts the user to enter the hours minutes and seconds for the Timer. It then creates a Timer object with the specified duration and returns it.
| run | A boolean reference that determines whether to continue the loop. |
| run | A reference to a boolean flag indicating whether to continue running the sequence. |
Definition at line 386 of file Menu.cpp.
References LOOPTIME.
| void Menu::credits | ( | ) |
Displays the credits for the Timer Stopwatch and Alarm.
Displays the start screen with logo art and credits.
Definition at line 58 of file Menu.cpp.
References Display::BOLD_CYAN, and Display::WHITE.
| char Menu::getMenuInput | ( | int & | selected | ) |
Waits for the user to press a valid key (1 2 3 or Q) for menu selection.
Waits for the user to press a valid key (1, 2, 3, or Q) for menu selection.
This function repeatedly checks for user input until a valid menu option is pressed. It then returns the corresponding character for the selected menu option.
Definition at line 732 of file Menu.cpp.
References LOOPTIME.
| char Menu::getSettingsInput | ( | int & | selected | ) |
Waits for the user to press a valid key (1 2 3 4 or Q) for settings selection.
Waits for the user to press a valid key (1, 2, 3, or Q) for settings selection.
This function repeatedly checks for user input until a valid settings option is pressed. It then returns the corresponding character for the selected settings option.
| selected | The current selected setting. |
Definition at line 789 of file Menu.cpp.
References LOOPTIME.
| void Menu::loadSettings | ( | ) |
| void Menu::mainMenu | ( | int | selected | ) |
Starts the main menu loop allowing the user to choose between Timer Stopwatch and Alarm.
Starts the main menu loop, allowing the user to choose between Timer, Stopwatch, and Alarm.
The menu displays options to the user processes the user's selection and runs the appropriate sequence for Timer Stopwatch or Alarm. It handles the input and output and returns to the menu after each operation unless the user chooses to quit.
The menu displays options to the user, processes the user's selection, and runs the appropriate sequence for Timer, Stopwatch, or Alarm. It handles the input and output and returns to the menu after each operation unless the user chooses to quit.
Definition at line 127 of file Menu.cpp.
References Display::BOLD_CYAN, Display::BOLD_WHITE, and Display::SELECTED.
| void Menu::printArt | ( | vector< string > | art, |
| string | formatting | ||
| ) |
Prints the Alarm's input duration to the console.
Prints ASCII art to the display with specified formatting.
This function prints the hours minutes and seconds of the Alarm's input duration to the console.
| hours | The hours of the Alarm's input duration. |
| minutes | The minutes of the Alarm's input duration. |
| seconds | The seconds of the Alarm's input duration. |
| art | A vector of strings representing the ASCII art. |
| formatting | The display format for the art. |
Definition at line 45 of file Menu.cpp.
| void Menu::printTimerInput | ( | int | , |
| int | , | ||
| int | |||
| ) |
| void Menu::saveSettings | ( | ) |
| void Menu::settingsMenu | ( | int | selected | ) |
Starts the settings menu loop allowing the user to change the notification and font settings.
Displays the settings menu and allows the user to modify settings.
The settings menu displays options to the user processes the user's selection and runs the appropriate sequence for changing the notification and font settings. It handles the input and output and returns to the settings menu after each operation unless the user chooses to quit.
The settings include font selection and notifications.
| selected | The index of the selected settings option. |
Definition at line 202 of file Menu.cpp.
References Display::BOLD_CYAN, Display::BOLD_WHITE, NUM_FONTS, and Display::SELECTED.
| void Menu::stopwatchSequence | ( | ) |
Displays the help menu for the Timer Stopwatch and Alarm.
Runs the stopwatch sequence, allowing the user to start, stop, and record splits.
Definition at line 319 of file Menu.cpp.
References LOOPTIME.
| void Menu::timerSequence | ( | ) |
Displays the help menu for the Timer Stopwatch and Alarm.
Runs the timer sequence, allowing the user to set and interact with a timer.
Definition at line 284 of file Menu.cpp.
References LOOPTIME, and Timer::remainingMilliseconds().

| void Menu::wait | ( | double | seconds | ) |
Waits for a specific duration using busy-waiting.
This function uses a high-resolution clock to wait for the specified amount of time (in seconds). It continuously checks the elapsed time until the desired duration has passed.
| seconds | The amount of time to wait in seconds. |
This function uses a high-resolution clock to wait for the specified amount of time (in seconds). It continuously checks the elapsed time until the desired duration has passed.
| seconds | The amount of time to wait, in seconds. |
| void Menu::waitForInput | ( | ) |
Waits for any key press from the user.
This function blocks until the user presses a key using _getch() to capture the input.
This function blocks until the user presses a key, using _getch() to capture the input.
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
1.8.13