[effects/fallapart] Fade out window parts

Summary:
Window parts disappear very rapidly, it feels not really pleasant.
Animate also opacity so window parts disappear over time. This
makes fall apart animation more pleasant.

### Before

{F5912359}

### After

{F5912360}

Test Plan:
* Enabled fall apart effect
* Closed System Settings

Reviewers: #kwin, #plasma, #vdg, davidedmundson

Reviewed By: #kwin, #plasma, #vdg, davidedmundson

Subscribers: ngraham, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D13528
This commit is contained in:
Vlad Zagorodniy 2018-06-14 13:30:52 +03:00
parent 9260b3c51e
commit 8593823f6c

View file

@ -74,6 +74,7 @@ void FallApartEffect::prePaintWindow(EffectWindow* w, WindowPrePaintData& data,
void FallApartEffect::paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data) void FallApartEffect::paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data)
{ {
if (windows.contains(w) && isRealWindow(w)) { if (windows.contains(w) && isRealWindow(w)) {
const qreal t = windows[w];
WindowQuadList new_quads; WindowQuadList new_quads;
int cnt = 0; int cnt = 0;
foreach (WindowQuad quad, data.quads) { // krazy:exclude=foreach foreach (WindowQuad quad, data.quads) { // krazy:exclude=foreach
@ -90,7 +91,7 @@ void FallApartEffect::paintWindow(EffectWindow* w, int mask, QRegion region, Win
ydiff = -(w->height() / 2 - p1.y()) / w->height() * 100; ydiff = -(w->height() / 2 - p1.y()) / w->height() * 100;
if (p1.y() > w->height() / 2) if (p1.y() > w->height() / 2)
ydiff = (p1.y() - w->height() / 2) / w->height() * 100; ydiff = (p1.y() - w->height() / 2) / w->height() * 100;
double modif = windows[ w ] * windows[ w ] * 64; double modif = t * t * 64;
srandom(cnt); // change direction randomly but consistently srandom(cnt); // change direction randomly but consistently
xdiff += (rand() % 21 - 10); xdiff += (rand() % 21 - 10);
ydiff += (rand() % 21 - 10); ydiff += (rand() % 21 - 10);
@ -119,6 +120,7 @@ void FallApartEffect::paintWindow(EffectWindow* w, int mask, QRegion region, Win
++cnt; ++cnt;
} }
data.quads = new_quads; data.quads = new_quads;
data.multiplyOpacity(interpolate(1.0, 0.0, t));
} }
effects->paintWindow(w, mask, region, data); effects->paintWindow(w, mask, region, data);
} }