Deluge Firmware
1.3.0
Build date: 2026.08.29
Toggle main menu visibility
Loading...
Searching...
No Matches
linked.h
1
/*
2
* Copyright (c) 2024 Sean Ditny
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/toggle.h"
21
#include "gui/ui/load/load_midi_device_definition_ui.h"
22
#include "gui/ui/sound_editor.h"
23
#include "model/instrument/midi_instrument.h"
24
#include "model/output.h"
25
#include "model/song/song.h"
26
27
namespace
deluge::gui::menu_item::midi::device_definition {
28
29
class
Linked
:
public
Toggle
{
30
public
:
31
using
Toggle::Toggle;
32
33
void
readCurrentValue
()
override
{
34
MIDIInstrument
* midiInstrument = (
MIDIInstrument
*)getCurrentOutput();
35
this->setValue(!midiInstrument->
deviceDefinitionFileName
.isEmpty());
36
}
37
void
writeCurrentValue()
override
{
38
t = this->getValue();
39
40
// if you want to link a definition file, open the load definition file UI
41
if
(t) {
42
openUI(&loadMidiDeviceDefinitionUI);
43
}
44
// if you want to unlink a definition file, just clear the definition file name
45
else
{
46
MIDIInstrument
* midiInstrument = (
MIDIInstrument
*)getCurrentOutput();
47
midiInstrument->
deviceDefinitionFileName
.clear();
48
}
49
}
50
51
bool
isRelevant
(
ModControllableAudio
* modControllable, int32_t whichThing) {
52
Output
* output = getCurrentOutput();
53
return
(output && output->type == OutputType::MIDI_OUT);
54
}
55
56
void
renderSubmenuItemTypeForOled(int32_t yPixel)
final
{
57
deluge::hid::display::oled_canvas::Canvas
& image = deluge::hid::display::OLED::main;
58
59
int32_t startX = getSubmenuItemTypeRenderIconStart();
60
61
if
(getToggleValue()) {
62
image.drawGraphicMultiLine(deluge::hid::display::OLED::checkedBoxIcon, startX, yPixel,
63
kSubmenuIconSpacingX);
64
65
MIDIInstrument
* midiInstrument = (
MIDIInstrument
*)getCurrentOutput();
66
67
char
const
* fullPath = midiInstrument->
deviceDefinitionFileName
.get();
68
69
// locate last occurence of "/" in string
70
char
* fileName = strrchr((
char
*)fullPath,
'/'
);
71
72
image.drawString(++fileName, kTextSpacingX, yPixel + (kTextSpacingY * 2), kTextSpacingX, kTextSpacingY);
73
}
74
else
{
75
image.drawGraphicMultiLine(deluge::hid::display::OLED::uncheckedBoxIcon, startX, yPixel,
76
kSubmenuIconSpacingX);
77
}
78
}
79
80
bool
t;
81
};
82
83
}
// namespace deluge::gui::menu_item::midi::device_definition
MIDIInstrument
Definition
midi_instrument.h:38
MIDIInstrument::deviceDefinitionFileName
String deviceDefinitionFileName
definition file
Definition
midi_instrument.h:66
ModControllableAudio
Definition
mod_controllable_audio.h:47
Output
Definition
output.h:81
deluge::gui::menu_item::Toggle
Definition
toggle.h:8
deluge::gui::menu_item::midi::device_definition::Linked
Definition
linked.h:29
deluge::gui::menu_item::midi::device_definition::Linked::isRelevant
bool isRelevant(ModControllableAudio *modControllable, int32_t whichThing)
Check if this MenuItem should show up in a containing deluge::gui::menu_item::Submenu.
Definition
linked.h:51
deluge::gui::menu_item::midi::device_definition::Linked::readCurrentValue
void readCurrentValue() override
Like readValueAgain, but does not redraw.
Definition
linked.h:33
deluge::hid::display::oled_canvas::Canvas
Definition
canvas.h:52