1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 16:37:47 +00:00

LibGUI+Userland: Port Labels to String

This commit is contained in:
thankyouverycool 2023-04-29 10:41:48 -04:00 committed by Andreas Kling
parent 3d53dc8228
commit 91bafc2653
92 changed files with 240 additions and 242 deletions

View file

@ -15,11 +15,11 @@ ProcessorParameterWidget::ProcessorParameterWidget(DSP::ProcessorParameter& raw_
: m_parameter(raw_parameter)
{
set_layout<GUI::VerticalBoxLayout>();
m_label = add<GUI::Label>(raw_parameter.name().to_deprecated_string());
m_label = add<GUI::Label>(raw_parameter.name());
switch (raw_parameter.type()) {
case DSP::ParameterType::Range: {
auto& parameter = static_cast<DSP::ProcessorRangeParameter&>(raw_parameter);
m_value_label = add<GUI::Label>(DeprecatedString::number(static_cast<double>(parameter.value())));
m_value_label = add<GUI::Label>(String::number(static_cast<double>(parameter.value())).release_value_but_fixme_should_propagate_errors());
m_parameter_modifier = add<ProcessorParameterSlider>(Orientation::Vertical, parameter, m_value_label);
break;
}

View file

@ -28,7 +28,7 @@ ProcessorParameterSlider::ProcessorParameterSlider(Orientation orientation, DSP:
}
set_tooltip(m_parameter.name().to_deprecated_string());
if (m_value_label != nullptr)
m_value_label->set_text(DeprecatedString::formatted("{:.2f}", static_cast<double>(m_parameter)));
m_value_label->set_text(String::formatted("{:.2f}", static_cast<double>(m_parameter)).release_value_but_fixme_should_propagate_errors());
on_change = [this](auto raw_value) {
if (m_currently_setting_from_ui)
@ -43,13 +43,9 @@ ProcessorParameterSlider::ProcessorParameterSlider(Orientation orientation, DSP:
m_parameter.set_value(real_value);
if (m_value_label) {
double value = static_cast<double>(m_parameter);
DeprecatedString label_text = DeprecatedString::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(DeprecatedString::formatted("{:.0f}", value));
else
m_value_label->set_text(label_text);
auto label_text = String::formatted("{:.2f}", value).release_value_but_fixme_should_propagate_errors();
m_value_label->set_autosize(true);
m_value_label->set_text(label_text);
}
m_currently_setting_from_ui = false;
};