diff options
-rw-r--r-- | Userland/Libraries/LibGUI/AbstractSlider.cpp | 4 | ||||
-rw-r--r-- | Userland/Libraries/LibGUI/AbstractSlider.h | 2 | ||||
-rw-r--r-- | Userland/Libraries/LibGUI/ValueSlider.cpp | 4 | ||||
-rw-r--r-- | Userland/Libraries/LibGUI/ValueSlider.h | 2 | ||||
-rw-r--r-- | Userland/Libraries/LibGUI/Widget.h | 6 |
5 files changed, 12 insertions, 6 deletions
diff --git a/Userland/Libraries/LibGUI/AbstractSlider.cpp b/Userland/Libraries/LibGUI/AbstractSlider.cpp index ccb0613c1b..c6109ad6cf 100644 --- a/Userland/Libraries/LibGUI/AbstractSlider.cpp +++ b/Userland/Libraries/LibGUI/AbstractSlider.cpp @@ -53,7 +53,7 @@ void AbstractSlider::set_range(int min, int max) update(); } -void AbstractSlider::set_value(int value) +void AbstractSlider::set_value(int value, CallOnChange call_on_change) { value = clamp(value, m_min, m_max); if (m_value == value) @@ -61,7 +61,7 @@ void AbstractSlider::set_value(int value) m_value = value; update(); - if (on_change) + if (on_change && call_on_change == CallOnChange::Yes) on_change(m_value); } diff --git a/Userland/Libraries/LibGUI/AbstractSlider.h b/Userland/Libraries/LibGUI/AbstractSlider.h index f3a1991982..dc6204e9e5 100644 --- a/Userland/Libraries/LibGUI/AbstractSlider.h +++ b/Userland/Libraries/LibGUI/AbstractSlider.h @@ -30,7 +30,7 @@ public: bool is_max() const { return m_value == m_max; } void set_range(int min, int max); - virtual void set_value(int); + virtual void set_value(int, CallOnChange call_on_change = CallOnChange::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/ValueSlider.cpp b/Userland/Libraries/LibGUI/ValueSlider.cpp index 4039f884d6..227c8ba607 100644 --- a/Userland/Libraries/LibGUI/ValueSlider.cpp +++ b/Userland/Libraries/LibGUI/ValueSlider.cpp @@ -141,9 +141,9 @@ int ValueSlider::value_at(const Gfx::IntPoint& position) const return (int)(relative_offset * (float)max()); } -void ValueSlider::set_value(int value) +void ValueSlider::set_value(int value, CallOnChange call_on_change) { - AbstractSlider::set_value(value); + AbstractSlider::set_value(value, call_on_change); m_textbox->set_text(formatted_value()); } diff --git a/Userland/Libraries/LibGUI/ValueSlider.h b/Userland/Libraries/LibGUI/ValueSlider.h index 886e1adf18..b9a3c91f3c 100644 --- a/Userland/Libraries/LibGUI/ValueSlider.h +++ b/Userland/Libraries/LibGUI/ValueSlider.h @@ -24,7 +24,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) override; + virtual void set_value(int value, CallOnChange call_on_change = CallOnChange::Yes) override; protected: virtual void paint_event(PaintEvent&) override; diff --git a/Userland/Libraries/LibGUI/Widget.h b/Userland/Libraries/LibGUI/Widget.h index 2327533830..e90f1c6269 100644 --- a/Userland/Libraries/LibGUI/Widget.h +++ b/Userland/Libraries/LibGUI/Widget.h @@ -39,6 +39,7 @@ enum class HorizontalDirection { Left, Right }; + enum class VerticalDirection { Up, Down @@ -53,6 +54,11 @@ enum class FocusPolicy { AK_ENUM_BITWISE_OPERATORS(FocusPolicy) +enum class CallOnChange { + No, + Yes +}; + class Widget : public Core::Object { C_OBJECT(Widget) public: |