not quite so much needs to be delayed to the init() function
[personal-kdebase.git] / workspace / kwin / effects / wobblywindows.h
blob90d5c4b24beffd78c0c8891f29c65c4c5f9ed86a
1 /*****************************************************************
2 KWin - the KDE window manager
3 This file is part of the KDE project.
5 Copyright (C) 2008 Cédric Borgese <cedric.borgese@gmail.com>
7 You can Freely distribute this program under the GNU General Public
8 License. See the file "COPYING" for the exact licensing terms.
9 ******************************************************************/
11 #ifndef WOBBLYWINDOWS_H
12 #define WOBBLYWINDOWS_H
14 // Include with base class for effects.
15 #include <kwineffects.h>
17 namespace KWin
20 struct ParameterSet;
22 /**
23 * Effect which wobble windows
24 **/
25 class WobblyWindowsEffect : public Effect
27 public:
29 WobblyWindowsEffect();
30 virtual ~WobblyWindowsEffect();
32 virtual void reconfigure( ReconfigureFlags );
33 virtual void prePaintScreen( ScreenPrePaintData& data, int time );
34 virtual void prePaintWindow( EffectWindow* w, WindowPrePaintData& data, int time );
35 virtual void paintWindow( EffectWindow* w, int mask, QRegion region, WindowPaintData& data );
36 virtual void postPaintScreen();
37 virtual void windowUserMovedResized( EffectWindow* c, bool first, bool last );
38 virtual void windowAdded( EffectWindow* w );
39 virtual void windowClosed( EffectWindow* w );
41 // Wobbly model parameters
42 void setStiffness(qreal stiffness);
43 void setDrag(qreal drag);
44 void setVelocityThreshold(qreal velocityThreshold);
45 void setMoveFactor(qreal factor);
47 struct Pair
49 qreal x;
50 qreal y;
53 enum WindowStatus
55 Free,
56 Moving,
57 Openning,
58 Closing
61 private:
63 bool updateWindowWobblyDatas(EffectWindow* w, qreal time);
65 struct WindowWobblyInfos
67 Pair* origin;
68 Pair* position;
69 Pair* velocity;
70 Pair* acceleration;
71 Pair* buffer;
73 // if true, the physics system moves this point based only on it "normal" destination
74 // given by the window position, ignoring neighbour points.
75 bool* constraint;
77 // if true, the point is locked to its normal destination position.
78 bool* locked;
80 unsigned int width;
81 unsigned int height;
82 unsigned int count;
84 Pair* bezierSurface;
85 unsigned int bezierWidth;
86 unsigned int bezierHeight;
87 unsigned int bezierCount;
89 WindowStatus status;
91 // for closing
92 QRectF closeRect;
95 QHash< const EffectWindow*, WindowWobblyInfos > windows;
97 QRect m_updateRegion;
99 qreal m_stiffness;
100 qreal m_drag;
101 qreal m_move_factor;
103 // the default tesselation for windows
104 // use qreal instead of int as I really often need
105 // these values as real to do divisions.
106 qreal m_xTesselation;
107 qreal m_yTesselation;
109 qreal m_minVelocity;
110 qreal m_maxVelocity;
111 qreal m_stopVelocity;
112 qreal m_minAcceleration;
113 qreal m_maxAcceleration;
114 qreal m_stopAcceleration;
116 bool m_moveEffectEnabled;
117 bool m_openEffectEnabled;
118 bool m_closeEffectEnabled;
120 bool m_moveWobble; // Expands m_moveEffectEnabled
121 bool m_resizeWobble;
123 void initWobblyInfo(WindowWobblyInfos& wwi, QRect geometry) const;
124 void freeWobblyInfo(WindowWobblyInfos& wwi) const;
125 void wobblyOpenInit(WindowWobblyInfos& wwi) const;
126 void wobblyCloseInit(WindowWobblyInfos& wwi, EffectWindow* w) const;
128 WobblyWindowsEffect::Pair computeBezierPoint(const WindowWobblyInfos& wwi, Pair point) const;
130 static void heightRingLinearMean(Pair** datas, WindowWobblyInfos& wwi);
132 void setParameterSet(const ParameterSet& pset);
135 } // namespace KWin
137 #endif // WOBBLYWINDOWS_H