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