Deluge Firmware 1.3.0
Build date: 2026.03.02
Loading...
Searching...
No Matches
linked.h
1#pragma once
2
3#include "gui/menu_item/toggle.h"
4#include "gui/ui/load/load_midi_device_definition_ui.h"
5#include "gui/ui/sound_editor.h"
6#include "model/instrument/midi_instrument.h"
7#include "model/output.h"
8#include "model/song/song.h"
9
10namespace deluge::gui::menu_item::midi::device_definition {
11
12class Linked : public Toggle {
13public:
14 using Toggle::Toggle;
15
16 void readCurrentValue() override {
17 MIDIInstrument* midiInstrument = (MIDIInstrument*)getCurrentOutput();
18 this->setValue(!midiInstrument->deviceDefinitionFileName.isEmpty());
19 }
20 void writeCurrentValue() override {
21 t = this->getValue();
22
23 // if you want to link a definition file, open the load definition file UI
24 if (t) {
25 openUI(&loadMidiDeviceDefinitionUI);
26 }
27 // if you want to unlink a definition file, just clear the definition file name
28 else {
29 MIDIInstrument* midiInstrument = (MIDIInstrument*)getCurrentOutput();
30 midiInstrument->deviceDefinitionFileName.clear();
31 }
32 }
33
34 bool isRelevant(ModControllableAudio* modControllable, int32_t whichThing) {
35 Output* output = getCurrentOutput();
36 return (output && output->type == OutputType::MIDI_OUT);
37 }
38
39 void renderSubmenuItemTypeForOled(int32_t yPixel) final {
40 deluge::hid::display::oled_canvas::Canvas& image = deluge::hid::display::OLED::main;
41
42 int32_t startX = getSubmenuItemTypeRenderIconStart();
43
44 if (getToggleValue()) {
45 image.drawGraphicMultiLine(deluge::hid::display::OLED::checkedBoxIcon, startX, yPixel,
46 kSubmenuIconSpacingX);
47
48 MIDIInstrument* midiInstrument = (MIDIInstrument*)getCurrentOutput();
49
50 char const* fullPath = midiInstrument->deviceDefinitionFileName.get();
51
52 // locate last occurence of "/" in string
53 char* fileName = strrchr((char*)fullPath, '/');
54
55 image.drawString(++fileName, kTextSpacingX, yPixel + kTextSpacingY, kTextSpacingX, kTextSpacingY);
56 }
57 else {
58 image.drawGraphicMultiLine(deluge::hid::display::OLED::uncheckedBoxIcon, startX, yPixel,
59 kSubmenuIconSpacingX);
60 }
61 }
62
63 bool t;
64};
65
66} // namespace deluge::gui::menu_item::midi::device_definition
Definition midi_instrument.h:37
String deviceDefinitionFileName
definition file
Definition midi_instrument.h:64
Definition mod_controllable_audio.h:47
Definition output.h:81
Definition toggle.h:8
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:34
void readCurrentValue() override
Like readValueAgain, but does not redraw.
Definition linked.h:16