mirror of
https://github.com/jhbruhn/eurorack.git
synced 2025-03-15 11:05:49 +00:00
36 lines
708 B
C
36 lines
708 B
C
|
#pragma once
|
||
|
|
||
|
#include "menu_items.h"
|
||
|
|
||
|
#include <u8g2.h>
|
||
|
|
||
|
#define MAXIMUM_MENU_ITEM_COUNT 16
|
||
|
|
||
|
class Menu {
|
||
|
private:
|
||
|
AbstractMenuItem* items[MAXIMUM_MENU_ITEM_COUNT];
|
||
|
uint8_t itemCount;
|
||
|
uint8_t selectedItem;
|
||
|
uint8_t currentScrollStart; // index we start rendering the menu from (for scrolling)
|
||
|
int8_t currentEditingItem;
|
||
|
|
||
|
public:
|
||
|
Menu()
|
||
|
: selectedItem(0)
|
||
|
, currentScrollStart(0)
|
||
|
, currentEditingItem(-1) {};
|
||
|
|
||
|
void up();
|
||
|
void down();
|
||
|
void enter();
|
||
|
|
||
|
void add_item(AbstractMenuItem* item)
|
||
|
{
|
||
|
if (itemCount < MAXIMUM_MENU_ITEM_COUNT) {
|
||
|
items[itemCount++] = item;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
void render(u8g2_t* u8g2_, uint8_t x, uint8_t y, uint8_t width, uint8_t height);
|
||
|
};
|