Mercurial > hg > svgui
comparison layer/TimeRulerLayer.cpp @ 997:296ccd36f626 tony-2.0-integration
Merge through to branch for Tony 2.0
author | Chris Cannam |
---|---|
date | Thu, 20 Aug 2015 14:54:21 +0100 |
parents | 2adca8f05583 |
children | 33d7e1a6747b |
comparison
equal
deleted
inserted
replaced
943:788b7623bfca | 997:296ccd36f626 |
---|---|
47 m_model = model; | 47 m_model = model; |
48 emit modelReplaced(); | 48 emit modelReplaced(); |
49 } | 49 } |
50 | 50 |
51 bool | 51 bool |
52 TimeRulerLayer::snapToFeatureFrame(View *v, sv_frame_t &frame, | 52 TimeRulerLayer::snapToFeatureFrame(LayerGeometryProvider *v, sv_frame_t &frame, |
53 int &resolution, SnapType snap) const | 53 int &resolution, SnapType snap) const |
54 { | 54 { |
55 if (!m_model) { | 55 if (!m_model) { |
56 resolution = 1; | 56 resolution = 1; |
57 return false; | 57 return false; |
86 frame = right; | 86 frame = right; |
87 break; | 87 break; |
88 | 88 |
89 case SnapNearest: | 89 case SnapNearest: |
90 { | 90 { |
91 if (labs(frame - left) > labs(right - frame)) { | 91 if (llabs(frame - left) > llabs(right - frame)) { |
92 frame = right; | 92 frame = right; |
93 } else { | 93 } else { |
94 frame = left; | 94 frame = left; |
95 } | 95 } |
96 break; | 96 break; |
139 | 139 |
140 return true; | 140 return true; |
141 } | 141 } |
142 | 142 |
143 int | 143 int |
144 TimeRulerLayer::getMajorTickSpacing(View *v, bool &quarterTicks) const | 144 TimeRulerLayer::getMajorTickSpacing(LayerGeometryProvider *v, bool &quarterTicks) const |
145 { | 145 { |
146 // return value is in milliseconds | 146 // return value is in milliseconds |
147 | 147 |
148 if (!m_model || !v) return 1000; | 148 if (!m_model || !v) return 1000; |
149 | 149 |
156 int minPixelSpacing = 50; | 156 int minPixelSpacing = 50; |
157 | 157 |
158 RealTime rtStart = RealTime::frame2RealTime(startFrame, sampleRate); | 158 RealTime rtStart = RealTime::frame2RealTime(startFrame, sampleRate); |
159 RealTime rtEnd = RealTime::frame2RealTime(endFrame, sampleRate); | 159 RealTime rtEnd = RealTime::frame2RealTime(endFrame, sampleRate); |
160 | 160 |
161 int count = v->width() / minPixelSpacing; | 161 int count = v->getPaintWidth() / minPixelSpacing; |
162 if (count < 1) count = 1; | 162 if (count < 1) count = 1; |
163 RealTime rtGap = (rtEnd - rtStart) / count; | 163 RealTime rtGap = (rtEnd - rtStart) / count; |
164 | 164 |
165 int incms; | 165 int incms; |
166 quarterTicks = false; | 166 quarterTicks = false; |
190 | 190 |
191 return incms; | 191 return incms; |
192 } | 192 } |
193 | 193 |
194 void | 194 void |
195 TimeRulerLayer::paint(View *v, QPainter &paint, QRect rect) const | 195 TimeRulerLayer::paint(LayerGeometryProvider *v, QPainter &paint, QRect rect) const |
196 { | 196 { |
197 #ifdef DEBUG_TIME_RULER_LAYER | 197 #ifdef DEBUG_TIME_RULER_LAYER |
198 SVDEBUG << "TimeRulerLayer::paint (" << rect.x() << "," << rect.y() | 198 SVDEBUG << "TimeRulerLayer::paint (" << rect.x() << "," << rect.y() |
199 << ") [" << rect.width() << "x" << rect.height() << "]" << endl; | 199 << ") [" << rect.width() << "x" << rect.height() << "]" << endl; |
200 #endif | 200 #endif |
285 cerr << "hm, maybe X isn't in range after all (x = " << x << ", tw = " << tw << ", rect.x() = " << rect.x() << ", rect.width() = " << rect.width() << ")" << endl; | 285 cerr << "hm, maybe X isn't in range after all (x = " << x << ", tw = " << tw << ", rect.x() = " << rect.x() << ", rect.width() = " << rect.width() << ")" << endl; |
286 #endif | 286 #endif |
287 } | 287 } |
288 | 288 |
289 paint.setPen(greyColour); | 289 paint.setPen(greyColour); |
290 paint.drawLine(x, 0, x, v->height()); | 290 paint.drawLine(x, 0, x, v->getPaintHeight()); |
291 | 291 |
292 paint.setPen(getBaseQColor()); | 292 paint.setPen(getBaseQColor()); |
293 paint.drawLine(x, 0, x, 5); | 293 paint.drawLine(x, 0, x, 5); |
294 paint.drawLine(x, v->height() - 6, x, v->height() - 1); | 294 paint.drawLine(x, v->getPaintHeight() - 6, x, v->getPaintHeight() - 1); |
295 | 295 |
296 int y; | 296 int y; |
297 switch (m_labelHeight) { | 297 switch (m_labelHeight) { |
298 default: | 298 default: |
299 case LabelTop: | 299 case LabelTop: |
300 y = 6 + metrics.ascent(); | 300 y = 6 + metrics.ascent(); |
301 break; | 301 break; |
302 case LabelMiddle: | 302 case LabelMiddle: |
303 y = v->height() / 2 - metrics.height() / 2 + metrics.ascent(); | 303 y = v->getPaintHeight() / 2 - metrics.height() / 2 + metrics.ascent(); |
304 break; | 304 break; |
305 case LabelBottom: | 305 case LabelBottom: |
306 y = v->height() - metrics.height() + metrics.ascent() - 6; | 306 y = v->getPaintHeight() - metrics.height() + metrics.ascent() - 6; |
307 } | 307 } |
308 | 308 |
309 if (v->getViewManager() && v->getViewManager()->getOverlayMode() != | 309 if (v->getViewManager() && v->getViewManager()->getOverlayMode() != |
310 ViewManager::NoOverlays) { | 310 ViewManager::NoOverlays) { |
311 | 311 |
312 if (v->getLayer(0) == this) { | 312 if (v->getView()->getLayer(0) == this) { |
313 // backmost layer, don't worry about outlining the text | 313 // backmost layer, don't worry about outlining the text |
314 paint.drawText(x+2 - tw/2, y, text); | 314 paint.drawText(x+2 - tw/2, y, text); |
315 } else { | 315 } else { |
316 v->drawVisibleText(paint, x+2 - tw/2, y, text, View::OutlinedText); | 316 v->drawVisibleText(paint, x+2 - tw/2, y, text, View::OutlinedText); |
317 } | 317 } |
342 | 342 |
343 int sz = 5; | 343 int sz = 5; |
344 if (ticks == 10) { | 344 if (ticks == 10) { |
345 if ((i % 2) == 1) { | 345 if ((i % 2) == 1) { |
346 if (i == 5) { | 346 if (i == 5) { |
347 paint.drawLine(x, 0, x, v->height()); | 347 paint.drawLine(x, 0, x, v->getPaintHeight()); |
348 } else sz = 3; | 348 } else sz = 3; |
349 } else { | 349 } else { |
350 sz = 7; | 350 sz = 7; |
351 } | 351 } |
352 } | 352 } |
353 paint.drawLine(x, 0, x, sz); | 353 paint.drawLine(x, 0, x, sz); |
354 paint.drawLine(x, v->height() - sz - 1, x, v->height() - 1); | 354 paint.drawLine(x, v->getPaintHeight() - sz - 1, x, v->getPaintHeight() - 1); |
355 } | 355 } |
356 | 356 |
357 ms += incms; | 357 ms += incms; |
358 } | 358 } |
359 | 359 |