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:
parent
c34fd10b5b
commit
50a6560413
22 changed files with 91 additions and 70 deletions
|
@ -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)
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue