Deluge Firmware 1.3.0
Build date: 2026.11.28
Loading...
Searching...
No Matches
param_locks.h
1/*
2 * Copyright © 2026 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/integer.h"
21#include "gui/menu_item/menu_item.h"
22#include "model/note/note_locks.h"
23#include "util/containers.h"
24
25namespace deluge::gui::menu_item::note {
26
31class ParamLockValue final : public Integer {
32public:
33 using Integer::Integer;
34 void setParam(int32_t param) { param_ = param; }
35 [[nodiscard]] int32_t getMinValue() const override { return -64; }
36 [[nodiscard]] int32_t getMaxValue() const override { return 64; }
37 [[nodiscard]] std::string_view getTitle() const override;
38 void readCurrentValue() override;
39 void readValueAgain() override;
40 void selectEncoderAction(int32_t offset) override;
41 void endSession() override;
43 void commit();
44 void deletePress();
45
46protected:
47 int32_t getDisplayValue() override;
48 void writeCurrentValue() override { dirty_ = true; }
49 void drawValue() override;
50
51private:
52 int32_t param_{0};
53 bool dirty_{false};
54};
55
58class ParamLocks final : public MenuItem {
59public:
60 using MenuItem::MenuItem;
61 void beginSession(MenuItem* navigatedBackwardFrom = nullptr) override;
62 void readValueAgain() override;
63 void selectEncoderAction(int32_t offset) override;
64 MenuItem* selectButtonPress() override;
65 bool shouldEnterSubmenu() override;
66 bool isSubmenu() override { return true; }
67 void getColumnLabel(StringBuf& label) override {
68 label.append(l10n::get(l10n::String::STRING_FOR_NOTE_EDITOR_PARAM_LOCKS_SHORT));
69 }
70 void renderInHorizontalMenu(const SlotPosition& slot) override;
71 void drawPixelsForOled() override;
72 void deletePress();
73
74private:
75 void readLocks();
76 void drawValue();
77 [[nodiscard]] int32_t numEntries() const { return locks_.size() + 1; } // + "Clear all" / "None"
78
80 deluge::vector<std::string_view> options_;
81 int32_t currentValue_{0};
82 int32_t scrollPos_{0};
83};
84
85} // namespace deluge::gui::menu_item::note
Definition d_stringbuf.h:16
Definition integer.h:24
void readCurrentValue() override
Like readValueAgain, but does not redraw.
Definition param_locks.cpp:81
std::string_view getTitle() const override
Get the title to be used when rendering on OLED, both as a deluge::gui::menu_item::Submenu and when d...
Definition param_locks.cpp:77
void selectEncoderAction(int32_t offset) override
Handle select encoder movement.
Definition param_locks.cpp:105
void endSession() override
End an editing session with this menu item.
Definition param_locks.cpp:133
void readValueAgain() override
Re-read the value from the system and redraw the display to match.
Definition param_locks.cpp:88
void commit()
Writes a pending edit to the notes (once). Safe to call more than once.
Definition param_locks.cpp:125
Definition param_locks.h:58
void beginSession(MenuItem *navigatedBackwardFrom=nullptr) override
Begin an editing session with this menu item.
Definition param_locks.cpp:176
MenuItem * selectButtonPress() override
Handle a select button press.
Definition param_locks.cpp:219
void selectEncoderAction(int32_t offset) override
Handle select encoder movement.
Definition param_locks.cpp:210
void drawPixelsForOled() override
Paints the pixels below the standard title block.
Definition param_locks.cpp:194
bool shouldEnterSubmenu() override
Check if selecting this menu item (with select encoder) should enter a submenu.
Definition param_locks.cpp:148
void readValueAgain() override
Re-read the value from the system and redraw the display to match.
Definition param_locks.cpp:184
Definition note_locks.h:63
Definition menu_item.h:35