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 12, 2023
1 parent 5e06563 commit 0ee20f8
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 1 deletion.
7 changes: 7 additions & 0 deletions src/waveform/widgets/allshader/waveformwidget.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#include "waveform/widgets/allshader/waveformwidget.h"

#include <QApplication>

#include "moc_waveformwidget.cpp"
#include "waveform/renderers/allshader/waveformrendererabstract.h"

Expand Down Expand Up @@ -52,3 +54,8 @@ void WaveformWidget::resizeGL(int w, int h) {
renderer->allshaderWaveformRenderer()->resizeGL(w, h);
}
}

void WaveformWidget::wheelEvent(QWheelEvent* event) {
QApplication::sendEvent(parentWidget(), event);
event->accept();
}
1 change: 1 addition & 0 deletions src/waveform/widgets/allshader/waveformwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,5 @@ class allshader::WaveformWidget : public ::WGLWidget,
}

private:
void wheelEvent(QWheelEvent* event) override;
};
7 changes: 7 additions & 0 deletions src/waveform/widgets/glwaveformwidgetabstract.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
#include "waveform/widgets/glwaveformwidgetabstract.h"

#include <QApplication>

GLWaveformWidgetAbstract::GLWaveformWidgetAbstract(const QString& group, QWidget* parent)
: WaveformWidgetAbstract(group),
WGLWidget(parent) {
}

void GLWaveformWidgetAbstract::wheelEvent(QWheelEvent* event) {
QApplication::sendEvent(parentWidget(), event);
event->accept();
}
3 changes: 3 additions & 0 deletions src/waveform/widgets/glwaveformwidgetabstract.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,7 @@ class GLWaveformWidgetAbstract : public WaveformWidgetAbstract, public WGLWidget
}

#endif // !defined(QT_NO_OPENGL) && !defined(QT_OPENGL_ES_2)

private:
void wheelEvent(QWheelEvent* event) override;
};
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 0ee20f8

Please sign in to comment.