comparison framework/MainWindowBase.cpp @ 624:15a566f26114 zoom

ZoomLevel fixes
author Chris Cannam
date Thu, 20 Sep 2018 11:45:37 +0100
parents 22e455beee3b
children 7eafe977a1fc
comparison
equal deleted inserted replaced
623:9e15607531b2 624:15a566f26114
2787 int sw = currentPane->getVerticalScaleWidth(); 2787 int sw = currentPane->getVerticalScaleWidth();
2788 if (pixels > sw * 2) pixels -= sw * 2; 2788 if (pixels > sw * 2) pixels -= sw * 2;
2789 else pixels = 1; 2789 else pixels = 1;
2790 if (pixels > 4) pixels -= 4; 2790 if (pixels > 4) pixels -= 4;
2791 2791
2792 int zoomLevel = int((end - start) / pixels); 2792 ZoomLevel zoomLevel = ZoomLevel::fromRatio(pixels, end - start);
2793 if (zoomLevel < 1) zoomLevel = 1;
2794
2795 currentPane->setZoomLevel(zoomLevel); 2793 currentPane->setZoomLevel(zoomLevel);
2796 currentPane->setCentreFrame((start + end) / 2); 2794 currentPane->setCentreFrame((start + end) / 2);
2797 } 2795 }
2798 2796
2799 void 2797 void
2802 Pane *currentPane = m_paneStack->getCurrentPane(); 2800 Pane *currentPane = m_paneStack->getCurrentPane();
2803 QSettings settings; 2801 QSettings settings;
2804 settings.beginGroup("MainWindow"); 2802 settings.beginGroup("MainWindow");
2805 int zoom = settings.value("zoom-default", 1024).toInt(); 2803 int zoom = settings.value("zoom-default", 1024).toInt();
2806 settings.endGroup(); 2804 settings.endGroup();
2807 if (currentPane) currentPane->setZoomLevel(zoom); 2805 if (currentPane) {
2806 currentPane->setZoomLevel(ZoomLevel(ZoomLevel::FramesPerPixel, zoom));
2807 }
2808 } 2808 }
2809 2809
2810 void 2810 void
2811 MainWindowBase::scrollLeft() 2811 MainWindowBase::scrollLeft()
2812 { 2812 {
3822 if (!m_paneStack || !(p = m_paneStack->getCurrentPane())) return; 3822 if (!m_paneStack || !(p = m_paneStack->getCurrentPane())) return;
3823 if (v == p) updateVisibleRangeDisplay(p); 3823 if (v == p) updateVisibleRangeDisplay(p);
3824 } 3824 }
3825 3825
3826 void 3826 void
3827 MainWindowBase::viewZoomLevelChanged(View *v, int , bool ) 3827 MainWindowBase::viewZoomLevelChanged(View *v, ZoomLevel, bool )
3828 { 3828 {
3829 if ((m_playSource && m_playSource->isPlaying()) || !getMainModel()) return; 3829 if ((m_playSource && m_playSource->isPlaying()) || !getMainModel()) return;
3830 Pane *p = 0; 3830 Pane *p = 0;
3831 if (!m_paneStack || !(p = m_paneStack->getCurrentPane())) return; 3831 if (!m_paneStack || !(p = m_paneStack->getCurrentPane())) return;
3832 if (v == p) updateVisibleRangeDisplay(p); 3832 if (v == p) updateVisibleRangeDisplay(p);