plugins/shakecursor: Add descale animation
This commit is contained in:
parent
0a5bd7397b
commit
57e2afaec1
2 changed files with 16 additions and 1 deletions
|
@ -24,8 +24,19 @@ ShakeCursorEffect::ShakeCursorEffect()
|
|||
|
||||
m_resetCursorScaleTimer.setSingleShot(true);
|
||||
connect(&m_resetCursorScaleTimer, &QTimer::timeout, this, [this]() {
|
||||
m_resetCursorScaleAnimation.setStartValue(m_cursorMagnification);
|
||||
m_resetCursorScaleAnimation.setEndValue(1.0);
|
||||
m_resetCursorScaleAnimation.setDuration(animationTime(150));
|
||||
m_resetCursorScaleAnimation.setEasingCurve(QEasingCurve::InOutCubic);
|
||||
m_resetCursorScaleAnimation.start();
|
||||
});
|
||||
|
||||
connect(&m_resetCursorScaleAnimation, &QVariantAnimation::valueChanged, this, [this]() {
|
||||
update(Transaction{
|
||||
.magnification = 1.0,
|
||||
.position = m_cursor->pos(),
|
||||
.hotspot = m_cursor->hotspot(),
|
||||
.size = m_cursor->geometry().size(),
|
||||
.magnification = m_resetCursorScaleAnimation.currentValue().toReal(),
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -73,11 +84,13 @@ void ShakeCursorEffect::pointerEvent(MouseEvent *event)
|
|||
.magnification = std::max(m_cursorMagnification, 1.0 + ShakeCursorConfig::magnification() * shakeFactor.value()),
|
||||
});
|
||||
m_resetCursorScaleTimer.start(1000);
|
||||
m_resetCursorScaleAnimation.stop();
|
||||
} else {
|
||||
update(Transaction{
|
||||
.magnification = 1.0,
|
||||
});
|
||||
m_resetCursorScaleTimer.stop();
|
||||
m_resetCursorScaleAnimation.stop();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include "plugins/shakecursor/shakedetector.h"
|
||||
|
||||
#include <QTimer>
|
||||
#include <QVariantAnimation>
|
||||
|
||||
namespace KWin
|
||||
{
|
||||
|
@ -51,6 +52,7 @@ private:
|
|||
void update(const Transaction &transaction);
|
||||
|
||||
QTimer m_resetCursorScaleTimer;
|
||||
QVariantAnimation m_resetCursorScaleAnimation;
|
||||
ShakeDetector m_shakeDetector;
|
||||
|
||||
Cursor *m_cursor;
|
||||
|
|
Loading…
Reference in a new issue