26class RetriggerPhase final :
public Decimal,
public FormattedTitle {
28 RetriggerPhase(l10n::String newName, l10n::String title_format_str, uint8_t source_id,
bool newForModulator =
false)
29 :
Decimal(newName), FormattedTitle(title_format_str, source_id + 1), for_modulator_(newForModulator),
30 source_id_(source_id) {}
32 [[nodiscard]] std::string_view
getTitle()
const override {
return FormattedTitle::title(); }
34 [[nodiscard]] int32_t getMinValue()
const override {
return -1; }
35 [[nodiscard]] int32_t getMaxValue()
const override {
return 360; }
36 [[nodiscard]] int32_t getNumDecimalPlaces()
const override {
return 0; }
37 [[nodiscard]] int32_t getDefaultEditPos()
const override {
return 1; }
40 uint32_t value = *getValueAddress();
41 if (value == 0xFFFFFFFF) {
45 this->setValue(value / 11930464);
49 void writeCurrentValue()
override {
51 if (this->getValue() < 0) {
55 value = this->getValue() * 11930464;
57 *getValueAddress() = value;
60 void drawValue()
override {
61 if (this->getValue() < 0) {
62 display->setText(l10n::get(l10n::String::STRING_FOR_DISABLED),
false, 255,
true);
71 if (this->getValue() < 0) {
72 canvas.
drawStringCentred(l10n::get(l10n::String::STRING_FOR_OFF), 20, kTextHugeSpacingX, kTextHugeSizeY);
80 if (this->getValue() >= 0) {
86 const auto sound =
static_cast<Sound*
>(modControllable);
87 Source& source = sound->sources[source_id_];
89 if (for_modulator_ && sound->getSynthMode() != SynthMode::FM) {
92 if (source.oscType == OscType::WAVETABLE) {
93 return source.hasAtLeastOneAudioFileLoaded();
96 return source.oscType != OscType::SAMPLE || sound->getSynthMode() == SynthMode::FM;
99 int32_t getNumberEditSize()
override {
100 if (parent !=
nullptr && parent->renderingStyle() == Submenu::RenderingStyle::HORIZONTAL) {
102 return Buttons::isButtonPressed(hid::button::SHIFT) ? 1 : 10;
104 return Decimal::getNumberEditSize();
108 if (offset > 0 && getValue() < 0) {
109 setValue(-getNumberEditSize());
114 void renderInHorizontalMenu(int32_t startX, int32_t width, int32_t startY, int32_t height)
override {
116 if (this->getValue() < 0) {
117 const char* off = l10n::get(l10n::String::STRING_FOR_OFF);
118 return canvas.
drawStringCentered(off, startX, startY + 3, kTextSpacingX, kTextSpacingY, width);
121 return Decimal::renderInHorizontalMenu(startX, width, startY, height);
125 if (this->getValue() < 0) {
126 return valueBuf.append(l10n::get(l10n::String::STRING_FOR_OFF));
128 valueBuf.appendInt(getValue());
131 void getColumnLabel(
StringBuf& label)
override {
132 label.append(l10n::get(l10n::String::STRING_FOR_RETRIGGER_PHASE_SHORT));
135 [[nodiscard]] NumberStyle getNumberStyle()
const override {
return SLIDER; }
141 [[nodiscard]] uint32_t* getValueAddress()
const {
142 if (for_modulator_) {
143 return &soundEditor.currentSound->modulatorRetriggerPhase[source_id_];
145 return &soundEditor.currentSound->oscRetriggerPhase[source_id_];
void drawStringCentered(char const *string, int32_t startX, int32_t startY, int32_t textSpacingX, int32_t textSpacingY, int32_t totalWidth)
Definition canvas.cpp:274
void drawStringCentred(char const *string, int32_t pixelY, int32_t textWidth, int32_t textHeight, int32_t centrePos=OLED_MAIN_WIDTH_PIXELS/2)
Definition canvas.cpp:266