Base class for complex menus. More...
Base class for complex menus.
This is the base class for any form of UiPage that displays a menu with multiple items. It handles all the logic behind a menu (selecting items, editing items, etc.) but doesn't implement any form of drawing. Implement your own drawing routines by overriding UiPage::Draw() or use FullScreenItemMenu
Vaious types of items can be added to the menu, e.g.
The Abstract Menu can work with a wide variety of physical controls, here are a couple of combinations that are possible:
These are the controls that the AbstractMenu will react to and their associated function:
Orientation::leftRightSelectUpDownModify
, directly edit value of the selected item when Orientation::upDownSelectLeftRightModify
.Orientation::upDownSelectLeftRightModify
, directly edit value of the selected item when Orientation::leftRightSelectUpDownModify
.ItemType::closeMenuItem
) otherwise enter/leave editing mode where the arrow buttons used for selection will now edit the value instead (only possible if allowEntering
is set to true
).#include <AbstractMenu.h>
Classes | |
class | CustomItem |
struct | ItemConfig |
Public Types | |
enum class | Orientation { leftRightSelectUpDownModify , upDownSelectLeftRightModify } |
enum class | ItemType { callbackFunctionItem , checkboxItem , valueItem , openUiPageItem , closeMenuItem , customItem } |
Protected Member Functions | |
void | Init (const ItemConfig *items, uint16_t numItems, Orientation orientation, bool allowEntering) |
bool | IsFunctionButtonDown () const |
Protected Attributes | |
Orientation | orientation_ = Orientation::upDownSelectLeftRightModify |
const ItemConfig * | items_ = nullptr |
uint16_t | numItems_ = 0 |
int16_t | selectedItemIdx_ = -1 |
bool | allowEntering_ = true |
bool | isEditing_ = false |
The types of entries that can be added to the menu.
Enumerator | |
---|---|
callbackFunctionItem | Displays a text and calls a callback function when activated with the enter button |
checkboxItem | Displays a name and a checkbox. When selected, the modify keys will allow to change the value directly. Pressing the enter button toggles the value. |
valueItem | Displays a name and a value (with unit) from a MappedValue. When selected, the modify keys will allow to change the value directly. Pressing the enter button allows to change the value with the selection buttons as well. |
openUiPageItem | Displays a name and opens another UiPage when selected. |
closeMenuItem | Displays a text and closes the menu page when selected. This is useful when no cancel button is available to close a menu and return to the page below. |
customItem | A custom item.
|
Controls which buttons are used to navigate back and forth between the menu items (selection buttons) and which buttons can be used to modify their value directly without pressing the enter button first (modify buttons; these don't have to be available).
Enumerator | |
---|---|
leftRightSelectUpDownModify | left/right buttons => selection buttons, up/down => value buttons |
upDownSelectLeftRightModify | up/down buttons => selection buttons, left/right => value buttons |
|
default |
|
inlineoverridevirtual |
|
inline |
|
inline |
|
inline |
|
protected |
Call this from your child class to initialize the menu. It's okay to re-initialize an AbstractMene multiple times, even while it's displayed on the UI.
items | An array of ItemConfig that determine which items are available in the menu. |
numItems | The number of items in the items array. |
orientation | Controls which pair of arrow buttons are used for selection / editing |
allowEntering | Globally controls if the Ok button can enter items for editing. If you have a physical controls that can edit selected items directly (value slider, a second arrow button pair, value encoder) you can set this to false, otherwise you set it to true so that the controls used for selecting items can now also be used to edit the values. |
|
inlineprotected |
Returns the state of the function button.
|
overridevirtual |
Called when an arrow button is pressed or released.
arrowType | The arrow button affected. |
numberOfPresses | Holds the number of successive button presses. It will be 1 on the first call and increasing by 1 with each successive call. A button down event is signaled by numberOfButtonPresses == 0. |
isRetriggering | True if the button is auto-retriggering (due to being held down) |
Reimplemented from daisy::UiPage.
|
overridevirtual |
Called when the cancel button is pressed or released.
numberOfPresses | Holds the number of successive button presses. It will be 1 on the first call and increasing by 1 with each successive call. A button down event is signaled by numberOfButtonPresses == 0. |
isRetriggering | True if the button is auto-retriggering (due to being held down) |
Reimplemented from daisy::UiPage.
|
overridevirtual |
Called when the function button is pressed or released.
numberOfPresses | Holds the number of successive button presses. It will be 1 on the first call and increasing by 1 with each successive call. A button down event is signaled by numberOfButtonPresses == 0. |
isRetriggering | True if the button is auto-retriggering (due to being held down) |
Reimplemented from daisy::UiPage.
|
overridevirtual |
Called when the menu encoder is turned.
turns | The number of increments, positive is clockwise. |
stepsPerRevolution | The total number of increments per revolution on this encoder. |
Reimplemented from daisy::UiPage.
|
overridevirtual |
Called when the okay button is pressed or released.
numberOfPresses | Holds the number of successive button presses. It will be 1 on the first call and increasing by 1 with each successive call. A button down event is signaled by numberOfButtonPresses == 0. |
isRetriggering | True if the button is auto-retriggering (due to being held down) |
Reimplemented from daisy::UiPage.
|
overridevirtual |
Called when the page is added to the UI.
Reimplemented from daisy::UiPage.
|
overridevirtual |
Called when the menu encoder is turned.
turns | The number of increments, positive is clockwise. |
stepsPerRevolution | The total number of increments per revolution on this encoder. |
Reimplemented from daisy::UiPage.
Called when the value potentiometer is turned.
newPosition | The new position in the range 0 .. 1 |
Reimplemented from daisy::UiPage.
If true, the menu allows "entering" an item to modify its value with the encoder / selection buttons.
If true, the currently selected item index is "entered" so that it can be edited with the encoder/ selection buttons.
|
protected |
A list of items to include in the menu.
|
protected |
The number of items in items_
|
protected |
The orientation of the menu. This is used to determine which function the arrow keys will be assigned to.
|
protected |
The currently selected item index