summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibGUI
diff options
context:
space:
mode:
Diffstat (limited to 'Userland/Libraries/LibGUI')
-rw-r--r--Userland/Libraries/LibGUI/AbstractSlider.cpp5
-rw-r--r--Userland/Libraries/LibGUI/AbstractSlider.h7
-rw-r--r--Userland/Libraries/LibGUI/Scrollbar.cpp4
-rw-r--r--Userland/Libraries/LibGUI/Scrollbar.h2
-rw-r--r--Userland/Libraries/LibGUI/ValueSlider.cpp4
-rw-r--r--Userland/Libraries/LibGUI/ValueSlider.h2
6 files changed, 15 insertions, 9 deletions
diff --git a/Userland/Libraries/LibGUI/AbstractSlider.cpp b/Userland/Libraries/LibGUI/AbstractSlider.cpp
index 9759df20fe..4f1442a0da 100644
--- a/Userland/Libraries/LibGUI/AbstractSlider.cpp
+++ b/Userland/Libraries/LibGUI/AbstractSlider.cpp
@@ -50,9 +50,10 @@ void AbstractSlider::set_range(int min, int max)
update();
}
-void AbstractSlider::set_value(int value, AllowCallback allow_callback)
+void AbstractSlider::set_value(int value, AllowCallback allow_callback, DoClamp do_clamp)
{
- value = clamp(value, m_min, m_max);
+ if (do_clamp == DoClamp::Yes)
+ value = clamp(value, m_min, m_max);
if (m_value == value)
return;
m_value = value;
diff --git a/Userland/Libraries/LibGUI/AbstractSlider.h b/Userland/Libraries/LibGUI/AbstractSlider.h
index 83c29254d8..87103e332b 100644
--- a/Userland/Libraries/LibGUI/AbstractSlider.h
+++ b/Userland/Libraries/LibGUI/AbstractSlider.h
@@ -30,7 +30,12 @@ public:
bool is_max() const { return m_value == m_max; }
void set_range(int min, int max);
- virtual void set_value(int, AllowCallback = AllowCallback::Yes);
+
+ enum class DoClamp {
+ Yes = 1,
+ No = 0
+ };
+ virtual void set_value(int, AllowCallback = AllowCallback::Yes, DoClamp = DoClamp::Yes);
void set_min(int min) { set_range(min, max()); }
void set_max(int max) { set_range(min(), max); }
diff --git a/Userland/Libraries/LibGUI/Scrollbar.cpp b/Userland/Libraries/LibGUI/Scrollbar.cpp
index 59366fa099..ebb0499cb0 100644
--- a/Userland/Libraries/LibGUI/Scrollbar.cpp
+++ b/Userland/Libraries/LibGUI/Scrollbar.cpp
@@ -119,13 +119,13 @@ void Scrollbar::set_scroll_animation(Animation scroll_animation)
m_scroll_animation = scroll_animation;
}
-void Scrollbar::set_value(int value, AllowCallback allow_callback)
+void Scrollbar::set_value(int value, AllowCallback allow_callback, DoClamp do_clamp)
{
m_target_value = value;
if (!(m_animated_scrolling_timer.is_null()))
m_animated_scrolling_timer->stop();
- AbstractSlider::set_value(value, allow_callback);
+ AbstractSlider::set_value(value, allow_callback, do_clamp);
}
void Scrollbar::set_target_value(int new_target_value)
diff --git a/Userland/Libraries/LibGUI/Scrollbar.h b/Userland/Libraries/LibGUI/Scrollbar.h
index e5b99185e7..0f6115055c 100644
--- a/Userland/Libraries/LibGUI/Scrollbar.h
+++ b/Userland/Libraries/LibGUI/Scrollbar.h
@@ -30,7 +30,7 @@ public:
void set_scroll_animation(Animation scroll_animation);
- virtual void set_value(int, AllowCallback = AllowCallback::Yes) override;
+ virtual void set_value(int, AllowCallback = AllowCallback::Yes, DoClamp = DoClamp::Yes) override;
void set_target_value(int);
virtual void increase_slider_by(int delta) override { set_target_value(m_target_value + delta); }
diff --git a/Userland/Libraries/LibGUI/ValueSlider.cpp b/Userland/Libraries/LibGUI/ValueSlider.cpp
index b7995fd0f8..6034361e07 100644
--- a/Userland/Libraries/LibGUI/ValueSlider.cpp
+++ b/Userland/Libraries/LibGUI/ValueSlider.cpp
@@ -142,9 +142,9 @@ int ValueSlider::value_at(const Gfx::IntPoint& position) const
return (int)(relative_offset * (float)max());
}
-void ValueSlider::set_value(int value, AllowCallback allow_callback)
+void ValueSlider::set_value(int value, AllowCallback allow_callback, DoClamp do_clamp)
{
- AbstractSlider::set_value(value, allow_callback);
+ AbstractSlider::set_value(value, allow_callback, do_clamp);
m_textbox->set_text(formatted_value());
}
diff --git a/Userland/Libraries/LibGUI/ValueSlider.h b/Userland/Libraries/LibGUI/ValueSlider.h
index 546917fbdd..91aba6ab19 100644
--- a/Userland/Libraries/LibGUI/ValueSlider.h
+++ b/Userland/Libraries/LibGUI/ValueSlider.h
@@ -25,7 +25,7 @@ public:
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) override;
+ virtual void set_value(int value, AllowCallback = AllowCallback::Yes, DoClamp = DoClamp::Yes) override;
protected:
virtual void paint_event(PaintEvent&) override;