Mercurial > hg > svgui
comparison view/Pane.cpp @ 1324:13d9b422f7fe zoom
Merge from default branch
author | Chris Cannam |
---|---|
date | Mon, 17 Sep 2018 13:51:31 +0100 |
parents | c0d8356e274f |
children | 97c68bffbda6 |
comparison
equal
deleted
inserted
replaced
1183:57d192e26331 | 1324:13d9b422f7fe |
---|---|
20 #include "base/RealTime.h" | 20 #include "base/RealTime.h" |
21 #include "base/Profiler.h" | 21 #include "base/Profiler.h" |
22 #include "ViewManager.h" | 22 #include "ViewManager.h" |
23 #include "widgets/CommandHistory.h" | 23 #include "widgets/CommandHistory.h" |
24 #include "widgets/TextAbbrev.h" | 24 #include "widgets/TextAbbrev.h" |
25 #include "widgets/IconLoader.h" | |
25 #include "base/Preferences.h" | 26 #include "base/Preferences.h" |
26 #include "layer/WaveformLayer.h" | 27 #include "layer/WaveformLayer.h" |
27 #include "layer/TimeRulerLayer.h" | 28 #include "layer/TimeRulerLayer.h" |
28 #include "layer/PaintAssistant.h" | 29 #include "layer/PaintAssistant.h" |
29 | 30 |
140 | 141 |
141 m_hthumb = new Thumbwheel(Qt::Horizontal); | 142 m_hthumb = new Thumbwheel(Qt::Horizontal); |
142 m_hthumb->setObjectName(tr("Horizontal Zoom")); | 143 m_hthumb->setObjectName(tr("Horizontal Zoom")); |
143 m_hthumb->setCursor(Qt::ArrowCursor); | 144 m_hthumb->setCursor(Qt::ArrowCursor); |
144 layout->addWidget(m_hthumb, 1, 0, 1, 2); | 145 layout->addWidget(m_hthumb, 1, 0, 1, 2); |
145 m_hthumb->setFixedWidth(70); | 146 m_hthumb->setFixedWidth(m_manager->scalePixelSize(70)); |
146 m_hthumb->setFixedHeight(16); | 147 m_hthumb->setFixedHeight(m_manager->scalePixelSize(16)); |
147 m_hthumb->setDefaultValue(0); | 148 m_hthumb->setDefaultValue(0); |
148 m_hthumb->setSpeed(0.6f); | 149 m_hthumb->setSpeed(0.6f); |
149 connect(m_hthumb, SIGNAL(valueChanged(int)), this, | 150 connect(m_hthumb, SIGNAL(valueChanged(int)), this, |
150 SLOT(horizontalThumbwheelMoved(int))); | 151 SLOT(horizontalThumbwheelMoved(int))); |
151 connect(m_hthumb, SIGNAL(mouseEntered()), this, SLOT(mouseEnteredWidget())); | 152 connect(m_hthumb, SIGNAL(mouseEntered()), this, SLOT(mouseEnteredWidget())); |
152 connect(m_hthumb, SIGNAL(mouseLeft()), this, SLOT(mouseLeftWidget())); | 153 connect(m_hthumb, SIGNAL(mouseLeft()), this, SLOT(mouseLeftWidget())); |
153 | 154 |
154 m_vpan = new Panner; | 155 m_vpan = new Panner; |
155 m_vpan->setCursor(Qt::ArrowCursor); | 156 m_vpan->setCursor(Qt::ArrowCursor); |
156 layout->addWidget(m_vpan, 0, 1); | 157 layout->addWidget(m_vpan, 0, 1); |
157 m_vpan->setFixedWidth(12); | 158 m_vpan->setFixedWidth(m_manager->scalePixelSize(12)); |
158 m_vpan->setFixedHeight(70); | 159 m_vpan->setFixedHeight(m_manager->scalePixelSize(70)); |
159 m_vpan->setAlpha(80, 130); | 160 m_vpan->setAlpha(80, 130); |
160 connect(m_vpan, SIGNAL(rectExtentsChanged(float, float, float, float)), | 161 connect(m_vpan, SIGNAL(rectExtentsChanged(float, float, float, float)), |
161 this, SLOT(verticalPannerMoved(float, float, float, float))); | 162 this, SLOT(verticalPannerMoved(float, float, float, float))); |
162 connect(m_vpan, SIGNAL(doubleClicked()), | 163 connect(m_vpan, SIGNAL(doubleClicked()), |
163 this, SLOT(editVerticalPannerExtents())); | 164 this, SLOT(editVerticalPannerExtents())); |
166 | 167 |
167 m_vthumb = new Thumbwheel(Qt::Vertical); | 168 m_vthumb = new Thumbwheel(Qt::Vertical); |
168 m_vthumb->setObjectName(tr("Vertical Zoom")); | 169 m_vthumb->setObjectName(tr("Vertical Zoom")); |
169 m_vthumb->setCursor(Qt::ArrowCursor); | 170 m_vthumb->setCursor(Qt::ArrowCursor); |
170 layout->addWidget(m_vthumb, 0, 2); | 171 layout->addWidget(m_vthumb, 0, 2); |
171 m_vthumb->setFixedWidth(16); | 172 m_vthumb->setFixedWidth(m_manager->scalePixelSize(16)); |
172 m_vthumb->setFixedHeight(70); | 173 m_vthumb->setFixedHeight(m_manager->scalePixelSize(70)); |
173 connect(m_vthumb, SIGNAL(valueChanged(int)), this, | 174 connect(m_vthumb, SIGNAL(valueChanged(int)), this, |
174 SLOT(verticalThumbwheelMoved(int))); | 175 SLOT(verticalThumbwheelMoved(int))); |
175 connect(m_vthumb, SIGNAL(mouseEntered()), this, SLOT(mouseEnteredWidget())); | 176 connect(m_vthumb, SIGNAL(mouseEntered()), this, SLOT(mouseEnteredWidget())); |
176 connect(m_vthumb, SIGNAL(mouseLeft()), this, SLOT(mouseLeftWidget())); | 177 connect(m_vthumb, SIGNAL(mouseLeft()), this, SLOT(mouseLeftWidget())); |
177 | 178 |
181 } | 182 } |
182 | 183 |
183 m_reset = new NotifyingPushButton; | 184 m_reset = new NotifyingPushButton; |
184 m_reset->setFlat(true); | 185 m_reset->setFlat(true); |
185 m_reset->setCursor(Qt::ArrowCursor); | 186 m_reset->setCursor(Qt::ArrowCursor); |
186 m_reset->setFixedHeight(16); | 187 m_reset->setFixedHeight(m_manager->scalePixelSize(16)); |
187 m_reset->setFixedWidth(16); | 188 m_reset->setFixedWidth(m_manager->scalePixelSize(16)); |
188 m_reset->setIcon(QPixmap(":/icons/zoom-reset.png")); | 189 m_reset->setIcon(IconLoader().load("zoom-reset")); |
189 m_reset->setToolTip(tr("Reset zoom to default")); | 190 m_reset->setToolTip(tr("Reset zoom to default")); |
190 layout->addWidget(m_reset, 1, 2); | 191 layout->addWidget(m_reset, 1, 2); |
191 | 192 |
192 layout->setColumnStretch(0, 20); | 193 layout->setColumnStretch(0, 20); |
193 | 194 |
282 } | 283 } |
283 | 284 |
284 updateVerticalPanner(); | 285 updateVerticalPanner(); |
285 | 286 |
286 if (m_manager && m_manager->getZoomWheelsEnabled() && | 287 if (m_manager && m_manager->getZoomWheelsEnabled() && |
287 width() > 120 && height() > 100) { | 288 width() > m_manager->scalePixelSize(120) && |
289 height() > m_manager->scalePixelSize(100)) { | |
288 if (!m_headsUpDisplay->isVisible()) { | 290 if (!m_headsUpDisplay->isVisible()) { |
289 m_headsUpDisplay->show(); | 291 m_headsUpDisplay->show(); |
290 } | 292 } |
293 int shift = m_manager->scalePixelSize(86); | |
291 if (haveVThumb) { | 294 if (haveVThumb) { |
292 m_headsUpDisplay->setFixedHeight(m_vthumb->height() + m_hthumb->height()); | 295 m_headsUpDisplay->setFixedHeight(m_vthumb->height() + m_hthumb->height()); |
293 m_headsUpDisplay->move(width() - 86, height() - 86); | 296 m_headsUpDisplay->move(width() - shift, height() - shift); |
294 } else { | 297 } else { |
295 m_headsUpDisplay->setFixedHeight(m_hthumb->height()); | 298 m_headsUpDisplay->setFixedHeight(m_hthumb->height()); |
296 m_headsUpDisplay->move(width() - 86, height() - 16); | 299 m_headsUpDisplay->move(width() - shift, |
300 height() - m_manager->scalePixelSize(16)); | |
297 } | 301 } |
298 } else { | 302 } else { |
299 m_headsUpDisplay->hide(); | 303 m_headsUpDisplay->hide(); |
300 } | 304 } |
301 } | 305 } |
422 if (e) paint.setClipRect(r); | 426 if (e) paint.setClipRect(r); |
423 | 427 |
424 ViewManager::ToolMode toolMode = ViewManager::NavigateMode; | 428 ViewManager::ToolMode toolMode = ViewManager::NavigateMode; |
425 if (m_manager) toolMode = m_manager->getToolModeFor(this); | 429 if (m_manager) toolMode = m_manager->getToolModeFor(this); |
426 | 430 |
427 if (m_manager && | 431 // Locate some relevant layers and models |
428 m_mouseInWidget && | 432 |
429 toolMode == ViewManager::MeasureMode) { | |
430 | |
431 for (LayerList::iterator vi = m_layerStack.end(); vi != m_layerStack.begin(); ) { | |
432 --vi; | |
433 | |
434 std::vector<QRect> crosshairExtents; | |
435 | |
436 if ((*vi)->getCrosshairExtents(this, paint, m_identifyPoint, | |
437 crosshairExtents)) { | |
438 (*vi)->paintCrosshairs(this, paint, m_identifyPoint); | |
439 break; | |
440 } else if ((*vi)->isLayerOpaque()) { | |
441 break; | |
442 } | |
443 } | |
444 } | |
445 | |
446 Layer *topLayer = getTopLayer(); | 433 Layer *topLayer = getTopLayer(); |
447 bool haveSomeTimeXAxis = false; | 434 bool haveSomeTimeXAxis = false; |
448 | 435 |
449 const Model *waveformModel = 0; // just for reporting purposes | 436 const Model *waveformModel = 0; // just for reporting purposes |
450 const Model *workModel = 0; | 437 const Model *workModel = 0; |
467 } | 454 } |
468 | 455 |
469 if (waveformModel && workModel && haveSomeTimeXAxis) break; | 456 if (waveformModel && workModel && haveSomeTimeXAxis) break; |
470 } | 457 } |
471 | 458 |
472 m_scaleWidth = 0; | 459 // Block off left and right extents so we can see where the main model ends |
473 | 460 |
474 if (workModel && hasTopLayerTimeXAxis()) { | 461 if (workModel && hasTopLayerTimeXAxis()) { |
475 drawModelTimeExtents(r, paint, workModel); | 462 drawModelTimeExtents(r, paint, workModel); |
476 } | 463 } |
477 | 464 |
465 // Crosshairs for mouse movement in measure mode | |
466 | |
467 if (m_manager && | |
468 m_mouseInWidget && | |
469 toolMode == ViewManager::MeasureMode) { | |
470 | |
471 for (LayerList::iterator vi = m_layerStack.end(); vi != m_layerStack.begin(); ) { | |
472 --vi; | |
473 | |
474 std::vector<QRect> crosshairExtents; | |
475 | |
476 if ((*vi)->getCrosshairExtents(this, paint, m_identifyPoint, | |
477 crosshairExtents)) { | |
478 (*vi)->paintCrosshairs(this, paint, m_identifyPoint); | |
479 break; | |
480 } else if ((*vi)->isLayerOpaque()) { | |
481 break; | |
482 } | |
483 } | |
484 } | |
485 | |
486 // Scale width will be set implicitly during drawVerticalScale call | |
487 m_scaleWidth = 0; | |
488 | |
478 if (m_manager && m_manager->shouldShowVerticalScale() && topLayer) { | 489 if (m_manager && m_manager->shouldShowVerticalScale() && topLayer) { |
479 drawVerticalScale(r, topLayer, paint); | 490 drawVerticalScale(r, topLayer, paint); |
480 } | 491 } |
481 | 492 |
493 // Feature description: the box in top-right showing values from | |
494 // the nearest feature to the mouse | |
495 | |
482 if (m_identifyFeatures && | 496 if (m_identifyFeatures && |
483 m_manager && m_manager->shouldIlluminateLocalFeatures() && | 497 m_manager && m_manager->shouldIlluminateLocalFeatures() && |
484 topLayer) { | 498 topLayer) { |
485 drawFeatureDescription(topLayer, paint); | 499 drawFeatureDescription(topLayer, paint); |
486 } | 500 } |
521 if (m_manager && | 535 if (m_manager && |
522 m_manager->shouldShowLayerNames()) { | 536 m_manager->shouldShowLayerNames()) { |
523 drawLayerNames(r, paint); | 537 drawLayerNames(r, paint); |
524 } | 538 } |
525 | 539 |
540 // The blue box that is shown when you ctrl-click in navigate mode | |
541 // to define a zoom region | |
542 | |
526 if (m_shiftPressed && m_clickedInRange && | 543 if (m_shiftPressed && m_clickedInRange && |
527 (toolMode == ViewManager::NavigateMode || m_navigating)) { | 544 (toolMode == ViewManager::NavigateMode || m_navigating)) { |
528 | 545 |
529 //!!! be nice if this looked a bit more in keeping with the | 546 //!!! be nice if this looked a bit more in keeping with the |
530 //selection block | 547 //selection block |
560 void | 577 void |
561 Pane::drawVerticalScale(QRect r, Layer *topLayer, QPainter &paint) | 578 Pane::drawVerticalScale(QRect r, Layer *topLayer, QPainter &paint) |
562 { | 579 { |
563 Layer *scaleLayer = 0; | 580 Layer *scaleLayer = 0; |
564 | 581 |
582 // cerr << "Pane::drawVerticalScale[" << this << "]" << endl; | |
583 | |
565 double min, max; | 584 double min, max; |
566 bool log; | 585 bool log; |
567 QString unit; | 586 QString unit; |
568 | 587 |
569 // If the top layer has no scale and reports no display | 588 // If the top layer has no scale and reports no display |
573 // then the scale should be drawn from any underlying layer | 592 // then the scale should be drawn from any underlying layer |
574 // with a scale regardless of unit. | 593 // with a scale regardless of unit. |
575 | 594 |
576 int sw = topLayer->getVerticalScaleWidth | 595 int sw = topLayer->getVerticalScaleWidth |
577 (this, m_manager->shouldShowVerticalColourScale(), paint); | 596 (this, m_manager->shouldShowVerticalColourScale(), paint); |
578 | 597 |
579 if (sw > 0) { | 598 if (sw > 0) { |
580 scaleLayer = topLayer; | 599 scaleLayer = topLayer; |
581 m_scaleWidth = sw; | 600 m_scaleWidth = sw; |
582 | 601 |
583 } else { | 602 } else { |
639 } | 658 } |
640 } | 659 } |
641 } | 660 } |
642 | 661 |
643 if (!scaleLayer) m_scaleWidth = 0; | 662 if (!scaleLayer) m_scaleWidth = 0; |
644 | 663 |
664 // cerr << "m_scaleWidth = " << m_scaleWidth << ", r.left = " << r.left() << endl; | |
665 | |
645 if (m_scaleWidth > 0 && r.left() < m_scaleWidth) { | 666 if (m_scaleWidth > 0 && r.left() < m_scaleWidth) { |
646 | 667 |
647 // Profiler profiler("Pane::paintEvent - painting vertical scale", true); | 668 // Profiler profiler("Pane::paintEvent - painting vertical scale", true); |
648 | 669 |
649 // SVDEBUG << "Pane::paintEvent: calling paint.save() in vertical scale block" << endl; | 670 // SVDEBUG << "Pane::paintEvent: calling paint.save() in vertical scale block" << endl; |
650 paint.save(); | 671 paint.save(); |
651 | 672 |
673 paint.setPen(Qt::NoPen); | |
674 paint.setBrush(getBackground()); | |
675 paint.drawRect(0, 0, m_scaleWidth, height()); | |
676 | |
652 paint.setPen(getForeground()); | 677 paint.setPen(getForeground()); |
653 paint.setBrush(getBackground()); | 678 paint.drawLine(m_scaleWidth, 0, m_scaleWidth, height()); |
654 paint.drawRect(0, -1, m_scaleWidth, height()+1); | 679 |
655 | |
656 paint.setBrush(Qt::NoBrush); | 680 paint.setBrush(Qt::NoBrush); |
657 scaleLayer->paintVerticalScale | 681 scaleLayer->paintVerticalScale |
658 (this, m_manager->shouldShowVerticalColourScale(), | 682 (this, m_manager->shouldShowVerticalColourScale(), |
659 paint, QRect(0, 0, m_scaleWidth, height())); | 683 paint, QRect(0, 0, m_scaleWidth, height())); |
660 | 684 |
728 QColor c = QColor(0, 0, 0); | 752 QColor c = QColor(0, 0, 0); |
729 if (!hasLightBackground()) { | 753 if (!hasLightBackground()) { |
730 c = QColor(240, 240, 240); | 754 c = QColor(240, 240, 240); |
731 } | 755 } |
732 | 756 |
733 paint.setPen(c); | 757 paint.setPen(PaintAssistant::scalePen(c)); |
734 int x = width() / 2; | 758 int x = width() / 2; |
735 | 759 |
736 if (!omitLine) { | 760 if (!omitLine) { |
737 paint.drawLine(x, 0, x, height() - 1); | 761 paint.drawLine(x, 0, x, height() - 1); |
738 paint.drawLine(x-1, 1, x+1, 1); | 762 paint.drawLine(x-1, 1, x+1, 1); |
798 paint.save(); | 822 paint.save(); |
799 | 823 |
800 QBrush brush; | 824 QBrush brush; |
801 | 825 |
802 if (hasLightBackground()) { | 826 if (hasLightBackground()) { |
803 brush = QBrush(QColor("#f8f8f8")); | 827 brush = QBrush(QColor("#aaf8f8f8")); |
804 paint.setPen(Qt::black); | 828 paint.setPen(Qt::black); |
805 } else { | 829 } else { |
806 brush = QBrush(QColor("#101010")); | 830 brush = QBrush(QColor("#aa101010")); |
807 paint.setPen(Qt::white); | 831 paint.setPen(Qt::white); |
808 } | 832 } |
809 | 833 |
810 if (x0 > r.x()) { | 834 if (x0 > r.x()) { |
811 paint.fillRect(0, 0, x0, height(), brush); | 835 paint.fillRect(0, 0, x0, height(), brush); |
918 int fontHeight = paint.fontMetrics().height(); | 942 int fontHeight = paint.fontMetrics().height(); |
919 int fontAscent = paint.fontMetrics().ascent(); | 943 int fontAscent = paint.fontMetrics().ascent(); |
920 | 944 |
921 int lly = height() - 6; | 945 int lly = height() - 6; |
922 if (m_manager->getZoomWheelsEnabled()) { | 946 if (m_manager->getZoomWheelsEnabled()) { |
923 lly -= 20; | 947 lly -= m_manager->scalePixelSize(20); |
924 } | 948 } |
925 | 949 |
926 if (r.y() + r.height() < lly - int(m_layerStack.size()) * fontHeight) { | 950 if (r.y() + r.height() < lly - int(m_layerStack.size()) * fontHeight) { |
927 return; | 951 return; |
928 } | 952 } |
940 int maxTextWidth = width() / 3; | 964 int maxTextWidth = width() / 3; |
941 texts = TextAbbrev::abbreviate(texts, paint.fontMetrics(), maxTextWidth); | 965 texts = TextAbbrev::abbreviate(texts, paint.fontMetrics(), maxTextWidth); |
942 | 966 |
943 int llx = width() - maxTextWidth - 5; | 967 int llx = width() - maxTextWidth - 5; |
944 if (m_manager->getZoomWheelsEnabled()) { | 968 if (m_manager->getZoomWheelsEnabled()) { |
945 llx -= 36; | 969 llx -= m_manager->scalePixelSize(36); |
946 } | 970 } |
947 | 971 |
948 if (r.x() + r.width() >= llx - fontAscent - 3) { | 972 if (r.x() + r.width() >= llx - fontAscent - 3) { |
949 | 973 |
950 for (int i = 0; i < texts.size(); ++i) { | 974 for (int i = 0; i < texts.size(); ++i) { |
1117 | 1141 |
1118 return true; | 1142 return true; |
1119 } | 1143 } |
1120 | 1144 |
1121 QImage * | 1145 QImage * |
1122 Pane::toNewImage(sv_frame_t f0, sv_frame_t f1) | 1146 Pane::renderPartToNewImage(sv_frame_t f0, sv_frame_t f1) |
1123 { | 1147 { |
1124 int x0 = int(f0 / getZoomLevel()); | 1148 int x0 = int(f0 / getZoomLevel()); |
1125 int x1 = int(f1 / getZoomLevel()); | 1149 int x1 = int(f1 / getZoomLevel()); |
1126 | 1150 |
1127 QImage *image = new QImage(x1 - x0 + m_scaleWidth, | 1151 QImage *image = new QImage(x1 - x0 + m_scaleWidth, |
1156 return image; | 1180 return image; |
1157 } | 1181 } |
1158 } | 1182 } |
1159 | 1183 |
1160 QSize | 1184 QSize |
1161 Pane::getImageSize(sv_frame_t f0, sv_frame_t f1) | 1185 Pane::getRenderedPartImageSize(sv_frame_t f0, sv_frame_t f1) |
1162 { | 1186 { |
1163 QSize s = View::getImageSize(f0, f1); | 1187 QSize s = View::getRenderedPartImageSize(f0, f1); |
1164 QImage *image = new QImage(100, 100, QImage::Format_RGB32); | 1188 QImage *image = new QImage(100, 100, QImage::Format_RGB32); |
1165 QPainter paint(image); | 1189 QPainter paint(image); |
1166 | 1190 |
1167 int sw = 0; | 1191 int sw = 0; |
1168 if (m_manager && m_manager->shouldShowVerticalScale()) { | 1192 if (m_manager && m_manager->shouldShowVerticalScale()) { |
1190 { | 1214 { |
1191 closeToLeftEdge = closeToRightEdge = false; | 1215 closeToLeftEdge = closeToRightEdge = false; |
1192 | 1216 |
1193 if (!m_manager) return Selection(); | 1217 if (!m_manager) return Selection(); |
1194 | 1218 |
1195 sv_frame_t testFrame = getFrameForX(x - 5); | 1219 sv_frame_t testFrame = getFrameForX(x - ViewManager::scalePixelSize(5)); |
1196 if (testFrame < 0) { | 1220 if (testFrame < 0) { |
1197 testFrame = getFrameForX(x); | 1221 testFrame = getFrameForX(x); |
1198 if (testFrame < 0) return Selection(); | 1222 if (testFrame < 0) return Selection(); |
1199 } | 1223 } |
1200 | 1224 |
1202 if (selection.isEmpty()) return selection; | 1226 if (selection.isEmpty()) return selection; |
1203 | 1227 |
1204 int lx = getXForFrame(selection.getStartFrame()); | 1228 int lx = getXForFrame(selection.getStartFrame()); |
1205 int rx = getXForFrame(selection.getEndFrame()); | 1229 int rx = getXForFrame(selection.getEndFrame()); |
1206 | 1230 |
1207 int fuzz = 2; | 1231 int fuzz = ViewManager::scalePixelSize(2); |
1208 if (x < lx - fuzz || x > rx + fuzz) return Selection(); | 1232 if (x < lx - fuzz || x > rx + fuzz) return Selection(); |
1209 | 1233 |
1210 int width = rx - lx; | 1234 int width = rx - lx; |
1211 fuzz = 3; | 1235 fuzz = ViewManager::scalePixelSize(3); |
1212 if (width < 12) fuzz = width / 4; | 1236 if (width < 12) fuzz = width / 4; |
1213 if (fuzz < 1) fuzz = 1; | 1237 if (fuzz < ViewManager::scalePixelSize(1)) { |
1238 fuzz = ViewManager::scalePixelSize(1); | |
1239 } | |
1214 | 1240 |
1215 if (x < lx + fuzz) closeToLeftEdge = true; | 1241 if (x < lx + fuzz) closeToLeftEdge = true; |
1216 if (x > rx - fuzz) closeToRightEdge = true; | 1242 if (x > rx - fuzz) closeToRightEdge = true; |
1217 | 1243 |
1218 return selection; | 1244 return selection; |
1867 if (newStartFrame >= getModelsEndFrame()) { | 1893 if (newStartFrame >= getModelsEndFrame()) { |
1868 newStartFrame = getModelsEndFrame() - 1; | 1894 newStartFrame = getModelsEndFrame() - 1; |
1869 } | 1895 } |
1870 | 1896 |
1871 double ratio = double(w) / double(width()); | 1897 double ratio = double(w) / double(width()); |
1872 // cerr << "ratio: " << ratio << endl; | 1898 // cerr << "ratio: " << ratio << endl; |
1873 int newZoomLevel = (int)nearbyint(m_zoomLevel * ratio); | 1899 int newZoomLevel = (int)nearbyint(m_zoomLevel * ratio); |
1874 if (newZoomLevel < 1) newZoomLevel = 1; | 1900 if (newZoomLevel < 1) newZoomLevel = 1; |
1875 | 1901 |
1876 // cerr << "start: " << m_startFrame << ", level " << m_zoomLevel << endl; | 1902 // cerr << "start: " << m_startFrame << ", level " << m_zoomLevel << endl; |
1877 setZoomLevel(getZoomConstraintBlockSize(newZoomLevel)); | 1903 setZoomLevel(getZoomConstraintBlockSize(newZoomLevel)); |
1878 setStartFrame(newStartFrame); | 1904 setStartFrame(newStartFrame); |
1879 | 1905 |
1880 QString unit; | 1906 QString unit; |
1881 double min, max; | 1907 double min, max; |
2091 layer->snapToFeatureFrame(this, snapFrameLeft, | 2117 layer->snapToFeatureFrame(this, snapFrameLeft, |
2092 resolution, Layer::SnapLeft); | 2118 resolution, Layer::SnapLeft); |
2093 layer->snapToFeatureFrame(this, snapFrameRight, | 2119 layer->snapToFeatureFrame(this, snapFrameRight, |
2094 resolution, Layer::SnapRight); | 2120 resolution, Layer::SnapRight); |
2095 } | 2121 } |
2096 | 2122 |
2097 // cerr << "snap: frame = " << mouseFrame << ", start frame = " << m_selectionStartFrame << ", left = " << snapFrameLeft << ", right = " << snapFrameRight << endl; | 2123 // cerr << "snap: frame = " << mouseFrame << ", start frame = " << m_selectionStartFrame << ", left = " << snapFrameLeft << ", right = " << snapFrameRight << endl; |
2098 | 2124 |
2099 if (snapFrameLeft < 0) snapFrameLeft = 0; | 2125 if (snapFrameLeft < 0) snapFrameLeft = 0; |
2100 if (snapFrameRight < 0) snapFrameRight = 0; | 2126 if (snapFrameRight < 0) snapFrameRight = 0; |
2101 | 2127 |
2102 sv_frame_t min, max; | 2128 sv_frame_t min, max; |
2263 } | 2289 } |
2264 | 2290 |
2265 void | 2291 void |
2266 Pane::wheelEvent(QWheelEvent *e) | 2292 Pane::wheelEvent(QWheelEvent *e) |
2267 { | 2293 { |
2268 cerr << "wheelEvent, delta " << e->delta() << ", angleDelta " << e->angleDelta().x() << "," << e->angleDelta().y() << ", pixelDelta " << e->pixelDelta().x() << "," << e->pixelDelta().y() << ", modifiers " << e->modifiers() << endl; | 2294 // cerr << "wheelEvent, delta " << e->delta() << ", angleDelta " << e->angleDelta().x() << "," << e->angleDelta().y() << ", pixelDelta " << e->pixelDelta().x() << "," << e->pixelDelta().y() << ", modifiers " << e->modifiers() << endl; |
2269 | 2295 |
2270 e->accept(); // we never want wheel events on the pane to be propagated | 2296 e->accept(); // we never want wheel events on the pane to be propagated |
2271 | 2297 |
2272 int dx = e->angleDelta().x(); | 2298 int dx = e->angleDelta().x(); |
2273 int dy = e->angleDelta().y(); | 2299 int dy = e->angleDelta().y(); |
2286 // treat a vertical wheel as horizontal | 2312 // treat a vertical wheel as horizontal |
2287 horizontal = true; | 2313 horizontal = true; |
2288 } | 2314 } |
2289 | 2315 |
2290 if (e->phase() == Qt::ScrollBegin || | 2316 if (e->phase() == Qt::ScrollBegin || |
2291 fabs(d) >= 120 || | 2317 std::abs(d) >= 120 || |
2292 (d > 0 && m_pendingWheelAngle < 0) || | 2318 (d > 0 && m_pendingWheelAngle < 0) || |
2293 (d < 0 && m_pendingWheelAngle > 0)) { | 2319 (d < 0 && m_pendingWheelAngle > 0)) { |
2294 m_pendingWheelAngle = d; | 2320 m_pendingWheelAngle = d; |
2295 } else { | 2321 } else { |
2296 m_pendingWheelAngle += d; | 2322 m_pendingWheelAngle += d; |
2332 } | 2358 } |
2333 | 2359 |
2334 void | 2360 void |
2335 Pane::wheelVertical(int sign, Qt::KeyboardModifiers mods) | 2361 Pane::wheelVertical(int sign, Qt::KeyboardModifiers mods) |
2336 { | 2362 { |
2337 cerr << "wheelVertical: sign = " << sign << endl; | 2363 // cerr << "wheelVertical: sign = " << sign << endl; |
2338 | 2364 |
2339 if (mods & Qt::ShiftModifier) { | 2365 if (mods & Qt::ShiftModifier) { |
2340 | 2366 |
2341 // Pan vertically | 2367 // Pan vertically |
2342 | 2368 |
2379 } | 2405 } |
2380 | 2406 |
2381 void | 2407 void |
2382 Pane::wheelHorizontal(int sign, Qt::KeyboardModifiers mods) | 2408 Pane::wheelHorizontal(int sign, Qt::KeyboardModifiers mods) |
2383 { | 2409 { |
2384 cerr << "wheelHorizontal: sign = " << sign << endl; | 2410 // cerr << "wheelHorizontal: sign = " << sign << endl; |
2385 | 2411 |
2386 // Scroll left or right, rapidly | 2412 // Scroll left or right, rapidly |
2387 | 2413 |
2388 wheelHorizontalFine((width() / 4) * sign, mods); | 2414 wheelHorizontalFine((width() / 4) * sign, mods); |
2389 } | 2415 } |
2390 | 2416 |
2391 void | 2417 void |
2392 Pane::wheelHorizontalFine(int pixels, Qt::KeyboardModifiers) | 2418 Pane::wheelHorizontalFine(int pixels, Qt::KeyboardModifiers) |
2393 { | 2419 { |
2394 cerr << "wheelHorizontalFine: pixels = " << pixels << endl; | 2420 // cerr << "wheelHorizontalFine: pixels = " << pixels << endl; |
2395 | 2421 |
2396 // Scroll left or right by a fixed number of pixels | 2422 // Scroll left or right by a fixed number of pixels |
2397 | 2423 |
2398 if (getStartFrame() < 0 && | 2424 if (getStartFrame() < 0 && |
2399 getEndFrame() >= getModelsEndFrame()) return; | 2425 getEndFrame() >= getModelsEndFrame()) return; |