Mercurial > hg > svgui
comparison view/Pane.cpp @ 922:26da827e8fb5 tonioni
Merge from cxx11 branch
author | Chris Cannam |
---|---|
date | Mon, 23 Mar 2015 11:26:28 +0000 |
parents | 4968bbaf1ed8 4a578a360011 |
children | 3fb91da7d98d |
comparison
equal
deleted
inserted
replaced
921:4968bbaf1ed8 | 922:26da827e8fb5 |
---|---|
141 m_hthumb->setCursor(Qt::ArrowCursor); | 141 m_hthumb->setCursor(Qt::ArrowCursor); |
142 layout->addWidget(m_hthumb, 1, 0, 1, 2); | 142 layout->addWidget(m_hthumb, 1, 0, 1, 2); |
143 m_hthumb->setFixedWidth(70); | 143 m_hthumb->setFixedWidth(70); |
144 m_hthumb->setFixedHeight(16); | 144 m_hthumb->setFixedHeight(16); |
145 m_hthumb->setDefaultValue(0); | 145 m_hthumb->setDefaultValue(0); |
146 m_hthumb->setSpeed(0.6); | 146 m_hthumb->setSpeed(0.6f); |
147 connect(m_hthumb, SIGNAL(valueChanged(int)), this, | 147 connect(m_hthumb, SIGNAL(valueChanged(int)), this, |
148 SLOT(horizontalThumbwheelMoved(int))); | 148 SLOT(horizontalThumbwheelMoved(int))); |
149 connect(m_hthumb, SIGNAL(mouseEntered()), this, SLOT(mouseEnteredWidget())); | 149 connect(m_hthumb, SIGNAL(mouseEntered()), this, SLOT(mouseEnteredWidget())); |
150 connect(m_hthumb, SIGNAL(mouseLeft()), this, SLOT(mouseLeftWidget())); | 150 connect(m_hthumb, SIGNAL(mouseLeft()), this, SLOT(mouseLeftWidget())); |
151 | 151 |
318 if (layer && layer->getVerticalZoomSteps(discard) == 0) { | 318 if (layer && layer->getVerticalZoomSteps(discard) == 0) { |
319 m_vpan->hide(); | 319 m_vpan->hide(); |
320 return; | 320 return; |
321 } | 321 } |
322 | 322 |
323 float vmin, vmax, dmin, dmax; | 323 double vmin, vmax, dmin, dmax; |
324 if (getTopLayerDisplayExtents(vmin, vmax, dmin, dmax) && vmax != vmin) { | 324 if (getTopLayerDisplayExtents(vmin, vmax, dmin, dmax) && vmax != vmin) { |
325 float y0 = (dmin - vmin) / (vmax - vmin); | 325 double y0 = (dmin - vmin) / (vmax - vmin); |
326 float y1 = (dmax - vmin) / (vmax - vmin); | 326 double y1 = (dmax - vmin) / (vmax - vmin); |
327 m_vpan->blockSignals(true); | 327 m_vpan->blockSignals(true); |
328 m_vpan->setRectExtents(0, 1.0 - y1, 1, y1 - y0); | 328 m_vpan->setRectExtents(0, float(1.0 - y1), 1, float(y1 - y0)); |
329 m_vpan->blockSignals(false); | 329 m_vpan->blockSignals(false); |
330 m_vpan->show(); | 330 m_vpan->show(); |
331 } else { | 331 } else { |
332 m_vpan->hide(); | 332 m_vpan->hide(); |
333 } | 333 } |
481 m_manager && m_manager->shouldIlluminateLocalFeatures() && | 481 m_manager && m_manager->shouldIlluminateLocalFeatures() && |
482 topLayer) { | 482 topLayer) { |
483 drawFeatureDescription(topLayer, paint); | 483 drawFeatureDescription(topLayer, paint); |
484 } | 484 } |
485 | 485 |
486 int sampleRate = getModelsSampleRate(); | 486 sv_samplerate_t sampleRate = getModelsSampleRate(); |
487 paint.setBrush(Qt::NoBrush); | 487 paint.setBrush(Qt::NoBrush); |
488 | 488 |
489 if (m_centreLineVisible && | 489 if (m_centreLineVisible && |
490 m_manager && | 490 m_manager && |
491 m_manager->shouldShowCentreLine()) { | 491 m_manager->shouldShowCentreLine()) { |
558 void | 558 void |
559 Pane::drawVerticalScale(QRect r, Layer *topLayer, QPainter &paint) | 559 Pane::drawVerticalScale(QRect r, Layer *topLayer, QPainter &paint) |
560 { | 560 { |
561 Layer *scaleLayer = 0; | 561 Layer *scaleLayer = 0; |
562 | 562 |
563 float min, max; | 563 double min, max; |
564 bool log; | 564 bool log; |
565 QString unit; | 565 QString unit; |
566 | 566 |
567 // If the top layer has no scale and reports no display | 567 // If the top layer has no scale and reports no display |
568 // extents, but does report a unit, then the scale should be | 568 // extents, but does report a unit, then the scale should be |
712 paint.restore(); | 712 paint.restore(); |
713 } | 713 } |
714 } | 714 } |
715 | 715 |
716 void | 716 void |
717 Pane::drawCentreLine(int sampleRate, QPainter &paint, bool omitLine) | 717 Pane::drawCentreLine(sv_samplerate_t sampleRate, QPainter &paint, bool omitLine) |
718 { | 718 { |
719 int fontHeight = paint.fontMetrics().height(); | 719 int fontHeight = paint.fontMetrics().height(); |
720 int fontAscent = paint.fontMetrics().ascent(); | 720 int fontAscent = paint.fontMetrics().ascent(); |
721 | 721 |
722 QColor c = QColor(0, 0, 0); | 722 QColor c = QColor(0, 0, 0); |
967 void | 967 void |
968 Pane::drawEditingSelection(QPainter &paint) | 968 Pane::drawEditingSelection(QPainter &paint) |
969 { | 969 { |
970 int offset = m_mousePos.x() - m_clickPos.x(); | 970 int offset = m_mousePos.x() - m_clickPos.x(); |
971 | 971 |
972 int origStart = m_editingSelection.getStartFrame(); | 972 sv_frame_t origStart = m_editingSelection.getStartFrame(); |
973 | 973 |
974 int p0 = getXForFrame(origStart) + offset; | 974 int p0 = getXForFrame(origStart) + offset; |
975 int p1 = getXForFrame(m_editingSelection.getEndFrame()) + offset; | 975 int p1 = getXForFrame(m_editingSelection.getEndFrame()) + offset; |
976 | 976 |
977 if (m_editingSelectionEdge < 0) { | 977 if (m_editingSelectionEdge < 0) { |
978 p1 = getXForFrame(m_editingSelection.getEndFrame()); | 978 p1 = getXForFrame(m_editingSelection.getEndFrame()); |
979 } else if (m_editingSelectionEdge > 0) { | 979 } else if (m_editingSelectionEdge > 0) { |
980 p0 = getXForFrame(m_editingSelection.getStartFrame()); | 980 p0 = getXForFrame(m_editingSelection.getStartFrame()); |
981 } | 981 } |
982 | 982 |
983 int newStart = getFrameForX(p0); | 983 sv_frame_t newStart = getFrameForX(p0); |
984 int newEnd = getFrameForX(p1); | 984 sv_frame_t newEnd = getFrameForX(p1); |
985 | 985 |
986 paint.save(); | 986 paint.save(); |
987 paint.setPen(QPen(getForeground(), 2)); | 987 paint.setPen(QPen(getForeground(), 2)); |
988 | 988 |
989 int fontHeight = paint.fontMetrics().height(); | 989 int fontHeight = paint.fontMetrics().height(); |
990 int fontAscent = paint.fontMetrics().ascent(); | 990 int fontAscent = paint.fontMetrics().ascent(); |
991 int sampleRate = getModelsSampleRate(); | 991 sv_samplerate_t sampleRate = getModelsSampleRate(); |
992 QString startText, endText, offsetText; | 992 QString startText, endText, offsetText; |
993 startText = QString("%1").arg(newStart); | 993 startText = QString("%1").arg(newStart); |
994 endText = QString("%1").arg(newEnd); | 994 endText = QString("%1").arg(newEnd); |
995 offsetText = QString("%1").arg(newStart - origStart); | 995 offsetText = QString("%1").arg(newStart - origStart); |
996 if (newStart >= origStart) { | 996 if (newStart >= origStart) { |
1035 paint.restore(); | 1035 paint.restore(); |
1036 } | 1036 } |
1037 | 1037 |
1038 void | 1038 void |
1039 Pane::drawDurationAndRate(QRect r, const Model *waveformModel, | 1039 Pane::drawDurationAndRate(QRect r, const Model *waveformModel, |
1040 int sampleRate, QPainter &paint) | 1040 sv_samplerate_t sampleRate, QPainter &paint) |
1041 { | 1041 { |
1042 int fontHeight = paint.fontMetrics().height(); | 1042 int fontHeight = paint.fontMetrics().height(); |
1043 int fontAscent = paint.fontMetrics().ascent(); | 1043 int fontAscent = paint.fontMetrics().ascent(); |
1044 | 1044 |
1045 if (r.y() + r.height() < height() - fontHeight - 6) return; | 1045 if (r.y() + r.height() < height() - fontHeight - 6) return; |
1046 | 1046 |
1047 int modelRate = waveformModel->getSampleRate(); | 1047 sv_samplerate_t modelRate = waveformModel->getSampleRate(); |
1048 int nativeRate = waveformModel->getNativeRate(); | 1048 sv_samplerate_t nativeRate = waveformModel->getNativeRate(); |
1049 int playbackRate = m_manager->getPlaybackSampleRate(); | 1049 sv_samplerate_t playbackRate = m_manager->getPlaybackSampleRate(); |
1050 int outputRate = m_manager->getOutputSampleRate(); | 1050 sv_samplerate_t outputRate = m_manager->getOutputSampleRate(); |
1051 | 1051 |
1052 QString srNote = ""; | 1052 QString srNote = ""; |
1053 | 1053 |
1054 // Show (R) for waveform models that have been resampled or will | 1054 // Show (R) for waveform models that have been resampled or will |
1055 // be resampled on playback, and (X) for waveform models that will | 1055 // be resampled on playback, and (X) for waveform models that will |
1084 desc, OutlinedText); | 1084 desc, OutlinedText); |
1085 } | 1085 } |
1086 } | 1086 } |
1087 | 1087 |
1088 bool | 1088 bool |
1089 Pane::render(QPainter &paint, int xorigin, int f0, int f1) | 1089 Pane::render(QPainter &paint, int xorigin, sv_frame_t f0, sv_frame_t f1) |
1090 { | 1090 { |
1091 if (!View::render(paint, xorigin + m_scaleWidth, f0, f1)) { | 1091 if (!View::render(paint, xorigin + m_scaleWidth, f0, f1)) { |
1092 return false; | 1092 return false; |
1093 } | 1093 } |
1094 | 1094 |
1115 | 1115 |
1116 return true; | 1116 return true; |
1117 } | 1117 } |
1118 | 1118 |
1119 QImage * | 1119 QImage * |
1120 Pane::toNewImage(int f0, int f1) | 1120 Pane::toNewImage(sv_frame_t f0, sv_frame_t f1) |
1121 { | 1121 { |
1122 int x0 = f0 / getZoomLevel(); | 1122 int x0 = int(f0 / getZoomLevel()); |
1123 int x1 = f1 / getZoomLevel(); | 1123 int x1 = int(f1 / getZoomLevel()); |
1124 | 1124 |
1125 QImage *image = new QImage(x1 - x0 + m_scaleWidth, | 1125 QImage *image = new QImage(x1 - x0 + m_scaleWidth, |
1126 height(), QImage::Format_RGB32); | 1126 height(), QImage::Format_RGB32); |
1127 | 1127 |
1128 int formerScaleWidth = m_scaleWidth; | 1128 int formerScaleWidth = m_scaleWidth; |
1154 return image; | 1154 return image; |
1155 } | 1155 } |
1156 } | 1156 } |
1157 | 1157 |
1158 QSize | 1158 QSize |
1159 Pane::getImageSize(int f0, int f1) | 1159 Pane::getImageSize(sv_frame_t f0, sv_frame_t f1) |
1160 { | 1160 { |
1161 QSize s = View::getImageSize(f0, f1); | 1161 QSize s = View::getImageSize(f0, f1); |
1162 QImage *image = new QImage(100, 100, QImage::Format_RGB32); | 1162 QImage *image = new QImage(100, 100, QImage::Format_RGB32); |
1163 QPainter paint(image); | 1163 QPainter paint(image); |
1164 | 1164 |
1172 } | 1172 } |
1173 | 1173 |
1174 return QSize(sw + s.width(), s.height()); | 1174 return QSize(sw + s.width(), s.height()); |
1175 } | 1175 } |
1176 | 1176 |
1177 int | 1177 sv_frame_t |
1178 Pane::getFirstVisibleFrame() const | 1178 Pane::getFirstVisibleFrame() const |
1179 { | 1179 { |
1180 int f0 = getFrameForX(m_scaleWidth); | 1180 sv_frame_t f0 = getFrameForX(m_scaleWidth); |
1181 int f = View::getFirstVisibleFrame(); | 1181 sv_frame_t f = View::getFirstVisibleFrame(); |
1182 if (f0 < 0 || f0 < long(f)) return f; | 1182 if (f0 < 0 || f0 < f) return f; |
1183 return f0; | 1183 return f0; |
1184 } | 1184 } |
1185 | 1185 |
1186 Selection | 1186 Selection |
1187 Pane::getSelectionAt(int x, bool &closeToLeftEdge, bool &closeToRightEdge) const | 1187 Pane::getSelectionAt(int x, bool &closeToLeftEdge, bool &closeToRightEdge) const |
1188 { | 1188 { |
1189 closeToLeftEdge = closeToRightEdge = false; | 1189 closeToLeftEdge = closeToRightEdge = false; |
1190 | 1190 |
1191 if (!m_manager) return Selection(); | 1191 if (!m_manager) return Selection(); |
1192 | 1192 |
1193 int testFrame = getFrameForX(x - 5); | 1193 sv_frame_t testFrame = getFrameForX(x - 5); |
1194 if (testFrame < 0) { | 1194 if (testFrame < 0) { |
1195 testFrame = getFrameForX(x); | 1195 testFrame = getFrameForX(x); |
1196 if (testFrame < 0) return Selection(); | 1196 if (testFrame < 0) return Selection(); |
1197 } | 1197 } |
1198 | 1198 |
1199 Selection selection = m_manager->getContainingSelection(testFrame, true); | 1199 Selection selection = m_manager->getContainingSelection(testFrame, true); |
1200 if (selection.isEmpty()) return selection; | 1200 if (selection.isEmpty()) return selection; |
1201 | 1201 |
1217 } | 1217 } |
1218 | 1218 |
1219 bool | 1219 bool |
1220 Pane::canTopLayerMoveVertical() | 1220 Pane::canTopLayerMoveVertical() |
1221 { | 1221 { |
1222 float vmin, vmax, dmin, dmax; | 1222 double vmin, vmax, dmin, dmax; |
1223 if (!getTopLayerDisplayExtents(vmin, vmax, dmin, dmax)) return false; | 1223 if (!getTopLayerDisplayExtents(vmin, vmax, dmin, dmax)) return false; |
1224 if (dmin <= vmin && dmax >= vmax) return false; | 1224 if (dmin <= vmin && dmax >= vmax) return false; |
1225 return true; | 1225 return true; |
1226 } | 1226 } |
1227 | 1227 |
1228 bool | 1228 bool |
1229 Pane::getTopLayerDisplayExtents(float &vmin, float &vmax, | 1229 Pane::getTopLayerDisplayExtents(double &vmin, double &vmax, |
1230 float &dmin, float &dmax, | 1230 double &dmin, double &dmax, |
1231 QString *unit) | 1231 QString *unit) |
1232 { | 1232 { |
1233 Layer *layer = getTopLayer(); | 1233 Layer *layer = getTopLayer(); |
1234 if (!layer) return false; | 1234 if (!layer) return false; |
1235 bool vlog; | 1235 bool vlog; |
1239 if (unit) *unit = vunit; | 1239 if (unit) *unit = vunit; |
1240 return rv; | 1240 return rv; |
1241 } | 1241 } |
1242 | 1242 |
1243 bool | 1243 bool |
1244 Pane::setTopLayerDisplayExtents(float dmin, float dmax) | 1244 Pane::setTopLayerDisplayExtents(double dmin, double dmax) |
1245 { | 1245 { |
1246 Layer *layer = getTopLayer(); | 1246 Layer *layer = getTopLayer(); |
1247 if (!layer) return false; | 1247 if (!layer) return false; |
1248 return layer->setDisplayExtents(dmin, dmax); | 1248 return layer->setDisplayExtents(dmin, dmax); |
1249 } | 1249 } |
1325 | 1325 |
1326 m_navigating = true; | 1326 m_navigating = true; |
1327 m_dragCentreFrame = m_centreFrame; | 1327 m_dragCentreFrame = m_centreFrame; |
1328 m_dragStartMinValue = 0; | 1328 m_dragStartMinValue = 0; |
1329 | 1329 |
1330 float vmin, vmax, dmin, dmax; | 1330 double vmin, vmax, dmin, dmax; |
1331 if (getTopLayerDisplayExtents(vmin, vmax, dmin, dmax)) { | 1331 if (getTopLayerDisplayExtents(vmin, vmax, dmin, dmax)) { |
1332 m_dragStartMinValue = dmin; | 1332 m_dragStartMinValue = dmin; |
1333 } | 1333 } |
1334 | 1334 |
1335 if (m_followPlay == PlaybackScrollPage) { | 1335 if (m_followPlay == PlaybackScrollPage) { |
1360 m_manager->setInProgressSelection(selection, false); | 1360 m_manager->setInProgressSelection(selection, false); |
1361 m_resizing = true; | 1361 m_resizing = true; |
1362 | 1362 |
1363 } else { | 1363 } else { |
1364 | 1364 |
1365 int mouseFrame = getFrameForX(e->x()); | 1365 sv_frame_t mouseFrame = getFrameForX(e->x()); |
1366 int resolution = 1; | 1366 int resolution = 1; |
1367 int snapFrame = mouseFrame; | 1367 sv_frame_t snapFrame = mouseFrame; |
1368 | 1368 |
1369 Layer *layer = getInteractionLayer(); | 1369 Layer *layer = getInteractionLayer(); |
1370 if (layer && !m_shiftPressed) { | 1370 if (layer && !m_shiftPressed) { |
1371 layer->snapToFeatureFrame(this, snapFrame, | 1371 layer->snapToFeatureFrame(this, snapFrame, |
1372 resolution, Layer::SnapLeft); | 1372 resolution, Layer::SnapLeft); |
1431 | 1431 |
1432 emit paneInteractedWith(); | 1432 emit paneInteractedWith(); |
1433 } | 1433 } |
1434 | 1434 |
1435 void | 1435 void |
1436 Pane::schedulePlaybackFrameMove(int frame) | 1436 Pane::schedulePlaybackFrameMove(sv_frame_t frame) |
1437 { | 1437 { |
1438 m_playbackFrameMoveTo = frame; | 1438 m_playbackFrameMoveTo = frame; |
1439 m_playbackFrameMoveScheduled = true; | 1439 m_playbackFrameMoveScheduled = true; |
1440 QTimer::singleShot(QApplication::doubleClickInterval() + 10, this, | 1440 QTimer::singleShot(QApplication::doubleClickInterval() + 10, this, |
1441 SLOT(playbackScheduleTimerElapsed())); | 1441 SLOT(playbackScheduleTimerElapsed())); |
1466 | 1466 |
1467 if (m_clickedInRange) { | 1467 if (m_clickedInRange) { |
1468 mouseMoveEvent(e); | 1468 mouseMoveEvent(e); |
1469 } | 1469 } |
1470 | 1470 |
1471 int mouseFrame = e ? getFrameForX(e->x()) : 0; | 1471 sv_frame_t mouseFrame = e ? getFrameForX(e->x()) : 0; |
1472 if (mouseFrame < 0) mouseFrame = 0; | 1472 if (mouseFrame < 0) mouseFrame = 0; |
1473 | 1473 |
1474 if (m_navigating || mode == ViewManager::NavigateMode) { | 1474 if (m_navigating || mode == ViewManager::NavigateMode) { |
1475 | 1475 |
1476 m_navigating = false; | 1476 m_navigating = false; |
1852 int x1 = r.x() + r.width(); | 1852 int x1 = r.x() + r.width(); |
1853 int y1 = r.y() + r.height(); | 1853 int y1 = r.y() + r.height(); |
1854 | 1854 |
1855 int w = x1 - x0; | 1855 int w = x1 - x0; |
1856 | 1856 |
1857 int newStartFrame = getFrameForX(x0); | 1857 sv_frame_t newStartFrame = getFrameForX(x0); |
1858 | 1858 |
1859 int visibleFrames = getEndFrame() - getStartFrame(); | 1859 sv_frame_t visibleFrames = getEndFrame() - getStartFrame(); |
1860 if (newStartFrame <= -visibleFrames) { | 1860 if (newStartFrame <= -visibleFrames) { |
1861 newStartFrame = -visibleFrames + 1; | 1861 newStartFrame = -visibleFrames + 1; |
1862 } | 1862 } |
1863 | 1863 |
1864 if (newStartFrame >= long(getModelsEndFrame())) { | 1864 if (newStartFrame >= getModelsEndFrame()) { |
1865 newStartFrame = getModelsEndFrame() - 1; | 1865 newStartFrame = getModelsEndFrame() - 1; |
1866 } | 1866 } |
1867 | 1867 |
1868 float ratio = float(w) / float(width()); | 1868 double ratio = double(w) / double(width()); |
1869 // cerr << "ratio: " << ratio << endl; | 1869 // cerr << "ratio: " << ratio << endl; |
1870 int newZoomLevel = (int)nearbyint(m_zoomLevel * ratio); | 1870 int newZoomLevel = (int)nearbyint(m_zoomLevel * ratio); |
1871 if (newZoomLevel < 1) newZoomLevel = 1; | 1871 if (newZoomLevel < 1) newZoomLevel = 1; |
1872 | 1872 |
1873 // cerr << "start: " << m_startFrame << ", level " << m_zoomLevel << endl; | 1873 // cerr << "start: " << m_startFrame << ", level " << m_zoomLevel << endl; |
1874 setZoomLevel(getZoomConstraintBlockSize(newZoomLevel)); | 1874 setZoomLevel(getZoomConstraintBlockSize(newZoomLevel)); |
1875 setStartFrame(newStartFrame); | 1875 setStartFrame(newStartFrame); |
1876 | 1876 |
1877 QString unit; | 1877 QString unit; |
1878 float min, max; | 1878 double min, max; |
1879 bool log; | 1879 bool log; |
1880 Layer *layer = 0; | 1880 Layer *layer = 0; |
1881 for (LayerList::const_iterator i = m_layerStack.begin(); | 1881 for (LayerList::const_iterator i = m_layerStack.begin(); |
1882 i != m_layerStack.end(); ++i) { | 1882 i != m_layerStack.end(); ++i) { |
1883 if ((*i)->getValueExtents(min, max, log, unit) && | 1883 if ((*i)->getValueExtents(min, max, log, unit) && |
1887 } | 1887 } |
1888 } | 1888 } |
1889 | 1889 |
1890 if (layer) { | 1890 if (layer) { |
1891 if (log) { | 1891 if (log) { |
1892 min = (min < 0.0) ? -log10f(-min) : (min == 0.0) ? 0.0 : log10f(min); | 1892 min = (min < 0.0) ? -log10(-min) : (min == 0.0) ? 0.0 : log10(min); |
1893 max = (max < 0.0) ? -log10f(-max) : (max == 0.0) ? 0.0 : log10f(max); | 1893 max = (max < 0.0) ? -log10(-max) : (max == 0.0) ? 0.0 : log10(max); |
1894 } | 1894 } |
1895 float rmin = min + ((max - min) * (height() - y1)) / height(); | 1895 double rmin = min + ((max - min) * (height() - y1)) / height(); |
1896 float rmax = min + ((max - min) * (height() - y0)) / height(); | 1896 double rmax = min + ((max - min) * (height() - y0)) / height(); |
1897 cerr << "min: " << min << ", max: " << max << ", y0: " << y0 << ", y1: " << y1 << ", h: " << height() << ", rmin: " << rmin << ", rmax: " << rmax << endl; | 1897 cerr << "min: " << min << ", max: " << max << ", y0: " << y0 << ", y1: " << y1 << ", h: " << height() << ", rmin: " << rmin << ", rmax: " << rmax << endl; |
1898 if (log) { | 1898 if (log) { |
1899 rmin = powf(10, rmin); | 1899 rmin = pow(10, rmin); |
1900 rmax = powf(10, rmax); | 1900 rmax = pow(10, rmax); |
1901 } | 1901 } |
1902 cerr << "finally: rmin: " << rmin << ", rmax: " << rmax << " " << unit << endl; | 1902 cerr << "finally: rmin: " << rmin << ", rmax: " << rmax << " " << unit << endl; |
1903 | 1903 |
1904 layer->setDisplayExtents(rmin, rmax); | 1904 layer->setDisplayExtents(rmin, rmax); |
1905 updateVerticalPanner(); | 1905 updateVerticalPanner(); |
1944 !(m_manager && m_manager->isPlaying())); // resist vert | 1944 !(m_manager && m_manager->isPlaying())); // resist vert |
1945 | 1945 |
1946 if (m_dragMode == HorizontalDrag || | 1946 if (m_dragMode == HorizontalDrag || |
1947 m_dragMode == FreeDrag) { | 1947 m_dragMode == FreeDrag) { |
1948 | 1948 |
1949 int frameOff = getFrameForX(e->x()) - getFrameForX(m_clickPos.x()); | 1949 sv_frame_t frameOff = getFrameForX(e->x()) - getFrameForX(m_clickPos.x()); |
1950 int newCentreFrame = m_dragCentreFrame; | 1950 sv_frame_t newCentreFrame = m_dragCentreFrame; |
1951 | 1951 |
1952 if (frameOff < 0) { | 1952 if (frameOff < 0) { |
1953 newCentreFrame -= frameOff; | 1953 newCentreFrame -= frameOff; |
1954 } else if (newCentreFrame >= frameOff) { | 1954 } else if (newCentreFrame >= frameOff) { |
1955 newCentreFrame -= frameOff; | 1955 newCentreFrame -= frameOff; |
1973 } | 1973 } |
1974 | 1974 |
1975 if (m_dragMode == VerticalDrag || | 1975 if (m_dragMode == VerticalDrag || |
1976 m_dragMode == FreeDrag) { | 1976 m_dragMode == FreeDrag) { |
1977 | 1977 |
1978 float vmin = 0.f, vmax = 0.f; | 1978 double vmin = 0.f, vmax = 0.f; |
1979 float dmin = 0.f, dmax = 0.f; | 1979 double dmin = 0.f, dmax = 0.f; |
1980 | 1980 |
1981 if (getTopLayerDisplayExtents(vmin, vmax, dmin, dmax)) { | 1981 if (getTopLayerDisplayExtents(vmin, vmax, dmin, dmax)) { |
1982 | 1982 |
1983 // cerr << "ydiff = " << ydiff << endl; | 1983 // cerr << "ydiff = " << ydiff << endl; |
1984 | 1984 |
1985 int ydiff = e->y() - m_clickPos.y(); | 1985 int ydiff = e->y() - m_clickPos.y(); |
1986 float perpix = (dmax - dmin) / height(); | 1986 double perpix = (dmax - dmin) / height(); |
1987 float valdiff = ydiff * perpix; | 1987 double valdiff = ydiff * perpix; |
1988 // cerr << "valdiff = " << valdiff << endl; | 1988 // cerr << "valdiff = " << valdiff << endl; |
1989 | 1989 |
1990 if (m_dragMode == UnresolvedDrag && ydiff != 0) { | 1990 if (m_dragMode == UnresolvedDrag && ydiff != 0) { |
1991 m_dragMode = VerticalDrag; | 1991 m_dragMode = VerticalDrag; |
1992 } | 1992 } |
1993 | 1993 |
1994 float newmin = m_dragStartMinValue + valdiff; | 1994 double newmin = m_dragStartMinValue + valdiff; |
1995 float newmax = m_dragStartMinValue + (dmax - dmin) + valdiff; | 1995 double newmax = m_dragStartMinValue + (dmax - dmin) + valdiff; |
1996 if (newmin < vmin) { | 1996 if (newmin < vmin) { |
1997 newmax += vmin - newmin; | 1997 newmax += vmin - newmin; |
1998 newmin += vmin - newmin; | 1998 newmin += vmin - newmin; |
1999 } | 1999 } |
2000 if (newmax > vmax) { | 2000 if (newmax > vmax) { |
2075 } | 2075 } |
2076 | 2076 |
2077 void | 2077 void |
2078 Pane::dragExtendSelection(QMouseEvent *e) | 2078 Pane::dragExtendSelection(QMouseEvent *e) |
2079 { | 2079 { |
2080 int mouseFrame = getFrameForX(e->x()); | 2080 sv_frame_t mouseFrame = getFrameForX(e->x()); |
2081 int resolution = 1; | 2081 int resolution = 1; |
2082 int snapFrameLeft = mouseFrame; | 2082 sv_frame_t snapFrameLeft = mouseFrame; |
2083 int snapFrameRight = mouseFrame; | 2083 sv_frame_t snapFrameRight = mouseFrame; |
2084 | 2084 |
2085 Layer *layer = getInteractionLayer(); | 2085 Layer *layer = getInteractionLayer(); |
2086 if (layer && !m_shiftPressed) { | 2086 if (layer && !m_shiftPressed) { |
2087 layer->snapToFeatureFrame(this, snapFrameLeft, | 2087 layer->snapToFeatureFrame(this, snapFrameLeft, |
2088 resolution, Layer::SnapLeft); | 2088 resolution, Layer::SnapLeft); |
2093 // cerr << "snap: frame = " << mouseFrame << ", start frame = " << m_selectionStartFrame << ", left = " << snapFrameLeft << ", right = " << snapFrameRight << endl; | 2093 // cerr << "snap: frame = " << mouseFrame << ", start frame = " << m_selectionStartFrame << ", left = " << snapFrameLeft << ", right = " << snapFrameRight << endl; |
2094 | 2094 |
2095 if (snapFrameLeft < 0) snapFrameLeft = 0; | 2095 if (snapFrameLeft < 0) snapFrameLeft = 0; |
2096 if (snapFrameRight < 0) snapFrameRight = 0; | 2096 if (snapFrameRight < 0) snapFrameRight = 0; |
2097 | 2097 |
2098 int min, max; | 2098 sv_frame_t min, max; |
2099 | 2099 |
2100 if (m_selectionStartFrame > snapFrameLeft) { | 2100 if (m_selectionStartFrame > snapFrameLeft) { |
2101 min = snapFrameLeft; | 2101 min = snapFrameLeft; |
2102 max = m_selectionStartFrame; | 2102 max = m_selectionStartFrame; |
2103 } else if (snapFrameRight > m_selectionStartFrame) { | 2103 } else if (snapFrameRight > m_selectionStartFrame) { |
2124 } | 2124 } |
2125 | 2125 |
2126 void | 2126 void |
2127 Pane::edgeScrollMaybe(int x) | 2127 Pane::edgeScrollMaybe(int x) |
2128 { | 2128 { |
2129 int mouseFrame = getFrameForX(x); | 2129 sv_frame_t mouseFrame = getFrameForX(x); |
2130 | 2130 |
2131 bool doScroll = false; | 2131 bool doScroll = false; |
2132 if (!m_manager) doScroll = true; | 2132 if (!m_manager) doScroll = true; |
2133 else if (!m_manager->isPlaying()) doScroll = true; | 2133 else if (!m_manager->isPlaying()) doScroll = true; |
2134 | 2134 |
2135 if (m_followPlay != PlaybackScrollContinuous) doScroll = true; | 2135 if (m_followPlay != PlaybackScrollContinuous) doScroll = true; |
2136 | 2136 |
2137 if (doScroll) { | 2137 if (doScroll) { |
2138 int offset = mouseFrame - getStartFrame(); | 2138 sv_frame_t offset = mouseFrame - getStartFrame(); |
2139 int available = getEndFrame() - getStartFrame(); | 2139 sv_frame_t available = getEndFrame() - getStartFrame(); |
2140 int move = 0; | 2140 sv_frame_t move = 0; |
2141 if (offset >= available * 0.95) { | 2141 if (offset >= double(available) * 0.95) { |
2142 move = int(offset - available * 0.95) + 1; | 2142 move = sv_frame_t(double(offset - available) * 0.95) + 1; |
2143 } else if (offset <= available * 0.10) { | 2143 } else if (offset <= double(available) * 0.10) { |
2144 move = int(available * 0.10 - offset) + 1; | 2144 move = sv_frame_t(double(available) * 0.10 - double(offset)) + 1; |
2145 move = -move; | 2145 move = -move; |
2146 } | 2146 } |
2147 if (move != 0) { | 2147 if (move != 0) { |
2148 setCentreFrame(m_centreFrame + move); | 2148 setCentreFrame(m_centreFrame + move); |
2149 update(); | 2149 update(); |
2150 } | 2150 } |
2197 update(); | 2197 update(); |
2198 } | 2198 } |
2199 | 2199 |
2200 if (relocate) { | 2200 if (relocate) { |
2201 | 2201 |
2202 int f = getFrameForX(e->x()); | 2202 sv_frame_t f = getFrameForX(e->x()); |
2203 | 2203 |
2204 setCentreFrame(f); | 2204 setCentreFrame(f); |
2205 | 2205 |
2206 m_dragCentreFrame = f; | 2206 m_dragCentreFrame = f; |
2207 m_dragStartMinValue = 0; | 2207 m_dragStartMinValue = 0; |
2208 m_dragMode = UnresolvedDrag; | 2208 m_dragMode = UnresolvedDrag; |
2209 | 2209 |
2210 float vmin, vmax, dmin, dmax; | 2210 double vmin, vmax, dmin, dmax; |
2211 if (getTopLayerDisplayExtents(vmin, vmax, dmin, dmax)) { | 2211 if (getTopLayerDisplayExtents(vmin, vmax, dmin, dmax)) { |
2212 m_dragStartMinValue = dmin; | 2212 m_dragStartMinValue = dmin; |
2213 } | 2213 } |
2214 } | 2214 } |
2215 | 2215 |
2291 // Coarse wheel information (or vertical zoom, which is | 2291 // Coarse wheel information (or vertical zoom, which is |
2292 // necessarily coarse itself) | 2292 // necessarily coarse itself) |
2293 | 2293 |
2294 // Sometimes on Linux we're seeing absurdly extreme angles on | 2294 // Sometimes on Linux we're seeing absurdly extreme angles on |
2295 // the first wheel event -- discard those entirely | 2295 // the first wheel event -- discard those entirely |
2296 if (abs(m_pendingWheelAngle) > 1000) { | 2296 if (abs(m_pendingWheelAngle) >= 600) { |
2297 m_pendingWheelAngle = 0; | 2297 m_pendingWheelAngle = 0; |
2298 return; | 2298 return; |
2299 } | 2299 } |
2300 | 2300 |
2301 while (abs(m_pendingWheelAngle) >= 120) { | 2301 while (abs(m_pendingWheelAngle) >= 120) { |
2466 } | 2466 } |
2467 | 2467 |
2468 void | 2468 void |
2469 Pane::verticalPannerMoved(float , float y0, float , float h) | 2469 Pane::verticalPannerMoved(float , float y0, float , float h) |
2470 { | 2470 { |
2471 float vmin, vmax, dmin, dmax; | 2471 double vmin, vmax, dmin, dmax; |
2472 if (!getTopLayerDisplayExtents(vmin, vmax, dmin, dmax)) return; | 2472 if (!getTopLayerDisplayExtents(vmin, vmax, dmin, dmax)) return; |
2473 float y1 = y0 + h; | 2473 double y1 = y0 + h; |
2474 float newmax = vmin + ((1.0 - y0) * (vmax - vmin)); | 2474 double newmax = vmin + ((1.0 - y0) * (vmax - vmin)); |
2475 float newmin = vmin + ((1.0 - y1) * (vmax - vmin)); | 2475 double newmin = vmin + ((1.0 - y1) * (vmax - vmin)); |
2476 // cerr << "verticalPannerMoved: (" << x0 << "," << y0 << "," << w | 2476 // cerr << "verticalPannerMoved: (" << x0 << "," << y0 << "," << w |
2477 // << "," << h << ") -> (" << newmin << "," << newmax << ")" << endl; | 2477 // << "," << h << ") -> (" << newmin << "," << newmax << ")" << endl; |
2478 setTopLayerDisplayExtents(newmin, newmax); | 2478 setTopLayerDisplayExtents(newmin, newmax); |
2479 } | 2479 } |
2480 | 2480 |
2481 void | 2481 void |
2482 Pane::editVerticalPannerExtents() | 2482 Pane::editVerticalPannerExtents() |
2483 { | 2483 { |
2484 if (!m_vpan || !m_manager || !m_manager->getZoomWheelsEnabled()) return; | 2484 if (!m_vpan || !m_manager || !m_manager->getZoomWheelsEnabled()) return; |
2485 | 2485 |
2486 float vmin, vmax, dmin, dmax; | 2486 double vmin, vmax, dmin, dmax; |
2487 QString unit; | 2487 QString unit; |
2488 if (!getTopLayerDisplayExtents(vmin, vmax, dmin, dmax, &unit) | 2488 if (!getTopLayerDisplayExtents(vmin, vmax, dmin, dmax, &unit) |
2489 || vmax == vmin) { | 2489 || vmax == vmin) { |
2490 return; | 2490 return; |
2491 } | 2491 } |
2492 | 2492 |
2493 RangeInputDialog dialog(tr("Enter new range"), | 2493 RangeInputDialog dialog(tr("Enter new range"), |
2494 tr("New vertical display range, from %1 to %2 %4:") | 2494 tr("New vertical display range, from %1 to %2 %4:") |
2495 .arg(vmin).arg(vmax).arg(unit), | 2495 .arg(vmin).arg(vmax).arg(unit), |
2496 unit, vmin, vmax, this); | 2496 unit, float(vmin), float(vmax), this); |
2497 dialog.setRange(dmin, dmax); | 2497 dialog.setRange(float(dmin), float(dmax)); |
2498 | 2498 |
2499 if (dialog.exec() == QDialog::Accepted) { | 2499 if (dialog.exec() == QDialog::Accepted) { |
2500 dialog.getRange(dmin, dmax); | 2500 float newmin, newmax; |
2501 setTopLayerDisplayExtents(dmin, dmax); | 2501 dialog.getRange(newmin, newmax); |
2502 setTopLayerDisplayExtents(newmin, newmax); | |
2502 updateVerticalPanner(); | 2503 updateVerticalPanner(); |
2503 } | 2504 } |
2504 } | 2505 } |
2505 | 2506 |
2506 void | 2507 void |
2602 } | 2603 } |
2603 | 2604 |
2604 int p0 = getXForFrame(m_editingSelection.getStartFrame()) + offset; | 2605 int p0 = getXForFrame(m_editingSelection.getStartFrame()) + offset; |
2605 int p1 = getXForFrame(m_editingSelection.getEndFrame()) + offset; | 2606 int p1 = getXForFrame(m_editingSelection.getEndFrame()) + offset; |
2606 | 2607 |
2607 int f0 = getFrameForX(p0); | 2608 sv_frame_t f0 = getFrameForX(p0); |
2608 int f1 = getFrameForX(p1); | 2609 sv_frame_t f1 = getFrameForX(p1); |
2609 | 2610 |
2610 Selection newSelection(f0, f1); | 2611 Selection newSelection(f0, f1); |
2611 | 2612 |
2612 if (m_editingSelectionEdge == 0) { | 2613 if (m_editingSelectionEdge == 0) { |
2613 | 2614 |