Aurore
A Switch-like interface for your app, on every screen
Loading...
Searching...
No Matches
animation.hpp
Go to the documentation of this file.
1/*
2 Copyright 2021 natinusala
3
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
15*/
16
17#pragma once
18
19#include <stdint.h>
20#include <tweeny.h>
21
22#include <aurore/core/time.hpp>
23
24namespace aurore
25{
26
27using EasingFunction = tweeny::easing::enumerated;
28
29// An animatable is a float which value can be animated from an initial value to a target value,
30// during a given amount of time. An easing function can also be specified.
31//
32// Declare the animatable and then use reset(initialValue) to reset the animation.
33// Add as many steps as you like by calling addStep(targetValue, duration, easing) one or multiple times.
34// Then, start and stop the animation with start() and stop().
35//
36// setEndCallback() and setTickCallback() allow you to execute code as long as the animation runs and / or once when it finishes.
37// Use .getValue() to get the current value at any time.
38//
39// An animatable has overloads for float conversion, comparison (==) and assignment operator (=) to allow
40// basic usage as a simple float. Assignment operator is a shortcut to the reset() method.
42{
43 public:
47 Animatable(float value = 0.0f);
48
52 float getValue();
53
60 void reset(float initialValue);
61
68 void reset();
69
79 void addStep(float targetValue, int32_t duration, EasingFunction easing = EasingFunction::linear);
80
84 float getProgress();
85
86 operator float() const;
87 operator float();
88 void operator=(const float value);
89 bool operator==(const float value);
90
91 protected:
92 bool onUpdate(Time delta) override;
93
94 void onReset() override;
95 void onRewind() override;
96
97 private:
98 float currentValue = 0.0f;
99 tweeny::tween<float> tween;
100};
101
103void getHighlightAnimation(float* gradient_x, float* gradient_y, float* color);
104
105// Holds the focus highlight's moving glow where it is, so that a screenshot
106// does not depend on when it was taken.
108
109} // namespace aurore
Definition animation.hpp:42
bool operator==(const float value)
void reset(float initialValue)
void operator=(const float value)
void onReset() override
void onRewind() override
bool onUpdate(Time delta) override
void addStep(float targetValue, int32_t duration, EasingFunction easing=EasingFunction::linear)
Animatable(float value=0.0f)
Definition time.hpp:205
Definition actions.hpp:25
void getHighlightAnimation(float *gradient_x, float *gradient_y, float *color)
void setHighlightAnimationStill(bool still)
void updateHighlightAnimation()
retro_time_t Time
Definition time.hpp:31
tweeny::easing::enumerated EasingFunction
Definition animation.hpp:27