Serenity Operating System
at master 50 lines 1.1 kB view raw
1/* 2 * Copyright (c) 2021, Andreas Kling <kling@serenityos.org> 3 * 4 * SPDX-License-Identifier: BSD-2-Clause 5 */ 6 7#pragma once 8 9#include <AK/Forward.h> 10#include <AK/Function.h> 11#include <AK/NonnullRefPtr.h> 12#include <AK/RefCounted.h> 13#include <LibCore/ElapsedTimer.h> 14#include <LibGfx/Forward.h> 15 16namespace WindowServer { 17 18class Compositor; 19class Screen; 20 21class Animation : public RefCounted<Animation> { 22public: 23 static NonnullRefPtr<Animation> create() { return adopt_ref(*new Animation); } 24 25 ~Animation(); 26 27 bool is_running() const { return m_running; } 28 29 void start(); 30 void stop(); 31 void was_removed(Badge<Compositor>); 32 33 void set_duration(int duration_in_ms); 34 int duration() const { return m_duration; } 35 36 bool update(Badge<Compositor>, Gfx::Painter&, Screen&, Gfx::DisjointIntRectSet& flush_rects); 37 38 Function<void(float progress, Gfx::Painter&, Screen&, Gfx::DisjointIntRectSet& flush_rects)> on_update; 39 Function<void()> on_stop; 40 41private: 42 Animation(); 43 44 Core::ElapsedTimer m_timer; 45 int m_duration { 0 }; 46 bool m_running { false }; 47 bool m_was_removed { false }; 48}; 49 50}