Repository navigation
Expand file tree
/
Copy pathDropDown.hpp
More file actions
69 lines (58 loc) · 1.64 KB
/
Copy pathDropDown.hpp
File metadata and controls
69 lines (58 loc) · 1.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#include "Button.hpp"
#include <vector>
#include <utility>
#include <functional>
#include <string>
#include "Container.hpp"
#include "Screen.hpp"
#include "ListElement.hpp"
#ifndef DROPDOWN_HPP_
#define DROPDOWN_HPP_
namespace Chesto {
class DropDownChoices;
class DropDownControllerElement : public Screen
{
public:
void rebuildUI() override {}
};
class DropDown : public Button
{
public:
DropDown(
int physicalButton,
std::vector<std::pair<std::string, std::string>> choices,
std::function<void(std::string)> onSelect,
int textSize,
std::string defaultChoice = "",
bool isDarkMode = false
);
std::vector<std::pair<std::string, std::string>> choices;
std::function<void(std::string)> onSelect;
std::string selectedChoice; // Current selection
// element overriden functions
bool process(InputEvents* event);
};
// DropDownChoices is now a Screen that gets pushed onto the screen stack
class DropDownChoices : public Screen
{
public:
DropDownChoices(
std::vector<std::pair<std::string, std::string>> choices,
std::function<void(std::string)> onSelect,
bool isDarkMode,
std::string header = ""
);
bool process(InputEvents* event) override;
void render(Element* parent) override;
void rebuildUI() override; // Required by Screen
int curHighlighted = -1;
Container* container = nullptr; // the container that contains the actual choice elements (used for navigation)
ListElement* scrollList = nullptr; // the scrollable wrapper for everything
private:
std::vector<std::pair<std::string, std::string>> choices;
std::function<void(std::string)> onSelectCallback;
bool isDarkMode;
std::string header;
};
} // namespace Chesto
#endif