esp32 firmware for a toaster reflow oven WIP!!!!!
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
reflower/main/scenes/scene_menu.h

66 lines
1.5 KiB

/**
* Scrollable menu
*
* Created on 2020/01/05.
*/
#ifndef REFLOWER_SCENE_MENU_H
#define REFLOWER_SCENE_MENU_H
#include <stdint.h>
#include <stddef.h>
#define MENUITEM_LABEL_LEN 30
/**
* One item of the menu
*/
struct MenuItem {
// menu label
char label[MENUITEM_LABEL_LEN];
// item tag (useful with dynamically generated menus)
uint32_t tag;
};
struct MenuScene;
/**
* Selection handler.
*
* When an item is selected, this abstract method is fired to determine what should happen.
*
* The selected item is available as scene.selected.
* Return SceneEvent to take, e.g. to close the menu, or to open a sub-scene.
*/
typedef struct SceneEvent (*MenuScene_onSelect_t)(struct MenuScene *scene);
struct MenuScene {
struct Scene base;
// items array
struct MenuItem *items;
// items count
size_t items_len;
// Vertical scroll offset (how many steps is the topmost item moved above the screen)
int32_t scroll_up;
// Selected item number
int32_t selected;
// selection handler
MenuScene_onSelect_t onSelect;
// Extra field for the subclass's private use.
void *extra;
// fp for extra's deinit function
Scene_deinit_t extra_deinit;
};
/**
* Create a new items menu.
*
* This is normally called from a subclass.
*
* @param items - menu items on heap (the MenuScene will free them on close)
* @param items_len - item count
* @return the menu
*/
struct MenuScene *NewScene_Menu(struct MenuItem *items, size_t items_len);
#endif //REFLOWER_SCENE_MENU_H