# HG changeset patch # User Chris Cannam # Date 1161090289 0 # Node ID 06b3c3f437e6678f008c5f25f9086b496624c722 # Parent 1016a8ceceda027539b028ffe694a7cd17ebe237 * Make audio dial remember its more accurate mapped value as well as its display position * Add tool tip support to audio dial to show values diff -r 1016a8ceceda -r 06b3c3f437e6 audioio/PlaySpeedRangeMapper.cpp --- a/audioio/PlaySpeedRangeMapper.cpp Tue Oct 17 11:42:14 2006 +0000 +++ b/audioio/PlaySpeedRangeMapper.cpp Tue Oct 17 13:04:49 2006 +0000 @@ -28,9 +28,14 @@ PlaySpeedRangeMapper::getPositionForValue(float value) const { // value is percent + float factor = getFactorForValue(value); + int position = getPositionForFactor(factor); + return position; +} - float factor = getFactorForValue(value); - +int +PlaySpeedRangeMapper::getPositionForFactor(float factor) const +{ bool slow = (factor > 1.0); if (!slow) factor = 1.0 / factor; @@ -55,6 +60,13 @@ PlaySpeedRangeMapper::getValueForPosition(int position) const { float factor = getFactorForPosition(position); + float pc = getValueForFactor(factor); + return pc; +} + +float +PlaySpeedRangeMapper::getValueForFactor(float factor) const +{ float pc; if (factor < 1.0) pc = ((1.0 / factor) - 1.0) * 100.0; else pc = (1.0 - factor) * 100.0; diff -r 1016a8ceceda -r 06b3c3f437e6 audioio/PlaySpeedRangeMapper.h --- a/audioio/PlaySpeedRangeMapper.h Tue Oct 17 11:42:14 2006 +0000 +++ b/audioio/PlaySpeedRangeMapper.h Tue Oct 17 13:04:49 2006 +0000 @@ -26,6 +26,9 @@ virtual int getPositionForValue(float value) const; virtual float getValueForPosition(int position) const; + int getPositionForFactor(float factor) const; + float getValueForFactor(float factor) const; + float getFactorForPosition(int position) const; float getFactorForValue(float value) const; diff -r 1016a8ceceda -r 06b3c3f437e6 main/MainWindow.cpp --- a/main/MainWindow.cpp Tue Oct 17 11:42:14 2006 +0000 +++ b/main/MainWindow.cpp Tue Oct 17 13:04:49 2006 +0000 @@ -177,10 +177,11 @@ m_playSpeed->setFixedHeight(24); m_playSpeed->setNotchesVisible(true); m_playSpeed->setPageStep(10); - m_playSpeed->setToolTip(tr("Playback speed: +0%")); - m_playSpeed->setObjectName(tr("Playback Speed")); +//!!! m_playSpeed->setToolTip(tr("Playback speed: +0%")); + m_playSpeed->setObjectName(tr("Playback Speedup")); m_playSpeed->setDefaultValue(100); m_playSpeed->setRangeMapper(new PlaySpeedRangeMapper(0, 200)); + m_playSpeed->setShowToolTip(true); connect(m_playSpeed, SIGNAL(valueChanged(int)), this, SLOT(playSpeedChanged(int))); @@ -3085,20 +3086,25 @@ MainWindow::playSpeedChanged(int position) { PlaySpeedRangeMapper mapper(0, 200); - float factor = mapper.getFactorForPosition(position); - float percent = mapper.getValueForPosition(position); - -// std::cerr << "speed = " << position << " factor = " << factor << std::endl; - - bool slow = (position < 100); + + float percent = m_playSpeed->mappedValue(); + + float factor = mapper.getFactorForValue(percent); + +// float factor = mapper.getFactorForPosition(position); +// float percent = mapper.getValueForPosition(position); + + std::cerr << "speed = " << position << " percent = " << percent << " factor = " << factor << std::endl; + +//!!! bool slow = (position < 100); bool something = (position != 100); - +/*!!! int pc = lrintf(percent); m_playSpeed->setToolTip(tr("Playback speed: %1%2%") - .arg(!slow ? "+" : "-") + .arg(!slow ? "+" : "") .arg(pc)); - +*/ m_playSharpen->setEnabled(something); m_playMono->setEnabled(something); bool sharpen = (something && m_playSharpen->isChecked());