Deluge Firmware 1.3.0
Build date: 2025.04.16
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
26namespace deluge::gui::menu_item::midi {
27class Preset : public Integer {
28public:
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 deluge::hid::display::oled_canvas::Canvas& canvas = hid::display::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() + 1, 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() + 1);
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 }
69 }
70};
71} // namespace deluge::gui::menu_item::midi
virtual void selectEncoderAction(int32_t offset)
Handle select encoder movement.
Definition menu_item.h:81
Definition mod_controllable_audio.h:47
Definition integer.h:24
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
void selectEncoderAction(int32_t offset) override
Handle select encoder movement.
Definition preset.h:60
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:189