diff options
author | kleines Filmröllchen <malu.bertsch@gmail.com> | 2021-10-06 18:57:47 +0200 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2021-11-15 23:04:16 +0000 |
commit | cca4268ff84b7abd09b04db4f8d73cbdf960110c (patch) | |
tree | f9cae9920014b1ddc4c4ff463b40aaec73b0f37c /Userland/Applications | |
parent | d50b1465c352fdb472638b196db7644f231deb3a (diff) | |
download | serenity-cca4268ff84b7abd09b04db4f8d73cbdf960110c.zip |
Piano: Always show Processor parameter values
The processor parameter values are displayed with two decimal places by
default. However, when these values become very large and exceed about 7
text symbols, the text is too long to fit the label and it'll simply not
show up. This commit fixes that by disabling the decimal place for such
large values, which allows us to show values up to 9,999,999, be it
only at integer precision.
Diffstat (limited to 'Userland/Applications')
-rw-r--r-- | Userland/Applications/Piano/ProcessorParameterSlider.cpp | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/Userland/Applications/Piano/ProcessorParameterSlider.cpp b/Userland/Applications/Piano/ProcessorParameterSlider.cpp index fd7b20e67a..e83648f48c 100644 --- a/Userland/Applications/Piano/ProcessorParameterSlider.cpp +++ b/Userland/Applications/Piano/ProcessorParameterSlider.cpp @@ -21,8 +21,16 @@ ProcessorParameterSlider::ProcessorParameterSlider(Orientation orientation, LibD LibDSP::ParameterFixedPoint real_value; real_value.raw() = value; m_parameter.set_value_sneaky(real_value, LibDSP::Detail::ProcessorParameterSetValueTag {}); - if (m_value_label) - m_value_label->set_text(String::formatted("{:.2f}", static_cast<double>(m_parameter))); + if (m_value_label) { + double value = static_cast<double>(m_parameter); + String label_text = String::formatted("{:.2f}", value); + // FIXME: This is a magic value; we know that with normal font sizes, the label will disappear starting from approximately this length. + // Can we do this dynamically? + if (label_text.length() > 7) + m_value_label->set_text(String::formatted("{:.0f}", value)); + else + m_value_label->set_text(label_text); + } }; m_parameter.did_change_value = [this](auto value) { set_value(value.raw()); |