#include <QOpenGLFunctions>
#include <QWheelEvent>
+#include <QMouseEvent>
using namespace std;
using namespace std::chrono;
fixup_zoom_matrix();
}
+void VideoWidget::mousePressEvent(QMouseEvent *e)
+{
+ if (e->button() == Qt::LeftButton) {
+ dragging = true;
+ last_drag_x = e->position().x();
+ last_drag_y = e->position().y();
+ }
+}
+
+void VideoWidget::mouseReleaseEvent(QMouseEvent *e)
+{
+ if (e->button() == Qt::LeftButton) {
+ dragging = false;
+ }
+}
+
+void VideoWidget::mouseMoveEvent(QMouseEvent *e)
+{
+ if (!dragging) {
+ return;
+ }
+ float dx = (e->position().x() - last_drag_x) / width();
+ float dy = (e->position().y() - last_drag_y) / height();
+
+ //zoom_matrix[6] += dx * zoom_matrix[0];
+ //zoom_matrix[7] += dy * zoom_matrix[4];
+ zoom_matrix[6] += dx;
+ zoom_matrix[7] -= dy;
+ fixup_zoom_matrix();
+
+ last_drag_x = e->position().x();
+ last_drag_y = e->position().y();
+}
+
// Normalize the matrix so that we never get skew or similar,
// and also never can zoom or pan too far out.
void VideoWidget::fixup_zoom_matrix()
void paintGL() override;
void wheelEvent(QWheelEvent *event) override;
+ // For dragging.
+ void mousePressEvent(QMouseEvent *e);
+ void mouseReleaseEvent(QMouseEvent *e);
+ void mouseMoveEvent(QMouseEvent *e);
+
signals:
void position_changed(uint64_t pos);
std::string pathname;
+ bool dragging = false;
+ float last_drag_x, last_drag_y;
+
void producer_thread_func();
bool play_video(const std::string &pathname);
void internal_rewind();