28class Type final :
public Selection, FormattedTitle {
30 Type(l10n::String name, l10n::String title, uint8_t lfoId)
31 :
Selection(name, title), FormattedTitle(title, lfoId + 1), lfoId_(lfoId) {}
33 [[nodiscard]] std::string_view
getTitle()
const override {
return FormattedTitle::title(); }
35 deluge::vector<std::string_view> getOptions(OptType optType)
override {
36 using enum l10n::String;
37 bool shortOpt = optType == OptType::SHORT;
39 l10n::getView(STRING_FOR_SINE),
40 l10n::getView(STRING_FOR_TRIANGLE),
41 l10n::getView(STRING_FOR_SQUARE),
42 l10n::getView(STRING_FOR_SAW),
43 l10n::getView(STRING_FOR_SAMPLE_AND_HOLD),
44 l10n::getView(shortOpt ? STRING_FOR_RANDOM_WALK_SHORT : STRING_FOR_RANDOM_WALK),
45 l10n::getView(STRING_FOR_WARBLE),
49 void readCurrentValue()
override { this->setValue(soundEditor.currentSound->lfoConfig[lfoId_].waveType); }
51 void writeCurrentValue()
override {
52 auto current_value = this->getValue<LFOType>();
54 if (currentUIMode == UI_MODE_HOLDING_AFFECT_ENTIRE_IN_SOUND_EDITOR && soundEditor.editingKitRow()) {
56 Kit* kit = getCurrentKit();
58 for (
Drum* thisDrum = kit->firstDrum; thisDrum !=
nullptr; thisDrum = thisDrum->next) {
59 if (thisDrum->type == DrumType::SOUND) {
60 auto* soundDrum =
static_cast<SoundDrum*
>(thisDrum);
61 soundDrum->lfoConfig[lfoId_].waveType = current_value;
65 soundDrum->resyncGlobalLFOs();
71 soundEditor.currentSound->lfoConfig[lfoId_].waveType = current_value;
75 soundEditor.currentSound->resyncGlobalLFOs();
80 void renderInHorizontalMenu(int32_t startX, int32_t width, int32_t startY, int32_t height)
override {
83 const Icon& icon = [&] {
84 switch (soundEditor.currentSound->lfoConfig[lfoId_].waveType) {
86 return OLED::sineIcon;
87 case LFOType::TRIANGLE:
88 return OLED::triangleIcon;
90 return OLED::squareIcon;
93 case LFOType::SAMPLE_AND_HOLD:
94 return OLED::sampleHoldIcon;
95 case LFOType::RANDOM_WALK:
96 return OLED::randomWalkIcon;
97 case LFOType::WARBLER:
98 return OLED::warblerIcon;
100 return OLED::sineIcon;
103 image.drawIconCentered(icon, startX, width, startY + 4);