25#ifndef TGUI_ANIMATION_HPP
26#define TGUI_ANIMATION_HPP
28#include <TGUI/Duration.hpp>
29#include <TGUI/Layout.hpp>
72 class TGUI_API Animation
76 Animation(
const Animation&) =
default;
77 Animation(Animation&&) =
default;
78 Animation& operator=(
const Animation&) =
default;
79 Animation& operator=(Animation&&) =
default;
80 virtual ~Animation() =
default;
82 [[nodiscard]] AnimationType getType()
const;
84 virtual bool update(Duration elapsedTime) = 0;
85 virtual void finish();
88 Animation(AnimationType type, std::shared_ptr<Widget> widget, Duration duration, std::function<
void()> finishedCallback);
92 std::shared_ptr<Widget> m_widget;
94 Duration m_totalDuration;
95 Duration m_elapsedTime;
97 std::function<void()> m_finishedCallback;
102 class TGUI_API MoveAnimation :
public Animation
105 MoveAnimation(std::shared_ptr<Widget> widget,
109 std::function<
void()> finishedCallback =
nullptr);
111 bool update(Duration elapsedTime)
override;
113 void finish()
override;
122 class TGUI_API ResizeAnimation :
public Animation
125 ResizeAnimation(std::shared_ptr<Widget> widget,
129 std::function<
void()> finishedCallback =
nullptr);
131 bool update(Duration elapsedTime)
override;
133 void finish()
override;
136 Vector2f m_startSize;
142 class TGUI_API FadeAnimation :
public Animation
145 FadeAnimation(std::shared_ptr<Widget> widget,
149 std::function<
void()> finishedCallback =
nullptr);
151 bool update(Duration elapsedTime)
override;
153 void finish()
override;
156 float m_startOpacity;
Namespace that contains all TGUI functions and classes.
Definition AbsoluteOrRelativeValue.hpp:37
ShowEffectType
Type of effect to show/hide widget.
Definition Animation.hpp:44
@ Fade
Fade widget in or out.
Definition Animation.hpp:45
@ SlideFromBottom
Slide from bottom to show or to the top to hide.
Definition Animation.hpp:55
@ SlideToLeft
Slide to the left to hide or from right to show.
Definition Animation.hpp:48
@ SlideToRight
Slide to the right to hide or from left to show.
Definition Animation.hpp:47
@ SlideFromLeft
Slide from left to show or to the right to hide.
Definition Animation.hpp:52
@ Scale
Shrink to the center of the widget to hide or grow from its center to show.
Definition Animation.hpp:46
@ SlideToBottom
Slide to the bottom to hide or from top to show.
Definition Animation.hpp:49
@ SlideFromTop
Slide from top to show or to the bottom to hide.
Definition Animation.hpp:54
@ SlideToTop
Slide to the top to hide or from bottom to show.
Definition Animation.hpp:50
@ SlideFromRight
Slide from right to show or to the left to hide.
Definition Animation.hpp:53
AnimationType
Type of animation.
Definition Animation.hpp:62
@ Move
Position is being changed.
Definition Animation.hpp:63
@ Resize
Size is being changed.
Definition Animation.hpp:64
@ Opacity
Opacity is being changed.
Definition Animation.hpp:65