Class daisy::AbstractMenu¶
ClassList > daisy > AbstractMenu
Base class for complex menus. More...
#include <AbstractMenu.h>
Inherits the following classes: daisy::UiPage
Inherited by the following classes: daisy::FullScreenItemMenu
Classes¶
Type | Name |
---|---|
class | CustomItem |
struct | ItemConfig |
Public Types¶
Type | Name |
---|---|
enum | ItemType |
enum | Orientation |
Public Functions¶
Type | Name |
---|---|
AbstractMenu () = default |
|
const ItemConfig & | GetItem (uint16_t itemIdx) const |
uint16_t | GetNumItems () const |
int16_t | GetSelectedItemIdx () const |
virtual bool | OnArrowButton (ArrowButtonType arrowType, uint8_t numberOfPresses, bool isRetriggering) override |
virtual bool | OnCancelButton (uint8_t numberOfPresses, bool isRetriggering) override |
virtual bool | OnFunctionButton (uint8_t numberOfPresses, bool isRetriggering) override |
virtual bool | OnMenuEncoderTurned (int16_t turns, uint16_t stepsPerRevolution) override |
virtual bool | OnOkayButton (uint8_t numberOfPresses, bool isRetriggering) override |
virtual void | OnShow () override |
virtual bool | OnValueEncoderTurned (int16_t turns, uint16_t stepsPerRevolution) override |
virtual bool | OnValuePotMoved (float newPosition) override |
void | SelectItem (uint16_t itemIdx) |
virtual | ~AbstractMenu () override |
Public Functions inherited from daisy::UiPage¶
See daisy::UiPage
Type | Name |
---|---|
void | Close () |
virtual void | Draw (const UiCanvasDescriptor & canvas) = 0 |
UI * | GetParentUI () |
const UI * | GetParentUI () const |
bool | IsActive () |
virtual bool | IsOpaque (const UiCanvasDescriptor & display) |
virtual bool | OnArrowButton (ArrowButtonType arrowType, uint8_t numberOfPresses, bool isRetriggering) |
virtual bool | OnButton (uint16_t buttonID, uint8_t numberOfPresses, bool isRetriggering) |
virtual bool | OnCancelButton (uint8_t numberOfPresses, bool isRetriggering) |
virtual bool | OnEncoderActivityChanged (uint16_t encoderID, bool isCurrentlyActive) |
virtual bool | OnEncoderTurned (uint16_t encoderID, int16_t turns, uint16_t stepsPerRevolution) |
virtual void | OnFocusGained () |
virtual void | OnFocusLost () |
virtual bool | OnFunctionButton (uint8_t numberOfPresses, bool isRetriggering) |
virtual void | OnHide () |
virtual bool | OnMenuEncoderActivityChanged (bool isCurrentlyActive) |
virtual bool | OnMenuEncoderTurned (int16_t turns, uint16_t stepsPerRevolution) |
virtual bool | OnOkayButton (uint8_t numberOfPresses, bool isRetriggering) |
virtual bool | OnPotActivityChanged (uint16_t potID, bool isCurrentlyActive) |
virtual bool | OnPotMoved (uint16_t potID, float newPosition) |
virtual void | OnShow () |
virtual void | OnUserInteraction () |
virtual bool | OnValueEncoderActivityChanged (bool isCurrentlyActive) |
virtual bool | OnValueEncoderTurned (int16_t turns, uint16_t stepsPerRevolution) |
virtual bool | OnValuePotActivityChanged (bool isCurrentlyActive) |
virtual bool | OnValuePotMoved (float newPosition) |
UiPage () |
|
virtual | ~UiPage () |
Protected Attributes¶
Type | Name |
---|---|
bool | allowEntering_ = [**true**](classdaisy_1_1Apds9960.md) |
bool | isEditing_ = [**false**](classdaisy_1_1Apds9960.md) |
const ItemConfig * | items_ = [**nullptr**](classdaisy_1_1Apds9960.md) |
uint16_t | numItems_ = 0 |
Orientation | orientation_ = Orientation::upDownSelectLeftRightModify |
int16_t | selectedItemIdx_ = -1 |
Protected Functions¶
Type | Name |
---|---|
void | Init (const ItemConfig * items, uint16_t numItems, Orientation orientation, bool allowEntering) |
bool | IsFunctionButtonDown () const |
Detailed Description¶
Author:
jelliesen
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. * Checkbox items to toggle something on/off, * Generic action items that call a function when activated, * Value editing items for editing int/float/enum values, * Close items that close the menu when activated (useful when no cancel button is available), * Custom items that do whatever you want them to do, by providing a CustomItem object that handles the item-specific functionality.
The Abstract Menu can work with a wide variety of physical controls, here are a couple of combinations that are possible: * 3 buttons: Left/Right to select and edit items, Ok to activate or enter/leave editing mode * 5 buttons: Up/Down to select, Ok to activate/enter/leave, Cancel to close menu, function button to use coarse step size when editing * 6 buttons: Left/Right to select, Up/Down to quickly edit selected items, Ok/Cancel to enter/leave * 1 encoder with pushbutton * 1 encoder for selecting items, another one for editing their values * 1 encoder for selecting items and a value slider potentiometer for editing * ... any other combination of the above
These are the controls that the AbstractMenu will react to and their associated function:
* Left/Right buttons: Select items when Orientation::leftRightSelectUpDownModify
, directly edit value of the selected item when Orientation::upDownSelectLeftRightModify
.
* Up/Down buttons: Select items when Orientation::upDownSelectLeftRightModify
, directly edit value of the selected item when Orientation::leftRightSelectUpDownModify
.
* Ok button: Activate the action of the selected item (if it has an action, e.g. 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
).
* Cancel button: Closes the menu page or leaves editing mode
* Menu encoder: Selects items; edits item value when in editing mode
* Value Encoder: Edits value of selected item
* Value potentiometer/slider: Edits value of selected item
* Function button: Uses an alternate step size when modifying the value with encoders or buttons while pressed
Public Types Documentation¶
enum ItemType¶
enum daisy::AbstractMenu::ItemType {
callbackFunctionItem,
checkboxItem,
valueItem,
openUiPageItem,
closeMenuItem,
customItem
};
The types of entries that can be added to the menu.
enum Orientation¶
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).
See also: AbstractMenuPage
Public Functions Documentation¶
function AbstractMenu [½]¶
function GetItem¶
function GetNumItems¶
function GetSelectedItemIdx¶
function OnArrowButton¶
virtual bool daisy::AbstractMenu::OnArrowButton (
ArrowButtonType arrowType,
uint8_t numberOfPresses,
bool isRetriggering
) override
Called when an arrow button is pressed or released.
Parameters:
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)
Returns:
false, if you want the event to be passed on to the page below.
Implements daisy::UiPage::OnArrowButton
function OnCancelButton¶
virtual bool daisy::AbstractMenu::OnCancelButton (
uint8_t numberOfPresses,
bool isRetriggering
) override
Called when the cancel button is pressed or released.
Parameters:
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)
Returns:
false, if you want the event to be passed on to the page below.
Implements daisy::UiPage::OnCancelButton
function OnFunctionButton¶
virtual bool daisy::AbstractMenu::OnFunctionButton (
uint8_t numberOfPresses,
bool isRetriggering
) override
Called when the function button is pressed or released.
Parameters:
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)
Returns:
false, if you want the event to be passed on to the page below.
Implements daisy::UiPage::OnFunctionButton
function OnMenuEncoderTurned¶
virtual bool daisy::AbstractMenu::OnMenuEncoderTurned (
int16_t turns,
uint16_t stepsPerRevolution
) override
Called when the menu encoder is turned.
Parameters:
turns
The number of increments, positive is clockwise.stepsPerRevolution
The total number of increments per revolution on this encoder.
Returns:
false, if you want the event to be passed on to the page below.
Implements daisy::UiPage::OnMenuEncoderTurned
function OnOkayButton¶
virtual bool daisy::AbstractMenu::OnOkayButton (
uint8_t numberOfPresses,
bool isRetriggering
) override
Called when the okay button is pressed or released.
Parameters:
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)
Returns:
false, if you want the event to be passed on to the page below.
Implements daisy::UiPage::OnOkayButton
function OnShow¶
Called when the page is added to the UI.
Implements daisy::UiPage::OnShow
function OnValueEncoderTurned¶
virtual bool daisy::AbstractMenu::OnValueEncoderTurned (
int16_t turns,
uint16_t stepsPerRevolution
) override
Called when the menu encoder is turned.
Parameters:
turns
The number of increments, positive is clockwise.stepsPerRevolution
The total number of increments per revolution on this encoder.
Returns:
false, if you want the event to be passed on to the page below.
Implements daisy::UiPage::OnValueEncoderTurned
function OnValuePotMoved¶
Called when the value potentiometer is turned.
Parameters:
newPosition
The new position in the range 0 .. 1
Returns:
false, if you want the event to be passed on to the page below.
Implements daisy::UiPage::OnValuePotMoved
function SelectItem¶
function ~AbstractMenu¶
Protected Attributes Documentation¶
variable allowEntering_¶
If true, the menu allows "entering" an item to modify its value with the encoder / selection buttons.
variable isEditing_¶
If true, the currently selected item index is "entered" so that it can be edited with the encoder/ selection buttons.
variable items_¶
A list of items to include in the menu.
variable numItems_¶
The number of items in items_
variable orientation_¶
The orientation of the menu. This is used to determine which function the arrow keys will be assigned to.
variable selectedItemIdx_¶
The currently selected item index
Protected Functions Documentation¶
function Init¶
void daisy::AbstractMenu::Init (
const ItemConfig * items,
uint16_t numItems,
Orientation orientation,
bool allowEntering
)
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.
Parameters:
items
An array of ItemConfig that determine which items are available in the menu.numItems
The number of items in theitems
array.orientation
Controls which pair of arrow buttons are used for selection / editingallowEntering
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.
function IsFunctionButtonDown¶
Returns the state of the function button.
The documentation for this class was generated from the following file external-docs/libDaisy/src/ui/AbstractMenu.h