Deluge Firmware 1.3.0
Build date: 2025.04.16
Loading...
Searching...
No Matches
randomizer_lock.h
1/*
2 * Copyright (c) 2014-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#pragma once
18#include "gui/l10n/strings.h"
19#include "gui/menu_item/selection.h"
20#include "gui/ui/sound_editor.h"
21#include "model/drum/drum.h"
22#include "model/instrument/kit.h"
23#include "model/song/song.h"
24#include "processing/sound/sound.h"
25
26namespace deluge::gui::menu_item::arpeggiator {
27class RandomizerLock final : public Selection {
28public:
29 using Selection::Selection;
30 void readCurrentValue() override { this->setValue(soundEditor.currentArpSettings->randomizerLock); }
31
32 bool usesAffectEntire() override { return true; }
33 void writeCurrentValue() override {
34 bool current_value = this->getValue() != 0;
35
36 // If affect-entire button held, do whole kit
37 if (currentUIMode == UI_MODE_HOLDING_AFFECT_ENTIRE_IN_SOUND_EDITOR && soundEditor.editingKitRow()) {
38
39 Kit* kit = getCurrentKit();
40
41 for (Drum* thisDrum = kit->firstDrum; thisDrum != nullptr; thisDrum = thisDrum->next) {
42 thisDrum->arpSettings.randomizerLock = current_value;
43 }
44 }
45 // Or, the normal case of just one sound
46 else {
47 soundEditor.currentArpSettings->randomizerLock = current_value;
48 }
49 }
50
51 deluge::vector<std::string_view> getOptions(OptType optType) override {
52 (void)optType;
53 using enum l10n::String;
54 return {
55 l10n::getView(STRING_FOR_OFF), //<
56 l10n::getView(STRING_FOR_ON), //<
57 };
58 }
59
60 void getColumnLabel(StringBuf& label) override {
61 label.append(deluge::l10n::get(deluge::l10n::built_in::seven_segment, this->name));
62 }
63
64 // flag this selection menu as a toggle menu so we can use a checkbox to toggle value
65 bool isToggle() override { return true; }
66
67 // don't enter menu on select button press
68 bool shouldEnterSubmenu() override { return false; }
69};
70} // namespace deluge::gui::menu_item::arpeggiator
Definition drum.h:44
Definition kit.h:34
Definition d_string.h:106
Definition selection.h:26
void getColumnLabel(StringBuf &label) override
Get the name for use on horizontal menus.
Definition randomizer_lock.h:60
void readCurrentValue() override
Like readValueAgain, but does not redraw.
Definition randomizer_lock.h:30
bool usesAffectEntire() override
Claim support for Kit AFFECT_ENTIRE editing.
Definition randomizer_lock.h:32
bool shouldEnterSubmenu() override
Check if selecting this menu item (with select encoder) should enter a submenu.
Definition randomizer_lock.h:68