1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-06-01 08:38:10 +00:00

LibCore: Convert CTimer to ObjectPtr

This commit is contained in:
Andreas Kling 2019-09-20 15:19:46 +02:00
parent c34fd10b5b
commit 50a6560413
22 changed files with 91 additions and 70 deletions

View file

@ -9,9 +9,9 @@ GAbstractButton::GAbstractButton(GWidget* parent)
GAbstractButton::GAbstractButton(const StringView& text, GWidget* parent)
: GWidget(parent)
, m_text(text)
, m_auto_repeat_timer(this)
{
m_auto_repeat_timer.on_timeout = [this] {
m_auto_repeat_timer = CTimer::create(this);
m_auto_repeat_timer->on_timeout = [this] {
click();
};
}
@ -71,9 +71,9 @@ void GAbstractButton::mousemove_event(GMouseEvent& event)
m_being_pressed = being_pressed;
if (m_auto_repeat_interval) {
if (!m_being_pressed)
m_auto_repeat_timer.stop();
m_auto_repeat_timer->stop();
else
m_auto_repeat_timer.start(m_auto_repeat_interval);
m_auto_repeat_timer->start(m_auto_repeat_interval);
}
update();
}
@ -94,7 +94,7 @@ void GAbstractButton::mousedown_event(GMouseEvent& event)
if (m_auto_repeat_interval) {
click();
m_auto_repeat_timer.start(m_auto_repeat_interval);
m_auto_repeat_timer->start(m_auto_repeat_interval);
}
}
}
@ -107,8 +107,8 @@ void GAbstractButton::mouseup_event(GMouseEvent& event)
dbgprintf("GAbstractButton::mouse_up_event: x=%d, y=%d, button=%u\n", event.x(), event.y(), (unsigned)event.button());
#endif
if (event.button() == GMouseButton::Left) {
bool was_auto_repeating = m_auto_repeat_timer.is_active();
m_auto_repeat_timer.stop();
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;

View file

@ -61,7 +61,7 @@ private:
bool m_exclusive { false };
int m_auto_repeat_interval { 0 };
CTimer m_auto_repeat_timer;
ObjectPtr<CTimer> m_auto_repeat_timer;
};
template<>

View file

@ -60,8 +60,8 @@ static CharacterBitmap* s_right_arrow_bitmap;
GScrollBar::GScrollBar(Orientation orientation, GWidget* parent)
: GWidget(parent)
, m_orientation(orientation)
, m_automatic_scrolling_timer(this)
{
m_automatic_scrolling_timer = CTimer::create(this);
if (!s_up_arrow_bitmap)
s_up_arrow_bitmap = &CharacterBitmap::create_from_ascii(s_up_arrow_bitmap_data, 9, 9).leak_ref();
if (!s_down_arrow_bitmap)
@ -77,8 +77,8 @@ GScrollBar::GScrollBar(Orientation orientation, GWidget* parent)
set_preferred_size(0, 15);
}
m_automatic_scrolling_timer.set_interval(100);
m_automatic_scrolling_timer.on_timeout = [this] {
m_automatic_scrolling_timer->set_interval(100);
m_automatic_scrolling_timer->on_timeout = [this] {
on_automatic_scrolling_timer_fired();
};
}
@ -293,9 +293,9 @@ void GScrollBar::set_automatic_scrolling_active(bool active)
{
if (active) {
on_automatic_scrolling_timer_fired();
m_automatic_scrolling_timer.start();
m_automatic_scrolling_timer->start();
} else {
m_automatic_scrolling_timer.stop();
m_automatic_scrolling_timer->stop();
}
}

View file

@ -82,5 +82,5 @@ private:
};
AutomaticScrollingDirection m_automatic_scrolling_direction { AutomaticScrollingDirection::None };
CTimer m_automatic_scrolling_timer;
ObjectPtr<CTimer> m_automatic_scrolling_timer;
};