Changeset View
Changeset View
Standalone View
Standalone View
effects/slidingpopups/slidingpopups.cpp
1 | /******************************************************************** | 1 | /******************************************************************** | ||
---|---|---|---|---|---|
2 | KWin - the KDE window manager | 2 | KWin - the KDE window manager | ||
3 | This file is part of the KDE project. | 3 | This file is part of the KDE project. | ||
4 | 4 | | |||
5 | Copyright (C) 2009 Marco Martin notmart@gmail.com | 5 | Copyright (C) 2009 Marco Martin notmart@gmail.com | ||
6 | Copyright (C) 2018 Vlad Zagorodniy <vladzzag@gmail.com> | 6 | Copyright (C) 2018 Vlad Zagorodniy <vladzzag@gmail.com> | ||
7 | Copyright (C) 2019 Sefa Eyeoglu <contact@scrumplex.net> | ||||
7 | 8 | | |||
8 | This program is free software; you can redistribute it and/or modify | 9 | This program is free software; you can redistribute it and/or modify | ||
9 | it under the terms of the GNU General Public License as published by | 10 | it under the terms of the GNU General Public License as published by | ||
10 | the Free Software Foundation; either version 2 of the License, or | 11 | the Free Software Foundation; either version 2 of the License, or | ||
11 | (at your option) any later version. | 12 | (at your option) any later version. | ||
12 | 13 | | |||
13 | This program is distributed in the hope that it will be useful, | 14 | This program is distributed in the hope that it will be useful, | ||
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
▲ Show 20 Lines • Show All 115 Lines • ▼ Show 20 Line(s) | 122 | { | |||
130 | 131 | | |||
131 | const QRect screenRect = effects->clientArea(FullScreenArea, w->screen(), effects->currentDesktop()); | 132 | const QRect screenRect = effects->clientArea(FullScreenArea, w->screen(), effects->currentDesktop()); | ||
132 | int splitPoint = 0; | 133 | int splitPoint = 0; | ||
133 | const QRect geo = w->expandedGeometry(); | 134 | const QRect geo = w->expandedGeometry(); | ||
134 | const qreal t = (*animationIt).timeLine.value(); | 135 | const qreal t = (*animationIt).timeLine.value(); | ||
135 | 136 | | |||
136 | switch (animData.location) { | 137 | switch (animData.location) { | ||
137 | case Location::Left: | 138 | case Location::Left: | ||
138 | if (slideLength < geo.width()) { | 139 | if (slideLength < geo.width()) { | ||
davidedmundson: Have you tested this with the autohide panel. I doubt it will look good.
We want that for… | |||||
139 | data.multiplyOpacity(t); | 140 | data.multiplyOpacity(interpolate(0.0, 1.0, t)); | ||
data.multiplyOpacity(t) and data.multiplyOpacity(interpolate(0.0, 1.0, t)); do the same thing. Could you please revert this change? zzag: `data.multiplyOpacity(t)` and `data.multiplyOpacity(interpolate(0.0, 1.0, t));` do the same… | |||||
140 | } | 141 | } | ||
142 | | ||||
141 | data.translate(-interpolate(qMin(geo.width(), slideLength), 0.0, t)); | 143 | data.translate(-interpolate(qMin(geo.width(), slideLength), 0.0, t)); | ||
142 | splitPoint = geo.width() - (geo.x() + geo.width() - screenRect.x() - animData.offset); | 144 | splitPoint = geo.width() - (geo.x() + geo.width() - screenRect.x() - animData.offset); | ||
143 | region = QRegion(geo.x() + splitPoint, geo.y(), geo.width() - splitPoint, geo.height()); | 145 | region = QRegion(geo.x() + splitPoint, geo.y(), geo.width() - splitPoint, geo.height()); | ||
zzag: Unrelated change. | |||||
144 | break; | 146 | break; | ||
145 | case Location::Top: | 147 | case Location::Top: | ||
146 | if (slideLength < geo.height()) { | 148 | if (slideLength < geo.width()) { | ||
147 | data.multiplyOpacity(t); | 149 | data.multiplyOpacity(interpolate(0.0, 1.0, t)); | ||
148 | } | 150 | } | ||
151 | | ||||
149 | data.translate(0.0, -interpolate(qMin(geo.height(), slideLength), 0.0, t)); | 152 | data.translate(0.0, -interpolate(qMin(geo.height(), slideLength), 0.0, t)); | ||
150 | splitPoint = geo.height() - (geo.y() + geo.height() - screenRect.y() - animData.offset); | 153 | splitPoint = geo.height() - (geo.y() + geo.height() - screenRect.y() - animData.offset); | ||
151 | region = QRegion(geo.x(), geo.y() + splitPoint, geo.width(), geo.height() - splitPoint); | 154 | region = QRegion(geo.x(), geo.y() + splitPoint, geo.width(), geo.height() - splitPoint); | ||
152 | break; | 155 | break; | ||
153 | case Location::Right: | 156 | case Location::Right: | ||
154 | if (slideLength < geo.width()) { | 157 | if (slideLength < geo.width()) { | ||
155 | data.multiplyOpacity(t); | 158 | data.multiplyOpacity(interpolate(0.0, 1.0, t)); | ||
156 | } | 159 | } | ||
160 | | ||||
157 | data.translate(interpolate(qMin(geo.width(), slideLength), 0.0, t)); | 161 | data.translate(interpolate(qMin(geo.width(), slideLength), 0.0, t)); | ||
158 | splitPoint = screenRect.x() + screenRect.width() - geo.x() - animData.offset; | 162 | splitPoint = screenRect.x() + screenRect.width() - geo.x() - animData.offset; | ||
159 | region = QRegion(geo.x(), geo.y(), splitPoint, geo.height()); | 163 | region = QRegion(geo.x(), geo.y(), splitPoint, geo.height()); | ||
160 | break; | 164 | break; | ||
161 | case Location::Bottom: | 165 | case Location::Bottom: | ||
162 | default: | 166 | default: | ||
163 | if (slideLength < geo.height()) { | 167 | if (slideLength < geo.width()) { | ||
164 | data.multiplyOpacity(t); | 168 | data.multiplyOpacity(interpolate(0.0, 1.0, t)); | ||
165 | } | 169 | } | ||
170 | | ||||
166 | data.translate(0.0, interpolate(qMin(geo.height(), slideLength), 0.0, t)); | 171 | data.translate(0.0, interpolate(qMin(geo.height(), slideLength), 0.0, t)); | ||
167 | splitPoint = screenRect.y() + screenRect.height() - geo.y() - animData.offset; | 172 | splitPoint = screenRect.y() + screenRect.height() - geo.y() - animData.offset; | ||
168 | region = QRegion(geo.x(), geo.y(), geo.width(), splitPoint); | 173 | region = QRegion(geo.x(), geo.y(), geo.width(), splitPoint); | ||
169 | } | 174 | } | ||
170 | 175 | | |||
171 | effects->paintWindow(w, mask, region, data); | 176 | effects->paintWindow(w, mask, region, data); | ||
172 | } | 177 | } | ||
173 | 178 | | |||
▲ Show 20 Lines • Show All 283 Lines • ▼ Show 20 Line(s) | 452 | { | |||
457 | if (dataIt == m_animationsData.constEnd()) { | 462 | if (dataIt == m_animationsData.constEnd()) { | ||
458 | return; | 463 | return; | ||
459 | } | 464 | } | ||
460 | 465 | | |||
461 | Animation &animation = m_animations[w]; | 466 | Animation &animation = m_animations[w]; | ||
462 | animation.kind = AnimationKind::In; | 467 | animation.kind = AnimationKind::In; | ||
463 | animation.timeLine.setDirection(TimeLine::Forward); | 468 | animation.timeLine.setDirection(TimeLine::Forward); | ||
464 | animation.timeLine.setDuration((*dataIt).slideInDuration); | 469 | animation.timeLine.setDuration((*dataIt).slideInDuration); | ||
465 | animation.timeLine.setEasingCurve(QEasingCurve::InOutSine); | 470 | animation.timeLine.setEasingCurve(QEasingCurve::OutQuart); | ||
Let's make this InQuad to be consistent with most other animations in Plasma, and conform to the emerging guidelines in D25343. ngraham: Let's make this `InQuad` to be consistent with most other animations in Plasma, and conform to… | |||||
466 | 471 | | |||
467 | // If the opposite animation (Out) was active and it had shorter duration, | 472 | // If the opposite animation (Out) was active and it had shorter duration, | ||
468 | // at this point, the timeline can end up in the "done" state. Thus, we have | 473 | // at this point, the timeline can end up in the "done" state. Thus, we have | ||
469 | // to reset it. | 474 | // to reset it. | ||
470 | if (animation.timeLine.done()) { | 475 | if (animation.timeLine.done()) { | ||
471 | animation.timeLine.reset(); | 476 | animation.timeLine.reset(); | ||
472 | } | 477 | } | ||
473 | 478 | | |||
Show All 22 Lines | 487 | { | |||
496 | if (w->isDeleted()) { | 501 | if (w->isDeleted()) { | ||
497 | w->refWindow(); | 502 | w->refWindow(); | ||
498 | } | 503 | } | ||
499 | 504 | | |||
500 | Animation &animation = m_animations[w]; | 505 | Animation &animation = m_animations[w]; | ||
501 | animation.kind = AnimationKind::Out; | 506 | animation.kind = AnimationKind::Out; | ||
502 | animation.timeLine.setDirection(TimeLine::Backward); | 507 | animation.timeLine.setDirection(TimeLine::Backward); | ||
503 | animation.timeLine.setDuration((*dataIt).slideOutDuration); | 508 | animation.timeLine.setDuration((*dataIt).slideOutDuration); | ||
504 | animation.timeLine.setEasingCurve(QEasingCurve::InOutSine); | 509 | animation.timeLine.setEasingCurve(QEasingCurve::OutQuad); // basically InQuart, as direction is backwards | ||
The comment here needs to be changed. It says InQuart, as I was experimenting with different easing functions before settling on OutExpo. sefaeyeoglu: The comment here needs to be changed. It says InQuart, as I was experimenting with different… | |||||
Technically the "OutQuad" here turns into "InQuad". In L504 the animation is reversed, which also reverses the easing curve. sefaeyeoglu: Technically the "OutQuad" here turns into "InQuad". In L504 the animation is reversed, which… | |||||
505 | 510 | | |||
506 | // If the opposite animation (In) was active and it had shorter duration, | 511 | // If the opposite animation (In) was active and it had shorter duration, | ||
507 | // at this point, the timeline can end up in the "done" state. Thus, we have | 512 | // at this point, the timeline can end up in the "done" state. Thus, we have | ||
508 | // to reset it. | 513 | // to reset it. | ||
509 | if (animation.timeLine.done()) { | 514 | if (animation.timeLine.done()) { | ||
510 | animation.timeLine.reset(); | 515 | animation.timeLine.reset(); | ||
511 | } | 516 | } | ||
512 | 517 | | |||
Show All 29 Lines |
Have you tested this with the autohide panel. I doubt it will look good.
We want that for newly appearing windows in the middle of the screen, but not for a window that clearly comes in from offscreen.
The current heuristic of basing that off slideLength seems to work.