Changeset View
Changeset View
Standalone View
Standalone View
effects/slidingpopups/slidingpopups.cpp
Show All 34 Lines | |||||
35 | SlidingPopupsEffect::SlidingPopupsEffect() | 35 | SlidingPopupsEffect::SlidingPopupsEffect() | ||
36 | { | 36 | { | ||
37 | initConfig<SlidingPopupsConfig>(); | 37 | initConfig<SlidingPopupsConfig>(); | ||
38 | KWayland::Server::Display *display = effects->waylandDisplay(); | 38 | KWayland::Server::Display *display = effects->waylandDisplay(); | ||
39 | if (display) { | 39 | if (display) { | ||
40 | display->createSlideManager(this)->create(); | 40 | display->createSlideManager(this)->create(); | ||
41 | } | 41 | } | ||
42 | 42 | | |||
43 | m_slideLength = QFontMetrics(qApp->font()).height() * 8; | | |||
44 | | ||||
45 | m_atom = effects->announceSupportProperty("_KDE_SLIDE", this); | 43 | m_atom = effects->announceSupportProperty("_KDE_SLIDE", this); | ||
46 | connect(effects, &EffectsHandler::windowAdded, this, &SlidingPopupsEffect::slotWindowAdded); | 44 | connect(effects, &EffectsHandler::windowAdded, this, &SlidingPopupsEffect::slotWindowAdded); | ||
47 | connect(effects, &EffectsHandler::windowClosed, this, &SlidingPopupsEffect::slideOut); | 45 | connect(effects, &EffectsHandler::windowClosed, this, &SlidingPopupsEffect::slideOut); | ||
48 | connect(effects, &EffectsHandler::windowDeleted, this, &SlidingPopupsEffect::slotWindowDeleted); | 46 | connect(effects, &EffectsHandler::windowDeleted, this, &SlidingPopupsEffect::slotWindowDeleted); | ||
49 | connect(effects, &EffectsHandler::propertyNotify, this, &SlidingPopupsEffect::slotPropertyNotify); | 47 | connect(effects, &EffectsHandler::propertyNotify, this, &SlidingPopupsEffect::slotPropertyNotify); | ||
50 | connect(effects, &EffectsHandler::windowShown, this, &SlidingPopupsEffect::slideIn); | 48 | connect(effects, &EffectsHandler::windowShown, this, &SlidingPopupsEffect::slideIn); | ||
51 | connect(effects, &EffectsHandler::windowHidden, this, &SlidingPopupsEffect::slideOut); | 49 | connect(effects, &EffectsHandler::windowHidden, this, &SlidingPopupsEffect::slideOut); | ||
52 | connect(effects, &EffectsHandler::xcbConnectionChanged, this, | 50 | connect(effects, &EffectsHandler::xcbConnectionChanged, this, | ||
▲ Show 20 Lines • Show All 63 Lines • ▼ Show 20 Line(s) | |||||
116 | { | 114 | { | ||
117 | auto animationIt = m_animations.constFind(w); | 115 | auto animationIt = m_animations.constFind(w); | ||
118 | if (animationIt == m_animations.constEnd()) { | 116 | if (animationIt == m_animations.constEnd()) { | ||
119 | effects->paintWindow(w, mask, region, data); | 117 | effects->paintWindow(w, mask, region, data); | ||
120 | return; | 118 | return; | ||
121 | } | 119 | } | ||
122 | 120 | | |||
123 | const AnimationData &animData = m_animationsData[w]; | 121 | const AnimationData &animData = m_animationsData[w]; | ||
124 | const int slideLength = (animData.slideLength > 0) ? animData.slideLength : m_slideLength; | | |||
125 | 122 | | |||
126 | const QRect screenRect = effects->clientArea(FullScreenArea, w->screen(), effects->currentDesktop()); | 123 | const QRect screenRect = effects->clientArea(FullScreenArea, w->screen(), effects->currentDesktop()); | ||
127 | int splitPoint = 0; | 124 | int splitPoint = 0; | ||
128 | const QRect geo = w->expandedGeometry(); | 125 | const QRect geo = w->expandedGeometry(); | ||
129 | const qreal t = (*animationIt).timeLine.value(); | 126 | const qreal t = (*animationIt).timeLine.value(); | ||
130 | 127 | | |||
128 | int slideLength = animData.slideLength; | ||||
129 | | ||||
130 | data.multiplyOpacity(interpolate(0.0, 1.0, t)); | ||||
davidedmundson: Have you tested this with the autohide panel. I doubt it will look good.
We want that for… | |||||
131 | | ||||
131 | switch (animData.location) { | 132 | switch (animData.location) { | ||
132 | case Location::Left: | 133 | case Location::Left: | ||
133 | if (slideLength < geo.width()) { | 134 | slideLength = (slideLength > 0) ? slideLength : geo.width(); | ||
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… | |||||
134 | data.multiplyOpacity(t); | 135 | slideLength = qMin(geo.width(), slideLength); | ||
135 | } | 136 | | ||
136 | data.translate(-interpolate(qMin(geo.width(), slideLength), 0.0, t)); | 137 | data.translate(-interpolate(slideLength, 0.0, t)); | ||
137 | splitPoint = geo.width() - (geo.x() + geo.width() - screenRect.x() - animData.offset); | 138 | splitPoint = geo.width() - (geo.x() + geo.width() - screenRect.x() - animData.offset); | ||
138 | region = QRegion(geo.x() + splitPoint, geo.y(), geo.width() - splitPoint, geo.height()); | 139 | region = QRegion(geo.x() + splitPoint, geo.y(), geo.width() - splitPoint, geo.height()); | ||
139 | break; | 140 | break; | ||
zzag: Unrelated change. | |||||
140 | case Location::Top: | 141 | case Location::Top: | ||
141 | if (slideLength < geo.height()) { | 142 | slideLength = (slideLength > 0) ? slideLength : geo.height(); | ||
142 | data.multiplyOpacity(t); | 143 | slideLength = qMin(geo.height(), slideLength); | ||
143 | } | 144 | | ||
144 | data.translate(0.0, -interpolate(qMin(geo.height(), slideLength), 0.0, t)); | 145 | data.translate(0.0, -interpolate(slideLength, 0.0, t)); | ||
145 | splitPoint = geo.height() - (geo.y() + geo.height() - screenRect.y() - animData.offset); | 146 | splitPoint = geo.height() - (geo.y() + geo.height() - screenRect.y() - animData.offset); | ||
146 | region = QRegion(geo.x(), geo.y() + splitPoint, geo.width(), geo.height() - splitPoint); | 147 | region = QRegion(geo.x(), geo.y() + splitPoint, geo.width(), geo.height() - splitPoint); | ||
147 | break; | 148 | break; | ||
148 | case Location::Right: | 149 | case Location::Right: | ||
149 | if (slideLength < geo.width()) { | 150 | slideLength = (slideLength > 0) ? slideLength : geo.width(); | ||
150 | data.multiplyOpacity(t); | 151 | slideLength = qMin(geo.width(), slideLength); | ||
151 | } | 152 | | ||
152 | data.translate(interpolate(qMin(geo.width(), slideLength), 0.0, t)); | 153 | data.translate(interpolate(slideLength, 0.0, t)); | ||
153 | splitPoint = screenRect.x() + screenRect.width() - geo.x() - animData.offset; | 154 | splitPoint = screenRect.x() + screenRect.width() - geo.x() - animData.offset; | ||
154 | region = QRegion(geo.x(), geo.y(), splitPoint, geo.height()); | 155 | region = QRegion(geo.x(), geo.y(), splitPoint, geo.height()); | ||
155 | break; | 156 | break; | ||
156 | case Location::Bottom: | 157 | case Location::Bottom: | ||
157 | default: | 158 | default: | ||
158 | if (slideLength < geo.height()) { | 159 | slideLength = (slideLength > 0) ? slideLength : geo.height(); | ||
159 | data.multiplyOpacity(t); | 160 | slideLength = qMin(geo.height(), slideLength); | ||
160 | } | 161 | | ||
161 | data.translate(0.0, interpolate(qMin(geo.height(), slideLength), 0.0, t)); | 162 | data.translate(0.0, interpolate(slideLength, 0.0, t)); | ||
162 | splitPoint = screenRect.y() + screenRect.height() - geo.y() - animData.offset; | 163 | splitPoint = screenRect.y() + screenRect.height() - geo.y() - animData.offset; | ||
163 | region = QRegion(geo.x(), geo.y(), geo.width(), splitPoint); | 164 | region = QRegion(geo.x(), geo.y(), geo.width(), splitPoint); | ||
164 | } | 165 | } | ||
165 | 166 | | |||
166 | effects->paintWindow(w, mask, region, data); | 167 | effects->paintWindow(w, mask, region, data); | ||
167 | } | 168 | } | ||
168 | 169 | | |||
169 | void SlidingPopupsEffect::postPaintWindow(EffectWindow *w) | 170 | void SlidingPopupsEffect::postPaintWindow(EffectWindow *w) | ||
▲ Show 20 Lines • Show All 221 Lines • ▼ Show 20 Line(s) | 382 | { | |||
391 | if (dataIt == m_animationsData.constEnd()) { | 392 | if (dataIt == m_animationsData.constEnd()) { | ||
392 | return; | 393 | return; | ||
393 | } | 394 | } | ||
394 | 395 | | |||
395 | Animation &animation = m_animations[w]; | 396 | Animation &animation = m_animations[w]; | ||
396 | animation.kind = AnimationKind::In; | 397 | animation.kind = AnimationKind::In; | ||
397 | animation.timeLine.setDirection(TimeLine::Forward); | 398 | animation.timeLine.setDirection(TimeLine::Forward); | ||
398 | animation.timeLine.setDuration((*dataIt).slideInDuration); | 399 | animation.timeLine.setDuration((*dataIt).slideInDuration); | ||
399 | animation.timeLine.setEasingCurve(QEasingCurve::InOutSine); | 400 | animation.timeLine.setEasingCurve(QEasingCurve::OutExpo); | ||
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… | |||||
400 | 401 | | |||
401 | // If the opposite animation (Out) was active and it had shorter duration, | 402 | // If the opposite animation (Out) was active and it had shorter duration, | ||
402 | // at this point, the timeline can end up in the "done" state. Thus, we have | 403 | // at this point, the timeline can end up in the "done" state. Thus, we have | ||
403 | // to reset it. | 404 | // to reset it. | ||
404 | if (animation.timeLine.done()) { | 405 | if (animation.timeLine.done()) { | ||
405 | animation.timeLine.reset(); | 406 | animation.timeLine.reset(); | ||
406 | } | 407 | } | ||
407 | 408 | | |||
Show All 22 Lines | 417 | { | |||
430 | if (w->isDeleted()) { | 431 | if (w->isDeleted()) { | ||
431 | w->refWindow(); | 432 | w->refWindow(); | ||
432 | } | 433 | } | ||
433 | 434 | | |||
434 | Animation &animation = m_animations[w]; | 435 | Animation &animation = m_animations[w]; | ||
435 | animation.kind = AnimationKind::Out; | 436 | animation.kind = AnimationKind::Out; | ||
436 | animation.timeLine.setDirection(TimeLine::Backward); | 437 | animation.timeLine.setDirection(TimeLine::Backward); | ||
437 | animation.timeLine.setDuration((*dataIt).slideOutDuration); | 438 | animation.timeLine.setDuration((*dataIt).slideOutDuration); | ||
438 | animation.timeLine.setEasingCurve(QEasingCurve::InOutSine); | 439 | animation.timeLine.setEasingCurve(QEasingCurve::OutExpo); // 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… | |||||
439 | 440 | | |||
440 | // If the opposite animation (In) was active and it had shorter duration, | 441 | // If the opposite animation (In) was active and it had shorter duration, | ||
441 | // at this point, the timeline can end up in the "done" state. Thus, we have | 442 | // at this point, the timeline can end up in the "done" state. Thus, we have | ||
442 | // to reset it. | 443 | // to reset it. | ||
443 | if (animation.timeLine.done()) { | 444 | if (animation.timeLine.done()) { | ||
444 | animation.timeLine.reset(); | 445 | animation.timeLine.reset(); | ||
445 | } | 446 | } | ||
446 | 447 | | |||
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.