combine with desktop project
Signed-off-by: Peter Siegmund <developer@mars3142.org>
This commit is contained in:
39
components/justus/include/common/PSMenu.h
Normal file
39
components/justus/include/common/PSMenu.h
Normal file
@@ -0,0 +1,39 @@
|
||||
#pragma once
|
||||
|
||||
#include <functional>
|
||||
|
||||
#include "MenuOptions.h"
|
||||
#include "Widget.h"
|
||||
#include "data/MenuItem.h"
|
||||
|
||||
typedef std::function<void(uint8_t)> MenuCallback;
|
||||
|
||||
class PSMenu : public Widget {
|
||||
public:
|
||||
explicit PSMenu(menu_options_t* options);
|
||||
~PSMenu() override;
|
||||
|
||||
void render() override;
|
||||
void onButtonClicked(uint8_t button) override;
|
||||
|
||||
void addText(const std::string& text, const MenuCallback& callback);
|
||||
void addSwitch(const std::string& text, std::string& value, const MenuCallback& callback);
|
||||
void addNumber(const std::string& text, std::string& value, const MenuCallback& callback);
|
||||
|
||||
private:
|
||||
void onPressedDown();
|
||||
void onPressedUp();
|
||||
void onPressedLeft();
|
||||
void onPressedRight();
|
||||
void onPressedSelect() const;
|
||||
void onPressedBack() const;
|
||||
|
||||
void drawScrollBar() const;
|
||||
void drawSelectionBox() const;
|
||||
|
||||
void renderWidget(uint8_t type, const uint8_t *font, int x, int y, const char *text) const;
|
||||
|
||||
size_t m_selected_item = 0;
|
||||
std::vector<MenuItem> m_items;
|
||||
menu_options_t *m_options;
|
||||
};
|
Reference in New Issue
Block a user