~ubuntu-branches/ubuntu/vivid/mygui/vivid

« back to all changes in this revision

Viewing changes to UnitTests/UnitTest_GraphView/FadeController.h

  • Committer: Package Import Robot
  • Author(s): Scott Howard, Bret Curtis, Scott Howard
  • Date: 2014-09-18 17:57:48 UTC
  • mfrom: (1.1.1)
  • Revision ID: package-import@ubuntu.com-20140918175748-dd8va78mvpw1jbes
Tags: 3.2.1-1
[ Bret Curtis ]
* Updated license for majority of files from LGPL to Expat (MIT)

[ Scott Howard ]
* New upstream release
* Updated patch to add build option for system GLEW libraries
* All patches accepted upstream except shared_libraries.patch
* Bumped SONAME due to dropped symbols, updated *.symbols and package
  names
* Updated license of debian/* to Expat with permission of all authors
* Don't install Doxygen autogenerated md5 and map files (thanks
  lintian)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*!
2
 
        @file
3
 
        @author         Albert Semenov
4
 
        @date           08/2008
5
 
*/
6
 
#ifndef __FADE_CONTROLLER_H__
7
 
#define __FADE_CONTROLLER_H__
8
 
 
9
 
#include "IAnimationNode.h"
10
 
#include "IAnimationGraph.h"
11
 
#include "ConnectionReceiver.h"
12
 
 
13
 
namespace animation
14
 
{
15
 
 
16
 
        class FadeController :
17
 
                public IAnimationNode
18
 
        {
19
 
        public:
20
 
                FadeController() :
21
 
                        IAnimationNode(),
22
 
                        mIsAnimationRun(false),
23
 
                        mWeight(0)
24
 
                {
25
 
                }
26
 
 
27
 
                FadeController(const std::string& _name, IAnimationGraph* _graph) :
28
 
                        IAnimationNode(_name, _graph),
29
 
                        mIsAnimationRun(false),
30
 
                        mWeight(0)
31
 
                {
32
 
                }
33
 
 
34
 
                virtual ~FadeController()
35
 
                {
36
 
                }
37
 
 
38
 
                virtual void setEvent(const std::string& _name, float _value = 0)
39
 
                {
40
 
                        if (_name == "Start")
41
 
                        {
42
 
                                mIsAnimationRun = true;
43
 
                                if (mWeight == 0)
44
 
                                        mConnection.forceEvent("Start");
45
 
                        }
46
 
                        else if (_name == "Stop") mIsAnimationRun = false;
47
 
                }
48
 
 
49
 
                virtual void addConnection(const std::string& _eventout, IAnimationNode* _node, const std::string& _eventin)
50
 
                {
51
 
                        mConnection.addConnection(_eventout, _node, _eventin);
52
 
                }
53
 
 
54
 
                virtual void removeConnection(const std::string& _eventout, IAnimationNode* _node, const std::string& _eventin)
55
 
                {
56
 
                        mConnection.removeConnection(_eventout, _node, _eventin);
57
 
                }
58
 
 
59
 
                virtual void addTime(float _value)
60
 
                {
61
 
                        const float fade_time = 0.3;
62
 
                        if (mIsAnimationRun)
63
 
                        {
64
 
                                if (mWeight != 1)
65
 
                                {
66
 
                                        mWeight += _value * (1 / fade_time);
67
 
                                        if (mWeight > 1) mWeight = 1;
68
 
                                        mConnection.forceEvent("Weight", mWeight);
69
 
                                }
70
 
                        }
71
 
                        else
72
 
                        {
73
 
                                if (mWeight != 0)
74
 
                                {
75
 
                                        mWeight -= _value * (1 / fade_time);
76
 
                                        if (mWeight < 0) mWeight = 0;
77
 
                                        mConnection.forceEvent("Weight", mWeight);
78
 
 
79
 
                                        if (mWeight == 0)
80
 
                                                mConnection.forceEvent("Stop");
81
 
                                }
82
 
                        }
83
 
                }
84
 
 
85
 
        private:
86
 
                ConnectionReceiver mConnection;
87
 
 
88
 
                bool mIsAnimationRun;
89
 
                float mWeight;
90
 
        };
91
 
 
92
 
} // namespace animation
93
 
 
94
 
#endif // __FADE_CONTROLLER_H__
 
1
/*!
 
2
        @file
 
3
        @author         Albert Semenov
 
4
        @date           08/2008
 
5
*/
 
6
#ifndef __FADE_CONTROLLER_H__
 
7
#define __FADE_CONTROLLER_H__
 
8
 
 
9
#include "IAnimationNode.h"
 
10
#include "IAnimationGraph.h"
 
11
#include "ConnectionReceiver.h"
 
12
 
 
13
namespace animation
 
14
{
 
15
 
 
16
        class FadeController :
 
17
                public IAnimationNode
 
18
        {
 
19
        public:
 
20
                FadeController() :
 
21
                        IAnimationNode(),
 
22
                        mIsAnimationRun(false),
 
23
                        mWeight(0)
 
24
                {
 
25
                }
 
26
 
 
27
                FadeController(const std::string& _name, IAnimationGraph* _graph) :
 
28
                        IAnimationNode(_name, _graph),
 
29
                        mIsAnimationRun(false),
 
30
                        mWeight(0)
 
31
                {
 
32
                }
 
33
 
 
34
                virtual ~FadeController()
 
35
                {
 
36
                }
 
37
 
 
38
                virtual void setEvent(const std::string& _name, float _value = 0)
 
39
                {
 
40
                        if (_name == "Start")
 
41
                        {
 
42
                                mIsAnimationRun = true;
 
43
                                if (mWeight == 0)
 
44
                                        mConnection.forceEvent("Start");
 
45
                        }
 
46
                        else if (_name == "Stop") mIsAnimationRun = false;
 
47
                }
 
48
 
 
49
                virtual void addConnection(const std::string& _eventout, IAnimationNode* _node, const std::string& _eventin)
 
50
                {
 
51
                        mConnection.addConnection(_eventout, _node, _eventin);
 
52
                }
 
53
 
 
54
                virtual void removeConnection(const std::string& _eventout, IAnimationNode* _node, const std::string& _eventin)
 
55
                {
 
56
                        mConnection.removeConnection(_eventout, _node, _eventin);
 
57
                }
 
58
 
 
59
                virtual void addTime(float _value)
 
60
                {
 
61
                        const float fade_time = 0.3f;
 
62
                        if (mIsAnimationRun)
 
63
                        {
 
64
                                if (mWeight != 1)
 
65
                                {
 
66
                                        mWeight += _value * (1 / fade_time);
 
67
                                        if (mWeight > 1) mWeight = 1;
 
68
                                        mConnection.forceEvent("Weight", mWeight);
 
69
                                }
 
70
                        }
 
71
                        else
 
72
                        {
 
73
                                if (mWeight != 0)
 
74
                                {
 
75
                                        mWeight -= _value * (1 / fade_time);
 
76
                                        if (mWeight < 0) mWeight = 0;
 
77
                                        mConnection.forceEvent("Weight", mWeight);
 
78
 
 
79
                                        if (mWeight == 0)
 
80
                                                mConnection.forceEvent("Stop");
 
81
                                }
 
82
                        }
 
83
                }
 
84
 
 
85
        private:
 
86
                ConnectionReceiver mConnection;
 
87
 
 
88
                bool mIsAnimationRun;
 
89
                float mWeight;
 
90
        };
 
91
 
 
92
} // namespace animation
 
93
 
 
94
#endif // __FADE_CONTROLLER_H__