KO
apps/winzik / src / Gui / NoteWindow.php · commit 6576d6f
<?phpnamespace App\Gui;use JumPHP\Kernel\Platform;/** * The web version only: a sticky note on the desktop saying what the version to download (Linux, Windows) does more, * with its button to the downloads. Moved like the other windows, closed by its x (for good: options.webNoteClosed). */final class NoteWindow extends SkinWindow{    public const WIDTH = 236;    public const DOWNLOADS = 'https://git.jumphp.net/duchnoun/winzik/releases/latest';    /** the tests: shown outside the browser too */    public bool $forced = false;    private const LINES = [        'Fenêtres libres sur tout l\'écran (plusieurs écrans)',        'YouTube, Spotify, Deezer : chercher, télécharger',        '   en MP3 / MP4, importer vos playlists',        'Vos dossiers de musique et de vidéos',        'Paroles créées (Whisper + Claude), LRCLIB,',        '   éditeur par syllabes, balle karaoké',        'Égaliseur réel, saut des blancs et des intros',        'Notes, étoiles, préférés, recherche',        'Mini barre sur la fenêtre active',        'Icône près de l\'horloge, démarrage avec',        '   l\'ordinateur, mises à jour toutes seules',    ];    public function id(): string    {        return 'note';    }    public function width(): float    {        return self::WIDTH;    }    public function height(): float    {        return 44 + count(self::LINES) * 11 + 26;    }    public function visible(): bool    {        return ($this->forced || Platform::isWasm()) && !$this->desk->phone && !($this->wz->options['webNoteClosed'] ?? false)            && !$this->wz->ui['tray'] && !$this->wz->ui['lyricsOnly'];    }    public function restore(): void    {        parent::restore();        if (!isset($this->wz->ui['note'])) {            // the first time: at the right of the player            $main = $this->desk->main;            $this->x = $main !== null ? $main->x + $main->width() + 24 : 300;            $this->y = $main !== null ? $main->y + 10 : 20;        }    }    public function controls(): array    {        $h = $this->height();        return ['close' => [self::WIDTH - 16, 3, 13, 12], 'download' => [12, $h - 24, self::WIDTH - 24, 17]];    }    public function render(Canvas $c): void    {        $w = self::WIDTH;        $h = $this->height();        // a yellow note, a little shadow, a strip of tape        $c->fill(3, 3, $w - 3, $h - 3, [0, 0, 0, 70]);        $c->fill(0, 0, $w - 3, $h - 3, '#fff3a6');        $c->fill(0, 0, $w - 3, 18, '#ffe873');        $c->fill($w / 2 - 26, -2, 52, 8, [255, 255, 255, 150]);        $c->text('La version à télécharger fait bien plus :', 8, 4, 8, '#5a4500');        $c->text('x', $w - 10, 2, 9, '#5a4500', 'center');        $this->pushed($c, 'close');        $y = 24;        foreach (self::LINES as $line) {            $bullet = !str_starts_with($line, '   ');            if ($bullet) {                $c->fill(10, $y + 4, 3, 3, '#c0392b');            }            $c->text($c->fit(trim($line), $w - 26, 7.5), 17, $y, 7.5, '#3a2c00');            $y += 11;        }        $c->text('Linux et Windows, gratuit.', 8, $y + 2, 7, '#7a6200');        [, $by, $bw, $bh] = $this->controls()['download'];        $c->fill(12, $by, $bw, $bh, $this->pressed === 'download' ? '#a8331f' : '#c0392b');        $c->text('Télécharger WinZik pour le bureau', 12 + $bw / 2, $by + 3.5, 8, '#ffffff', 'center');    }    protected function clicked(string $id, bool $double): void    {        if ($id === 'close') {            $this->wz->options['webNoteClosed'] = true;            $this->wz->touch();        } elseif ($id === 'download') {            if (!\JumPHP\Native\Shell::openUrl(self::DOWNLOADS)) {                $this->wz->notice('Téléchargements : ' . self::DOWNLOADS, 10);            }        }    }}