Deluge Firmware 1.3.0
Build date: 2025.07.05
Loading...
Searching...
No Matches
submenu.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/menu_item.h"
21#include "gui/ui/sound_editor.h"
22#include "menu_item.h"
23#include "util/containers.h"
24#include <initializer_list>
25#include <span>
26
27namespace deluge::gui::menu_item {
28
29class Submenu : public MenuItem {
30public:
31 enum RenderingStyle { VERTICAL, HORIZONTAL };
32
33 Submenu(l10n::String newName, std::initializer_list<MenuItem*> newItems)
34 : MenuItem(newName), items{newItems}, current_item_{items.end()} {}
35 Submenu(l10n::String newName, std::span<MenuItem*> newItems)
36 : MenuItem(newName), items{newItems.begin(), newItems.end()}, current_item_{items.end()} {}
37 Submenu(l10n::String newName, l10n::String title, std::initializer_list<MenuItem*> newItems)
38 : MenuItem(newName, title), items{newItems}, current_item_{items.end()} {}
39 Submenu(l10n::String newName, l10n::String title, std::span<MenuItem*> newItems)
40 : MenuItem(newName, title), items{newItems.begin(), newItems.end()}, current_item_{items.end()} {}
41 Submenu(l10n::String newName, std::span<MenuItem*> newItems, int32_t newThingIndex)
42 : MenuItem(newName), items{newItems.begin(), newItems.end()}, current_item_{items.end()},
43 thingIndex(newThingIndex) {}
44 Submenu(l10n::String newName, std::initializer_list<MenuItem*> newItems, int32_t newThingIndex)
45 : MenuItem(newName), items{newItems}, current_item_{items.end()}, thingIndex(newThingIndex) {}
46
47 void beginSession(MenuItem* navigatedBackwardFrom = nullptr) override;
48 void updateDisplay();
49 void selectEncoderAction(int32_t offset) override;
50 MenuItem* selectButtonPress() final;
51 ActionResult buttonAction(deluge::hid::Button b, bool on, bool inCardRoutine) override;
52 void readValueAgain() final { updateDisplay(); }
53 void unlearnAction() final;
54 bool usesAffectEntire() override;
55 bool allowsLearnMode() final;
56 void learnKnob(MIDICable* cable, int32_t whichKnob, int32_t modKnobMode, int32_t midiChannel) final;
57 void learnProgramChange(MIDICable& cable, int32_t channel, int32_t programNumber) override;
58 bool learnNoteOn(MIDICable& cable, int32_t channel, int32_t noteCode) final;
59 virtual RenderingStyle renderingStyle() const { return RenderingStyle::VERTICAL; };
60 void renderInHorizontalMenu(int32_t startX, int32_t width, int32_t startY, int32_t height) override;
61 void drawPixelsForOled() override;
62 void drawSubmenuItemsForOled(std::span<MenuItem*> options, const int32_t selectedOption);
65 bool wrapAround();
66 bool isSubmenu() override { return true; }
67 virtual bool focusChild(const MenuItem* child);
68 void updatePadLights() override;
69 MenuItem* patchingSourceShortcutPress(PatchSource s, bool previousPressStillActive = false) override;
71 uint32_t getParamIndex() override;
72 std::optional<uint8_t> getThingIndex() { return thingIndex; }
73 [[nodiscard]] int32_t getColumnSpan() const override { return 2; };
74 [[nodiscard]] bool showPopup() const override { return false; }
75
76protected:
77 std::optional<uint8_t> thingIndex = std::nullopt;
78 uint32_t initial_index_ = 0;
79 deluge::vector<MenuItem*> items;
80 typename decltype(items)::iterator current_item_;
81
82private:
83 bool shouldForwardButtons();
84};
85
86} // namespace deluge::gui::menu_item
A MIDI cable connection. Stores all state specific to a given cable and its contained ports and chann...
Definition midi_device.h:94
Base class for all menu items.
Definition menu_item.h:40
deluge::l10n::String title
Can get overridden by getTitle(). Actual max num chars for OLED display is 14.
Definition menu_item.h:212
bool learnNoteOn(MIDICable &cable, int32_t channel, int32_t noteCode) final
Attempt to bind this menu item to a note code.
Definition submenu.cpp:264
bool allowsLearnMode() final
Used by SoundEditor to determine if the current menu item can accept MIDI learning.
Definition submenu.cpp:246
void readValueAgain() final
Re-read the value from the system and redraw the display to match.
Definition submenu.h:52
bool wrapAround()
Indicates if the menu-like object should wrap-around. Destined to be virtualized. At the moment imple...
Definition submenu.cpp:145
void unlearnAction() final
Unlearn the parameter controlled by this menu.
Definition submenu.cpp:240
void drawPixelsForOled() override
Paints the pixels below the standard title block.
Definition submenu.cpp:74
bool showPopup() const override
Show a popup with the full name of the editing parameter at the top of the horizontal menu.
Definition submenu.h:74
bool usesAffectEntire() override
Claim support for Kit AFFECT_ENTIRE editing.
Definition submenu.cpp:280
int32_t getColumnSpan() const override
Get the number of occupied virtual columns in the horizontal menu.
Definition submenu.h:73
ActionResult buttonAction(deluge::hid::Button b, bool on, bool inCardRoutine) override
Handle an arbitrary button.
Definition submenu.cpp:213
void learnKnob(MIDICable *cable, int32_t whichKnob, int32_t modKnobMode, int32_t midiChannel) final
Definition submenu.cpp:253
deluge::modulation::params::Kind getParamKind() override
Definition submenu.cpp:222
void beginSession(MenuItem *navigatedBackwardFrom=nullptr) override
Begin an editing session with this menu item.
Definition submenu.cpp:14
uint32_t getParamIndex() override
Definition submenu.cpp:231
MenuItem * selectButtonPress() final
Handle a select button press.
Definition submenu.cpp:204
void selectEncoderAction(int32_t offset) override
Handle select encoder movement.
Definition submenu.cpp:149
MenuItem * patchingSourceShortcutPress(PatchSource s, bool previousPressStillActive=false) override
Action to take when a source shortcut is pressed.
Definition submenu.cpp:290
Kind
Definition param.h:42