OpenMW
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
screenfader.hpp
Go to the documentation of this file.
1 #ifndef OPENMW_MWGUI_SCREENFADER_H
2 #define OPENMW_MWGUI_SCREENFADER_H
3 
4 #include <deque>
5 
6 #include <boost/shared_ptr.hpp>
7 
8 #include "windowbase.hpp"
9 
10 namespace MWGui
11 {
12  class ScreenFader;
13 
14  class FadeOp
15  {
16  public:
17  typedef boost::shared_ptr<FadeOp> Ptr;
18 
19  FadeOp(ScreenFader * fader, float time, float targetAlpha);
20 
21  bool isRunning();
22 
23  void start();
24  void update(float dt);
25  void finish();
26 
27  private:
30  float mTargetTime;
31  float mTargetAlpha;
32  float mStartAlpha;
33  bool mRunning;
34  };
35 
36  class ScreenFader : public WindowBase
37  {
38  public:
39  ScreenFader(const std::string & texturePath, const std::string& layout = "openmw_screen_fader.layout", const MyGUI::FloatCoord& texCoordOverride = MyGUI::FloatCoord(0,0,1,1));
40 
41  void update(float dt);
42 
43  void fadeIn(const float time);
44  void fadeOut(const float time);
45  void fadeTo(const int percent, const float time);
46 
47  void setFactor (float factor);
48  void setRepeat(bool repeat);
49 
50  void queue(float time, float targetAlpha);
51  bool isEmpty();
52  void clearQueue();
53 
54  void notifyAlphaChanged(float alpha);
56  float getCurrentAlpha();
57 
58  private:
59  void applyAlpha();
60 
62  float mFactor;
63 
64  bool mRepeat; // repeat queued operations without removing them
65  std::deque<FadeOp::Ptr> mQueue;
66  };
67 }
68 
69 #endif
ScreenFader(const std::string &texturePath, const std::string &layout="openmw_screen_fader.layout", const MyGUI::FloatCoord &texCoordOverride=MyGUI::FloatCoord(0, 0, 1, 1))
Definition: screenfader.cpp:70
Definition: screenfader.hpp:14
void notifyOperationFinished()
Definition: screenfader.cpp:171
float mStartAlpha
Definition: screenfader.hpp:32
float getCurrentAlpha()
Definition: screenfader.cpp:180
void setRepeat(bool repeat)
Definition: screenfader.cpp:128
float mRemainingTime
Definition: screenfader.hpp:29
void start()
Definition: screenfader.cpp:24
void notifyAlphaChanged(float alpha)
Definition: screenfader.cpp:158
float mTargetAlpha
Definition: screenfader.hpp:31
void fadeIn(const float time)
Definition: screenfader.cpp:107
void update(float dt)
Definition: screenfader.cpp:91
void queue(float time, float targetAlpha)
Definition: screenfader.cpp:133
void finish()
Definition: screenfader.cpp:64
void fadeOut(const float time)
Definition: screenfader.cpp:112
void clearQueue()
Definition: screenfader.cpp:153
bool mRepeat
Definition: screenfader.hpp:64
FadeOp(ScreenFader *fader, float time, float targetAlpha)
Definition: screenfader.cpp:9
void update(float dt)
Definition: screenfader.cpp:34
float mTargetTime
Definition: screenfader.hpp:30
Definition: windowbase.hpp:16
float mFactor
Definition: screenfader.hpp:62
boost::shared_ptr< FadeOp > Ptr
Definition: screenfader.hpp:17
bool mRunning
Definition: screenfader.hpp:33
ScreenFader * mFader
Definition: screenfader.hpp:28
void setFactor(float factor)
Definition: screenfader.cpp:122
Definition: screenfader.hpp:36
float mCurrentAlpha
Definition: screenfader.hpp:61
void applyAlpha()
Definition: screenfader.cpp:101
bool isRunning()
Definition: screenfader.cpp:19
bool isEmpty()
Definition: screenfader.cpp:148
std::deque< FadeOp::Ptr > mQueue
Definition: screenfader.hpp:65
void fadeTo(const int percent, const float time)
Definition: screenfader.cpp:117