scroller_p.h
110 lines
| 2.6 KiB
| text/x-c
|
CLexer
|
r855 | /**************************************************************************** | ||
** | ||||
|
r2776 | ** Copyright (C) 2015 The Qt Company Ltd | ||
|
r855 | ** All rights reserved. | ||
|
r2776 | ** For any questions to The Qt Company, please use contact form at http://qt.io | ||
|
r855 | ** | ||
|
r2740 | ** This file is part of the Qt Charts module. | ||
|
r855 | ** | ||
|
r2740 | ** Licensees holding valid commercial license for Qt may use this file in | ||
** accordance with the Qt License Agreement provided with the Software | ||||
** or, alternatively, in accordance with the terms contained in a written | ||||
|
r2776 | ** agreement between you and The Qt Company. | ||
|
r855 | ** | ||
** If you have questions regarding the use of this file, please use | ||||
|
r2740 | ** contact form at http://qt.io | ||
|
r855 | ** | ||
****************************************************************************/ | ||||
// W A R N I N G | ||||
// ------------- | ||||
// | ||||
|
r2574 | // This file is not part of the Qt Enterprise Chart API. It exists purely as an | ||
|
r855 | // implementation detail. This header file may change from version to | ||
// version without notice, or even be removed. | ||||
// | ||||
// We mean it. | ||||
|
r969 | #ifndef SCROLLER_P_H | ||
#define SCROLLER_P_H | ||||
|
r855 | |||
|
r2714 | #include <QtCharts/QChartGlobal> | ||
|
r2731 | #include <QtCore/QObject> | ||
|
r2714 | #include <QtCore/QBasicTimer> | ||
#include <QtCore/QTime> | ||||
#include <QtCore/QPointF> | ||||
|
r855 | |||
|
r2774 | QT_BEGIN_NAMESPACE | ||
|
r855 | class QGraphicsSceneMouseEvent; | ||
|
r2774 | QT_END_NAMESPACE | ||
|
r855 | |||
|
r2712 | QT_CHARTS_BEGIN_NAMESPACE | ||
|
r855 | |||
class Scroller; | ||||
class QLegend; | ||||
class ScrollTicker : public QObject | ||||
{ | ||||
|
r974 | Q_OBJECT | ||
|
r855 | public: | ||
|
r2097 | explicit ScrollTicker(Scroller *scroller, QObject *parent = 0); | ||
|
r855 | void start(int interval); | ||
void stop(); | ||||
protected: | ||||
void timerEvent(QTimerEvent *event); | ||||
private: | ||||
QBasicTimer m_timer; | ||||
Scroller *m_scroller; | ||||
}; | ||||
class Scroller | ||||
{ | ||||
public: | ||||
enum State { | ||||
Idle, | ||||
|
r2199 | Pressed, | ||
|
r855 | Move, | ||
|
r2189 | Scroll | ||
|
r855 | }; | ||
|
r859 | Scroller(); | ||
|
r855 | virtual ~Scroller(); | ||
|
r2104 | virtual void setOffset(const QPointF &point) = 0; | ||
|
r859 | virtual QPointF offset() const = 0; | ||
|
r855 | |||
|
r2189 | void move(const QPointF &delta); | ||
|
r2197 | void scrollTo(const QPointF &delta); | ||
|
r2183 | |||
|
r2199 | void handleMousePressEvent(QGraphicsSceneMouseEvent *event); | ||
void handleMouseMoveEvent(QGraphicsSceneMouseEvent *event); | ||||
void handleMouseReleaseEvent(QGraphicsSceneMouseEvent *event); | ||||
|
r855 | void scrollTick(); | ||
|
r2189 | private: | ||
void startTicker(int interval); | ||||
void stopTicker(); | ||||
|
r855 | private: | ||
|
r2104 | void calculateSpeed(const QPointF &position); | ||
void lowerSpeed(QPointF &speed, qreal maxSpeed = 100); | ||||
|
r855 | |||
private: | ||||
ScrollTicker m_ticker; | ||||
QTime m_timeStamp; | ||||
QPointF m_speed; | ||||
QPointF m_fraction; | ||||
|
r2189 | int m_timeTresholdMin; | ||
int m_timeTresholdMax; | ||||
State m_state; | ||||
|
r2199 | QPointF m_pressPos; | ||
QPointF m_lastPos; | ||||
qreal m_treshold; | ||||
|
r855 | }; | ||
|
r2712 | QT_CHARTS_END_NAMESPACE | ||
|
r855 | |||
|
r1935 | #endif /* SCROLLER_P_H */ | ||