DCC-EX Simple Throttle
Simple throttle for a DCC-EX CommandStation
Loading...
Searching...
No Matches
/home/runner/work/DCCEXSimpleThrottle/DCCEXSimpleThrottle/BaseMenu.h
Go to the documentation of this file.
1
/*
2
* © 2024 Peter Cole
3
* © 2023 Peter Cole
4
*
5
* This is free software: you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License as published by
7
* the Free Software Foundation, either version 3 of the License, or
8
* (at your option) any later version.
9
*
10
* It is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
14
*
15
* You should have received a copy of the GNU General Public License
16
* along with this code. If not, see <https://www.gnu.org/licenses/>.
17
*/
18
19
#ifndef BASEMENU_H
20
#define BASEMENU_H
21
22
#include "
BaseMenuItem.h
"
23
#include "
Defines.h
"
24
#include "
DisplayInterface.h
"
25
#include "
EventManager.h
"
26
#include "
UserConfirmationInterface.h
"
27
#include "
UserSelectionInterface.h
"
28
#include <Arduino.h>
29
31
class
BaseMenu
{
32
public
:
35
virtual
void
handleUserConfirmationAction
(
UserConfirmationAction
action) = 0;
36
39
void
handleUserSelectionAction
(
UserSelectionAction
action);
40
43
void
displayMenu
(
DisplayInterface
*displayInterface);
44
47
void
setMenuName
(
const
char
*name);
48
51
const
char
*
getMenuName
();
52
55
void
addItem
(
BaseMenuItem
*menuItem);
56
59
BaseMenuItem
*
getFirstMenuItem
();
60
64
BaseMenuItem
*
getMenuItemAtIndex
(uint8_t index);
65
68
uint8_t
getMenuItemCount
();
69
72
uint8_t
getSelectedItemIndex
();
73
76
bool
getSelectionChanged
();
77
80
void
setEventManager
(
EventManager
*eventManager);
81
84
EventManager
*
getEventManager
();
85
86
private
:
87
const
char
*
_name
=
nullptr
;
// Name of this menu
88
BaseMenuItem
*
_firstMenuItem
=
nullptr
;
// Pointer to the first menu item in the linked list
89
uint8_t
_menuItemCount
= 0;
// Count of menu items associated with this menu
90
uint8_t
_currentItemIndex
= 0;
// Incrementing index to ensure each menu item has a unique index
91
uint8_t
_selectedItemIndex
= 0;
// Index of the item currently selected by the user
92
bool
_selectionChanged
=
false
;
// Flag if user has selected a different item
93
EventManager
*
_eventManager
=
nullptr
;
// pointer to the application event manager
94
};
95
96
#endif
// MENU_H
BaseMenuItem.h
Defines.h
DisplayInterface.h
EventManager.h
UserConfirmationInterface.h
UserConfirmationAction
UserConfirmationAction
User confirmation action data types available.
Definition
UserConfirmationInterface.h:23
UserSelectionInterface.h
UserSelectionAction
UserSelectionAction
User selection action data types available.
Definition
UserSelectionInterface.h:23
BaseMenuItem
Base class for all menu item types, and all menu item types must inherit from this....
Definition
BaseMenuItem.h:28
BaseMenu
Class for maintaining a linked list of menu items to form a menu.
Definition
BaseMenu.h:31
BaseMenu::setEventManager
void setEventManager(EventManager *eventManager)
Set the application's event manager instance.
Definition
BaseMenu.cpp:92
BaseMenu::_firstMenuItem
BaseMenuItem * _firstMenuItem
Definition
BaseMenu.h:88
BaseMenu::_selectionChanged
bool _selectionChanged
Definition
BaseMenu.h:92
BaseMenu::_selectedItemIndex
uint8_t _selectedItemIndex
Definition
BaseMenu.h:91
BaseMenu::handleUserSelectionAction
void handleUserSelectionAction(UserSelectionAction action)
Method to respond to user selection actions.
Definition
BaseMenu.cpp:21
BaseMenu::_name
const char * _name
Definition
BaseMenu.h:87
BaseMenu::_currentItemIndex
uint8_t _currentItemIndex
Definition
BaseMenu.h:90
BaseMenu::displayMenu
void displayMenu(DisplayInterface *displayInterface)
Method to display the menu on screen.
Definition
BaseMenu.cpp:49
BaseMenu::handleUserConfirmationAction
virtual void handleUserConfirmationAction(UserConfirmationAction action)=0
Implement this method to respond to user confirmation actions.
BaseMenu::_menuItemCount
uint8_t _menuItemCount
Definition
BaseMenu.h:89
BaseMenu::getMenuItemAtIndex
BaseMenuItem * getMenuItemAtIndex(uint8_t index)
Get the menu item at the specified index.
Definition
BaseMenu.cpp:73
BaseMenu::getMenuItemCount
uint8_t getMenuItemCount()
Get the number of menu items associated with this menu.
Definition
BaseMenu.cpp:86
BaseMenu::getFirstMenuItem
BaseMenuItem * getFirstMenuItem()
Get the first menu item associated with this menu.
Definition
BaseMenu.cpp:71
BaseMenu::_eventManager
EventManager * _eventManager
Definition
BaseMenu.h:93
BaseMenu::getEventManager
EventManager * getEventManager()
Get the application's event manager instance.
Definition
BaseMenu.cpp:94
BaseMenu::getSelectionChanged
bool getSelectionChanged()
Check if the user selection has changed.
Definition
BaseMenu.cpp:90
BaseMenu::getSelectedItemIndex
uint8_t getSelectedItemIndex()
Get the index of the currently selected menu item.
Definition
BaseMenu.cpp:88
BaseMenu::setMenuName
void setMenuName(const char *name)
Set the name of this menu.
Definition
BaseMenu.cpp:53
BaseMenu::getMenuName
const char * getMenuName()
Get the name of this menu.
Definition
BaseMenu.cpp:55
BaseMenu::addItem
void addItem(BaseMenuItem *menuItem)
Add a menu item to this menu.
Definition
BaseMenu.cpp:57
DisplayInterface
Interface class to abstract construction of what is displayed on screen from the physical implementat...
Definition
DisplayInterface.h:29
EventManager
Class to centrally manage all events for the application Exposes methods to register subscribers that...
Definition
EventManager.h:28
Generated by
1.9.8