Deluge Firmware
1.3.0
Build date: 2026.07.30
Toggle main menu visibility
Loading...
Searching...
No Matches
selection.h
1
/*
2
* Copyright © 2017-2023 Synthstrom Audible Limited
3
*
4
* This file is part of The Synthstrom Audible Deluge Firmware.
5
*
6
* The Synthstrom Audible Deluge Firmware is free software: you can redistribute it and/or modify it under the
7
* terms of the GNU General Public License as published by the Free Software Foundation,
8
* either version 3 of the License, or (at your option) any later version.
9
*
10
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
11
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12
* See the GNU General Public License for more details.
13
*
14
* You should have received a copy of the GNU General Public License along with this program.
15
* If not, see <https://www.gnu.org/licenses/>.
16
*/
17
18
#pragma once
19
20
#include "gui/menu_item/enumeration.h"
21
#include "gui/ui/sound_editor.h"
22
#include "util/containers.h"
23
#include <string_view>
24
25
namespace
deluge::gui::menu_item {
26
class
Selection
:
public
Enumeration
{
27
public
:
28
using
Enumeration::Enumeration;
29
30
enum class
OptType { FULL, SHORT };
31
virtual
deluge::vector<std::string_view> getOptions(OptType optType = OptType::FULL) = 0;
32
33
void
drawValue()
override
;
34
35
void
drawPixelsForOled
()
override
;
36
size_t
size()
override
{
return
this->getOptions().size(); }
37
38
virtual
bool
isToggle() {
return
false
; }
39
40
void
displayToggleValue();
41
42
// renders toggle item type in submenus after the item name
43
void
renderSubmenuItemTypeForOled(int32_t yPixel)
override
;
44
45
// toggles boolean ON / OFF
46
void
toggleValue() {
47
if
(isToggle()) {
48
readCurrentValue
();
49
setValue(!getValue());
50
writeCurrentValue();
51
}
52
};
53
54
// handles toggling a "toggle" selection menu from sub-menu level
55
// or handles going back up a level after making a selection from within selection menu
56
MenuItem*
selectButtonPress
()
override
{
57
// this is true if you open a selection menu using grid shortcut
58
// or you enter a selection menu that isn't a toggle
59
if
(soundEditor.getCurrentMenuItem() ==
this
) {
60
return
nullptr
;
// go up a level
61
}
62
// you're toggling selection menu from submenu level
63
toggleValue();
64
displayToggleValue();
65
return
NO_NAVIGATION;
66
}
67
68
// get's toggle status for rendering checkbox on OLED
69
bool
getToggleValue() {
70
readCurrentValue
();
71
return
this->getValue();
72
}
73
74
// get's toggle status for rendering dot on 7SEG
75
uint8_t
shouldDrawDotOnName
()
override
{
76
if
(isToggle()) {
77
readCurrentValue
();
78
return
this->getValue() ? 3 : 255;
79
}
80
else
{
81
return
255;
82
}
83
}
84
85
protected
:
86
void
getShortOption
(
StringBuf
&)
override
;
87
void
getNotificationValue
(
StringBuf
&)
override
;
88
};
89
}
// namespace deluge::gui::menu_item
MenuItem::readCurrentValue
virtual void readCurrentValue()
Like readValueAgain, but does not redraw.
Definition
menu_item.h:131
StringBuf
Definition
d_stringbuf.h:16
deluge::gui::menu_item::Enumeration
An enumeration has a fixed number of items, with values from 1 to n (exclusive).
Definition
enumeration.h:9
deluge::gui::menu_item::Selection
Definition
selection.h:26
deluge::gui::menu_item::Selection::selectButtonPress
MenuItem * selectButtonPress() override
Handle a select button press.
Definition
selection.h:56
deluge::gui::menu_item::Selection::drawPixelsForOled
void drawPixelsForOled() override
Paints the pixels below the standard title block.
Definition
selection.cpp:18
deluge::gui::menu_item::Selection::getShortOption
void getShortOption(StringBuf &) override
Definition
selection.cpp:73
deluge::gui::menu_item::Selection::getNotificationValue
void getNotificationValue(StringBuf &) override
Get the parameter value string to show in the popup.
Definition
selection.cpp:77
deluge::gui::menu_item::Selection::shouldDrawDotOnName
uint8_t shouldDrawDotOnName() override
Get the "draw dot state".
Definition
selection.h:75