1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-28 00:37:35 +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

@ -38,7 +38,7 @@ ErrorOr<void> ExportProgressWindow::initialize_fallibles()
void ExportProgressWindow::set_filename(StringView filename)
{
m_label->set_text(DeprecatedString::formatted("Rendering audio to {}…", filename));
m_label->set_text(String::formatted("Rendering audio to {}…", filename).release_value_but_fixme_should_propagate_errors());
update();
}

View file

@ -59,9 +59,9 @@ ErrorOr<void> MainWidget::initialize()
m_octave_container = TRY(m_keys_and_knobs_container->try_add<GUI::Widget>());
m_octave_container->set_preferred_width(GUI::SpecialDimension::Fit);
TRY(m_octave_container->try_set_layout<GUI::VerticalBoxLayout>());
auto octave_label = TRY(m_octave_container->try_add<GUI::Label>("Octave"));
auto octave_label = TRY(m_octave_container->try_add<GUI::Label>("Octave"_short_string));
octave_label->set_preferred_width(GUI::SpecialDimension::Fit);
m_octave_value = TRY(m_octave_container->try_add<GUI::Label>(DeprecatedString::number(m_track_manager.keyboard()->virtual_keyboard_octave())));
m_octave_value = TRY(m_octave_container->try_add<GUI::Label>(TRY(String::number(m_track_manager.keyboard()->virtual_keyboard_octave()))));
m_octave_value->set_preferred_width(GUI::SpecialDimension::Fit);
// FIXME: Implement vertical flipping in GUI::Slider, not here.
@ -75,7 +75,7 @@ ErrorOr<void> MainWidget::initialize()
int new_octave = octave_max - value;
set_octave_via_slider(new_octave);
VERIFY(new_octave == m_track_manager.keyboard()->virtual_keyboard_octave());
m_octave_value->set_text(DeprecatedString::number(new_octave));
m_octave_value->set_text(String::number(new_octave).release_value_but_fixme_should_propagate_errors());
};
m_knobs_widget = TRY(m_keys_and_knobs_container->try_add<TrackControlsWidget>(m_track_manager, *this));

View file

@ -43,7 +43,7 @@ ErrorOr<void> PlayerWidget::initialize()
set_fill_with_background_color(true);
TRY(m_track_number_choices.try_append("1"));
RefPtr<GUI::Label> label = TRY(try_add<GUI::Label>("Track"));
RefPtr<GUI::Label> label = TRY(try_add<GUI::Label>("Track"_short_string));
label->set_max_width(75);
m_track_dropdown = TRY(try_add<GUI::ComboBox>());

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;
};

View file

@ -56,11 +56,11 @@ SamplerWidget::SamplerWidget(TrackManager& track_manager)
if (!open_path.has_value())
return;
// TODO: We don't actually load the sample.
m_recorded_sample_name->set_text(open_path.value());
m_recorded_sample_name->set_text(String::from_deprecated_string(open_path.value()).release_value_but_fixme_should_propagate_errors());
m_wave_editor->update();
};
m_recorded_sample_name = m_open_button_and_recorded_sample_name_container->add<GUI::Label>("No sample loaded");
m_recorded_sample_name = m_open_button_and_recorded_sample_name_container->add<GUI::Label>("No sample loaded"_string.release_value_but_fixme_should_propagate_errors());
m_recorded_sample_name->set_text_alignment(Gfx::TextAlignment::CenterLeft);
m_wave_editor = add<WaveEditor>(m_track_manager);