Debian Codegraph @

engine/core/gui/fifechan/widgets/animationicon.h

raw
1 /***************************************************************************
2 * Copyright (C) 2005-2013 by the FIFE team *
3 * http://www.fifengine.net *
4 * This file is part of FIFE. *
5 * *
6 * FIFE is free software; you can redistribute it and/or *
7 * modify it under the terms of the GNU Lesser General Public *
8 * License as published by the Free Software Foundation; either *
9 * version 2.1 of the License, or (at your option) any later version. *
10 * *
11 * This library 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 GNU *
14 * Lesser General Public License for more details. *
15 * *
16 * You should have received a copy of the GNU Lesser General Public *
17 * License along with this library; if not, write to the *
18 * Free Software Foundation, Inc., *
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
20 ***************************************************************************/
21
22 #ifndef FIFE_GUI_WIDGETS_ANIMATIONICON_H
23 #define FIFE_GUI_WIDGETS_ANIMATIONICON_H
24
25 // Standard C++ library includes
26
27 // 3rd party library includes
28 #include <fifechan/image.hpp>
29 #include <fifechan/platform.hpp>
30 #include <fifechan.hpp>
31
32 // FIFE includes
33 // These includes are split up in two parts, separated by one empty line
34 // First block: files included from the FIFE root src directory
35 // Second block: files included from the same folder
36 #include "util/base/fife_stdint.h"
37 #include "video/animation.h"
38
39 namespace FIFE {
40 class TimeManager;
41 }
42
43 namespace fcn {
44
45 /**
46 * Implements an icon capable of displaying an animation.
47 */
48 class AnimationIcon : public Icon {
49 public:
50 /**
51 * Default constructor.
52 */
53 AnimationIcon();
54
55 /**
56 * Constructor.
57 *
58 * @param animation The animation to display.
59 */
60 AnimationIcon(FIFE::AnimationPtr animation);
61
62 /**
63 * Destructor.
64 */
65 virtual ~AnimationIcon();
66
67 /**
68 * Sets the animation to display.
69 *
70 * @param animation The animation to display.
71 */
72 void setAnimation(FIFE::AnimationPtr animation);
73
74 /**
75 * Gets the current animation.
76 *
77 * @return The current animation.
78 */
79 FIFE::AnimationPtr getAnimation() const;
80
81 /**
82 * Sets repeating of the animation.
83 *
84 * @param repeat True if the animation repeating is enabled, otherwise false.
85 */
86 void setRepeating(bool repeat);
87
88 /**
89 * Gets repeating of the animation.
90 *
91 * @return True if the animation repeating is enabled, otherwise false.
92 */
93 bool isRepeating() const;
94
95 /**
96 * Starts the animation from beginning.
97 */
98 void play();
99
100 /**
101 * Gets if the animation is playing.
102 *
103 * @return True if the animation is playing, otherwise false.
104 */
105 bool isPlaying() const;
106
107 /**
108 * Stops the animation at the current frame.
109 */
110 void pause();
111
112 /**
113 * Stops the animation and sets the current frame to the first frame.
114 */
115 void stop();
116
117
118 // Inherited from Widget
119
120 virtual void logic();
121
122 protected:
123 /**
124 * Holds pointer to Fifes TimeManager.
125 */
126 FIFE::TimeManager* mTimemanager;
127
128 /**
129 * The animation to display.
130 */
131 FIFE::AnimationPtr mAnimation;
132
133 /**
134 * Currently used image. It's the current frame from the animation
135 * encapsulated in a GuiImage.
136 */
137 const Image* mCurrentImage;
138
139 /**
140 * The time as the animation was started.
141 */
142 uint32_t mAnimtime;
143
144 /**
145 * The last used frame index from the animation.
146 */
147 int32_t mFrameIndex;
148
149 /**
150 * True if the animation should be repeating, otherwise false.
151 */
152 bool mRepeat;
153
154 /**
155 * True if the animation was started, otherwise false.
156 */
157 bool mPlay;
158
159 };
160 }
161
162 #endif