Deluge Firmware
1.3.0
Build date: 2026.08.23
Toggle main menu visibility
Loading...
Searching...
No Matches
iterance_step_toggle.h
1
/*
2
* Copyright (c) 2024 Sean Ditny / Raúl Muñoz
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
#include "definitions_cxx.hpp"
20
#include "gui/menu_item/toggle.h"
21
#include "gui/views/instrument_clip_view.h"
22
#include "model/clip/instrument_clip.h"
23
#include "model/note/note.h"
24
25
namespace
deluge::gui::menu_item::note {
26
class
IteranceStepToggle :
public
Toggle
{
27
public
:
28
using
Toggle::Toggle;
29
30
IteranceStepToggle(l10n::String newName, l10n::String
title
, uint8_t newIndex) :
Toggle
(newName,
title
) {
31
this->index = newIndex;
32
}
33
34
void
readCurrentValue
()
override
{
35
Note
* leftMostNote = instrumentClipView.getLeftMostNotePressed();
36
37
if
(leftMostNote) {
38
Iterance
iterance = leftMostNote->getIterance();
39
if
(iterance == kDefaultIteranceValue) {
40
// if we end up here in this menu, convert OFF to the default CUSTOM value 1of1
41
// so we can make edits from here
42
iterance = kCustomIteranceValue;
43
}
44
this->setValue(iterance.iteranceStep[index]);
45
}
46
}
47
void
writeCurrentValue()
override
{
48
bool
value = this->getValue();
49
Note
* leftMostNote = instrumentClipView.getLeftMostNotePressed();
50
51
if
(leftMostNote) {
52
Iterance
iterance = leftMostNote->getIterance();
53
if
(iterance == kDefaultIteranceValue) {
54
// if we end up here in this menu, convert OFF to the default CUSTOM value 1of1
55
// so we can make edits from here
56
iterance = kCustomIteranceValue;
57
}
58
int32_t newIteranceSteps = iterance.toInt() & 0xFF;
59
if
(value) {
60
newIteranceSteps |= (1 << index);
61
}
62
else
{
63
newIteranceSteps &= ~(1 << index);
64
}
65
instrumentClipView.adjustNoteIteranceWithFinalValue(
Iterance
{iterance.divisor, newIteranceSteps});
66
}
67
}
68
69
uint8_t index;
70
71
bool
isRelevant
(
ModControllableAudio
* modControllable, int32_t whichThing)
override
{
72
Note
* leftMostNote = instrumentClipView.getLeftMostNotePressed();
73
74
if
(leftMostNote) {
75
Iterance
iterance = leftMostNote->getIterance();
76
// Only show this iteration step if its index is smaller than current divisor value
77
return
(iterance == kDefaultIteranceValue && index == 0) || iterance.divisor > index;
78
}
79
return
false
;
80
}
81
};
82
}
// namespace deluge::gui::menu_item::note
MenuItem::title
deluge::l10n::String title
Can get overridden by getTitle(). Actual max num chars for OLED display is 14.
Definition
menu_item.h:222
ModControllableAudio
Definition
mod_controllable_audio.h:47
Note
Definition
note.h:24
deluge::gui::menu_item::Toggle
Definition
toggle.h:8
deluge::gui::menu_item::note::IteranceStepToggle::readCurrentValue
void readCurrentValue() override
Like readValueAgain, but does not redraw.
Definition
iterance_step_toggle.h:34
deluge::gui::menu_item::note::IteranceStepToggle::isRelevant
bool isRelevant(ModControllableAudio *modControllable, int32_t whichThing) override
Check if this MenuItem should show up in a containing deluge::gui::menu_item::Submenu.
Definition
iterance_step_toggle.h:71
Iterance
Definition
iterance.h:25