ScummVM API documentation
ScaleAnimation.h
1/* ScummVM - Graphic Adventure Engine
2 *
3 * ScummVM is the legal property of its developers, whose names
4 * are too numerous to list here. Please refer to the COPYRIGHT
5 * file distributed with this source distribution.
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 *
20 */
21
22// Based on code by omergilad.
23
24#ifndef GUI_ANIMATION_SCALEANIMATION_H
25#define GUI_ANIMATION_SCALEANIMATION_H
26
27#include "gui/animation/Animation.h"
28
29namespace GUI {
30
32public:
33 ScaleAnimation() : _endWidth(0), _endWidthFactor(0) {}
34
35 virtual ~ScaleAnimation() {}
36
37 float getEndWidth() const { return _endWidth; }
38 void setEndWidth(float endWidth) { _endWidth = endWidth; }
39 float getEndWidthFactor() const { return _endWidthFactor; }
40 void setEndWidthFactor(float endWidthFactor) { _endWidthFactor = endWidthFactor; }
41 float getStartWidth() const { return _startWidth; }
42 void setStartWidth(float startWidth) { _startWidth = startWidth; }
43
44 void updateInternal(Drawable *drawable, float interpolation) {
45 // If start width was set as 0 -> use the current width as the start dimension
46 if (_startWidth == 0)
47 _startWidth = drawable->getWidth();
48
49 // If end width was set as 0 - multiply the start width by the given factor
50 if (_endWidth == 0)
51 _endWidth = _startWidth * _endWidthFactor;
52
53 // Calculate width based on interpolation
54 float width = _startWidth * (1 - interpolation) + _endWidth * interpolation;
55 drawable->setWidth(width);
56 }
57
58private:
59 virtual void updateInternal(Drawable *drawable, float interpolation);
60 float _startWidth;
61 float _endWidth;
62 float _endWidthFactor;
63};
64
65} // End of namespace GUI
66
67
68#endif /* GUI_ANIMATION_SCALEANIMATION_H */
Definition: Animation.h:33
Definition: Drawable.h:37
Definition: ScaleAnimation.h:31