-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathApp.php
More file actions
48 lines (35 loc) · 945 Bytes
/
App.php
File metadata and controls
48 lines (35 loc) · 945 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?php
declare(strict_types=1);
namespace Ardillo\Examples\Clock;
use Ardillo\Examples\Clock\Main\Window;
use Ardillo\{
ReactApp,
Size,
TimedTask,
};
class App extends ReactApp
{
public Window $win;
protected TimedTask $timer;
public function stopDrawing(): void
{
if (isset($this->timer)) {
$this->loop->cancelTimer($this->timer);
}
}
public function onSigInt(int $signo): void
{
echo 'Caught SIGINT ...' . PHP_EOL;
$this->stopDrawing();
unset($this->win);
$this->stop();
}
protected function OnInit(): void
{
$this->win = new Window('Ardillo Clock', new Size(400, 400), false);
$this->win->setup();
$this->win->show();
$this->timer = $this->loop->addPeriodicTimer(1 / 2, $this->win->area->queueRedrawAll(...));
$this->loop->addSignal(self::SIGINT, $this->onSigInt(...));
}
}