V-Gears 0
Free Final Fantasy VII engine.
UiAnimation.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2022 The V-Gears Team
3 *
4 * This file is part of V-Gears
5 *
6 * V-Gears is free software: you can redistribute it and/or modify it under
7 * terms of the GNU General Public License as published by the Free Software
8 * Foundation, version 3.0 (GPLv3) of the License.
9 *
10 * V-Gears is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 */
15
16#pragma once
17
18#include <OgreString.h>
19#include <Ogre.h>
20#include <vector>
21
22class UiWidget;
23
28
32 float time;
33
37 float value;
38};
39
44
48 float time;
49
53 Ogre::Vector2 value;
54};
55
60
61 public:
62
69 UiAnimation(const Ogre::String& name, UiWidget* widget);
70
74 virtual ~UiAnimation();
75
79 enum State{
80
85
89 ONCE
90 };
91
97 void AddTime(const float time);
98
104 const Ogre::String& GetName() const;
105
111 void SetTime(const float time);
112
118 float GetTime() const;
119
125 void SetLength(const float time);
126
132 float GetLength() const;
133
139 void AddScaleKeyFrame(const UiKeyFrameVector2& key_frame);
140
146 void AddXKeyFrame(const UiKeyFrameVector2& key_frame);
147
153 void AddYKeyFrame(const UiKeyFrameVector2& key_frame);
154
160 void AddWidthKeyFrame(const UiKeyFrameVector2& key_frame);
161
167 void AddHeightKeyFrame(const UiKeyFrameVector2& key_frame);
168
174 void AddRotationKeyFrame(const UiKeyFrameFloat& key_frame);
175
181 void AddAlphaKeyFrame(const UiKeyFrameFloat& key_frame);
182
193 const UiKeyFrameVector2& x1, const UiKeyFrameVector2& y1,
194 const UiKeyFrameVector2& x2, const UiKeyFrameVector2& y2
195 );
196
197 private:
198
203
209 float KeyFrameGetValue(std::vector<UiKeyFrameFloat>& data);
210
216 Ogre::Vector2 KeyFrameGetValue(std::vector<UiKeyFrameVector2>& data);
217
222
227
231 float time_;
232
236 float length_;
237
241 std::vector<UiKeyFrameVector2> scale_;
242
246 std::vector<UiKeyFrameVector2> x_;
247
251 std::vector<UiKeyFrameVector2> y_;
252
256 std::vector<UiKeyFrameVector2> width_;
257
261 std::vector<UiKeyFrameVector2> height_;
262
266 std::vector<UiKeyFrameFloat> rotation_;
267
271 std::vector<UiKeyFrameFloat> alpha_;
272
276 std::vector<UiKeyFrameVector2> scissor_x_top_;
277
281 std::vector<UiKeyFrameVector2> scissor_y_left_;
282
286 std::vector<UiKeyFrameVector2> scissor_x_bottom_;
287
291 std::vector<UiKeyFrameVector2> scissor_y_right_;
292};
An UI element animation.
Definition: UiAnimation.h:59
void SetLength(const float time)
Sets the animation length.
Definition: UiAnimation.cpp:77
std::vector< UiKeyFrameFloat > alpha_
List of alpha keyframes.
Definition: UiAnimation.h:271
virtual ~UiAnimation()
Destructor.
Definition: UiAnimation.cpp:27
void AddScaleKeyFrame(const UiKeyFrameVector2 &key_frame)
Adds a scale keyframe to the animation.
Definition: UiAnimation.cpp:81
void AddHeightKeyFrame(const UiKeyFrameVector2 &key_frame)
Adds a height keyframe to the animation.
Definition: UiAnimation.cpp:97
float time_
The animation's current time.
Definition: UiAnimation.h:231
const Ogre::String & GetName() const
Retrieves the animation name.
Definition: UiAnimation.cpp:71
float GetLength() const
Retrieves the animation length.
Definition: UiAnimation.cpp:79
std::vector< UiKeyFrameVector2 > width_
List of width keyframes.
Definition: UiAnimation.h:256
float GetTime() const
Retrieves the animation current time.
Definition: UiAnimation.cpp:75
std::vector< UiKeyFrameVector2 > scale_
List of scale keyframes.
Definition: UiAnimation.h:241
UiAnimation()
Constructor.
std::vector< UiKeyFrameVector2 > scissor_x_top_
Definition: UiAnimation.h:276
Ogre::String name_
The UI animation name.
Definition: UiAnimation.h:221
std::vector< UiKeyFrameVector2 > scissor_x_bottom_
Definition: UiAnimation.h:286
std::vector< UiKeyFrameVector2 > x_
List of X position keyframes.
Definition: UiAnimation.h:246
State
Animation state.
Definition: UiAnimation.h:79
@ ONCE
Animate only once.
Definition: UiAnimation.h:89
@ DEFAULT
Definition: UiAnimation.h:84
std::vector< UiKeyFrameFloat > rotation_
List of rotation keyframes.
Definition: UiAnimation.h:266
UiWidget * widget_
The UI widget.
Definition: UiAnimation.h:226
void AddTime(const float time)
Adds time to the animation and updates it.
Definition: UiAnimation.cpp:29
std::vector< UiKeyFrameVector2 > scissor_y_left_
Definition: UiAnimation.h:281
void AddScissorKeyFrame(const UiKeyFrameVector2 &x1, const UiKeyFrameVector2 &y1, const UiKeyFrameVector2 &x2, const UiKeyFrameVector2 &y2)
Adds an scissor keyframe to the animation.
Definition: UiAnimation.cpp:109
float KeyFrameGetValue(std::vector< UiKeyFrameFloat > &data)
Gets the value from asee UiKeyFrameFloat}.
Definition: UiAnimation.cpp:119
void AddAlphaKeyFrame(const UiKeyFrameFloat &key_frame)
Adds an alpha keyframe to the animation.
Definition: UiAnimation.cpp:105
void SetTime(const float time)
Sets the time of the animation and updates it.
Definition: UiAnimation.cpp:73
std::vector< UiKeyFrameVector2 > y_
List of Y position keyframes.
Definition: UiAnimation.h:251
float length_
The animation length.
Definition: UiAnimation.h:236
std::vector< UiKeyFrameVector2 > height_
List of height keyframes.
Definition: UiAnimation.h:261
void AddYKeyFrame(const UiKeyFrameVector2 &key_frame)
Adds a Y position keyframe to the animation.
Definition: UiAnimation.cpp:89
void AddWidthKeyFrame(const UiKeyFrameVector2 &key_frame)
Adds a width keyframe to the animation.
Definition: UiAnimation.cpp:93
void AddRotationKeyFrame(const UiKeyFrameFloat &key_frame)
Adds a rotation keyframe to the animation.
Definition: UiAnimation.cpp:101
std::vector< UiKeyFrameVector2 > scissor_y_right_
Definition: UiAnimation.h:291
void AddXKeyFrame(const UiKeyFrameVector2 &key_frame)
Adds a X position keyframe to the animation.
Definition: UiAnimation.cpp:85
An UI widget.
Definition: UiWidget.h:28
Ogre::String String
Definition: TypeDefine.h:37
A keyframe value.
Definition: UiAnimation.h:27
float value
Value for the keyframe.
Definition: UiAnimation.h:37
float time
Keyframe time, in seconds.
Definition: UiAnimation.h:32
Coordinate keyframe.
Definition: UiAnimation.h:43
Ogre::Vector2 value
Position for the keyframe.
Definition: UiAnimation.h:53
float time
Keyframe time, in seconds.
Definition: UiAnimation.h:48