Deluge Firmware 1.3.0
Build date: 2025.09.14
Loading...
Searching...
No Matches
actual_source.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/ui/sound_editor.h"
19#include "processing/sound/sound.h"
20#include "string.h"
21
22namespace deluge::gui::menu_item::submenu {
23class ActualSource final : public HorizontalMenu {
24public:
25 ActualSource(l10n::String newName, std::span<MenuItem*> newItems, uint8_t sourceId)
26 : HorizontalMenu(newName, newItems), source_id_{sourceId} {}
27
28 [[nodiscard]] std::string_view getName() const override { return getNameOrTitle(title); }
29 [[nodiscard]] std::string_view getTitle() const override {
30 auto l10nString = title;
31
32 // If we are in the sample oscillator menu and not on the first page,
33 // we display OSC1/2 SAMPLE as the menu title
34 const auto& source = soundEditor.currentSound->sources[source_id_];
35 if (renderingStyle() == HORIZONTAL && source.oscType == OscType::SAMPLE && paging.visiblePageNumber > 0) {
36 l10nString = l10n::String::STRING_FOR_OSC_SAMPLE_MENU_TITLE;
37 }
38
39 return getNameOrTitle(l10nString);
40 }
41
42 // 7seg Only
43 void drawName() override {
44 if (soundEditor.currentSound->getSynthMode() == SynthMode::FM) {
45 char buffer[5];
46 strcpy(buffer, "CAR");
47 intToString(source_id_ + 1, buffer + 3);
48 display->setText(buffer);
49 }
50 else {
52 }
53 }
54
55private:
56 uint8_t source_id_;
57 mutable std::string name_or_title_;
58
59 std::string_view getNameOrTitle(l10n::String l10n) const {
60 std::string result = l10n::get(l10n);
61 asterixToInt(result.data(), source_id_ + 1);
62 name_or_title_ = result;
63 return name_or_title_;
64 }
65};
66
67} // namespace deluge::gui::menu_item::submenu
deluge::l10n::String title
Can get overridden by getTitle(). Actual max num chars for OLED display is 14.
Definition menu_item.h:215
virtual void drawName()
Draw the name we want to use when selecting this in a deluge::gui::menu_item::Submenu to the 7SEG.
Definition menu_item.cpp:43
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 actual_source.h:29
void drawName() override
Draw the name we want to use when selecting this in a deluge::gui::menu_item::Submenu to the 7SEG.
Definition actual_source.h:43
std::string_view getName() const override
Get the actual name for use on OLED for deluge::gui::menu_item::Submenu s.
Definition actual_source.h:28