Deluge Firmware 1.3.0
Build date: 2025.09.14
Loading...
Searching...
No Matches
decimal.h
1/*
2 * Copyright © 2017-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
18#pragma once
19
20#include "number.h"
21
22namespace deluge::gui::menu_item {
23
24class Decimal : public Number {
25public:
26 using Number::Number;
27 void beginSession(MenuItem* navigatedBackwardFrom = nullptr) override;
28 void selectEncoderAction(int32_t offset) override;
29 void horizontalEncoderAction(int32_t offset) override;
30 void renderInHorizontalMenu(int32_t startX, int32_t width, int32_t startY, int32_t height) override;
31 void getNotificationValue(StringBuf& valueBuf) override { valueBuf.appendFloat(getValue() / 100.f, 2, 2); }
32 [[nodiscard]] NumberStyle getNumberStyle() const override { return NUMBER; }
33
34protected:
35 void drawValue() override;
36 [[nodiscard]] virtual int32_t getNumDecimalPlaces() const = 0;
37 [[nodiscard]] virtual int32_t getDefaultEditPos() const { return 2; }
38 [[nodiscard]] virtual int32_t getNumberEditSize();
39
40 void drawPixelsForOled() override;
41
42 // 7Seg Only
43 virtual void drawActualValue(bool justDidHorizontalScroll = false);
44 virtual void appendAdditionalDots(std::vector<uint8_t>& dotPositions) {};
45 static int32_t getNumNonZeroDecimals(int32_t value);
46
47private:
48 void scrollToGoodPos();
49};
50
52 using Decimal::Decimal;
53
54public:
55 void selectEncoderAction(int32_t offset) override;
56 void horizontalEncoderAction(int32_t offset) override { return; }
57
58protected:
59 virtual float getDisplayValue() { return this->getValue(); }
60 void getNotificationValue(StringBuf& value) override;
61 virtual const char* getUnit() { return ""; }
62 void drawPixelsForOled() override;
63 void drawDecimal(int32_t textWidth, int32_t textHeight, int32_t yPixel);
64 // 7Seg Only
65 void drawActualValue(bool justDidHorizontalScroll = false) override;
66};
67
68} // namespace deluge::gui::menu_item
Definition d_stringbuf.h:16
void horizontalEncoderAction(int32_t offset) override
Handle horizontal encoder movement.
Definition decimal.h:56
void drawPixelsForOled() override
Paints the pixels below the standard title block.
Definition decimal.cpp:262
void selectEncoderAction(int32_t offset) override
Handle select encoder movement.
Definition decimal.cpp:238
void getNotificationValue(StringBuf &value) override
Get the parameter value string to show in the popup.
Definition decimal.cpp:274
Definition decimal.h:24
void beginSession(MenuItem *navigatedBackwardFrom=nullptr) override
Begin an editing session with this menu item.
Definition decimal.cpp:34
void selectEncoderAction(int32_t offset) override
Handle select encoder movement.
Definition decimal.cpp:65
void drawPixelsForOled() override
Paints the pixels below the standard title block.
Definition decimal.cpp:142
void getNotificationValue(StringBuf &valueBuf) override
Get the parameter value string to show in the popup.
Definition decimal.h:31
void horizontalEncoderAction(int32_t offset) override
Handle horizontal encoder movement.
Definition decimal.cpp:91
Definition number.h:27