comparison framework/MainWindowBase.cpp @ 628:b936872faff2

Merge from branch zoom
author Chris Cannam
date Wed, 10 Oct 2018 08:44:37 +0100
parents 7eafe977a1fc
children 29bef008588e
comparison
equal deleted inserted replaced
626:51ecc3e2d71c 628:b936872faff2
2801 int sw = currentPane->getVerticalScaleWidth(); 2801 int sw = currentPane->getVerticalScaleWidth();
2802 if (pixels > sw * 2) pixels -= sw * 2; 2802 if (pixels > sw * 2) pixels -= sw * 2;
2803 else pixels = 1; 2803 else pixels = 1;
2804 if (pixels > 4) pixels -= 4; 2804 if (pixels > 4) pixels -= 4;
2805 2805
2806 int zoomLevel = int((end - start) / pixels); 2806 ZoomLevel zoomLevel = ZoomLevel::fromRatio(pixels, end - start);
2807 if (zoomLevel < 1) zoomLevel = 1;
2808
2809 currentPane->setZoomLevel(zoomLevel); 2807 currentPane->setZoomLevel(zoomLevel);
2810 currentPane->setCentreFrame((start + end) / 2); 2808 currentPane->setCentreFrame((start + end) / 2);
2811 } 2809 }
2812 2810
2813 void 2811 void
2816 Pane *currentPane = m_paneStack->getCurrentPane(); 2814 Pane *currentPane = m_paneStack->getCurrentPane();
2817 QSettings settings; 2815 QSettings settings;
2818 settings.beginGroup("MainWindow"); 2816 settings.beginGroup("MainWindow");
2819 int zoom = settings.value("zoom-default", 1024).toInt(); 2817 int zoom = settings.value("zoom-default", 1024).toInt();
2820 settings.endGroup(); 2818 settings.endGroup();
2821 if (currentPane) currentPane->setZoomLevel(zoom); 2819 if (currentPane) {
2820 currentPane->setZoomLevel(ZoomLevel(ZoomLevel::FramesPerPixel, zoom));
2821 }
2822 } 2822 }
2823 2823
2824 void 2824 void
2825 MainWindowBase::scrollLeft() 2825 MainWindowBase::scrollLeft()
2826 { 2826 {
3836 if (!m_paneStack || !(p = m_paneStack->getCurrentPane())) return; 3836 if (!m_paneStack || !(p = m_paneStack->getCurrentPane())) return;
3837 if (v == p) updateVisibleRangeDisplay(p); 3837 if (v == p) updateVisibleRangeDisplay(p);
3838 } 3838 }
3839 3839
3840 void 3840 void
3841 MainWindowBase::viewZoomLevelChanged(View *v, int , bool ) 3841 MainWindowBase::viewZoomLevelChanged(View *v, ZoomLevel, bool )
3842 { 3842 {
3843 if ((m_playSource && m_playSource->isPlaying()) || !getMainModel()) return; 3843 if ((m_playSource && m_playSource->isPlaying()) || !getMainModel()) return;
3844 Pane *p = 0; 3844 Pane *p = 0;
3845 if (!m_paneStack || !(p = m_paneStack->getCurrentPane())) return; 3845 if (!m_paneStack || !(p = m_paneStack->getCurrentPane())) return;
3846 if (v == p) updateVisibleRangeDisplay(p); 3846 if (v == p) updateVisibleRangeDisplay(p);