Skip to content

Commit

Permalink
Fix waveform zooming
Browse files Browse the repository at this point in the history
  • Loading branch information
ywwg committed Jun 11, 2023
1 parent 5e06563 commit c357a82
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/widget/wglwidgetqopengl.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include <QApplication>
#include <QResizeEvent>

#include "widget/openglwindow.h"
Expand Down Expand Up @@ -54,6 +55,11 @@ void WGLWidget::resizeEvent(QResizeEvent* event) {
QWidget::resizeEvent(event);
}

void WGLWidget::wheelEvent(QWheelEvent* event) {
QApplication::sendEvent(parentWidget(), event);
event->accept();
}

bool WGLWidget::isContextValid() const {
return m_pOpenGLWindow && m_pOpenGLWindow->context() && m_pOpenGLWindow->context()->isValid();
}
Expand Down
1 change: 1 addition & 0 deletions src/widget/wglwidgetqopengl.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class WGLWidget : public QWidget {
protected:
void showEvent(QShowEvent* event) override;
void resizeEvent(QResizeEvent* event) override;
void wheelEvent(QWheelEvent* event) override;

QPaintDevice* paintDevice();

Expand Down
2 changes: 1 addition & 1 deletion src/widget/wwaveformviewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ void WWaveformViewer::wheelEvent(QWheelEvent* event) {
if (m_waveformWidget) {
if (event->angleDelta().y() > 0) {
onZoomChange(m_waveformWidget->getZoomFactor() / 1.05);
} else {
} else if (event->angleDelta().y() < 0) {
onZoomChange(m_waveformWidget->getZoomFactor() * 1.05);
}
}
Expand Down

0 comments on commit c357a82

Please sign in to comment.