Panning now only works if the viewier is zoomed
This commit is contained in:
@@ -79,6 +79,7 @@ ViewerWidget::ViewerWidget(QWidget *parent) :
|
||||
connect(display_widget_, &ViewerDisplayWidget::ColorProcessorChanged, this, &ViewerWidget::ColorProcessorChanged);
|
||||
connect(display_widget_, &ViewerDisplayWidget::ColorManagerChanged, this, &ViewerWidget::ColorManagerChanged);
|
||||
connect(sizer_, &ViewerSizer::RequestMatrix, display_widget_, &ViewerDisplayWidget::SetMatrixZoom);
|
||||
connect(sizer_, &ViewerSizer::SetZoomFlag, display_widget_, &ViewerDisplayWidget::SetZoomFlag);
|
||||
sizer_->SetWidget(display_widget_);
|
||||
|
||||
// Create waveform view when audio is connected and video isn't
|
||||
|
||||
@@ -47,7 +47,8 @@ ViewerDisplayWidget::ViewerDisplayWidget(QWidget *parent) :
|
||||
signal_cursor_color_(false),
|
||||
gizmos_(nullptr),
|
||||
gizmo_click_(false),
|
||||
last_loaded_buffer_(nullptr)
|
||||
last_loaded_buffer_(nullptr),
|
||||
zoomed_(false)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -68,6 +69,16 @@ void ViewerDisplayWidget::SetMatrixZoom(const QMatrix4x4 &mat)
|
||||
update();
|
||||
}
|
||||
|
||||
void ViewerDisplayWidget::SetZoomFlag(bool flag)
|
||||
{
|
||||
zoomed_ = flag;
|
||||
// If not scaled reset translation matrix to identity
|
||||
if (!flag) {
|
||||
QMatrix4x4 mat;
|
||||
SetMatrixTranslate(mat);
|
||||
}
|
||||
}
|
||||
|
||||
QMatrix4x4 ViewerDisplayWidget::GetCompleteMatrix()
|
||||
{
|
||||
QMatrix4x4 mat;
|
||||
@@ -164,7 +175,7 @@ void ViewerDisplayWidget::mousePressEvent(QMouseEvent *event)
|
||||
}
|
||||
|
||||
// get current position in preperation for move event
|
||||
if (event->button() == Qt::MiddleButton) {
|
||||
if (event->button() == Qt::MiddleButton && zoomed_) {
|
||||
position_ = event->pos();
|
||||
return;
|
||||
}
|
||||
@@ -178,7 +189,7 @@ void ViewerDisplayWidget::mousePressEvent(QMouseEvent *event)
|
||||
|
||||
void ViewerDisplayWidget::mouseMoveEvent(QMouseEvent *event)
|
||||
{
|
||||
if (event->buttons() & Qt::MiddleButton) {
|
||||
if (event->buttons() & Qt::MiddleButton && zoomed_) {
|
||||
QPointF delta = event->pos() - position_;
|
||||
// scale delta to widget size
|
||||
delta.setX(delta.x() / width());
|
||||
|
||||
@@ -116,6 +116,8 @@ public slots:
|
||||
*/
|
||||
void SetImage(FramePtr in_buffer);
|
||||
|
||||
void SetZoomFlag(bool flag);
|
||||
|
||||
signals:
|
||||
/**
|
||||
* @brief Signal emitted when the user starts dragging from the viewer
|
||||
@@ -179,6 +181,8 @@ private:
|
||||
*/
|
||||
QMatrix4x4 scale_matrix_;
|
||||
|
||||
bool zoomed_;
|
||||
|
||||
#ifdef Q_OS_LINUX
|
||||
static bool nouveau_check_done_;
|
||||
#endif
|
||||
|
||||
@@ -105,6 +105,7 @@ void ViewerSizer::UpdateSize()
|
||||
// This container is taller than the image, scale by width
|
||||
child_size = QSize(width(), qRound(child_size.width() / aspect_ratio_));
|
||||
}
|
||||
emit SetZoomFlag(false);
|
||||
|
||||
} else {
|
||||
|
||||
@@ -128,7 +129,7 @@ void ViewerSizer::UpdateSize()
|
||||
child_matrix.scale(x_scale, y_scale, 1.0F);
|
||||
|
||||
child_size = QSize(zoomed_width, zoomed_height);
|
||||
|
||||
emit SetZoomFlag(true);
|
||||
}
|
||||
|
||||
widget_->resize(child_size);
|
||||
|
||||
@@ -65,6 +65,7 @@ public:
|
||||
|
||||
signals:
|
||||
void RequestMatrix(const QMatrix4x4& matrix);
|
||||
void SetZoomFlag(bool flag);
|
||||
|
||||
protected:
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user