24class Portamento final :
public UnpatchedParam {
26 using UnpatchedParam::UnpatchedParam;
28 Portamento(l10n::String newName) : UnpatchedParam(newName, deluge::modulation::params::UNPATCHED_PORTAMENTO) {}
30 void getColumnLabel(
StringBuf& label)
override {
31 label.append(deluge::l10n::get(l10n::String::STRING_FOR_PORTAMENTO_SHORT));
34 void renderInHorizontalMenu(
const SlotPosition& slot)
override {
35 using namespace deluge::hid::display;
38 constexpr uint8_t porta_graphics_width = 25;
39 const uint8_t center_x = slot.start_x + slot.width / 2;
40 const uint8_t porta_start_x = slot.start_x + 2;
41 const uint8_t porta_end_x = porta_start_x + porta_graphics_width - 1;
43 constexpr uint8_t porta_graphics_height = 11;
44 const uint8_t porta_start_y = slot.start_y + kHorizontalMenuSlotYOffset - 1;
45 const uint8_t porta_end_y = porta_start_y + porta_graphics_height - 1;
47 const float norm = normalize(getValue());
48 constexpr uint8_t porta_line_width = 9;
49 const uint8_t porta_x0 = std::lerp(center_x, center_x - porta_line_width, norm);
50 const uint8_t porta_x1 = std::lerp(center_x, center_x + porta_line_width, norm);
52 if (porta_x0 == porta_x1) {
53 for (uint8_t y = porta_start_y; y <= porta_end_y; y += 2) {
54 image.drawPixel(porta_x0, y);
58 image.drawLine(porta_x0, porta_end_y, porta_x1, porta_start_y);
61 constexpr uint8_t max_note_width = 6;
62 constexpr uint8_t note_offset = 2;
63 const uint8_t lower_note_start_x = std::max<uint8_t>(porta_start_x, porta_x0 - note_offset - max_note_width);
64 const uint8_t higher_note_end_x = std::min<uint8_t>(porta_end_x, porta_x1 + note_offset + max_note_width);
66 image.drawHorizontalLine(porta_end_y, lower_note_start_x, porta_x0 - note_offset);
67 image.drawHorizontalLine(porta_end_y - 1, lower_note_start_x, porta_x0 - note_offset);
68 image.drawHorizontalLine(porta_start_y, porta_x1 + note_offset, higher_note_end_x);
69 image.drawHorizontalLine(porta_start_y + 1, porta_x1 + note_offset, higher_note_end_x);