diff --git a/src/preferences/dialog/dlgprefwaveform.cpp b/src/preferences/dialog/dlgprefwaveform.cpp index c5625b7bcb7..28e62ee3c00 100644 --- a/src/preferences/dialog/dlgprefwaveform.cpp +++ b/src/preferences/dialog/dlgprefwaveform.cpp @@ -111,7 +111,8 @@ void DlgPrefWaveform::slotUpdate() { midVisualGain->setValue(factory->getVisualGain(WaveformWidgetFactory::Mid)); highVisualGain->setValue(factory->getVisualGain(WaveformWidgetFactory::High)); normalizeOverviewCheckBox->setChecked(factory->isOverviewNormalized()); - defaultZoomComboBox->setCurrentIndex(factory->getDefaultZoom() - 1); + // Round zoom to int to get a default zoom index. + defaultZoomComboBox->setCurrentIndex(static_cast(factory->getDefaultZoom()) - 1); playMarkerPositionSlider->setValue(factory->getPlayMarkerPosition() * 100); beatGridAlphaSpinBox->setValue(factory->beatGridAlpha()); beatGridAlphaSlider->setValue(factory->beatGridAlpha()); diff --git a/src/waveform/renderers/waveformwidgetrenderer.cpp b/src/waveform/renderers/waveformwidgetrenderer.cpp index 9f203cd07ed..211914d13be 100644 --- a/src/waveform/renderers/waveformwidgetrenderer.cpp +++ b/src/waveform/renderers/waveformwidgetrenderer.cpp @@ -9,9 +9,9 @@ #include "util/math.h" #include "util/performancetimer.h" -const int WaveformWidgetRenderer::s_waveformMinZoom = 1; -const int WaveformWidgetRenderer::s_waveformMaxZoom = 10; -const int WaveformWidgetRenderer::s_waveformDefaultZoom = 3; +const double WaveformWidgetRenderer::s_waveformMinZoom = 1.0; +const double WaveformWidgetRenderer::s_waveformMaxZoom = 10.0; +const double WaveformWidgetRenderer::s_waveformDefaultZoom = 3.0; const double WaveformWidgetRenderer::s_defaultPlayMarkerPosition = 0.5; WaveformWidgetRenderer::WaveformWidgetRenderer(const char* group) @@ -288,7 +288,7 @@ void WaveformWidgetRenderer::setup( } } -void WaveformWidgetRenderer::setZoom(int zoom) { +void WaveformWidgetRenderer::setZoom(double zoom) { //qDebug() << "WaveformWidgetRenderer::setZoom" << zoom; m_zoomFactor = math_clamp(zoom, s_waveformMinZoom, s_waveformMaxZoom); } diff --git a/src/waveform/renderers/waveformwidgetrenderer.h b/src/waveform/renderers/waveformwidgetrenderer.h index d8a86f0aa6b..1632ac1be26 100644 --- a/src/waveform/renderers/waveformwidgetrenderer.h +++ b/src/waveform/renderers/waveformwidgetrenderer.h @@ -21,9 +21,9 @@ class VSyncThread; class WaveformWidgetRenderer { public: - static const int s_waveformMinZoom; - static const int s_waveformMaxZoom; - static const int s_waveformDefaultZoom; + static const double s_waveformMinZoom; + static const double s_waveformMaxZoom; + static const double s_waveformDefaultZoom; static const double s_defaultPlayMarkerPosition; public: @@ -43,7 +43,7 @@ class WaveformWidgetRenderer { double getFirstDisplayedPosition() const { return m_firstDisplayedPosition;} double getLastDisplayedPosition() const { return m_lastDisplayedPosition;} - void setZoom(int zoom); + void setZoom(double zoom); void setDisplayBeatGrid(bool set); void setDisplayBeatGridAlpha(int alpha); diff --git a/src/waveform/waveformwidgetfactory.cpp b/src/waveform/waveformwidgetfactory.cpp index 725fa0f41f0..48362a87181 100644 --- a/src/waveform/waveformwidgetfactory.cpp +++ b/src/waveform/waveformwidgetfactory.cpp @@ -215,7 +215,7 @@ bool WaveformWidgetFactory::setConfig(UserSettingsPointer config) { int vsync = m_config->getValue(ConfigKey("[Waveform]","VSync"), 0); setVSyncType(vsync); - int defaultZoom = m_config->getValueString(ConfigKey("[Waveform]","DefaultZoom")).toInt(&ok); + double defaultZoom = m_config->getValueString(ConfigKey("[Waveform]","DefaultZoom")).toDouble(&ok); if (ok) { setDefaultZoom(defaultZoom); } else{ @@ -399,7 +399,7 @@ bool WaveformWidgetFactory::setWidgetTypeFromHandle(int handleIndex) { WaveformWidgetAbstract* previousWidget = holder.m_waveformWidget; TrackPointer pTrack = previousWidget->getTrackInfo(); //previousWidget->hold(); - int previousZoom = previousWidget->getZoomFactor(); + double previousZoom = previousWidget->getZoomFactor(); double previousPlayMarkerPosition = previousWidget->getPlayMarkerPosition(); delete previousWidget; WWaveformViewer* viewer = holder.m_waveformViewer; @@ -423,7 +423,7 @@ bool WaveformWidgetFactory::setWidgetTypeFromHandle(int handleIndex) { return true; } -void WaveformWidgetFactory::setDefaultZoom(int zoom) { +void WaveformWidgetFactory::setDefaultZoom(double zoom) { m_defaultZoom = math_clamp(zoom, WaveformWidgetRenderer::s_waveformMinZoom, WaveformWidgetRenderer::s_waveformMaxZoom); if (m_config) { @@ -445,7 +445,7 @@ void WaveformWidgetFactory::setZoomSync(bool sync) { return; } - int refZoom = m_waveformWidgetHolders[0].m_waveformWidget->getZoomFactor(); + double refZoom = m_waveformWidgetHolders[0].m_waveformWidget->getZoomFactor(); for (int i = 1; i < m_waveformWidgetHolders.size(); i++) { m_waveformWidgetHolders[i].m_waveformViewer->setZoom(refZoom); } @@ -496,7 +496,7 @@ void WaveformWidgetFactory::notifyZoomChange(WWaveformViewer* viewer) { WaveformWidgetAbstract* pWaveformWidget = viewer->getWaveformWidget(); if (pWaveformWidget != NULL && isZoomSync()) { //qDebug() << "WaveformWidgetFactory::notifyZoomChange"; - int refZoom = pWaveformWidget->getZoomFactor(); + double refZoom = pWaveformWidget->getZoomFactor(); for (int i = 0; i < m_waveformWidgetHolders.size(); ++i) { WaveformWidgetHolder& holder = m_waveformWidgetHolders[i]; diff --git a/src/waveform/waveformwidgetfactory.h b/src/waveform/waveformwidgetfactory.h index c6b1d54586e..ca8983efae3 100644 --- a/src/waveform/waveformwidgetfactory.h +++ b/src/waveform/waveformwidgetfactory.h @@ -81,8 +81,8 @@ class WaveformWidgetFactory : public QObject, public Singletonx() > width() - m_zoomZoneWidth) { - if (event->delta() > 0) { - //qDebug() << "WaveformWidgetRenderer::wheelEvent +1"; - onZoomChange(m_waveformWidget->getZoomFactor() + 1); - } else { - //qDebug() << "WaveformWidgetRenderer::wheelEvent -1"; - onZoomChange(m_waveformWidget->getZoomFactor() - 1); - } - //} + if (event->delta() > 0) { + onZoomChange(m_waveformWidget->getZoomFactor() * 1.05); + } else { + onZoomChange(m_waveformWidget->getZoomFactor() / 1.05); + } } } @@ -198,7 +193,7 @@ void WWaveformViewer::onZoomChange(double zoom) { WaveformWidgetFactory::instance()->notifyZoomChange(this); } -void WWaveformViewer::setZoom(int zoom) { +void WWaveformViewer::setZoom(double zoom) { //qDebug() << "WaveformWidgetRenderer::setZoom" << zoom; if (m_waveformWidget) { m_waveformWidget->setZoom(zoom); diff --git a/src/widget/wwaveformviewer.h b/src/widget/wwaveformviewer.h index 65b69e1e8d8..7d090080bea 100644 --- a/src/widget/wwaveformviewer.h +++ b/src/widget/wwaveformviewer.h @@ -55,7 +55,7 @@ private slots: return m_waveformWidget; } //direct access to let factory sync/set default zoom - void setZoom(int zoom); + void setZoom(double zoom); void setDisplayBeatGridAlpha(int alpha); void setPlayMarkerPosition(double position);