mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 21:17:45 +00:00
LibGUI+PixelPaint: Port GUI::ValueSlider's suffix to the new String
This commit is contained in:
parent
c4507bb56e
commit
67ffc687d8
18 changed files with 30 additions and 29 deletions
|
@ -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…
Add table
Add a link
Reference in a new issue