LCDGFX LCD display driver  1.2.0
Lightweight graphics library for SSD1306, SSD1325, SSD1327, SSD1331, SSD1351, SH1106, SH1107, IL9163, ST7735, ST7789, ILI9341, PCD8544 displays over I2C/SPI

Class implements menu objects for lcdgfx library. More...

#include <menu.h>

Public Member Functions

 LcdGfxMenu (const char **items, uint8_t count, const NanoRect &rect={})
 Creates menu object with the provided list of menu items. More...
 
template<typename D >
void update (D &d)
 Equivalent to show(). More...
 
void invalidate ()
 Forces the next show() to perform a full redraw (border + all visible items + scroll indicators). More...
 
void down ()
 Moves selection pointer down by 1 item. More...
 
void up ()
 Moves selection pointer up by 1 item. More...
 
uint8_t selection ()
 Returns currently selected menu item. More...
 
void setSelection (uint8_t s)
 
void setRect (const NanoRect &rect={})
 Sets rect area for the menu. More...
 
uint8_t size ()
 Returns total count of menu items in menu.
 
template<typename D >
void updateSize (D &d)
 Updates size of the object, if it was not set previously.
 
template<typename D >
uint8_t itemAtPoint (D &d, lcdint_t x, lcdint_t y)
 Returns the menu item index at the given screen coordinate, or 0xFF if the point lies outside any item row (e.g. More...
 
template<typename D >
bool onTouch (D &d, lcdint_t x, lcdint_t y)
 Handles a touch event at the given screen coordinates. More...
 
template<typename D >
void show (D &d)
 Shows menu items on the display. More...
 

Detailed Description

Class implements menu objects for lcdgfx library.

Definition at line 54 of file menu.h.

Constructor & Destructor Documentation

◆ LcdGfxMenu()

LcdGfxMenu::LcdGfxMenu ( const char **  items,
uint8_t  count,
const NanoRect rect = {} 
)

Creates menu object with the provided list of menu items.

List of menu items (strings) must exist all until menu object is no longer needed. Selection is set to the first item by default.

Parameters
itemsarray of null-termintated strings (located in SRAM)
countcount of menu items in the array
rectscreen area to use for menu

Member Function Documentation

◆ down()

void LcdGfxMenu::down ( )

Moves selection pointer down by 1 item.

If there are no items below, it will set selection pointer to the first item. Use show() to refresh menu state on the display.

◆ invalidate()

void LcdGfxMenu::invalidate ( )
inline

Forces the next show() to perform a full redraw (border + all visible items + scroll indicators).

Use this when the surrounding screen has been cleared / repainted by other code and the menu needs to repaint its border too.

Definition at line 96 of file menu.h.

◆ itemAtPoint()

template<typename D >
uint8_t LcdGfxMenu::itemAtPoint ( D &  d,
lcdint_t  x,
lcdint_t  y 
)
inline

Returns the menu item index at the given screen coordinate, or 0xFF if the point lies outside any item row (e.g.

on the border or scroll indicators).

Parameters
ddisplay object (needed for font metrics)
xscreen x coordinate
yscreen y coordinate

Definition at line 156 of file menu.h.

◆ onTouch()

template<typename D >
bool LcdGfxMenu::onTouch ( D &  d,
lcdint_t  x,
lcdint_t  y 
)
inline

Handles a touch event at the given screen coordinates.

Touches in the empty band between the border and the first/last item scroll the menu by one item (when more items are available in that direction). Touches on an item row select that item. Returns true if the touch was handled.

Call show() afterwards to refresh the display.

Parameters
ddisplay object
xscreen x coordinate of the touch
yscreen y coordinate of the touch

Definition at line 186 of file menu.h.

◆ selection()

uint8_t LcdGfxMenu::selection ( )

Returns currently selected menu item.

First item has zero-index.

◆ setRect()

void LcdGfxMenu::setRect ( const NanoRect rect = {})

Sets rect area for the menu.

Parameters
rectrect area to use for menu

◆ show()

template<typename D >
void LcdGfxMenu::show ( D &  d)

Shows menu items on the display.

If menu items cannot fit the display, the function provides scrolling.

The first call after construction (or after invalidate() / setRect()) performs a full redraw (border, every visible item, scroll indicators). Subsequent calls are flicker-free: when the selection moved within the already-visible window only the previously- and newly-selected item rows are redrawn; the border and untouched items are left alone. When the visible window changes (selection scrolls off-screen) a full redraw is performed automatically.

Parameters
ddisplay object

Definition at line 305 of file menu.h.

◆ up()

void LcdGfxMenu::up ( )

Moves selection pointer up by 1 item.

If selected item is the first one, then selection pointer will set to the last item in menu list. Use show() to refresh menu state on the display.

◆ update()

template<typename D >
void LcdGfxMenu::update ( D &  d)
inline

Equivalent to show().

Provided for backward compatibility and code that wants to make the incremental-refresh intent explicit.

Definition at line 88 of file menu.h.


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