diff view/View.cpp @ 313:1517c76cd678

* Make View getStartFrame etc non-virtual for easier inlining * Make getStartFrame use getFrameForX instead of vice versa
author Chris Cannam
date Tue, 16 Oct 2007 15:13:41 +0000
parents 5636eeacc467
children 7b96a3261e1c
line wrap: on
line diff
--- a/view/View.cpp	Wed Oct 10 15:18:02 2007 +0000
+++ b/view/View.cpp	Tue Oct 16 15:13:41 2007 +0000
@@ -287,16 +287,7 @@
 long
 View::getStartFrame() const
 {
-    size_t w2 = (width() / 2) * m_zoomLevel;
-    size_t frame = m_centreFrame;
-    if (frame >= w2) {
-	frame -= w2;
-	return (frame / m_zoomLevel * m_zoomLevel);
-    } else {
-	frame = w2 - frame;
-	frame = frame / m_zoomLevel * m_zoomLevel;
-	return -(long)frame - m_zoomLevel;
-    }
+    return getFrameForX(0);
 }
 
 size_t
@@ -349,7 +340,10 @@
 long
 View::getFrameForX(int x) const
 {
-    return (long(x) * long(m_zoomLevel)) + getStartFrame();
+    long z = (long)m_zoomLevel;
+    long frame = m_centreFrame - (width()/2) * z;
+    frame = (frame / z) * z; // this is start frame
+    return frame + x * z;
 }
 
 float