Deluge Firmware
1.3.0
Build date: 2026.08.23
Toggle main menu visibility
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
22
namespace
deluge::gui::menu_item {
23
24
class
Decimal
:
public
Number
{
25
public
:
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(
const
SlotPosition
& slot)
override
;
31
void
getNotificationValue
(
StringBuf
& valueBuf)
override
{ valueBuf.appendFloat(getValue() / 100.f, 2, 2); }
32
[[nodiscard]] RenderingStyle getRenderingStyle()
const override
{
return
NUMBER; }
33
34
protected
:
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
47
private
:
48
void
scrollToGoodPos();
49
};
50
51
class
DecimalWithoutScrolling
:
public
Decimal
{
52
using
Decimal::Decimal;
53
54
public
:
55
void
selectEncoderAction
(int32_t offset)
override
;
56
void
horizontalEncoderAction
(int32_t offset)
override
{
return
; }
57
58
protected
:
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
StringBuf
Definition
d_stringbuf.h:16
deluge::gui::menu_item::DecimalWithoutScrolling
Definition
decimal.h:51
deluge::gui::menu_item::DecimalWithoutScrolling::horizontalEncoderAction
void horizontalEncoderAction(int32_t offset) override
Handle horizontal encoder movement.
Definition
decimal.h:56
deluge::gui::menu_item::DecimalWithoutScrolling::drawPixelsForOled
void drawPixelsForOled() override
Paints the pixels below the standard title block.
Definition
decimal.cpp:263
deluge::gui::menu_item::DecimalWithoutScrolling::selectEncoderAction
void selectEncoderAction(int32_t offset) override
Handle select encoder movement.
Definition
decimal.cpp:239
deluge::gui::menu_item::DecimalWithoutScrolling::getNotificationValue
void getNotificationValue(StringBuf &value) override
Get the parameter value string to show in the popup.
Definition
decimal.cpp:275
deluge::gui::menu_item::Decimal
Definition
decimal.h:24
deluge::gui::menu_item::Decimal::beginSession
void beginSession(MenuItem *navigatedBackwardFrom=nullptr) override
Begin an editing session with this menu item.
Definition
decimal.cpp:34
deluge::gui::menu_item::Decimal::selectEncoderAction
void selectEncoderAction(int32_t offset) override
Handle select encoder movement.
Definition
decimal.cpp:65
deluge::gui::menu_item::Decimal::drawPixelsForOled
void drawPixelsForOled() override
Paints the pixels below the standard title block.
Definition
decimal.cpp:142
deluge::gui::menu_item::Decimal::getNotificationValue
void getNotificationValue(StringBuf &valueBuf) override
Get the parameter value string to show in the popup.
Definition
decimal.h:31
deluge::gui::menu_item::Decimal::horizontalEncoderAction
void horizontalEncoderAction(int32_t offset) override
Handle horizontal encoder movement.
Definition
decimal.cpp:91
deluge::gui::menu_item::Number
Definition
number.h:40
SlotPosition
Definition
menu_item.h:33