Deluge Firmware 1.3.0
Build date: 2025.10.15
Loading...
Searching...
No Matches
integer.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 "definitions_cxx.hpp"
19#include "gui/menu_item/integer.h"
20#include "gui/menu_item/patched_param.h"
21
22namespace deluge::gui::menu_item::patched_param {
23class Integer : public PatchedParam, public menu_item::IntegerContinuous {
24public:
25 Integer(l10n::String newName, int32_t newP = 0) : PatchedParam(newP), IntegerContinuous(newName) {}
26 Integer(l10n::String newName, int32_t newP, NumberStyle style)
27 : PatchedParam(newP), IntegerContinuous(newName), number_style_{style} {}
28 Integer(l10n::String newName, l10n::String title, int32_t newP = 0)
29 : PatchedParam(newP), IntegerContinuous(newName, title) {}
30 Integer(l10n::String newName, l10n::String title, int32_t newP, NumberStyle style)
31 : PatchedParam(newP), IntegerContinuous(newName, title), number_style_{style} {}
32 // 7SEG Only
33 void drawValue() override { display->setTextAsNumber(this->getValue(), shouldDrawDotOnName()); }
34
35 bool usesAffectEntire() override { return true; }
36
37 ParamDescriptor getLearningThing() final { return PatchedParam::getLearningThing(); }
38 [[nodiscard]] int32_t getMaxValue() const override { return PatchedParam::getMaxValue(); }
39 [[nodiscard]] int32_t getMinValue() const override { return PatchedParam::getMinValue(); }
40 uint8_t shouldBlinkPatchingSourceShortcut(PatchSource s, uint8_t* colour) final {
41 return PatchedParam::shouldBlinkPatchingSourceShortcut(s, colour);
42 }
43
44 uint8_t shouldDrawDotOnName() final { return PatchedParam::shouldDrawDotOnName(); }
45 MenuItem* selectButtonPress() final { return PatchedParam::selectButtonPress(); }
46 // this button action function definition should not be required as it should be inherited
47 // from the param class, however it does not work if the definition is removed, so there
48 // is likely a multi-inheritance issue that needs to be resolved
49 ActionResult buttonAction(deluge::hid::Button b, bool on, bool inCardRoutine) final {
50 return PatchedParam::buttonAction(b, on, inCardRoutine);
51 }
52 void horizontalEncoderAction(int32_t offset) final { return PatchedParam::horizontalEncoderAction(offset); }
53
54 deluge::modulation::params::Kind getParamKind() final { return PatchedParam::getParamKind(); }
55 uint32_t getParamIndex() final { return PatchedParam::getParamIndex(); }
56 MenuItem* patchingSourceShortcutPress(PatchSource s, bool previousPressStillActive = false) final {
57 return PatchedParam::patchingSourceShortcutPress(s, previousPressStillActive);
58 }
59
60 void unlearnAction() final { MenuItemWithCCLearning::unlearnAction(); }
61 bool allowsLearnMode() final { return MenuItemWithCCLearning::allowsLearnMode(); }
62 void learnKnob(MIDICable* cable, int32_t whichKnob, int32_t modKnobMode, int32_t midiChannel) final {
63 MenuItemWithCCLearning::learnKnob(cable, whichKnob, modKnobMode, midiChannel);
64 };
65
66 int32_t getParamValue() {
68 return getValue();
69 }
70
71 void updateAutomationViewParameter() override;
72
73 [[nodiscard]] NumberStyle getNumberStyle() const override {
74 return number_style_.value_or(IntegerContinuous::getNumberStyle());
75 }
76
77protected:
78 void readCurrentValue() override;
79 void writeCurrentValue() final;
80 virtual int32_t getFinalValue();
81
82private:
83 std::optional<NumberStyle> number_style_{std::nullopt};
84};
85} // namespace deluge::gui::menu_item::patched_param
A MIDI cable connection. Stores all state specific to a given cable and its contained ports and chann...
Definition midi_device.h:94
deluge::l10n::String title
Can get overridden by getTitle(). Actual max num chars for OLED display is 14.
Definition menu_item.h:215
virtual uint32_t getParamIndex()
Definition menu_item.h:141
virtual deluge::modulation::params::Kind getParamKind()
Definition menu_item.h:138
virtual uint8_t shouldDrawDotOnName()
Get the "draw dot state".
Definition menu_item.h:236
Definition param_descriptor.h:27
void updateAutomationViewParameter() override
Definition integer.cpp:84
void learnKnob(MIDICable *cable, int32_t whichKnob, int32_t modKnobMode, int32_t midiChannel) final
Definition integer.h:62
void horizontalEncoderAction(int32_t offset) final
Handle horizontal encoder movement.
Definition integer.h:52
bool usesAffectEntire() override
Claim support for Kit AFFECT_ENTIRE editing.
Definition integer.h:35
bool allowsLearnMode() final
Used by SoundEditor to determine if the current menu item can accept MIDI learning.
Definition integer.h:61
ActionResult buttonAction(deluge::hid::Button b, bool on, bool inCardRoutine) final
Handle an arbitrary button.
Definition integer.h:49
MenuItem * selectButtonPress() final
Handle a select button press.
Definition integer.h:45
uint8_t shouldBlinkPatchingSourceShortcut(PatchSource s, uint8_t *colour) final
Definition integer.h:40
void readCurrentValue() override
Like readValueAgain, but does not redraw.
Definition integer.cpp:33
MenuItem * patchingSourceShortcutPress(PatchSource s, bool previousPressStillActive=false) final
Action to take when a source shortcut is pressed.
Definition integer.h:56
void unlearnAction() final
Unlearn the parameter controlled by this menu.
Definition integer.h:60
Kind
Definition param.h:42