comparison layer/TimeRulerLayer.cpp @ 978:64c2b3a4435a 3.0-integration

Merge from branch osx-retina
author Chris Cannam
date Fri, 26 Jun 2015 14:10:40 +0100
parents a5488775f880
children 2adca8f05583
comparison
equal deleted inserted replaced
977:f40ccbf228c2 978:64c2b3a4435a
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;
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