-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmovieframeslider.cpp
35 lines (27 loc) · 1.1 KB
/
movieframeslider.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
#include "movieframeslider.h"
#include <QMouseEvent>
MovieFrameSlider::MovieFrameSlider(QWidget *parent) :
QSlider (parent)
{
}
void MovieFrameSlider::mousePressEvent(QMouseEvent *ev)
{
// Figure out what frame this corresponds to, then set the value
double percentageLocation {double(ev->x()) / double(this->width())};
int frame {int(round(this->minimum() + percentageLocation * (this->maximum() - this->minimum())))};
setValue (frame);
}
void MovieFrameSlider::mouseMoveEvent(QMouseEvent *ev)
{
// Figure out what frame this corresponds to, then set the value
double percentageLocation {double(ev->x()) / double(this->width())};
int frame {int(round(this->minimum() + percentageLocation * (this->maximum() - this->minimum())))};
setValue (frame);
}
void MovieFrameSlider::mouseReleaseEvent(QMouseEvent *ev)
{
// Figure out what frame this corresponds to, then set the value
double percentageLocation {double(ev->x()) / double(this->width())};
int frame {int(round(this->minimum() + percentageLocation * (this->maximum() - this->minimum())))};
setValue (frame);
}