tcMenu
Classes | Typedefs | Functions
MenuIterator.h File Reference

Provides a number of utility functions for the processing of menu item structures. More...

Go to the source code of this file.

Classes

class  MenuItemPredicate
 
class  RemoteNoMenuItemPredicate
 
class  MenuItemTypePredicate
 
class  MenuItemIterator
 

Typedefs

typedef void(* MenuVisitorFn) (MenuItem *item)
 

Functions

MenuItemgetParentRootAndVisit (MenuItem *current, MenuVisitorFn visitor)
 
MenuItemgetParentRoot (MenuItem *current)
 
MenuItemgetSubMenuFor (MenuItem *current)
 
MenuItemgetMenuItemById (menuid_t id)
 
int offsetOfCurrentActive (MenuItem *root)
 
int offsetOfItem (MenuItem *itemToFind)
 
uint8_t itemCount (MenuItem *item, bool includeNonVisble=false)
 

Detailed Description

Provides a number of utility functions for the processing of menu item structures.

Typedef Documentation

◆ MenuVisitorFn

typedef void(* MenuVisitorFn) (MenuItem *item)

defines a function used when needing to visit all menu items

Function Documentation

◆ getParentRootAndVisit()

MenuItem* getParentRootAndVisit ( MenuItem current,
MenuVisitorFn  visitor 
)

Finds the parent root menu item to the item that's passed in, that is the root item that contains this menu item. Normally used by protocol and display layers when there's a need to traverse the menu structure. This version is also able to provide a function that will visit each element in the tree. It will always visit every item.

Parameters
currentthe menu item that is currently menu root
Returns
the parent menu item to the present menu item

◆ getParentRoot()

MenuItem* getParentRoot ( MenuItem current)
inline

Finds the parent root menu item to the item that's passed in, that is the root item that contains this menu item. This version will short circuit out of the traversal as soon as the item is found. Never returns NULL.

Parameters
currentthe menu item that is currently menu root
Returns
the parent menu item to the present menu item, returns root instead of NULL.

◆ getSubMenuFor()

MenuItem* getSubMenuFor ( MenuItem current)

Finds the submenu that a particular menu item belongs to, or nullptr

Parameters
currentthe menuitem that we are searching for
Returns
the submenu or nullptr if it was in the root.

◆ getMenuItemById()

MenuItem* getMenuItemById ( menuid_t  id)

Gets the first match by ID of a menu item in the menu structure.

Parameters
theID to locate the menu item for
Returns
the menu item associated or NULL.

◆ offsetOfCurrentActive()

int offsetOfCurrentActive ( MenuItem root)

Gets the zero based offset of the active item in the menu provided

Parameters
rootthe root of the current menu
Returns
the offset from zero of the item

◆ offsetOfItem()

int offsetOfItem ( MenuItem itemToFind)

Get the offset in the menu of the given item, but safely returns 0 if not the item is not found

Parameters
itemToFindthe item to be found
Returns
the position, or 0 if not there

◆ itemCount()

uint8_t itemCount ( MenuItem item,
bool  includeNonVisble = false 
)

returns the number of items in the current menu described by itemCount

Parameters
itemthe root item of the menu to be counted.
includeNonVisbleinclude menu items that are not marked visible
Returns
the number of items, may include only visible ones depending on flag