Mercurial > hg > svgui
comparison view/Pane.cpp @ 806:4c8ca536b54f warnfix_no_size_t
Some more unsigned/long removal
author | Chris Cannam |
---|---|
date | Tue, 17 Jun 2014 15:36:56 +0100 |
parents | 410816717c2c |
children | 40c6c9344ff6 |
comparison
equal
deleted
inserted
replaced
805:1d526ba11a24 | 806:4c8ca536b54f |
---|---|
541 } | 541 } |
542 | 542 |
543 paint.end(); | 543 paint.end(); |
544 } | 544 } |
545 | 545 |
546 size_t | 546 int |
547 Pane::getVerticalScaleWidth() const | 547 Pane::getVerticalScaleWidth() const |
548 { | 548 { |
549 if (m_scaleWidth > 0) return m_scaleWidth; | 549 if (m_scaleWidth > 0) return m_scaleWidth; |
550 else return 0; | 550 else return 0; |
551 } | 551 } |
782 Pane::drawModelTimeExtents(QRect r, QPainter &paint, const Model *model) | 782 Pane::drawModelTimeExtents(QRect r, QPainter &paint, const Model *model) |
783 { | 783 { |
784 int x0 = getXForFrame(model->getStartFrame()); | 784 int x0 = getXForFrame(model->getStartFrame()); |
785 int x1 = getXForFrame(model->getEndFrame()); | 785 int x1 = getXForFrame(model->getEndFrame()); |
786 | 786 |
787 int lw = 10; | |
788 | |
789 paint.save(); | 787 paint.save(); |
790 | 788 |
791 QBrush brush; | 789 QBrush brush; |
792 | 790 |
793 if (hasLightBackground()) { | 791 if (hasLightBackground()) { |
936 llx -= 36; | 934 llx -= 36; |
937 } | 935 } |
938 | 936 |
939 if (r.x() + r.width() >= llx - fontAscent - 3) { | 937 if (r.x() + r.width() >= llx - fontAscent - 3) { |
940 | 938 |
941 for (size_t i = 0; i < texts.size(); ++i) { | 939 for (int i = 0; i < texts.size(); ++i) { |
942 | 940 |
943 // cerr << "Pane "<< this << ": text " << i << ": " << texts[i] << endl; | 941 // cerr << "Pane "<< this << ": text " << i << ": " << texts[i] << endl; |
944 | 942 |
945 if (i + 1 == texts.size()) { | 943 if (i + 1 == texts.size()) { |
946 paint.setPen(getForeground()); | 944 paint.setPen(getForeground()); |
964 void | 962 void |
965 Pane::drawEditingSelection(QPainter &paint) | 963 Pane::drawEditingSelection(QPainter &paint) |
966 { | 964 { |
967 int offset = m_mousePos.x() - m_clickPos.x(); | 965 int offset = m_mousePos.x() - m_clickPos.x(); |
968 | 966 |
969 long origStart = m_editingSelection.getStartFrame(); | 967 int origStart = m_editingSelection.getStartFrame(); |
970 | 968 |
971 int p0 = getXForFrame(origStart) + offset; | 969 int p0 = getXForFrame(origStart) + offset; |
972 int p1 = getXForFrame(m_editingSelection.getEndFrame()) + offset; | 970 int p1 = getXForFrame(m_editingSelection.getEndFrame()) + offset; |
973 | 971 |
974 if (m_editingSelectionEdge < 0) { | 972 if (m_editingSelectionEdge < 0) { |
975 p1 = getXForFrame(m_editingSelection.getEndFrame()); | 973 p1 = getXForFrame(m_editingSelection.getEndFrame()); |
976 } else if (m_editingSelectionEdge > 0) { | 974 } else if (m_editingSelectionEdge > 0) { |
977 p0 = getXForFrame(m_editingSelection.getStartFrame()); | 975 p0 = getXForFrame(m_editingSelection.getStartFrame()); |
978 } | 976 } |
979 | 977 |
980 long newStart = getFrameForX(p0); | 978 int newStart = getFrameForX(p0); |
981 long newEnd = getFrameForX(p1); | 979 int newEnd = getFrameForX(p1); |
982 | 980 |
983 paint.save(); | 981 paint.save(); |
984 paint.setPen(QPen(getForeground(), 2)); | 982 paint.setPen(QPen(getForeground(), 2)); |
985 | 983 |
986 int fontHeight = paint.fontMetrics().height(); | 984 int fontHeight = paint.fontMetrics().height(); |
1039 int fontHeight = paint.fontMetrics().height(); | 1037 int fontHeight = paint.fontMetrics().height(); |
1040 int fontAscent = paint.fontMetrics().ascent(); | 1038 int fontAscent = paint.fontMetrics().ascent(); |
1041 | 1039 |
1042 if (r.y() + r.height() < height() - fontHeight - 6) return; | 1040 if (r.y() + r.height() < height() - fontHeight - 6) return; |
1043 | 1041 |
1044 size_t modelRate = waveformModel->getSampleRate(); | 1042 int modelRate = waveformModel->getSampleRate(); |
1045 size_t nativeRate = waveformModel->getNativeRate(); | 1043 int nativeRate = waveformModel->getNativeRate(); |
1046 size_t playbackRate = m_manager->getPlaybackSampleRate(); | 1044 int playbackRate = m_manager->getPlaybackSampleRate(); |
1047 size_t outputRate = m_manager->getOutputSampleRate(); | 1045 int outputRate = m_manager->getOutputSampleRate(); |
1048 | 1046 |
1049 QString srNote = ""; | 1047 QString srNote = ""; |
1050 | 1048 |
1051 // Show (R) for waveform models that have been resampled or will | 1049 // Show (R) for waveform models that have been resampled or will |
1052 // be resampled on playback, and (X) for waveform models that will | 1050 // be resampled on playback, and (X) for waveform models that will |
1081 desc, OutlinedText); | 1079 desc, OutlinedText); |
1082 } | 1080 } |
1083 } | 1081 } |
1084 | 1082 |
1085 bool | 1083 bool |
1086 Pane::render(QPainter &paint, int xorigin, size_t f0, size_t f1) | 1084 Pane::render(QPainter &paint, int xorigin, int f0, int f1) |
1087 { | 1085 { |
1088 if (!View::render(paint, xorigin + m_scaleWidth, f0, f1)) { | 1086 if (!View::render(paint, xorigin + m_scaleWidth, f0, f1)) { |
1089 return false; | 1087 return false; |
1090 } | 1088 } |
1091 | 1089 |
1112 | 1110 |
1113 return true; | 1111 return true; |
1114 } | 1112 } |
1115 | 1113 |
1116 QImage * | 1114 QImage * |
1117 Pane::toNewImage(size_t f0, size_t f1) | 1115 Pane::toNewImage(int f0, int f1) |
1118 { | 1116 { |
1119 size_t x0 = f0 / getZoomLevel(); | 1117 int x0 = f0 / getZoomLevel(); |
1120 size_t x1 = f1 / getZoomLevel(); | 1118 int x1 = f1 / getZoomLevel(); |
1121 | 1119 |
1122 QImage *image = new QImage(x1 - x0 + m_scaleWidth, | 1120 QImage *image = new QImage(x1 - x0 + m_scaleWidth, |
1123 height(), QImage::Format_RGB32); | 1121 height(), QImage::Format_RGB32); |
1124 | 1122 |
1125 int formerScaleWidth = m_scaleWidth; | 1123 int formerScaleWidth = m_scaleWidth; |
1152 return image; | 1150 return image; |
1153 } | 1151 } |
1154 } | 1152 } |
1155 | 1153 |
1156 QSize | 1154 QSize |
1157 Pane::getImageSize(size_t f0, size_t f1) | 1155 Pane::getImageSize(int f0, int f1) |
1158 { | 1156 { |
1159 QSize s = View::getImageSize(f0, f1); | 1157 QSize s = View::getImageSize(f0, f1); |
1160 QImage *image = new QImage(100, 100, QImage::Format_RGB32); | 1158 QImage *image = new QImage(100, 100, QImage::Format_RGB32); |
1161 QPainter paint(image); | 1159 QPainter paint(image); |
1162 | 1160 |
1171 } | 1169 } |
1172 | 1170 |
1173 return QSize(sw + s.width(), s.height()); | 1171 return QSize(sw + s.width(), s.height()); |
1174 } | 1172 } |
1175 | 1173 |
1176 size_t | 1174 int |
1177 Pane::getFirstVisibleFrame() const | 1175 Pane::getFirstVisibleFrame() const |
1178 { | 1176 { |
1179 long f0 = getFrameForX(m_scaleWidth); | 1177 int f0 = getFrameForX(m_scaleWidth); |
1180 size_t f = View::getFirstVisibleFrame(); | 1178 int f = View::getFirstVisibleFrame(); |
1181 if (f0 < 0 || f0 < long(f)) return f; | 1179 if (f0 < 0 || f0 < long(f)) return f; |
1182 return f0; | 1180 return f0; |
1183 } | 1181 } |
1184 | 1182 |
1185 Selection | 1183 Selection |
1187 { | 1185 { |
1188 closeToLeftEdge = closeToRightEdge = false; | 1186 closeToLeftEdge = closeToRightEdge = false; |
1189 | 1187 |
1190 if (!m_manager) return Selection(); | 1188 if (!m_manager) return Selection(); |
1191 | 1189 |
1192 long testFrame = getFrameForX(x - 5); | 1190 int testFrame = getFrameForX(x - 5); |
1193 if (testFrame < 0) { | 1191 if (testFrame < 0) { |
1194 testFrame = getFrameForX(x); | 1192 testFrame = getFrameForX(x); |
1195 if (testFrame < 0) return Selection(); | 1193 if (testFrame < 0) return Selection(); |
1196 } | 1194 } |
1197 | 1195 |
1352 m_resizing = true; | 1350 m_resizing = true; |
1353 | 1351 |
1354 } else { | 1352 } else { |
1355 | 1353 |
1356 int mouseFrame = getFrameForX(e->x()); | 1354 int mouseFrame = getFrameForX(e->x()); |
1357 size_t resolution = 1; | 1355 int resolution = 1; |
1358 int snapFrame = mouseFrame; | 1356 int snapFrame = mouseFrame; |
1359 | 1357 |
1360 Layer *layer = getSelectedLayer(); | 1358 Layer *layer = getSelectedLayer(); |
1361 if (layer && !m_shiftPressed) { | 1359 if (layer && !m_shiftPressed) { |
1362 layer->snapToFeatureFrame(this, snapFrame, | 1360 layer->snapToFeatureFrame(this, snapFrame, |
1820 int x1 = r.x() + r.width(); | 1818 int x1 = r.x() + r.width(); |
1821 int y1 = r.y() + r.height(); | 1819 int y1 = r.y() + r.height(); |
1822 | 1820 |
1823 int w = x1 - x0; | 1821 int w = x1 - x0; |
1824 | 1822 |
1825 long newStartFrame = getFrameForX(x0); | 1823 int newStartFrame = getFrameForX(x0); |
1826 | 1824 |
1827 long visibleFrames = getEndFrame() - getStartFrame(); | 1825 int visibleFrames = getEndFrame() - getStartFrame(); |
1828 if (newStartFrame <= -visibleFrames) { | 1826 if (newStartFrame <= -visibleFrames) { |
1829 newStartFrame = -visibleFrames + 1; | 1827 newStartFrame = -visibleFrames + 1; |
1830 } | 1828 } |
1831 | 1829 |
1832 if (newStartFrame >= long(getModelsEndFrame())) { | 1830 if (newStartFrame >= long(getModelsEndFrame())) { |
1833 newStartFrame = getModelsEndFrame() - 1; | 1831 newStartFrame = getModelsEndFrame() - 1; |
1834 } | 1832 } |
1835 | 1833 |
1836 float ratio = float(w) / float(width()); | 1834 float ratio = float(w) / float(width()); |
1837 // cerr << "ratio: " << ratio << endl; | 1835 // cerr << "ratio: " << ratio << endl; |
1838 size_t newZoomLevel = (size_t)nearbyint(m_zoomLevel * ratio); | 1836 int newZoomLevel = (int)nearbyint(m_zoomLevel * ratio); |
1839 if (newZoomLevel < 1) newZoomLevel = 1; | 1837 if (newZoomLevel < 1) newZoomLevel = 1; |
1840 | 1838 |
1841 // cerr << "start: " << m_startFrame << ", level " << m_zoomLevel << endl; | 1839 // cerr << "start: " << m_startFrame << ", level " << m_zoomLevel << endl; |
1842 setZoomLevel(getZoomConstraintBlockSize(newZoomLevel)); | 1840 setZoomLevel(getZoomConstraintBlockSize(newZoomLevel)); |
1843 setStartFrame(newStartFrame); | 1841 setStartFrame(newStartFrame); |
1912 !(m_manager && m_manager->isPlaying())); // resist vert | 1910 !(m_manager && m_manager->isPlaying())); // resist vert |
1913 | 1911 |
1914 if (m_dragMode == HorizontalDrag || | 1912 if (m_dragMode == HorizontalDrag || |
1915 m_dragMode == FreeDrag) { | 1913 m_dragMode == FreeDrag) { |
1916 | 1914 |
1917 long frameOff = getFrameForX(e->x()) - getFrameForX(m_clickPos.x()); | 1915 int frameOff = getFrameForX(e->x()) - getFrameForX(m_clickPos.x()); |
1918 | 1916 int newCentreFrame = m_dragCentreFrame; |
1919 size_t newCentreFrame = m_dragCentreFrame; | |
1920 | 1917 |
1921 if (frameOff < 0) { | 1918 if (frameOff < 0) { |
1922 newCentreFrame -= frameOff; | 1919 newCentreFrame -= frameOff; |
1923 } else if (newCentreFrame >= size_t(frameOff)) { | 1920 } else if (newCentreFrame >= frameOff) { |
1924 newCentreFrame -= frameOff; | 1921 newCentreFrame -= frameOff; |
1925 } else { | 1922 } else { |
1926 newCentreFrame = 0; | 1923 newCentreFrame = 0; |
1927 } | 1924 } |
1928 | 1925 |
2040 | 2037 |
2041 void | 2038 void |
2042 Pane::dragExtendSelection(QMouseEvent *e) | 2039 Pane::dragExtendSelection(QMouseEvent *e) |
2043 { | 2040 { |
2044 int mouseFrame = getFrameForX(e->x()); | 2041 int mouseFrame = getFrameForX(e->x()); |
2045 size_t resolution = 1; | 2042 int resolution = 1; |
2046 int snapFrameLeft = mouseFrame; | 2043 int snapFrameLeft = mouseFrame; |
2047 int snapFrameRight = mouseFrame; | 2044 int snapFrameRight = mouseFrame; |
2048 | 2045 |
2049 Layer *layer = getSelectedLayer(); | 2046 Layer *layer = getSelectedLayer(); |
2050 if (layer && !m_shiftPressed) { | 2047 if (layer && !m_shiftPressed) { |
2057 // cerr << "snap: frame = " << mouseFrame << ", start frame = " << m_selectionStartFrame << ", left = " << snapFrameLeft << ", right = " << snapFrameRight << endl; | 2054 // cerr << "snap: frame = " << mouseFrame << ", start frame = " << m_selectionStartFrame << ", left = " << snapFrameLeft << ", right = " << snapFrameRight << endl; |
2058 | 2055 |
2059 if (snapFrameLeft < 0) snapFrameLeft = 0; | 2056 if (snapFrameLeft < 0) snapFrameLeft = 0; |
2060 if (snapFrameRight < 0) snapFrameRight = 0; | 2057 if (snapFrameRight < 0) snapFrameRight = 0; |
2061 | 2058 |
2062 size_t min, max; | 2059 int min, max; |
2063 | 2060 |
2064 if (m_selectionStartFrame > size_t(snapFrameLeft)) { | 2061 if (m_selectionStartFrame > snapFrameLeft) { |
2065 min = snapFrameLeft; | 2062 min = snapFrameLeft; |
2066 max = m_selectionStartFrame; | 2063 max = m_selectionStartFrame; |
2067 } else if (size_t(snapFrameRight) > m_selectionStartFrame) { | 2064 } else if (snapFrameRight > m_selectionStartFrame) { |
2068 min = m_selectionStartFrame; | 2065 min = m_selectionStartFrame; |
2069 max = snapFrameRight; | 2066 max = snapFrameRight; |
2070 } else { | 2067 } else { |
2071 min = snapFrameLeft; | 2068 min = snapFrameLeft; |
2072 max = snapFrameRight; | 2069 max = snapFrameRight; |
2153 update(); | 2150 update(); |
2154 } | 2151 } |
2155 | 2152 |
2156 if (relocate) { | 2153 if (relocate) { |
2157 | 2154 |
2158 long f = getFrameForX(e->x()); | 2155 int f = getFrameForX(e->x()); |
2159 | 2156 |
2160 setCentreFrame(f); | 2157 setCentreFrame(f); |
2161 | 2158 |
2162 m_dragCentreFrame = f; | 2159 m_dragCentreFrame = f; |
2163 m_dragStartMinValue = 0; | 2160 m_dragStartMinValue = 0; |
2224 // Scroll left or right, rapidly | 2221 // Scroll left or right, rapidly |
2225 | 2222 |
2226 if (getStartFrame() < 0 && | 2223 if (getStartFrame() < 0 && |
2227 getEndFrame() >= getModelsEndFrame()) return; | 2224 getEndFrame() >= getModelsEndFrame()) return; |
2228 | 2225 |
2229 long delta = ((width() / 2) * count * m_zoomLevel); | 2226 int delta = ((width() / 2) * count * m_zoomLevel); |
2230 | 2227 |
2231 if (int(m_centreFrame) < delta) { | 2228 if (m_centreFrame < delta) { |
2232 setCentreFrame(0); | 2229 setCentreFrame(0); |
2233 } else if (int(m_centreFrame) - delta >= int(getModelsEndFrame())) { | 2230 } else if (m_centreFrame - delta >= getModelsEndFrame()) { |
2234 setCentreFrame(getModelsEndFrame()); | 2231 setCentreFrame(getModelsEndFrame()); |
2235 } else { | 2232 } else { |
2236 setCentreFrame(m_centreFrame - delta); | 2233 setCentreFrame(m_centreFrame - delta); |
2237 } | 2234 } |
2238 | 2235 |
2353 updateVerticalPanner(); | 2350 updateVerticalPanner(); |
2354 } | 2351 } |
2355 } | 2352 } |
2356 | 2353 |
2357 void | 2354 void |
2358 Pane::verticalPannerMoved(float x0, float y0, float w, float h) | 2355 Pane::verticalPannerMoved(float , float y0, float , float h) |
2359 { | 2356 { |
2360 float vmin, vmax, dmin, dmax; | 2357 float vmin, vmax, dmin, dmax; |
2361 if (!getTopLayerDisplayExtents(vmin, vmax, dmin, dmax)) return; | 2358 if (!getTopLayerDisplayExtents(vmin, vmax, dmin, dmax)) return; |
2362 float y1 = y0 + h; | 2359 float y1 = y0 + h; |
2363 float newmax = vmin + ((1.0 - y0) * (vmax - vmin)); | 2360 float newmax = vmin + ((1.0 - y0) * (vmax - vmin)); |
2491 } | 2488 } |
2492 | 2489 |
2493 int p0 = getXForFrame(m_editingSelection.getStartFrame()) + offset; | 2490 int p0 = getXForFrame(m_editingSelection.getStartFrame()) + offset; |
2494 int p1 = getXForFrame(m_editingSelection.getEndFrame()) + offset; | 2491 int p1 = getXForFrame(m_editingSelection.getEndFrame()) + offset; |
2495 | 2492 |
2496 long f0 = getFrameForX(p0); | 2493 int f0 = getFrameForX(p0); |
2497 long f1 = getFrameForX(p1); | 2494 int f1 = getFrameForX(p1); |
2498 | 2495 |
2499 Selection newSelection(f0, f1); | 2496 Selection newSelection(f0, f1); |
2500 | 2497 |
2501 if (m_editingSelectionEdge == 0) { | 2498 if (m_editingSelectionEdge == 0) { |
2502 | 2499 |
2589 updateHeadsUpDisplay(); | 2586 updateHeadsUpDisplay(); |
2590 update(); | 2587 update(); |
2591 } | 2588 } |
2592 | 2589 |
2593 void | 2590 void |
2594 Pane::viewZoomLevelChanged(View *v, unsigned long z, bool locked) | 2591 Pane::viewZoomLevelChanged(View *v, int z, bool locked) |
2595 { | 2592 { |
2596 // cerr << "Pane[" << this << "]::zoomLevelChanged (global now " | 2593 // cerr << "Pane[" << this << "]::zoomLevelChanged (global now " |
2597 // << (m_manager ? m_manager->getGlobalZoom() : 0) << ")" << endl; | 2594 // << (m_manager ? m_manager->getGlobalZoom() : 0) << ")" << endl; |
2598 | 2595 |
2599 View::viewZoomLevelChanged(v, z, locked); | 2596 View::viewZoomLevelChanged(v, z, locked); |