Add wobblyness when opening windows.
svn path=/trunk/KDE/kdebase/workspace/; revision=798624
This commit is contained in:
parent
7c8262068d
commit
666d612295
2 changed files with 79 additions and 6 deletions
|
@ -258,7 +258,7 @@ void WobblyWindowsEffect::windowUserMovedResized(EffectWindow* w, bool first, bo
|
||||||
}
|
}
|
||||||
|
|
||||||
WindowWobblyInfos& wwi = windows[w];
|
WindowWobblyInfos& wwi = windows[w];
|
||||||
wwi.onConstrain = true;
|
wwi.status = Moving;
|
||||||
const QRectF& rect = w->geometry();
|
const QRectF& rect = w->geometry();
|
||||||
|
|
||||||
qreal x_increment = rect.width() / (wwi.width-1.0);
|
qreal x_increment = rect.width() / (wwi.width-1.0);
|
||||||
|
@ -288,11 +288,28 @@ void WobblyWindowsEffect::windowUserMovedResized(EffectWindow* w, bool first, bo
|
||||||
if (windows.contains(w))
|
if (windows.contains(w))
|
||||||
{
|
{
|
||||||
WindowWobblyInfos& wwi = windows[w];
|
WindowWobblyInfos& wwi = windows[w];
|
||||||
wwi.onConstrain = false;
|
wwi.status = Moving;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void WobblyWindowsEffect::windowAdded(EffectWindow* w)
|
||||||
|
{
|
||||||
|
if(windows.contains(w))
|
||||||
|
{
|
||||||
|
// could this happen ??
|
||||||
|
WindowWobblyInfos& wwi = windows[w];
|
||||||
|
wobblyOpenInit(wwi);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
WindowWobblyInfos new_wwi;
|
||||||
|
initWobblyInfo(new_wwi, w->geometry());
|
||||||
|
wobblyOpenInit(new_wwi);
|
||||||
|
windows[w] = new_wwi;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void WobblyWindowsEffect::windowClosed(EffectWindow* w)
|
void WobblyWindowsEffect::windowClosed(EffectWindow* w)
|
||||||
{
|
{
|
||||||
if(windows.contains(w))
|
if(windows.contains(w))
|
||||||
|
@ -300,7 +317,52 @@ void WobblyWindowsEffect::windowClosed(EffectWindow* w)
|
||||||
WindowWobblyInfos& wwi = windows[w];
|
WindowWobblyInfos& wwi = windows[w];
|
||||||
freeWobblyInfo(wwi);
|
freeWobblyInfo(wwi);
|
||||||
windows.remove(w);
|
windows.remove(w);
|
||||||
|
// wobblyCloseInit(new_wwi);
|
||||||
|
// w->refWindow();
|
||||||
}
|
}
|
||||||
|
//else
|
||||||
|
//{
|
||||||
|
// WindowWobblyInfos new_wwi;
|
||||||
|
// initWobblyInfo(new_wwi, w->geometry());
|
||||||
|
// wobblyCloseInit(new_wwi);
|
||||||
|
// windows[w] = new_wwi;
|
||||||
|
// w->refWindow();
|
||||||
|
//}
|
||||||
|
}
|
||||||
|
|
||||||
|
void WobblyWindowsEffect::wobblyOpenInit(WindowWobblyInfos& wwi) const
|
||||||
|
{
|
||||||
|
Pair middle = wwi.origin[0];
|
||||||
|
middle.x += wwi.origin[15].x;
|
||||||
|
middle.y += wwi.origin[15].y;
|
||||||
|
middle.x /= 2;
|
||||||
|
middle.y /= 2;
|
||||||
|
|
||||||
|
for (unsigned int j=0; j<4; ++j)
|
||||||
|
{
|
||||||
|
for (unsigned int i=0; i<4; ++i)
|
||||||
|
{
|
||||||
|
unsigned int idx = j*4 + i;
|
||||||
|
wwi.constraint[idx] = false;
|
||||||
|
wwi.position[idx].x = (wwi.position[idx].x + 3*middle.x)/4;
|
||||||
|
wwi.position[idx].y = (wwi.position[idx].y + 3*middle.y)/4;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
wwi.status = Openning;
|
||||||
|
}
|
||||||
|
|
||||||
|
void WobblyWindowsEffect::wobblyCloseInit(WindowWobblyInfos& wwi) const
|
||||||
|
{
|
||||||
|
// for closing, not yet used...
|
||||||
|
for (unsigned int j=0; j<4; ++j)
|
||||||
|
{
|
||||||
|
for (unsigned int i=0; i<4; ++i)
|
||||||
|
{
|
||||||
|
unsigned int idx = j*4 + i;
|
||||||
|
wwi.constraint[idx] = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
wwi.status = Closing;
|
||||||
}
|
}
|
||||||
|
|
||||||
void WobblyWindowsEffect::initWobblyInfo(WindowWobblyInfos& wwi, QRect geometry) const
|
void WobblyWindowsEffect::initWobblyInfo(WindowWobblyInfos& wwi, QRect geometry) const
|
||||||
|
@ -322,7 +384,7 @@ void WobblyWindowsEffect::initWobblyInfo(WindowWobblyInfos& wwi, QRect geometry)
|
||||||
|
|
||||||
wwi.bezierSurface = new Pair[wwi.bezierCount];
|
wwi.bezierSurface = new Pair[wwi.bezierCount];
|
||||||
|
|
||||||
wwi.onConstrain = true;
|
wwi.status = Moving;
|
||||||
|
|
||||||
qreal x = geometry.x(), y = geometry.y();
|
qreal x = geometry.x(), y = geometry.y();
|
||||||
qreal width = geometry.width(), height = geometry.height();
|
qreal width = geometry.width(), height = geometry.height();
|
||||||
|
@ -907,7 +969,7 @@ bool WobblyWindowsEffect::updateWindowWobblyDatas(EffectWindow* w, qreal time)
|
||||||
kDebug() << "sum_acc : " << acc_sum << " *** sum_vel :" << vel_sum;
|
kDebug() << "sum_acc : " << acc_sum << " *** sum_vel :" << vel_sum;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!wwi.onConstrain && acc_sum < m_stopAcceleration && vel_sum < m_stopVelocity)
|
if (wwi.status != Moving && acc_sum < m_stopAcceleration && vel_sum < m_stopVelocity)
|
||||||
{
|
{
|
||||||
freeWobblyInfo(wwi);
|
freeWobblyInfo(wwi);
|
||||||
windows.remove(w);
|
windows.remove(w);
|
||||||
|
|
|
@ -41,7 +41,8 @@ class WobblyWindowsEffect : public Effect
|
||||||
virtual void paintWindow( EffectWindow* w, int mask, QRegion region, WindowPaintData& data );
|
virtual void paintWindow( EffectWindow* w, int mask, QRegion region, WindowPaintData& data );
|
||||||
virtual void postPaintScreen();
|
virtual void postPaintScreen();
|
||||||
virtual void windowUserMovedResized( EffectWindow* c, bool first, bool last );
|
virtual void windowUserMovedResized( EffectWindow* c, bool first, bool last );
|
||||||
virtual void windowClosed( EffectWindow* c );
|
virtual void windowAdded( EffectWindow* w );
|
||||||
|
virtual void windowClosed( EffectWindow* w );
|
||||||
|
|
||||||
// Wobbly model parameters
|
// Wobbly model parameters
|
||||||
void setRaideur(qreal raideur);
|
void setRaideur(qreal raideur);
|
||||||
|
@ -64,6 +65,14 @@ class WobblyWindowsEffect : public Effect
|
||||||
|
|
||||||
bool updateWindowWobblyDatas(EffectWindow* w, qreal time);
|
bool updateWindowWobblyDatas(EffectWindow* w, qreal time);
|
||||||
|
|
||||||
|
enum WindowStatus
|
||||||
|
{
|
||||||
|
Free,
|
||||||
|
Moving,
|
||||||
|
Openning,
|
||||||
|
Closing
|
||||||
|
};
|
||||||
|
|
||||||
struct WindowWobblyInfos
|
struct WindowWobblyInfos
|
||||||
{
|
{
|
||||||
Pair* origin;
|
Pair* origin;
|
||||||
|
@ -86,7 +95,7 @@ class WobblyWindowsEffect : public Effect
|
||||||
unsigned int bezierHeight;
|
unsigned int bezierHeight;
|
||||||
unsigned int bezierCount;
|
unsigned int bezierCount;
|
||||||
|
|
||||||
bool onConstrain;
|
WindowStatus status;
|
||||||
};
|
};
|
||||||
|
|
||||||
QHash< const EffectWindow*, WindowWobblyInfos > windows;
|
QHash< const EffectWindow*, WindowWobblyInfos > windows;
|
||||||
|
@ -115,6 +124,8 @@ class WobblyWindowsEffect : public Effect
|
||||||
|
|
||||||
void initWobblyInfo(WindowWobblyInfos& wwi, QRect geometry) const;
|
void initWobblyInfo(WindowWobblyInfos& wwi, QRect geometry) const;
|
||||||
void freeWobblyInfo(WindowWobblyInfos& wwi) const;
|
void freeWobblyInfo(WindowWobblyInfos& wwi) const;
|
||||||
|
void wobblyOpenInit(WindowWobblyInfos& wwi) const;
|
||||||
|
void wobblyCloseInit(WindowWobblyInfos& wwi) const;
|
||||||
|
|
||||||
WobblyWindowsEffect::Pair computeBezierPoint(const WindowWobblyInfos& wwi, Pair point) const;
|
WobblyWindowsEffect::Pair computeBezierPoint(const WindowWobblyInfos& wwi, Pair point) const;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue