Mercurial > hg > svgui
comparison 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 |
comparison
equal
deleted
inserted
replaced
312:6de6f78b13a1 | 313:1517c76cd678 |
---|---|
285 } | 285 } |
286 | 286 |
287 long | 287 long |
288 View::getStartFrame() const | 288 View::getStartFrame() const |
289 { | 289 { |
290 size_t w2 = (width() / 2) * m_zoomLevel; | 290 return getFrameForX(0); |
291 size_t frame = m_centreFrame; | |
292 if (frame >= w2) { | |
293 frame -= w2; | |
294 return (frame / m_zoomLevel * m_zoomLevel); | |
295 } else { | |
296 frame = w2 - frame; | |
297 frame = frame / m_zoomLevel * m_zoomLevel; | |
298 return -(long)frame - m_zoomLevel; | |
299 } | |
300 } | 291 } |
301 | 292 |
302 size_t | 293 size_t |
303 View::getEndFrame() const | 294 View::getEndFrame() const |
304 { | 295 { |
347 } | 338 } |
348 | 339 |
349 long | 340 long |
350 View::getFrameForX(int x) const | 341 View::getFrameForX(int x) const |
351 { | 342 { |
352 return (long(x) * long(m_zoomLevel)) + getStartFrame(); | 343 long z = (long)m_zoomLevel; |
344 long frame = m_centreFrame - (width()/2) * z; | |
345 frame = (frame / z) * z; // this is start frame | |
346 return frame + x * z; | |
353 } | 347 } |
354 | 348 |
355 float | 349 float |
356 View::getYForFrequency(float frequency, | 350 View::getYForFrequency(float frequency, |
357 float minf, | 351 float minf, |