From 8593823f6cd83492cc2fa68d464aef3a417d90ec Mon Sep 17 00:00:00 2001 From: Vlad Zagorodniy Date: Thu, 14 Jun 2018 13:30:52 +0300 Subject: [PATCH] [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 --- effects/fallapart/fallapart.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/effects/fallapart/fallapart.cpp b/effects/fallapart/fallapart.cpp index 4e928bbc11..5d3f0997b9 100644 --- a/effects/fallapart/fallapart.cpp +++ b/effects/fallapart/fallapart.cpp @@ -74,6 +74,7 @@ void FallApartEffect::prePaintWindow(EffectWindow* w, WindowPrePaintData& data, void FallApartEffect::paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data) { if (windows.contains(w) && isRealWindow(w)) { + const qreal t = windows[w]; WindowQuadList new_quads; int cnt = 0; 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; if (p1.y() > w->height() / 2) 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 xdiff += (rand() % 21 - 10); ydiff += (rand() % 21 - 10); @@ -119,6 +120,7 @@ void FallApartEffect::paintWindow(EffectWindow* w, int mask, QRegion region, Win ++cnt; } data.quads = new_quads; + data.multiplyOpacity(interpolate(1.0, 0.0, t)); } effects->paintWindow(w, mask, region, data); }