mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 23:50:19 +00:00
LibGUI+PixelPaint: Port GUI::ValueSlider's suffix to the new String
This commit is contained in:
parent
c4507bb56e
commit
67ffc687d8
Notes:
sideshowbarker
2024-07-17 08:45:34 +09:00
Author: https://github.com/krkk Commit: https://github.com/SerenityOS/serenity/commit/67ffc687d8 Pull-request: https://github.com/SerenityOS/serenity/pull/17455
18 changed files with 30 additions and 29 deletions
|
@ -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) {
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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());
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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());
|
||||
|
||||
|
|
|
@ -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));
|
||||
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue