2009-12-27 23:16:11 +01:00
|
|
|
/*
|
|
|
|
Copyright (C) 2009 Igor Trindade Oliveira <igor.oliveira@indt.org.br>
|
|
|
|
Copyright (C) 2009 Adenilson Cavalcanti <adenilson.silva@idnt.org.br>
|
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU Lesser General Public
|
|
|
|
License as published by the Free Software Foundation; either
|
|
|
|
version 2.1 of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This library is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
Lesser General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Lesser General Public
|
|
|
|
License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2009-09-17 18:24:19 +02:00
|
|
|
#ifndef PLASMA_KINETICSCROLLING_H
|
|
|
|
#define PLASMA_KINETICSCROLLING_H
|
|
|
|
|
|
|
|
class QGraphicsSceneMouseEvent;
|
|
|
|
class QGraphicsWidget;
|
2009-10-13 14:36:48 +02:00
|
|
|
class QGraphicsSceneWheelEvent;
|
2009-11-13 08:16:25 +01:00
|
|
|
class QKeyEvent;
|
2009-09-17 18:24:19 +02:00
|
|
|
#include <QObject>
|
2009-10-13 14:29:55 +02:00
|
|
|
#include <QPointF>
|
2009-12-21 19:36:39 +01:00
|
|
|
#include <QtCore/QAbstractAnimation>
|
2009-09-17 18:24:19 +02:00
|
|
|
|
2009-09-19 19:07:56 +02:00
|
|
|
|
2009-09-17 18:24:19 +02:00
|
|
|
namespace Plasma
|
|
|
|
{
|
|
|
|
|
|
|
|
class KineticScrollingPrivate;
|
|
|
|
|
|
|
|
class KineticScrolling: public QObject
|
|
|
|
{
|
2009-10-13 12:47:41 +02:00
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2009-10-20 00:10:25 +02:00
|
|
|
KineticScrolling(QGraphicsWidget *parent);
|
2009-10-13 12:47:41 +02:00
|
|
|
~KineticScrolling();
|
2009-10-15 21:11:34 +02:00
|
|
|
void setWidget(QGraphicsWidget *parent);
|
2010-02-22 12:21:30 +01:00
|
|
|
void stop();
|
2009-10-15 21:11:34 +02:00
|
|
|
|
2009-12-21 19:36:39 +01:00
|
|
|
Q_SIGNALS:
|
|
|
|
void stateChanged(QAbstractAnimation::State newState,
|
|
|
|
QAbstractAnimation::State oldState);
|
|
|
|
|
2009-10-15 21:11:34 +02:00
|
|
|
protected:
|
2009-10-13 12:47:41 +02:00
|
|
|
void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
|
|
|
|
void mousePressEvent(QGraphicsSceneMouseEvent *event);
|
|
|
|
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
|
|
|
|
void wheelReleaseEvent(QGraphicsSceneWheelEvent *event);
|
2009-11-12 21:44:02 +01:00
|
|
|
void keyPressEvent(QKeyEvent *event);
|
2009-10-15 21:11:34 +02:00
|
|
|
|
2009-10-13 12:47:41 +02:00
|
|
|
private:
|
|
|
|
KineticScrollingPrivate *d;
|
2009-11-18 18:35:50 +01:00
|
|
|
void resetAnimation(QPointF finalPosition, int duration);
|
|
|
|
void setScrollValue(QPointF value);
|
2009-11-18 18:59:56 +01:00
|
|
|
QPointF thresholdPosition(QPointF value) const;
|
2009-10-13 12:47:41 +02:00
|
|
|
void duration();
|
2009-11-18 18:35:50 +01:00
|
|
|
|
|
|
|
private Q_SLOTS:
|
|
|
|
void overshoot();
|
2009-09-17 18:24:19 +02:00
|
|
|
|
2009-10-15 21:11:34 +02:00
|
|
|
protected:
|
|
|
|
bool eventFilter(QObject *watched, QEvent *event);
|
|
|
|
|
2009-09-17 18:24:19 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|