Deluge Firmware 1.3.0
Build date: 2025.04.16
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
42 void beginSession(MenuItem* navigatedBackwardFrom = nullptr) override;
43 void updateDisplay();
44 void selectEncoderAction(int32_t offset) final;
45 MenuItem* selectButtonPress() final;
46 ActionResult buttonAction(deluge::hid::Button b, bool on, bool inCardRoutine) final;
47 void readValueAgain() final { updateDisplay(); }
48 void unlearnAction() final;
49 bool usesAffectEntire() override;
50 bool allowsLearnMode() final;
51 void learnKnob(MIDICable* cable, int32_t whichKnob, int32_t modKnobMode, int32_t midiChannel) final;
52 void learnProgramChange(MIDICable& cable, int32_t channel, int32_t programNumber) override;
53 bool learnNoteOn(MIDICable& cable, int32_t channel, int32_t noteCode) final;
54 void drawPixelsForOled() override;
55 void drawSubmenuItemsForOled(std::span<MenuItem*> options, const int32_t selectedOption);
58 bool wrapAround();
59 bool isSubmenu() override { return true; }
60 virtual bool focusChild(const MenuItem* child);
62 virtual bool supportsHorizontalRendering() { return false; }
63 RenderingStyle renderingStyle();
64 void updatePadLights() override;
65 MenuItem* patchingSourceShortcutPress(PatchSource s, bool previousPressStillActive = false) override;
67 uint32_t getParamIndex() override;
68
69protected:
70 void drawVerticalMenu();
71 void drawHorizontalMenu();
72
73private:
74 bool shouldForwardButtons();
75 deluge::vector<MenuItem*> items;
76 typename decltype(items)::iterator current_item_;
77};
78
79class HorizontalMenu : public Submenu {
80public:
81 HorizontalMenu(l10n::String newName, std::initializer_list<MenuItem*> newItems) : Submenu(newName, newItems) {}
82 HorizontalMenu(l10n::String newName, std::span<MenuItem*> newItems) : Submenu(newName, newItems) {}
83 HorizontalMenu(l10n::String newName, l10n::String title, std::initializer_list<MenuItem*> newItems)
84 : Submenu(newName, title, newItems) {}
85 HorizontalMenu(l10n::String newName, l10n::String title, std::span<MenuItem*> newItems)
86 : Submenu(newName, title, newItems) {}
87 bool supportsHorizontalRendering() { return true; }
88};
89
90} // 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:39
deluge::l10n::String title
Can get overridden by getTitle(). Actual max num chars for OLED display is 14.
Definition menu_item.h:208
bool supportsHorizontalRendering()
Submenus which support horizontal rendering need to override this.
Definition submenu.h:87
bool learnNoteOn(MIDICable &cable, int32_t channel, int32_t noteCode) final
Attempt to bind this menu item to a note code.
Definition submenu.cpp:336
bool allowsLearnMode() final
Used by SoundEditor to determine if the current menu item can accept MIDI learning.
Definition submenu.cpp:318
ActionResult buttonAction(deluge::hid::Button b, bool on, bool inCardRoutine) final
Handle an arbitrary button.
Definition submenu.cpp:285
virtual bool supportsHorizontalRendering()
Submenus which support horizontal rendering need to override this.
Definition submenu.h:62
void readValueAgain() final
Re-read the value from the system and redraw the display to match.
Definition submenu.h:47
bool wrapAround()
Indicates if the menu-like object should wrap-around. Destined to be virtualized. At the moment imple...
Definition submenu.cpp:187
void unlearnAction() final
Unlearn the parameter controlled by this menu.
Definition submenu.cpp:312
void drawPixelsForOled() override
Paints the pixels below the standard title block.
Definition submenu.cpp:52
bool usesAffectEntire() override
Claim support for Kit AFFECT_ENTIRE editing.
Definition submenu.cpp:362
void learnKnob(MIDICable *cable, int32_t whichKnob, int32_t modKnobMode, int32_t midiChannel) final
Definition submenu.cpp:325
deluge::modulation::params::Kind getParamKind() override
Definition submenu.cpp:294
void selectEncoderAction(int32_t offset) final
Handle select encoder movement.
Definition submenu.cpp:191
void beginSession(MenuItem *navigatedBackwardFrom=nullptr) override
Begin an editing session with this menu item.
Definition submenu.cpp:12
uint32_t getParamIndex() override
Definition submenu.cpp:303
MenuItem * selectButtonPress() final
Handle a select button press.
Definition submenu.cpp:276
MenuItem * patchingSourceShortcutPress(PatchSource s, bool previousPressStillActive=false) override
Action to take when a source shortcut is pressed.
Definition submenu.cpp:372
Kind
Definition param.h:42