diff options
author | Andreas Kling <kling@serenityos.org> | 2020-04-29 14:38:19 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-04-29 14:38:19 +0200 |
commit | 033a4aee50d1e037a3133ee791ebe86a0ee4e0d4 (patch) | |
tree | 34a44ef42865404a4fda7db796dc5a1f7ac51a2e /Libraries | |
parent | 40fe076e1030b2a5a40e73adfa01f814a8535eb2 (diff) | |
download | serenity-033a4aee50d1e037a3133ee791ebe86a0ee4e0d4.zip |
LibGUI: Remove copy-pasted auto-repeat logic from ColorInput
This was copy-pasted from button classes and not useful here.
Diffstat (limited to 'Libraries')
-rw-r--r-- | Libraries/LibGUI/ColorInput.cpp | 14 | ||||
-rw-r--r-- | Libraries/LibGUI/ColorInput.h | 10 |
2 files changed, 5 insertions, 19 deletions
diff --git a/Libraries/LibGUI/ColorInput.cpp b/Libraries/LibGUI/ColorInput.cpp index e68eb51ca6..46dc803ee5 100644 --- a/Libraries/LibGUI/ColorInput.cpp +++ b/Libraries/LibGUI/ColorInput.cpp @@ -36,11 +36,6 @@ ColorInput::ColorInput() : TextEditor(TextEditor::SingleLine) { set_readonly(true); - - m_auto_repeat_timer = add<Core::Timer>(); - m_auto_repeat_timer->on_timeout = [this] { - click(); - }; } ColorInput::~ColorInput() @@ -64,11 +59,6 @@ void ColorInput::mousedown_event(MouseEvent& event) if (is_enabled()) { m_being_pressed = true; update(); - - if (m_auto_repeat_interval) { - click(); - m_auto_repeat_timer->start(m_auto_repeat_interval); - } } } @@ -78,13 +68,11 @@ void ColorInput::mousedown_event(MouseEvent& event) void ColorInput::mouseup_event(MouseEvent& event) { if (event.button() == MouseButton::Left) { - bool was_auto_repeating = m_auto_repeat_timer->is_active(); - m_auto_repeat_timer->stop(); if (is_enabled()) { bool was_being_pressed = m_being_pressed; m_being_pressed = false; update(); - if (was_being_pressed && !was_auto_repeating) + if (was_being_pressed) click(); } } diff --git a/Libraries/LibGUI/ColorInput.h b/Libraries/LibGUI/ColorInput.h index c3d23f304e..8e541d6e3d 100644 --- a/Libraries/LibGUI/ColorInput.h +++ b/Libraries/LibGUI/ColorInput.h @@ -31,14 +31,14 @@ namespace GUI { -class ColorInput : public TextEditor { - C_OBJECT(ColorInput) +class ColorInput final : public TextEditor { + C_OBJECT(ColorInput); public: ColorInput(); virtual ~ColorInput() override; - void set_color(Color color); + void set_color(Color); Color color() { return m_color; } void set_color_picker_title(String title) { m_color_picker_title = title; } @@ -53,14 +53,12 @@ protected: virtual void paint_event(PaintEvent&) override; private: - virtual void click(); + void click(); Color m_color; String m_color_picker_title { "Select Color" }; - int m_auto_repeat_interval { 0 }; bool m_being_pressed { false }; - RefPtr<Core::Timer> m_auto_repeat_timer; }; } |