Deluge Firmware 1.3.0
Build date: 2025.04.16
Loading...
Searching...
No Matches
context_menu.h
1/*
2 * Copyright © 2018-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/ui/ui.h"
21#include "hid/button.h"
22#include <cstdint>
23#include <span>
24
25namespace deluge::gui {
26
27class ContextMenu : public UI {
28public:
29 ContextMenu() { oledShowsUIUnderneath = true; };
30
31 virtual ~ContextMenu() = default;
32
33 void focusRegained() override;
34 void selectEncoderAction(int8_t offset) override;
35 ActionResult buttonAction(deluge::hid::Button b, bool on, bool inCardRoutine) override;
36 void drawCurrentOption();
37 virtual bool isCurrentOptionAvailable() { return true; }
38 virtual bool acceptCurrentOption() { return false; } // If returns false, will cause UI to exit
39
40 virtual std::span<char const*> getOptions() = 0;
41
42 bool getGreyoutColsAndRows(uint32_t* cols, uint32_t* rows) override;
43 ActionResult padAction(int32_t x, int32_t y, int32_t velocity) override;
44 virtual bool setupAndCheckAvailability();
45
46 virtual deluge::hid::Button getAcceptButton() { return deluge::hid::button::SELECT_ENC; }
47
48 int32_t currentOption = 0; // Don't make static. We'll have multiple nested ContextMenus open at the same time
49
50 void renderOLED(deluge::hid::display::oled_canvas::Canvas& canvas) override;
51 int32_t scrollPos = 0; // Don't make static. We'll have multiple nested ContextMenus open at the same time
52 virtual char const* getTitle() = 0;
53
54 // UI
55
56 // NB! Context menus all share a type!
57 UIType getUIType() override { return UIType::CONTEXT_MENU; }
58};
59
60class ContextMenuForSaving : public ContextMenu {
61public:
62 ContextMenuForSaving() = default;
63 ~ContextMenuForSaving() override = default;
64
65 void focusRegained() final;
66 deluge::hid::Button getAcceptButton() final { return deluge::hid::button::SAVE; }
67};
68
69class ContextMenuForLoading : public ContextMenu {
70public:
71 ContextMenuForLoading() = default;
72 ~ContextMenuForLoading() override = default;
73
74 void focusRegained() override;
75 deluge::hid::Button getAcceptButton() final { return deluge::hid::button::LOAD; }
76};
77} // namespace deluge::gui