53 lines
1.0 KiB
C++
53 lines
1.0 KiB
C++
#ifndef __menuscreen
|
|
#define __menuscreen
|
|
|
|
#include "screen.h"
|
|
|
|
class MenuItem
|
|
{
|
|
public:
|
|
virtual ~MenuItem() { }
|
|
|
|
virtual const char* getTitle() = 0;
|
|
virtual const char* getValue() { return NULL; }
|
|
|
|
virtual bool editable() { return false; }
|
|
|
|
// Editable = true
|
|
virtual bool canIncrement() { return true; }
|
|
virtual bool canDecrement() { return true; }
|
|
virtual void incrementValue() { }
|
|
virtual void decrementValue() { }
|
|
|
|
// Editable = false
|
|
virtual void execute(ScreenManager* screenManager, uint32_t currentTime) { }
|
|
};
|
|
|
|
class MenuScreen : public BaseScreen
|
|
{
|
|
private:
|
|
uint8_t mCount;
|
|
MenuItem** mItems;
|
|
uint8_t mSelected = 0;
|
|
bool mEditing = false;
|
|
|
|
protected:
|
|
void printFullUpdate();
|
|
|
|
void printTitle();
|
|
void printScrollIndicators();
|
|
void printValue();
|
|
|
|
public:
|
|
MenuScreen(ScreenManager* screenManager);
|
|
~MenuScreen();
|
|
|
|
void onShow();
|
|
void onHide();
|
|
|
|
void onButton();
|
|
void onEncoder(int32_t lastPosition, int32_t newPosition);
|
|
void onTick();
|
|
};
|
|
|
|
#endif |