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

« back to all changes in this revision

Viewing changes to Tools/EditorFramework/MessageBoxFadeControl.cpp

  • 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/2010
 
5
*/
 
6
 
 
7
#include "Precompiled.h"
 
8
#include "MessageBoxFadeControl.h"
 
9
#include "MessageBoxManager.h"
 
10
 
 
11
namespace tools
 
12
{
 
13
 
 
14
        MessageBoxFadeControl::MessageBoxFadeControl() :
 
15
                mMaxAlpha(1)
 
16
        {
 
17
        }
 
18
 
 
19
        MessageBoxFadeControl::~MessageBoxFadeControl()
 
20
        {
 
21
                MyGUI::Gui::getInstance().eventFrameStart -= MyGUI::newDelegate(this, &MessageBoxFadeControl::notifyFrameStart);
 
22
        }
 
23
 
 
24
        void MessageBoxFadeControl::OnInitialise(Control* _parent, MyGUI::Widget* _place, const std::string& _layoutName)
 
25
        {
 
26
                Control::OnInitialise(_parent, _place, "MessageBoxFadeControl.layout");
 
27
 
 
28
                MyGUI::Gui::getInstance().eventFrameStart += MyGUI::newDelegate(this, &MessageBoxFadeControl::notifyFrameStart);
 
29
 
 
30
                mMaxAlpha = mMainWidget->getAlpha();
 
31
                mMainWidget->setAlpha(0);
 
32
        }
 
33
 
 
34
 
 
35
        void MessageBoxFadeControl::notifyFrameStart(float _time)
 
36
        {
 
37
                const float coef = 1;
 
38
 
 
39
                bool visible = MessageBoxManager::getInstance().hasAny();
 
40
 
 
41
                if (visible)
 
42
                {
 
43
                        if (!mMainWidget->getVisible())
 
44
                        {
 
45
                                mMainWidget->setVisible(true);
 
46
                                mMainWidget->setAlpha(0);
 
47
                        }
 
48
                        else
 
49
                        {
 
50
                                float alpha = mMainWidget->getAlpha();
 
51
                                if (alpha < mMaxAlpha)
 
52
                                {
 
53
                                        alpha += _time * coef;
 
54
                                        if (alpha > mMaxAlpha)
 
55
                                                alpha = mMaxAlpha;
 
56
                                        mMainWidget->setAlpha(alpha);
 
57
                                }
 
58
                        }
 
59
                }
 
60
                else
 
61
                {
 
62
                        if (mMainWidget->getVisible())
 
63
                        {
 
64
                                float alpha = mMainWidget->getAlpha();
 
65
                                alpha -= _time * coef;
 
66
                                if (alpha <= 0)
 
67
                                {
 
68
                                        mMainWidget->setVisible(false);
 
69
                                }
 
70
                                else
 
71
                                {
 
72
                                        mMainWidget->setAlpha(alpha);
 
73
                                }
 
74
                        }
 
75
                }
 
76
        }
 
77
 
 
78
}