Tweaking kinetic scrolling parameters to slow down a bit.
It also started to use QRectF to improve precision (should make movement smoother). svn path=/trunk/KDE/kdelibs/; revision=1030203
This commit is contained in:
parent
99cdc241c3
commit
0373ff836d
@ -46,7 +46,7 @@ class KineticScrollingPrivate
|
||||
public:
|
||||
KineticScrollingPrivate(): timerID(0),
|
||||
overshoot(20), bounceFlag(0), hasOvershoot(true),
|
||||
friction(0.9)
|
||||
friction(0.8)
|
||||
{
|
||||
maximum = 100 + overshoot;
|
||||
minimum = -overshoot;
|
||||
@ -67,11 +67,11 @@ public:
|
||||
|
||||
unsigned int timeDelta;
|
||||
qreal scrollVelocity;
|
||||
QPoint kinMovement;
|
||||
QPointF kinMovement;
|
||||
|
||||
enum { None, Up, Down };
|
||||
int timerID, overshoot, direction;
|
||||
QPoint cposition;
|
||||
QPointF cposition;
|
||||
char bounceFlag;
|
||||
bool hasOvershoot;
|
||||
QObject *parent;
|
||||
@ -93,7 +93,7 @@ KineticScrolling::~KineticScrolling()
|
||||
delete d;
|
||||
}
|
||||
|
||||
QPoint KineticScrolling::kinMovement()
|
||||
QPointF KineticScrolling::kinMovement()
|
||||
{
|
||||
return d->kinMovement;
|
||||
}
|
||||
@ -126,14 +126,17 @@ void KineticScrolling::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
||||
{
|
||||
duration();
|
||||
QPoint temp = event->pos().toPoint() - event->lastPos().toPoint();
|
||||
if (!temp.isNull())
|
||||
if (!temp.isNull()) {
|
||||
d->kinMovement += temp;
|
||||
/* Not so fast baby! */
|
||||
d->kinMovement *= 0.3;
|
||||
}
|
||||
|
||||
if (d->timeDelta > 600) {
|
||||
if (d->kinMovement.y() > 0)
|
||||
d->kinMovement.setY(-3);
|
||||
else
|
||||
d->kinMovement.setY(3);
|
||||
else
|
||||
d->kinMovement.setY(-3);
|
||||
}
|
||||
|
||||
d->direction = KineticScrollingPrivate::None;
|
||||
@ -150,9 +153,9 @@ void KineticScrolling::wheelReleaseEvent(QGraphicsSceneWheelEvent *event)
|
||||
/* scroll down is negative in pixels and we want 6% */
|
||||
int temp = event->delta();
|
||||
if (temp < 0)
|
||||
temp = d->geo.height() * 0.06;
|
||||
temp = d->geo.height() * 0.07;
|
||||
else
|
||||
temp = d->geo.height() * -0.06;
|
||||
temp = d->geo.height() * -0.07;
|
||||
|
||||
d->kinMovement.setY(kinMovement().y() + temp);
|
||||
startAnimationTimer(30);
|
||||
@ -203,7 +206,7 @@ void KineticScrolling::timerEvent(QTimerEvent *event)
|
||||
}
|
||||
}
|
||||
|
||||
void KineticScrolling::setKineticScrollValue(QPoint value)
|
||||
void KineticScrolling::setKineticScrollValue(QPointF value)
|
||||
{
|
||||
if (!(d->geo.height())) {
|
||||
d->kinMovement.setY(0);
|
||||
|
@ -26,7 +26,7 @@ class QGraphicsSceneMouseEvent;
|
||||
class QGraphicsWidget;
|
||||
#include <QObject>
|
||||
|
||||
class QPoint;
|
||||
class QPointF;
|
||||
|
||||
namespace Plasma
|
||||
{
|
||||
@ -48,12 +48,12 @@ class KineticScrolling: public QObject
|
||||
void timerEvent(QTimerEvent *event);
|
||||
void bounceTimer();
|
||||
void duration();
|
||||
QPoint kinMovement();
|
||||
QPointF kinMovement();
|
||||
void startAnimationTimer(int interval);
|
||||
void doneOvershoot(void);
|
||||
|
||||
public Q_SLOTS:
|
||||
void setKineticScrollValue(QPoint value);
|
||||
void setKineticScrollValue(QPointF value);
|
||||
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user