libDaisy
Hardware Library for Daisy
Loading...
Searching...
No Matches
daisy::FullScreenItemMenu Class Reference

A menu page for small screens. More...

Detailed Description

A menu page for small screens.

Author
jelliesen

This class builds upon the menu logic of AbstractMenu and adds drawing routines that are suitable for small screens.

By default, it will paint to the canvas returned by UI::GetPrimaryOneBitGraphicsDisplayId(). It can also be configured to paint to a different canvas.

Each item will occupy the entire display. FullScreenItemMenu uses the LookAndFeel system to draw draw the items. This means that you can create your own graphics design by creating your own LookAndFeel based on the OneBitGraphicsLookAndFeel class and apply that either globally (UI::SetOneBitGraphicsLookAndFeel()) or to this page only (UiPage::SetOneBitGraphicsLookAndFeel()).

#include <FullScreenItemMenu.h>

Inheritance diagram for daisy::FullScreenItemMenu:
daisy::AbstractMenu daisy::UiPage

Public Member Functions

void Init (const AbstractMenu::ItemConfig *items, uint16_t numItems, AbstractMenu::Orientation orientation=AbstractMenu::Orientation::leftRightSelectUpDownModify, bool allowEntering=true)
 
void SetOneBitGraphicsDisplayToDrawTo (uint16_t canvasId)
 
void Draw (const UiCanvasDescriptor &canvas) override
 
- Public Member Functions inherited from daisy::AbstractMenu
 AbstractMenu ()=default
 
virtual ~AbstractMenu () override
 
uint16_t GetNumItems () const
 
const ItemConfigGetItem (uint16_t itemIdx) const
 
void SelectItem (uint16_t itemIdx)
 
int16_t GetSelectedItemIdx () const
 
bool OnOkayButton (uint8_t numberOfPresses, bool isRetriggering) override
 
bool OnCancelButton (uint8_t numberOfPresses, bool isRetriggering) override
 
bool OnArrowButton (ArrowButtonType arrowType, uint8_t numberOfPresses, bool isRetriggering) override
 
bool OnFunctionButton (uint8_t numberOfPresses, bool isRetriggering) override
 
bool OnMenuEncoderTurned (int16_t turns, uint16_t stepsPerRevolution) override
 
bool OnValueEncoderTurned (int16_t turns, uint16_t stepsPerRevolution) override
 
bool OnValuePotMoved (float newPosition) override
 
void OnShow () override
 
- Public Member Functions inherited from daisy::UiPage
 UiPage ()
 
virtual ~UiPage ()
 
virtual bool IsOpaque (const UiCanvasDescriptor &display)
 
bool IsActive ()
 
virtual void OnUserInteraction ()
 
void Close ()
 
virtual bool OnButton (uint16_t buttonID, uint8_t numberOfPresses, bool isRetriggering)
 
virtual bool OnEncoderTurned (uint16_t encoderID, int16_t turns, uint16_t stepsPerRevolution)
 
virtual bool OnMenuEncoderActivityChanged (bool isCurrentlyActive)
 
virtual bool OnValueEncoderActivityChanged (bool isCurrentlyActive)
 
virtual bool OnEncoderActivityChanged (uint16_t encoderID, bool isCurrentlyActive)
 
virtual bool OnPotMoved (uint16_t potID, float newPosition)
 
virtual bool OnValuePotActivityChanged (bool isCurrentlyActive)
 
virtual bool OnPotActivityChanged (uint16_t potID, bool isCurrentlyActive)
 
virtual void OnHide ()
 
virtual void OnFocusGained ()
 
virtual void OnFocusLost ()
 
UIGetParentUI ()
 
const UIGetParentUI () const
 

Additional Inherited Members

- Public Types inherited from daisy::AbstractMenu
enum class  Orientation { leftRightSelectUpDownModify , upDownSelectLeftRightModify }
 
enum class  ItemType {
  callbackFunctionItem , checkboxItem , valueItem , openUiPageItem ,
  closeMenuItem , customItem
}
 
- Protected Member Functions inherited from daisy::AbstractMenu
void Init (const ItemConfig *items, uint16_t numItems, Orientation orientation, bool allowEntering)
 
bool IsFunctionButtonDown () const
 
- Protected Attributes inherited from daisy::AbstractMenu
Orientation orientation_ = Orientation::upDownSelectLeftRightModify
 
const ItemConfigitems_ = nullptr
 
uint16_t numItems_ = 0
 
int16_t selectedItemIdx_ = -1
 
bool allowEntering_ = true
 
bool isEditing_ = false
 

Member Function Documentation

◆ Draw()

void daisy::FullScreenItemMenu::Draw ( const UiCanvasDescriptor canvas)
overridevirtual

Called to make the UIPage repaint everything on a canvas. Check the ID to determine which display this corresponds to. Cast the handle to the corresponding type and do your draw operations on it.

Implements daisy::UiPage.

◆ Init()

void daisy::FullScreenItemMenu::Init ( const AbstractMenu::ItemConfig items,
uint16_t  numItems,
AbstractMenu::Orientation  orientation = AbstractMenu::Orientation::leftRightSelectUpDownModify,
bool  allowEntering = true 
)

Call this to initialize the menu. It's okay to re-initialize a FullScreenItemMenu multiple times, even while it's displayed on the UI.

Parameters
itemsAn array of ItemConfig that determine which items are available in the menu.
numItemsThe number of items in the items array.
orientationControls which pair of arrow buttons are used for selection / editing
allowEnteringGlobally 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.

◆ SetOneBitGraphicsDisplayToDrawTo()

void daisy::FullScreenItemMenu::SetOneBitGraphicsDisplayToDrawTo ( uint16_t  canvasId)

Call this to change which canvas this menu will draw to. The canvas must be a OneBitGraphicsDisplay, e.g. the OledDisplay class. If canvasId == UI::invalidCanvasId then this menu will draw to the canvas returned by UI::GetPrimaryOneBitGraphicsDisplayId(). This is also the default behaviour.


The documentation for this class was generated from the following file: