1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-28 03:07:35 +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

@ -11,10 +11,11 @@
SprayTool::SprayTool()
{
m_timer.on_timeout = [=]() {
m_timer = CTimer::create();
m_timer->on_timeout = [&]() {
paint_it();
};
m_timer.set_interval(200);
m_timer->set_interval(200);
}
SprayTool::~SprayTool()
@ -54,22 +55,22 @@ void SprayTool::on_mousedown(GMouseEvent& event)
m_color = m_widget->color_for(event);
m_last_pos = event.position();
m_timer.start();
m_timer->start();
paint_it();
}
void SprayTool::on_mousemove(GMouseEvent& event)
{
m_last_pos = event.position();
if (m_timer.is_active()) {
if (m_timer->is_active()) {
paint_it();
m_timer.restart(m_timer.interval());
m_timer->restart(m_timer->interval());
}
}
void SprayTool::on_mouseup(GMouseEvent&)
{
m_timer.stop();
m_timer->stop();
}
void SprayTool::on_contextmenu(GContextMenuEvent& event)

View file

@ -19,7 +19,7 @@ public:
private:
virtual const char* class_name() const override { return "SprayTool"; }
void paint_it();
CTimer m_timer;
ObjectPtr<CTimer> m_timer;
Point m_last_pos;
Color m_color;
OwnPtr<GMenu> m_context_menu;