-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathAnimPreview.cpp
47 lines (43 loc) · 1.07 KB
/
AnimPreview.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include "AnimPreview.h"
AnimPreview::AnimPreview(QWidget * parent) : QGraphicsView(parent)
{
_pan = false;
_panStartX = _panStartY = 0;
}
void AnimPreview::mousePressEvent(QMouseEvent *event)
{
if (event->button() == Qt::MidButton)
{
_pan = true;
_panStartX = event->x();
_panStartY = event->y();
setCursor(Qt::ClosedHandCursor);
event->accept();
return;
}
event->ignore();
}
void AnimPreview::mouseReleaseEvent(QMouseEvent *event)
{
if (event->button() == Qt::MidButton)
{
_pan = false;
setCursor(Qt::ArrowCursor);
event->accept();
return;
}
event->ignore();
}
void AnimPreview::mouseMoveEvent(QMouseEvent *event)
{
if (_pan)
{
horizontalScrollBar()->setValue(horizontalScrollBar()->value() - (event->x() - _panStartX));
verticalScrollBar()->setValue(verticalScrollBar()->value() - (event->y() - _panStartY));
_panStartX = event->x();
_panStartY = event->y();
event->accept();
return;
}
event->ignore();
}