mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 06:58:11 +00:00
LibGUI: Add an auto-repeat interval to GAbstractButton.
Use this in GSpinBox to implement auto-increment / auto-decrement while you are pressing down the respective buttons. :^)
This commit is contained in:
parent
c53f6a52e0
commit
b425de18cc
5 changed files with 35 additions and 2 deletions
|
@ -1,5 +1,6 @@
|
|||
#pragma once
|
||||
|
||||
#include <LibCore/CTimer.h>
|
||||
#include <LibGUI/GWidget.h>
|
||||
#include <SharedGraphics/TextAlignment.h>
|
||||
|
||||
|
@ -32,6 +33,9 @@ public:
|
|||
virtual bool supports_keyboard_activation() const override { return true; }
|
||||
virtual bool is_uncheckable() const { return true; }
|
||||
|
||||
int auto_repeat_interval() const { return m_auto_repeat_interval; }
|
||||
void set_auto_repeat_interval(int interval) { m_auto_repeat_interval = interval; }
|
||||
|
||||
protected:
|
||||
explicit GAbstractButton(GWidget* parent);
|
||||
GAbstractButton(const StringView&, GWidget* parent);
|
||||
|
@ -55,6 +59,9 @@ private:
|
|||
bool m_hovered { false };
|
||||
bool m_being_pressed { false };
|
||||
bool m_exclusive { false };
|
||||
|
||||
int m_auto_repeat_interval { 0 };
|
||||
CTimer m_auto_repeat_timer;
|
||||
};
|
||||
|
||||
template<>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue