libDaisy
Hardware Library for Daisy
Loading...
Searching...
No Matches
AbstractMenu.h
Go to the documentation of this file.
1#pragma once
2
3#include "hid/disp/display.h"
4#include "util/MappedValue.h"
5#include "UI.h"
6
7namespace daisy
8{
55class AbstractMenu : public UiPage
56{
57 public:
71
92
95 {
96 public:
97 virtual ~CustomItem() {}
98
106 virtual void Draw(OneBitGraphicsDisplay& display,
107 int currentIndex,
108 int numItemsTotal,
110 bool isEditing)
111 = 0;
112
114 virtual bool CanBeEnteredForEditing() const { return false; }
115
120 {
121 (void)(increments); // silence unused variable warnings
122 (void)(stepsPerRevolution); // silence unused variable warnings
123 (void)(isFunctionButtonPressed); // silence unused variable warnings
124 };
125
129 {
130 (void)(valueSliderPosition0To1); // silence unused variable warnings
131 (void)(isFunctionButtonPressed); // silence unused variable warnings
132 };
133
135 virtual void OnOkayButton(){};
136 };
137
139 {
143 const char* text = "";
144
146 union
147 {
149 struct
150 {
152 void* context;
154
156 struct
157 {
161
163 struct
164 {
168
170 struct
171 {
177
179 struct
180 {
185 };
186 };
187
188 AbstractMenu() = default;
189 virtual ~AbstractMenu() override {}
190
191 uint16_t GetNumItems() const { return numItems_; }
193 {
194 return items_[itemIdx];
195 }
198
199 // inherited from UiPage
204 bool isRetriggering) override;
206 bool isRetriggering) override;
211 bool OnValuePotMoved(float newPosition) override;
212 void OnShow() override;
213
214 protected:
230 void Init(const ItemConfig* items,
233 bool allowEntering);
234
236 bool IsFunctionButtonDown() const { return isFuncButtonDown_; }
237
242 const ItemConfig* items_ = nullptr;
249 bool allowEntering_ = true;
253 bool isEditing_ = false;
254
255 private:
256 AbstractMenu(const AbstractMenu& other) = delete;
257 AbstractMenu& operator=(const AbstractMenu& other) = delete;
258
259 bool CanItemBeEnteredForEditing(uint16_t itemIdx);
260 void ModifyItemValue(uint16_t itemIdx,
264 void ModifyItemValue(uint16_t itemIdx,
267 void TriggerItemAction(uint16_t itemIdx);
268
269 bool isFuncButtonDown_ = false;
270};
271
272
273} // namespace daisy
Definition AbstractMenu.h:95
virtual ~CustomItem()
Definition AbstractMenu.h:97
virtual void ModifyValue(int16_t increments, uint16_t stepsPerRevolution, bool isFunctionButtonPressed)
Definition AbstractMenu.h:117
virtual void ModifyValue(float valueSliderPosition0To1, bool isFunctionButtonPressed)
Definition AbstractMenu.h:127
virtual void OnOkayButton()
Definition AbstractMenu.h:135
virtual void Draw(OneBitGraphicsDisplay &display, int currentIndex, int numItemsTotal, Rectangle boundsToDrawIn, bool isEditing)=0
virtual bool CanBeEnteredForEditing() const
Definition AbstractMenu.h:114
Base class for complex menus.
Definition AbstractMenu.h:56
void OnShow() override
bool OnCancelButton(uint8_t numberOfPresses, bool isRetriggering) override
void SelectItem(uint16_t itemIdx)
AbstractMenu()=default
uint16_t numItems_
Definition AbstractMenu.h:244
virtual ~AbstractMenu() override
Definition AbstractMenu.h:189
bool isEditing_
Definition AbstractMenu.h:253
const ItemConfig & GetItem(uint16_t itemIdx) const
Definition AbstractMenu.h:192
uint16_t GetNumItems() const
Definition AbstractMenu.h:191
int16_t selectedItemIdx_
Definition AbstractMenu.h:246
ItemType
Definition AbstractMenu.h:74
void Init(const ItemConfig *items, uint16_t numItems, Orientation orientation, bool allowEntering)
bool OnValuePotMoved(float newPosition) override
Orientation orientation_
Definition AbstractMenu.h:240
bool OnOkayButton(uint8_t numberOfPresses, bool isRetriggering) override
Orientation
Definition AbstractMenu.h:65
bool OnValueEncoderTurned(int16_t turns, uint16_t stepsPerRevolution) override
const ItemConfig * items_
Definition AbstractMenu.h:242
int16_t GetSelectedItemIdx() const
Definition AbstractMenu.h:197
bool OnArrowButton(ArrowButtonType arrowType, uint8_t numberOfPresses, bool isRetriggering) override
bool OnMenuEncoderTurned(int16_t turns, uint16_t stepsPerRevolution) override
bool OnFunctionButton(uint8_t numberOfPresses, bool isRetriggering) override
bool allowEntering_
Definition AbstractMenu.h:249
bool IsFunctionButtonDown() const
Definition AbstractMenu.h:236
Definition leddriver.h:33
Definition MappedValue.h:12
Definition display.h:20
Definition graphics_common.h:22
The base class for a page in the UI system.
Definition UI.h:75
ArrowButtonType
The type of arrow button in the UI system.
Definition UI.h:15
Hardware defines and helpers for daisy field platform.
Definition index.h:2
Definition AbstractMenu.h:139
ItemType type
Definition AbstractMenu.h:141
UiPage * pageToOpen
Definition AbstractMenu.h:175
void(* callbackFunction)(void *context)
Definition AbstractMenu.h:151
struct daisy::AbstractMenu::ItemConfig::@21::@25 asMappedValueItem
struct daisy::AbstractMenu::ItemConfig::@21::@24 asCheckboxItem
struct daisy::AbstractMenu::ItemConfig::@21::@26 asOpenUiPageItem
bool * valueToModify
Definition AbstractMenu.h:159
const char * text
Definition AbstractMenu.h:143
struct daisy::AbstractMenu::ItemConfig::@21::@27 asCustomItem
MappedValue * valueToModify
Definition AbstractMenu.h:166
CustomItem * itemObject
Definition AbstractMenu.h:183
struct daisy::AbstractMenu::ItemConfig::@21::@23 asCallbackFunctionItem
void * context
Definition AbstractMenu.h:152