tcMenu
Loading...
Searching...
No Matches
MenuHistoryNavigator.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2018 https://www.thecoderscorner.com (Dave Cherry).
3 * This product is licensed under an Apache license, see the LICENSE file in the top-level directory.
4 */
5
12#ifndef TCMENU_MENUHISTORYNAVIGATOR_H
13#define TCMENU_MENUHISTORYNAVIGATOR_H
14
15#include "MenuItems.h"
16
17#ifndef NAV_ITEM_ARRAY_SIZE
18#define NAV_ITEM_ARRAY_SIZE 4
19#endif
20
21namespace tcnav {
23 NavigationListener* next = nullptr;
24 public:
25 virtual void navigationHasChanged(MenuItem* newItem, bool completelyReset)=0;
26 NavigationListener* getNext() { return next; }
27 void setNext(NavigationListener* nxt) { next = nxt; }
28 };
29
31 private:
32 MenuItem* root;
33 MenuItem* currentRoot;
34 MenuItem* currentSub;
35 MenuItem* navItems[NAV_ITEM_ARRAY_SIZE];
36 MenuItem* activeItems[NAV_ITEM_ARRAY_SIZE];
37 NavigationListener* navigationLister = nullptr;
38 uint8_t navIdx;
39 bool currentIsCustom;
40 public:
41 MenuNavigationStore() = default;
42
43 void addNavigationListener(NavigationListener* newListener);
44 void clearNavigationListeners() { navigationLister = nullptr; }
45
46 void triggerNavigationListener(bool completeReset);
47
51 MenuItem* getRoot() { return root; }
55 MenuItem* getCurrentRoot() { return currentRoot; }
60 MenuItem* getCurrentSubMenu() { return currentSub; }
61
66 void setRootItem(MenuItem* item);
67
74 void navigateTo(MenuItem* activeItem, MenuItem* newRoot, bool custom);
75
81
82 bool isShowingRoot();
83
87 int getNavigationDepth() const { return navIdx; }
88
94 MenuItem* getActiveAt(uint8_t i) { return i < navIdx ? activeItems[i] : nullptr; }
95
101 MenuItem* getRootAt(uint8_t i) { return i < navIdx ? navItems[i] : nullptr; }
102
104 void resetStack();
105 };
106}
107
108#endif //TCMENU_MENUHISTORYNAVIGATOR_H
In TcMenu, MenuItem storage is shared between program memory and RAM. Usually each MenuItem has assoc...
Definition MenuItems.h:329
Definition MenuHistoryNavigator.h:30
void resetStack()
Definition MenuHistoryNavigator.cpp:60
MenuItem * getRootAt(uint8_t i)
Definition MenuHistoryNavigator.h:101
void navigateTo(MenuItem *activeItem, MenuItem *newRoot, bool custom)
Definition MenuHistoryNavigator.cpp:21
MenuItem * getRoot()
Definition MenuHistoryNavigator.h:51
void setRootItem(MenuItem *item)
Definition MenuHistoryNavigator.cpp:12
MenuItem * popNavigationGetActive()
Definition MenuHistoryNavigator.cpp:38
MenuItem * getCurrentSubMenu()
Definition MenuHistoryNavigator.h:60
MenuItem * getCurrentRoot()
Definition MenuHistoryNavigator.h:55
MenuItem * getActiveAt(uint8_t i)
Definition MenuHistoryNavigator.h:94
int getNavigationDepth() const
Definition MenuHistoryNavigator.h:87
Definition MenuHistoryNavigator.h:22