Deluge Firmware
1.3.0
Build date: 2026.08.23
Toggle main menu visibility
Loading...
Searching...
No Matches
preset.h
1
/*
2
* Copyright (c) 2014-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
#pragma once
18
#include "gui/menu_item/integer.h"
19
#include "gui/ui/sound_editor.h"
20
#include "hid/display/display.h"
21
#include "hid/display/oled.h"
22
#include "model/clip/instrument_clip.h"
23
#include "model/output.h"
24
#include "model/song/song.h"
25
26
namespace
deluge::gui::menu_item::midi {
27
class
Preset
:
public
Integer
{
28
public
:
29
using
Integer::Integer;
30
31
[[nodiscard]] int32_t getMaxValue()
const override
{
return
128; }
// Probably not needed cos we override below...
32
33
void
drawInteger(int32_t textWidth, int32_t textHeight, int32_t yPixel)
override
{
34
oled_canvas::Canvas
& canvas = OLED::main;
35
char
buffer[12];
36
char
const
* text;
37
if
(this->getValue() == 128) {
38
text = l10n::get(l10n::String::STRING_FOR_NONE);
39
}
40
else
{
41
intToString(this->getValue(), buffer, 1);
42
text = buffer;
43
}
44
canvas.
drawStringCentred
(text, yPixel + OLED_MAIN_TOPMOST_PIXEL, textWidth, textHeight);
45
}
46
47
void
drawValue()
override
{
48
if
(this->getValue() == 128) {
49
display->setText(l10n::get(l10n::String::STRING_FOR_NONE));
50
}
51
else
{
52
display->setTextAsNumber(this->getValue());
53
}
54
}
55
56
bool
isRelevant
(
ModControllableAudio
* modControllable, int32_t whichThing)
override
{
57
return
getCurrentOutputType() == OutputType::MIDI_OUT;
58
}
59
60
void
selectEncoderAction
(int32_t offset)
override
{
61
this->setValue(this->getValue() + offset);
62
if
(this->getValue() >= 129) {
63
this->setValue(this->getValue() - 129);
64
}
65
else
if
(this->getValue() < 0) {
66
this->setValue(this->getValue() + 129);
67
}
68
Number::selectEncoderAction
(offset);
69
}
70
71
void
renderInHorizontalMenu(
const
SlotPosition
& slot)
override
{
72
oled_canvas::Canvas
& image = OLED::main;
73
74
DEF_STACK_STRING_BUF(paramValue, 5);
75
int32_t size_x, size_y;
76
if
(this->getValue() == 128) {
77
paramValue.append(l10n::get(l10n::String::STRING_FOR_NONE));
78
size_x = kTextSpacingX;
79
size_y = kTextSpacingY;
80
}
81
else
{
82
paramValue.appendInt(getValue());
83
size_x = kTextTitleSpacingX;
84
size_y = kTextTitleSizeY;
85
}
86
image.drawStringCentered(paramValue, slot.start_x, slot.start_y + kHorizontalMenuSlotYOffset, size_x, size_y,
87
slot.width);
88
}
89
90
[[nodiscard]]
bool
showNotification
()
const override
{
return
false
; }
91
};
92
}
// namespace deluge::gui::menu_item::midi
MenuItem::selectEncoderAction
virtual void selectEncoderAction(int32_t offset)
Handle select encoder movement.
Definition
menu_item.h:92
ModControllableAudio
Definition
mod_controllable_audio.h:47
deluge::gui::menu_item::Integer
Definition
integer.h:24
deluge::gui::menu_item::midi::Preset
Definition
preset.h:27
deluge::gui::menu_item::midi::Preset::isRelevant
bool isRelevant(ModControllableAudio *modControllable, int32_t whichThing) override
Check if this MenuItem should show up in a containing deluge::gui::menu_item::Submenu.
Definition
preset.h:56
deluge::gui::menu_item::midi::Preset::showNotification
bool showNotification() const override
Show a popup with the full name and value of the editing parameter at the top of Horizontal menu.
Definition
preset.h:90
deluge::gui::menu_item::midi::Preset::selectEncoderAction
void selectEncoderAction(int32_t offset) override
Handle select encoder movement.
Definition
preset.h:60
deluge::hid::display::oled_canvas::Canvas
Definition
canvas.h:52
deluge::hid::display::oled_canvas::Canvas::drawStringCentred
void drawStringCentred(char const *string, int32_t pixelY, int32_t textWidth, int32_t textHeight, int32_t centrePos=OLED_MAIN_WIDTH_PIXELS/2)
Definition
canvas.cpp:383
SlotPosition
Definition
menu_item.h:33