daisy::UI¶
#include <UI.h>
Public Classes¶
Name | |
---|---|
struct | SpecialControlIds |
Public Functions¶
Name | |
---|---|
UI() | |
~UI() | |
void | Init(UiEventQueue & inputQueue, const SpecialControlIds & specialControlIds, std::initializer_list< UiCanvasDescriptor > canvases, uint16_t primaryOneBitGraphicsDisplayId =invalidCanvasId) |
void | Process() |
void | Mute(bool shouldBeMuted, bool queueEvents =false) |
void | OpenPage(UiPage & page) |
void | ClosePage(UiPage & page) |
uint16_t | GetPrimaryOneBitGraphicsDisplayId() const |
SpecialControlIds | GetSpecialControlIds() const |
Public Attributes¶
Name | |
---|---|
constexpr uint16_t | invalidCanvasId |
Detailed Description¶
A generic UI system.
Author: jelliesen
This system allows you to create complex and dynamic user interfaces with menus, pages and dialogs. It holds a stack of pages. Each page can react to user input on buttons, potentiometers, and encoders while drawing to one or multiple displays, leds or other output devices.
User input is consumed from a UiEventQueue and distributed to the pages from the top down. If a page doesn't handle an event, it will be forwarded to the next page below.
Pages are drawn from the bottom up. Multiple abstract canvases can be used for the drawing, where each canvas could be a graphics display, LEDs, alphanumeric displays, etc. The UI system makes sure that drawing is executed with a constant refresh rate that can be individually specified for each canvas.
Public Functions Documentation¶
function UI¶
function ~UI¶
function Init¶
void Init(
UiEventQueue & inputQueue,
const SpecialControlIds & specialControlIds,
std::initializer_list< UiCanvasDescriptor > canvases,
uint16_t primaryOneBitGraphicsDisplayId =invalidCanvasId
)
Parameters:
- inputQueue The UiEventQueue to read user input events from.
- specialControlIds Information about the control IDs used for special buttons/encoders/pots.
- canvases A list of UiCanvasDescriptor that define which canvases to use.
- primaryOneBitGraphicsDisplayId The ID of a OneBitGraphicsDisplay canvas that should be used as the main display. Menus will draw to this canvas. If no such dispaly is available, use Ui::invalidCanvasId.
Initializes the UI.
function Process¶
Call this regularly to allow processing user input, redraw canvases and do other "housekeeping" work. This is best done from a low priority context, ideally from your main() idle loop.
function Mute¶
Call this to temporarily disable processing of user input, e.g. while a project is loading. If queueEvents==true, all user input that happens while muted will be queued up and processed when the mute state is removed. If queueEvents==false, all user input that happens while muted will be discarded.
function OpenPage¶
Adds a new UIPage on the top of the stack of UI pages without taking ownership of the object. The new page is set to be visible. The page must stay alive until it was removed from the UI. It's best to have each page statically allocated as a global variable.
function ClosePage¶
Called to close a page.
function GetPrimaryOneBitGraphicsDisplayId¶
If this UI has a canvas that uses a OneBitGraphicsDisplay AND this canvas should be used as the main display for menus, etc. then this function returns the canvas ID of this display. If no such canvas exists, this function returns UI::invalidCanvasId.
function GetSpecialControlIds¶
Returns the button IDs, encoder IDs and pot IDs used for special functions.
Public Attributes Documentation¶
variable invalidCanvasId¶
Use this to denote a nonexistent / invalid canvas ID
Updated on 2024-01-03 at 19:41:01 +0000