neoGFX
Cross-platform C++ app/game engine
Loading...
Searching...
No Matches
transition_animator.hpp
Go to the documentation of this file.
1// transition_animator.hpp
2/*
3 neogfx C++ App/Game Engine
4 Copyright (c) 2018, 2020 Leigh Johnston. All Rights Reserved.
5
6 This program is free software: you can redistribute it and / or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>.
18*/
19
20#pragma once
21
22#include <neogfx/neogfx.hpp>
23#include <neolib/core/jar.hpp>
25#include <neogfx/core/event.hpp>
27
28namespace neogfx
29{
30 class transition : public reference_counted<i_transition>
31 {
32 public:
33 transition(i_animator& aAnimator, easing aEasingFunction, double aDuration, bool aEnabled = true);
35 public:
36 transition_id id() const override;
37 i_animator& animator() const override;
38 bool enabled() const override;
39 bool disabled() const override;
40 bool disable_when_finished() const override;
41 void enable(bool aDisableWhenFinished = false) override;
42 void disable() override;
43 easing easing_function() const override;
44 double duration() const override;
45 double start_time() const override;
46 double mix_value() const override;
47 bool animation_finished() const override;
48 public:
49 bool active() const override;
50 bool paused() const override;
51 void pause() override;
52 void resume() override;
53 public:
54 void reset(bool aEnable = true, bool aDisableWhenFinished = false, bool aResetStartTime = true) override;
55 void reset(easing aNewEasingFunction, bool aEnable = true, bool aDisableWhenFinished = false, bool aResetStartTime = true) override;
56 private:
57 i_animator& iAnimator;
58 transition_id iId;
59 bool iEnabled;
60 bool iDisableWhenFinished;
61 easing iEasingFunction;
62 double iDuration;
63 mutable std::optional<double> iStartTime;
64 bool iPaused;
65 };
66
67 class animator : public i_animator
68 {
69 public:
71 public:
72 i_transition& transition(transition_id aTransitionId) override;
74 void remove_transition(transition_id aTransitionId) override;
75 void stop() override;
76 public:
77 double animation_time() const override;
78 protected:
80 private:
81 void next_frame();
82 private:
85 std::chrono::time_point<std::chrono::high_resolution_clock> iZeroHour;
86 double iAnimationTime;
87 };
88}
void stop() override
i_transition & transition(transition_id aTransitionId) override
void remove_transition(transition_id aTransitionId) override
transition_id add_transition(i_transition &aTransition) override
transition_id allocate_id() override
double animation_time() const override
bool animation_finished() const override
easing easing_function() const override
transition(i_animator &aAnimator, easing aEasingFunction, double aDuration, bool aEnabled=true)
bool active() const override
void enable(bool aDisableWhenFinished=false) override
double start_time() const override
void reset(easing aNewEasingFunction, bool aEnable=true, bool aDisableWhenFinished=false, bool aResetStartTime=true) override
bool enabled() const override
double mix_value() const override
bool disabled() const override
i_animator & animator() const override
double duration() const override
void pause() override
void resume() override
void disable() override
transition_id id() const override
bool disable_when_finished() const override
bool paused() const override
void reset(bool aEnable=true, bool aDisableWhenFinished=false, bool aResetStartTime=true) override
neolib::cookie transition_id
basic_jar< T, vector< T >, cookie, MutexType > jar
Definition jar.hpp:736