Viking Skull Lamp  V1.0.1
Loading...
Searching...
No Matches
menuItem Class Reference

Menu Item Class. More...

#include <menu.hpp>

Collaboration diagram for menuItem:
[legend]

Public Types

enum  encoderState_t { NEXT , UP , DOWN }
 Used for actionFunc to pass the event as an argument. More...
 
enum  menuStyle_t { NORMAL , INVERTED }
 Describes the style of the item drawing. More...
 

Public Member Functions

 menuItem (const char *name_p)
 Constructor. More...
 

Public Attributes

menuItemup = NULL
 Pointer to the upper neighbor. More...
 
menuItemdown = NULL
 Pointer to the lower neighbor. More...
 
menuItemnext = NULL
 Pointer to the next neighbor. More...
 
bool selectable = true
 If set, the item won't be selectable. More...
 
bool selected = false
 If set, a filled circle will appear on the right side, next to the item name. More...
 
enum menuStyle_t style = NORMAL
 Menu style variable. By default it is set to NORMAL. More...
 
void(* actionFunc )(enum encoderState_t state) = NULL
 Function pointer to override the button action behaviour. More...
 
void(* drawFunc )(ssd1306 *oled) = NULL
 Function pointer to override the drawing behaviour. More...
 
const char * name = NULL
 It is a pointer to a string. More...
 

Detailed Description

Menu Item Class.

This object describes an element in the menu. An element usually just a line of text. In the menu the elements are placed like a list. In normal case an element have an upper neighbor and a lower neighbor. If you scroll through the menu the selection system will use the neighborhood of the item to draw the upper and lower menus. Also there is a special neighbor called next. It will be selected when we press the button on the item. There are some other parameters but they will be described below.

Definition at line 50 of file menu.hpp.

Member Enumeration Documentation

◆ encoderState_t

Used for actionFunc to pass the event as an argument.

Enumerator
NEXT 

Encoder button pressed.

UP 

Encoder rotated up.

DOWN 

Encoder rotated down.

Definition at line 56 of file menu.hpp.

◆ menuStyle_t

Describes the style of the item drawing.

Enumerator
NORMAL 

The active pixel is lit, the inactive is black.

INVERTED 

The active pixel is black, the inactive is lit.

Definition at line 63 of file menu.hpp.

Constructor & Destructor Documentation

◆ menuItem()

menuItem::menuItem ( const char *  name_p)

Constructor.

Parameters
name_pIt is a pointer to a string. This string will be displayed in the menu.
Warning
The source of name_p argument has to be placed in PROGMEM!

Definition at line 99 of file menu.cpp.

Member Data Documentation

◆ actionFunc

void(* menuItem::actionFunc) (enum encoderState_t state) = NULL

Function pointer to override the button action behaviour.

If it's not NULL, the menu controller will call this function instead of the regular menu behaviour if any interaction happen to this item.

Definition at line 100 of file menu.hpp.

◆ down

menuItem* menuItem::down = NULL

Pointer to the lower neighbor.

Definition at line 77 of file menu.hpp.

◆ drawFunc

void(* menuItem::drawFunc) (ssd1306 *oled) = NULL

Function pointer to override the drawing behaviour.

If it's not NULL, the menu controller will call this function instead of the regular drawing behaviour. It can be useful when you nedd to control or set something.

Definition at line 107 of file menu.hpp.

◆ name

const char* menuItem::name = NULL

It is a pointer to a string.

This string will be displayed in the menu.

Warning
The source has to be placed in PROGMEM!

Definition at line 111 of file menu.hpp.

◆ next

menuItem* menuItem::next = NULL

Pointer to the next neighbor.

Definition at line 80 of file menu.hpp.

◆ selectable

bool menuItem::selectable = true

If set, the item won't be selectable.

That means the scrolling will stop before this item, and you can not reach it.

Definition at line 85 of file menu.hpp.

◆ selected

bool menuItem::selected = false

If set, a filled circle will appear on the right side, next to the item name.

It can be used to indicate that something has been activated.

Definition at line 90 of file menu.hpp.

◆ style

enum menuStyle_t menuItem::style = NORMAL

Menu style variable. By default it is set to NORMAL.

Definition at line 93 of file menu.hpp.

◆ up

menuItem* menuItem::up = NULL

Pointer to the upper neighbor.

Definition at line 74 of file menu.hpp.