Deluge Firmware 1.3.0
Build date: 2025.09.27
Loading...
Searching...
No Matches
tracking.h
1/*
2 * Copyright (c) 2025 Nikodemus Siivola
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 "deluge/gui/menu_item/horizontal_menu.h"
19#include "gui/menu_item/formatted_title.h"
20#include "gui/menu_item/toggle.h"
21#include "gui/ui/sound_editor.h"
22#include "hid/display/oled.h"
23#include "model/song/song.h"
24#include "processing/sound/sound.h"
25
26namespace deluge::gui::menu_item::osc {
27class Tracking final : public Toggle, public FormattedTitle {
28public:
29 using Toggle::Toggle;
30 Tracking(l10n::String title_format_str, uint8_t source_id)
31 : Toggle(), FormattedTitle(title_format_str, source_id + 1), source_id_{source_id} {}
32 void readCurrentValue() override { this->setValue(soundEditor.currentSound->sources[source_id_].isTracking); }
33 void writeCurrentValue() override { soundEditor.currentSound->sources[source_id_].isTracking = this->getValue(); }
34
35 [[nodiscard]] std::string_view getName() const override { return FormattedTitle::title(); }
36 [[nodiscard]] std::string_view getTitle() const override { return FormattedTitle::title(); }
37
38 void getColumnLabel(StringBuf& label) override {
39 label.append(getName());
40 label.truncate(4);
41 }
42
43 void selectEncoderAction(int32_t offset) override {
44 if (parent != nullptr && parent->renderingStyle() == Submenu::RenderingStyle::HORIZONTAL) {
45 // reverse direction
46 offset *= -1;
47 }
49 }
50
51 void renderInHorizontalMenu(int32_t startX, int32_t width, int32_t startY, int32_t height) override {
52 using namespace deluge::hid::display;
53 const auto& icon = getValue() ? OLED::oscTrackingEnabledIcon : OLED::oscTrackingDisabledIcon;
54 OLED::main.drawIconCentered(icon, startX, width, startY);
55 }
56
57private:
58 uint8_t source_id_;
59};
60
61} // namespace deluge::gui::menu_item::osc
Definition d_stringbuf.h:16
Definition toggle.h:8
void selectEncoderAction(int32_t offset) override
Handle select encoder movement.
Definition toggle.cpp:14
std::string_view getName() const override
Get the actual name for use on OLED for deluge::gui::menu_item::Submenu s.
Definition tracking.h:35
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 tracking.h:36
void readCurrentValue() override
Like readValueAgain, but does not redraw.
Definition tracking.h:32
void selectEncoderAction(int32_t offset) override
Handle select encoder movement.
Definition tracking.h:43