diff options
author | Karol Kosek <krkk@serenityos.org> | 2023-02-12 18:06:01 +0100 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2023-02-13 00:26:39 +0000 |
commit | 67ffc687d81ac0073912889036d6f394547cf2b9 (patch) | |
tree | c111a63e2af80673385faa9510e1787f8c1f6133 /Userland | |
parent | c4507bb56e5ef970abe2d103a6bacbc41b847106 (diff) | |
download | serenity-67ffc687d81ac0073912889036d6f394547cf2b9.zip |
LibGUI+PixelPaint: Port GUI::ValueSlider's suffix to the new String
Diffstat (limited to 'Userland')
18 files changed, 30 insertions, 29 deletions
diff --git a/Userland/Applications/PixelPaint/Filters/Bloom.cpp b/Userland/Applications/PixelPaint/Filters/Bloom.cpp index 3f16d93120..8347f5a521 100644 --- a/Userland/Applications/PixelPaint/Filters/Bloom.cpp +++ b/Userland/Applications/PixelPaint/Filters/Bloom.cpp @@ -71,7 +71,7 @@ RefPtr<GUI::Widget> Bloom::get_settings_widget() radius_label.set_text_alignment(Gfx::TextAlignment::CenterLeft); radius_label.set_fixed_height(20); - auto& radius_slider = radius_container.add<GUI::ValueSlider>(Orientation::Horizontal, "px"); + auto& radius_slider = radius_container.add<GUI::ValueSlider>(Orientation::Horizontal, String::from_utf8_short_string("px"sv)); radius_slider.set_range(0, 50); radius_slider.set_value(m_blur_radius); radius_slider.on_change = [&](int value) { diff --git a/Userland/Applications/PixelPaint/Filters/FastBoxBlur.cpp b/Userland/Applications/PixelPaint/Filters/FastBoxBlur.cpp index e12d15bf1a..a5279c223c 100644 --- a/Userland/Applications/PixelPaint/Filters/FastBoxBlur.cpp +++ b/Userland/Applications/PixelPaint/Filters/FastBoxBlur.cpp @@ -93,7 +93,7 @@ RefPtr<GUI::Widget> FastBoxBlur::get_settings_widget() radius_label.set_text_alignment(Gfx::TextAlignment::CenterLeft); radius_label.set_fixed_size(50, 20); - auto& radius_slider = m_radius_container->add<GUI::ValueSlider>(Orientation::Horizontal, "px"); + auto& radius_slider = m_radius_container->add<GUI::ValueSlider>(Orientation::Horizontal, String::from_utf8_short_string("px"sv)); radius_slider.set_range(0, 25); radius_slider.set_value(m_radius); radius_slider.on_change = [&](int value) { @@ -115,7 +115,7 @@ RefPtr<GUI::Widget> FastBoxBlur::get_settings_widget() radius_x_label.set_text_alignment(Gfx::TextAlignment::CenterLeft); radius_x_label.set_fixed_size(50, 20); - m_radius_x_slider = radius_x_container.add<GUI::ValueSlider>(Orientation::Horizontal, "px"); + m_radius_x_slider = radius_x_container.add<GUI::ValueSlider>(Orientation::Horizontal, String::from_utf8_short_string("px"sv)); m_radius_x_slider->set_range(0, 50); m_radius_x_slider->set_value(m_radius_x); m_radius_x_slider->on_change = [&](int value) { @@ -131,7 +131,7 @@ RefPtr<GUI::Widget> FastBoxBlur::get_settings_widget() radius_y_label.set_text_alignment(Gfx::TextAlignment::CenterLeft); radius_y_label.set_fixed_size(50, 20); - m_radius_y_slider = radius_y_container.add<GUI::ValueSlider>(Orientation::Horizontal, "px"); + m_radius_y_slider = radius_y_container.add<GUI::ValueSlider>(Orientation::Horizontal, String::from_utf8_short_string("px"sv)); m_radius_y_slider->set_range(0, 50); m_radius_y_slider->set_value(m_radius_y); m_radius_y_slider->on_change = [&](int value) { @@ -153,7 +153,7 @@ RefPtr<GUI::Widget> FastBoxBlur::get_settings_widget() angle_label.set_text_alignment(Gfx::TextAlignment::CenterLeft); angle_label.set_fixed_size(60, 20); - m_angle_slider = angle_container.add<GUI::ValueSlider>(Orientation::Horizontal, "°"); + m_angle_slider = angle_container.add<GUI::ValueSlider>(Orientation::Horizontal, String::from_utf8_short_string("°"sv)); m_angle_slider->set_range(0, 360); m_angle_slider->set_value(m_angle); m_angle_slider->on_change = [&](int value) { @@ -169,7 +169,7 @@ RefPtr<GUI::Widget> FastBoxBlur::get_settings_widget() magnitude_label.set_text_alignment(Gfx::TextAlignment::CenterLeft); magnitude_label.set_fixed_size(60, 20); - m_magnitude_slider = magnitude_container.add<GUI::ValueSlider>(Orientation::Horizontal, "px"); + m_magnitude_slider = magnitude_container.add<GUI::ValueSlider>(Orientation::Horizontal, String::from_utf8_short_string("px"sv)); m_magnitude_slider->set_range(0, 50); m_magnitude_slider->set_value(m_radius); m_magnitude_slider->on_change = [&](int value) { diff --git a/Userland/Applications/PixelPaint/Filters/Sepia.cpp b/Userland/Applications/PixelPaint/Filters/Sepia.cpp index e3e0851502..771fe465ae 100644 --- a/Userland/Applications/PixelPaint/Filters/Sepia.cpp +++ b/Userland/Applications/PixelPaint/Filters/Sepia.cpp @@ -37,7 +37,7 @@ RefPtr<GUI::Widget> Sepia::get_settings_widget() amount_label.set_text_alignment(Gfx::TextAlignment::CenterLeft); amount_label.set_fixed_size(50, 20); - auto& amount_slider = amount_container.add<GUI::ValueSlider>(Orientation::Horizontal, "%"); + auto& amount_slider = amount_container.add<GUI::ValueSlider>(Orientation::Horizontal, String::from_utf8_short_string("%"sv)); amount_slider.set_range(0, 100); amount_slider.set_value(m_amount * 100); amount_slider.on_change = [&](int value) { diff --git a/Userland/Applications/PixelPaint/Tools/BrushTool.cpp b/Userland/Applications/PixelPaint/Tools/BrushTool.cpp index 4c4ced3b6f..a4eff7ebd5 100644 --- a/Userland/Applications/PixelPaint/Tools/BrushTool.cpp +++ b/Userland/Applications/PixelPaint/Tools/BrushTool.cpp @@ -151,7 +151,7 @@ GUI::Widget* BrushTool::get_properties_widget() size_label.set_text_alignment(Gfx::TextAlignment::CenterLeft); size_label.set_fixed_size(80, 20); - auto& size_slider = size_container.add<GUI::ValueSlider>(Orientation::Horizontal, "px"); + auto& size_slider = size_container.add<GUI::ValueSlider>(Orientation::Horizontal, String::from_utf8_short_string("px"sv)); size_slider.set_range(1, 100); size_slider.set_value(m_size); size_slider.set_override_cursor(cursor()); @@ -171,7 +171,7 @@ GUI::Widget* BrushTool::get_properties_widget() hardness_label.set_text_alignment(Gfx::TextAlignment::CenterLeft); hardness_label.set_fixed_size(80, 20); - auto& hardness_slider = hardness_container.add<GUI::ValueSlider>(Orientation::Horizontal, "%"); + auto& hardness_slider = hardness_container.add<GUI::ValueSlider>(Orientation::Horizontal, String::from_utf8_short_string("%"sv)); hardness_slider.set_range(1, 100); hardness_slider.set_value(m_hardness); diff --git a/Userland/Applications/PixelPaint/Tools/BucketTool.cpp b/Userland/Applications/PixelPaint/Tools/BucketTool.cpp index b3beac27d4..9ec1b85158 100644 --- a/Userland/Applications/PixelPaint/Tools/BucketTool.cpp +++ b/Userland/Applications/PixelPaint/Tools/BucketTool.cpp @@ -75,7 +75,7 @@ GUI::Widget* BucketTool::get_properties_widget() threshold_label.set_text_alignment(Gfx::TextAlignment::CenterLeft); threshold_label.set_fixed_size(80, 20); - auto& threshold_slider = threshold_container.add<GUI::ValueSlider>(Orientation::Horizontal, "%"); + auto& threshold_slider = threshold_container.add<GUI::ValueSlider>(Orientation::Horizontal, String::from_utf8_short_string("%"sv)); threshold_slider.set_range(0, 100); threshold_slider.set_value(m_threshold); diff --git a/Userland/Applications/PixelPaint/Tools/CloneTool.cpp b/Userland/Applications/PixelPaint/Tools/CloneTool.cpp index 5cbc4f8b90..0fdf32690b 100644 --- a/Userland/Applications/PixelPaint/Tools/CloneTool.cpp +++ b/Userland/Applications/PixelPaint/Tools/CloneTool.cpp @@ -147,7 +147,7 @@ GUI::Widget* CloneTool::get_properties_widget() size_label.set_text_alignment(Gfx::TextAlignment::CenterLeft); size_label.set_fixed_size(80, 20); - auto& size_slider = size_container.add<GUI::ValueSlider>(Orientation::Horizontal, "px"); + auto& size_slider = size_container.add<GUI::ValueSlider>(Orientation::Horizontal, String::from_utf8_short_string("px"sv)); size_slider.set_range(1, 100); size_slider.set_value(size()); @@ -164,7 +164,7 @@ GUI::Widget* CloneTool::get_properties_widget() hardness_label.set_text_alignment(Gfx::TextAlignment::CenterLeft); hardness_label.set_fixed_size(80, 20); - auto& hardness_slider = hardness_container.add<GUI::ValueSlider>(Orientation::Horizontal, "%"); + auto& hardness_slider = hardness_container.add<GUI::ValueSlider>(Orientation::Horizontal, String::from_utf8_short_string("%"sv)); hardness_slider.set_range(1, 100); hardness_slider.on_change = [&](int value) { set_hardness(value); diff --git a/Userland/Applications/PixelPaint/Tools/EllipseTool.cpp b/Userland/Applications/PixelPaint/Tools/EllipseTool.cpp index a8bab9399a..893005277c 100644 --- a/Userland/Applications/PixelPaint/Tools/EllipseTool.cpp +++ b/Userland/Applications/PixelPaint/Tools/EllipseTool.cpp @@ -140,7 +140,7 @@ GUI::Widget* EllipseTool::get_properties_widget() thickness_label.set_text_alignment(Gfx::TextAlignment::CenterLeft); thickness_label.set_fixed_size(80, 20); - auto& thickness_slider = thickness_container.add<GUI::ValueSlider>(Orientation::Horizontal, "px"); + auto& thickness_slider = thickness_container.add<GUI::ValueSlider>(Orientation::Horizontal, String::from_utf8_short_string("px"sv)); thickness_slider.set_range(1, 10); thickness_slider.set_value(m_thickness); diff --git a/Userland/Applications/PixelPaint/Tools/EraseTool.cpp b/Userland/Applications/PixelPaint/Tools/EraseTool.cpp index faf0c65327..e6564abd04 100644 --- a/Userland/Applications/PixelPaint/Tools/EraseTool.cpp +++ b/Userland/Applications/PixelPaint/Tools/EraseTool.cpp @@ -67,7 +67,7 @@ GUI::Widget* EraseTool::get_properties_widget() size_label.set_text_alignment(Gfx::TextAlignment::CenterLeft); size_label.set_fixed_size(80, 20); - auto& size_slider = size_container.add<GUI::ValueSlider>(Orientation::Horizontal, "px"); + auto& size_slider = size_container.add<GUI::ValueSlider>(Orientation::Horizontal, String::from_utf8_short_string("px"sv)); size_slider.set_range(1, 100); size_slider.set_value(size()); @@ -85,7 +85,7 @@ GUI::Widget* EraseTool::get_properties_widget() hardness_label.set_text_alignment(Gfx::TextAlignment::CenterLeft); hardness_label.set_fixed_size(80, 20); - auto& hardness_slider = hardness_container.add<GUI::ValueSlider>(Orientation::Horizontal, "%"); + auto& hardness_slider = hardness_container.add<GUI::ValueSlider>(Orientation::Horizontal, String::from_utf8_short_string("%"sv)); hardness_slider.set_range(1, 100); hardness_slider.set_value(hardness()); diff --git a/Userland/Applications/PixelPaint/Tools/GuideTool.cpp b/Userland/Applications/PixelPaint/Tools/GuideTool.cpp index 1b1eb3bc0c..c4dd237907 100644 --- a/Userland/Applications/PixelPaint/Tools/GuideTool.cpp +++ b/Userland/Applications/PixelPaint/Tools/GuideTool.cpp @@ -191,7 +191,7 @@ GUI::Widget* GuideTool::get_properties_widget() snapping_label.set_fixed_size(80, 20); snapping_label.set_tooltip("Press Shift to snap"); - auto& snapping_slider = snapping_container.add<GUI::ValueSlider>(Orientation::Horizontal, "px"); + auto& snapping_slider = snapping_container.add<GUI::ValueSlider>(Orientation::Horizontal, String::from_utf8_short_string("px"sv)); snapping_slider.set_range(0, 50); snapping_slider.set_value(m_snap_size); diff --git a/Userland/Applications/PixelPaint/Tools/LineTool.cpp b/Userland/Applications/PixelPaint/Tools/LineTool.cpp index c365d15620..0d08b4bd3e 100644 --- a/Userland/Applications/PixelPaint/Tools/LineTool.cpp +++ b/Userland/Applications/PixelPaint/Tools/LineTool.cpp @@ -133,7 +133,7 @@ GUI::Widget* LineTool::get_properties_widget() thickness_label.set_text_alignment(Gfx::TextAlignment::CenterLeft); thickness_label.set_fixed_size(80, 20); - auto& thickness_slider = thickness_container.add<GUI::ValueSlider>(Orientation::Horizontal, "px"); + auto& thickness_slider = thickness_container.add<GUI::ValueSlider>(Orientation::Horizontal, String::from_utf8_short_string("px"sv)); thickness_slider.set_range(1, 10); thickness_slider.set_value(m_thickness); diff --git a/Userland/Applications/PixelPaint/Tools/PenTool.cpp b/Userland/Applications/PixelPaint/Tools/PenTool.cpp index ff1f7ce161..8342a20ea4 100644 --- a/Userland/Applications/PixelPaint/Tools/PenTool.cpp +++ b/Userland/Applications/PixelPaint/Tools/PenTool.cpp @@ -49,7 +49,7 @@ GUI::Widget* PenTool::get_properties_widget() size_label.set_text_alignment(Gfx::TextAlignment::CenterLeft); size_label.set_fixed_size(80, 20); - auto& size_slider = size_container.add<GUI::ValueSlider>(Orientation::Horizontal, "px"); + auto& size_slider = size_container.add<GUI::ValueSlider>(Orientation::Horizontal, String::from_utf8_short_string("px"sv)); size_slider.set_range(1, 20); size_slider.set_value(size()); diff --git a/Userland/Applications/PixelPaint/Tools/RectangleSelectTool.cpp b/Userland/Applications/PixelPaint/Tools/RectangleSelectTool.cpp index 19232d1839..d1d5ec458f 100644 --- a/Userland/Applications/PixelPaint/Tools/RectangleSelectTool.cpp +++ b/Userland/Applications/PixelPaint/Tools/RectangleSelectTool.cpp @@ -166,7 +166,7 @@ GUI::Widget* RectangleSelectTool::get_properties_widget() feather_label.set_fixed_size(80, 20); int const feather_slider_max = 100; - auto& feather_slider = feather_container.add<GUI::ValueSlider>(Orientation::Horizontal, "%"); + auto& feather_slider = feather_container.add<GUI::ValueSlider>(Orientation::Horizontal, String::from_utf8_short_string("%"sv)); feather_slider.set_range(0, feather_slider_max); feather_slider.set_value((int)floorf(m_edge_feathering * (float)feather_slider_max)); diff --git a/Userland/Applications/PixelPaint/Tools/RectangleTool.cpp b/Userland/Applications/PixelPaint/Tools/RectangleTool.cpp index 6568900961..f49f169ea5 100644 --- a/Userland/Applications/PixelPaint/Tools/RectangleTool.cpp +++ b/Userland/Applications/PixelPaint/Tools/RectangleTool.cpp @@ -154,7 +154,7 @@ GUI::Widget* RectangleTool::get_properties_widget() thickness_or_radius_label.set_text_alignment(Gfx::TextAlignment::CenterLeft); thickness_or_radius_label.set_fixed_size(80, 20); - auto& thickness_or_radius_slider = thickness_or_radius_container.add<GUI::ValueSlider>(Orientation::Horizontal, "px"); + auto& thickness_or_radius_slider = thickness_or_radius_container.add<GUI::ValueSlider>(Orientation::Horizontal, String::from_utf8_short_string("px"sv)); thickness_or_radius_slider.on_change = [&](int value) { if (m_fill_mode == FillMode::RoundedCorners) { diff --git a/Userland/Applications/PixelPaint/Tools/SprayTool.cpp b/Userland/Applications/PixelPaint/Tools/SprayTool.cpp index c1cf9f661b..4290d25212 100644 --- a/Userland/Applications/PixelPaint/Tools/SprayTool.cpp +++ b/Userland/Applications/PixelPaint/Tools/SprayTool.cpp @@ -104,7 +104,7 @@ GUI::Widget* SprayTool::get_properties_widget() size_label.set_text_alignment(Gfx::TextAlignment::CenterLeft); size_label.set_fixed_size(80, 20); - auto& size_slider = size_container.add<GUI::ValueSlider>(Orientation::Horizontal, "px"); + auto& size_slider = size_container.add<GUI::ValueSlider>(Orientation::Horizontal, String::from_utf8_short_string("px"sv)); size_slider.set_range(1, 20); size_slider.set_value(m_thickness); @@ -121,7 +121,7 @@ GUI::Widget* SprayTool::get_properties_widget() density_label.set_text_alignment(Gfx::TextAlignment::CenterLeft); density_label.set_fixed_size(80, 20); - auto& density_slider = density_container.add<GUI::ValueSlider>(Orientation::Horizontal, "%"); + auto& density_slider = density_container.add<GUI::ValueSlider>(Orientation::Horizontal, String::from_utf8_short_string("%"sv)); density_slider.set_range(1, 100); density_slider.set_value(m_density); diff --git a/Userland/Applications/PixelPaint/Tools/WandSelectTool.cpp b/Userland/Applications/PixelPaint/Tools/WandSelectTool.cpp index 5677c51030..750b0a4c26 100644 --- a/Userland/Applications/PixelPaint/Tools/WandSelectTool.cpp +++ b/Userland/Applications/PixelPaint/Tools/WandSelectTool.cpp @@ -81,7 +81,7 @@ GUI::Widget* WandSelectTool::get_properties_widget() threshold_label.set_text_alignment(Gfx::TextAlignment::CenterLeft); threshold_label.set_fixed_size(80, 20); - auto& threshold_slider = threshold_container.add<GUI::ValueSlider>(Orientation::Horizontal, "%"); + auto& threshold_slider = threshold_container.add<GUI::ValueSlider>(Orientation::Horizontal, String::from_utf8_short_string("%"sv)); threshold_slider.set_range(0, 100); threshold_slider.set_value(m_threshold); diff --git a/Userland/Applications/PixelPaint/Tools/ZoomTool.cpp b/Userland/Applications/PixelPaint/Tools/ZoomTool.cpp index f0e4b61995..0e1d0b60ee 100644 --- a/Userland/Applications/PixelPaint/Tools/ZoomTool.cpp +++ b/Userland/Applications/PixelPaint/Tools/ZoomTool.cpp @@ -37,7 +37,7 @@ GUI::Widget* ZoomTool::get_properties_widget() sensitivity_label.set_text_alignment(Gfx::TextAlignment::CenterLeft); sensitivity_label.set_fixed_size(80, 20); - auto& sensitivity_slider = sensitivity_container.add<GUI::ValueSlider>(Orientation::Horizontal, "%"); + auto& sensitivity_slider = sensitivity_container.add<GUI::ValueSlider>(Orientation::Horizontal, String::from_utf8_short_string("%"sv)); sensitivity_slider.set_range(1, 100); sensitivity_slider.set_value(100 * m_sensitivity); diff --git a/Userland/Libraries/LibGUI/ValueSlider.cpp b/Userland/Libraries/LibGUI/ValueSlider.cpp index 9bed7349f3..ac8cde7eec 100644 --- a/Userland/Libraries/LibGUI/ValueSlider.cpp +++ b/Userland/Libraries/LibGUI/ValueSlider.cpp @@ -17,7 +17,7 @@ REGISTER_WIDGET(GUI, ValueSlider) namespace GUI { -ValueSlider::ValueSlider(Gfx::Orientation orientation, DeprecatedString suffix) +ValueSlider::ValueSlider(Gfx::Orientation orientation, String suffix) : AbstractSlider(orientation) , m_suffix(move(suffix)) { @@ -34,7 +34,7 @@ ValueSlider::ValueSlider(Gfx::Orientation orientation, DeprecatedString suffix) m_textbox->on_change = [&]() { DeprecatedString value = m_textbox->text(); if (value.ends_with(m_suffix, AK::CaseSensitivity::CaseInsensitive)) - value = value.substring_view(0, value.length() - m_suffix.length()); + value = value.substring_view(0, value.length() - m_suffix.bytes_as_string_view().length()); auto integer_value = value.to_int(); if (integer_value.has_value()) AbstractSlider::set_value(integer_value.value()); diff --git a/Userland/Libraries/LibGUI/ValueSlider.h b/Userland/Libraries/LibGUI/ValueSlider.h index 52043b441f..191da5a343 100644 --- a/Userland/Libraries/LibGUI/ValueSlider.h +++ b/Userland/Libraries/LibGUI/ValueSlider.h @@ -7,6 +7,7 @@ #pragma once +#include <AK/String.h> #include <LibGUI/AbstractSlider.h> namespace GUI { @@ -22,7 +23,7 @@ public: virtual ~ValueSlider() override = default; - void set_suffix(DeprecatedString suffix) { m_suffix = move(suffix); } + void set_suffix(String suffix) { m_suffix = move(suffix); } void set_knob_style(KnobStyle knobstyle) { m_knob_style = knobstyle; } virtual void set_value(int value, AllowCallback = AllowCallback::Yes, DoClamp = DoClamp::Yes) override; @@ -36,14 +37,14 @@ protected: virtual void leave_event(Core::Event&) override; private: - explicit ValueSlider(Gfx::Orientation = Gfx::Orientation::Horizontal, DeprecatedString suffix = ""); + explicit ValueSlider(Gfx::Orientation = Gfx::Orientation::Horizontal, String suffix = {}); DeprecatedString formatted_value() const; int value_at(Gfx::IntPoint position) const; Gfx::IntRect bar_rect() const; Gfx::IntRect knob_rect() const; - DeprecatedString m_suffix {}; + String m_suffix {}; Orientation m_orientation { Orientation::Horizontal }; KnobStyle m_knob_style { KnobStyle::Thin }; RefPtr<GUI::TextBox> m_textbox; |