implemented middle click drag on zoomed viewer
This commit is contained in:
@@ -24,12 +24,31 @@ ViewerContainer::ViewerContainer(QWidget *parent) :
|
||||
setWidget(area);
|
||||
|
||||
child = new ViewerWidget(area);
|
||||
child->container = this;
|
||||
}
|
||||
|
||||
ViewerContainer::~ViewerContainer() {
|
||||
delete area;
|
||||
}
|
||||
|
||||
void ViewerContainer::dragScrollPress(const QPoint &p) {
|
||||
drag_start_x = p.x();
|
||||
drag_start_y = p.y();
|
||||
horiz_start = horizontalScrollBar()->value();
|
||||
vert_start = verticalScrollBar()->value();
|
||||
}
|
||||
|
||||
void ViewerContainer::dragScrollMove(const QPoint &p) {
|
||||
int true_x = p.x() + (horiz_start - horizontalScrollBar()->value());
|
||||
int true_y = p.y() + (vert_start - verticalScrollBar()->value());
|
||||
|
||||
horizontalScrollBar()->setValue(horizontalScrollBar()->value() + (drag_start_x - true_x));
|
||||
verticalScrollBar()->setValue(verticalScrollBar()->value() + (drag_start_y - true_y));
|
||||
|
||||
drag_start_x = true_x;
|
||||
drag_start_y = true_y;
|
||||
}
|
||||
|
||||
void ViewerContainer::adjust() {
|
||||
if (viewer->seq != NULL) {
|
||||
if (child->waveform) {
|
||||
|
||||
@@ -15,6 +15,9 @@ public:
|
||||
bool fit;
|
||||
double zoom;
|
||||
|
||||
void dragScrollPress(const QPoint&);
|
||||
void dragScrollMove(const QPoint&);
|
||||
|
||||
Viewer* viewer;
|
||||
ViewerWidget* child;
|
||||
void adjust();
|
||||
@@ -28,6 +31,10 @@ public slots:
|
||||
|
||||
private:
|
||||
QWidget* area;
|
||||
int drag_start_x;
|
||||
int drag_start_y;
|
||||
int horiz_start;
|
||||
int vert_start;
|
||||
};
|
||||
|
||||
#endif // VIEWERCONTAINER_H
|
||||
|
||||
+6
-1
@@ -19,6 +19,7 @@
|
||||
#include "ui/collapsiblewidget.h"
|
||||
#include "project/undo.h"
|
||||
#include "project/media.h"
|
||||
#include "ui/viewercontainer.h"
|
||||
|
||||
#include <QPainter>
|
||||
#include <QAudioOutput>
|
||||
@@ -215,6 +216,8 @@ void ViewerWidget::move_gizmos(QMouseEvent *event, bool done) {
|
||||
void ViewerWidget::mousePressEvent(QMouseEvent* event) {
|
||||
if (waveform) {
|
||||
seek_from_click(event->x());
|
||||
} else if (event->buttons() & Qt::MiddleButton) {
|
||||
container->dragScrollPress(event->pos());
|
||||
} else {
|
||||
drag_start_x = event->pos().x();
|
||||
drag_start_y = event->pos().y();
|
||||
@@ -232,9 +235,11 @@ void ViewerWidget::mousePressEvent(QMouseEvent* event) {
|
||||
}
|
||||
|
||||
void ViewerWidget::mouseMoveEvent(QMouseEvent* event) {
|
||||
if (dragging) {
|
||||
if (dragging) {
|
||||
if (waveform) {
|
||||
seek_from_click(event->x());
|
||||
} else if (event->buttons() & Qt::MiddleButton) {
|
||||
container->dragScrollMove(event->pos());
|
||||
} else if (gizmos == NULL) {
|
||||
QDrag* drag = new QDrag(this);
|
||||
QMimeData* mimeData = new QMimeData;
|
||||
|
||||
@@ -16,6 +16,7 @@ struct FootageStream;
|
||||
class QOpenGLFramebufferObject;
|
||||
class Effect;
|
||||
class EffectGizmo;
|
||||
class ViewerContainer;
|
||||
struct GLTextureCoords;
|
||||
|
||||
class ViewerWidget : public QOpenGLWidget, QOpenGLFunctions
|
||||
@@ -27,6 +28,7 @@ public:
|
||||
void paintGL();
|
||||
void initializeGL();
|
||||
Viewer* viewer;
|
||||
ViewerContainer* container;
|
||||
|
||||
QOpenGLFramebufferObject* default_fbo;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user