Mercurial > hg > svgui
comparison view/Pane.cpp @ 1216:dc2af6616c83
Merge from branch 3.0-integration
author | Chris Cannam |
---|---|
date | Fri, 13 Jan 2017 10:29:50 +0000 |
parents | 0a13a1de1d7e |
children | 6f0d7aa25816 |
comparison
equal
deleted
inserted
replaced
1048:e8102ff5573b | 1216:dc2af6616c83 |
---|---|
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" |
29 #include "layer/PaintAssistant.h" | |
28 | 30 |
29 // GF: added so we can propagate the mouse move event to the note layer for context handling. | 31 // GF: added so we can propagate the mouse move event to the note layer for context handling. |
30 #include "layer/LayerFactory.h" | 32 #include "layer/LayerFactory.h" |
31 #include "layer/FlexiNoteLayer.h" | 33 #include "layer/FlexiNoteLayer.h" |
32 | 34 |
139 | 141 |
140 m_hthumb = new Thumbwheel(Qt::Horizontal); | 142 m_hthumb = new Thumbwheel(Qt::Horizontal); |
141 m_hthumb->setObjectName(tr("Horizontal Zoom")); | 143 m_hthumb->setObjectName(tr("Horizontal Zoom")); |
142 m_hthumb->setCursor(Qt::ArrowCursor); | 144 m_hthumb->setCursor(Qt::ArrowCursor); |
143 layout->addWidget(m_hthumb, 1, 0, 1, 2); | 145 layout->addWidget(m_hthumb, 1, 0, 1, 2); |
144 m_hthumb->setFixedWidth(70); | 146 m_hthumb->setFixedWidth(m_manager->scalePixelSize(70)); |
145 m_hthumb->setFixedHeight(16); | 147 m_hthumb->setFixedHeight(m_manager->scalePixelSize(16)); |
146 m_hthumb->setDefaultValue(0); | 148 m_hthumb->setDefaultValue(0); |
147 m_hthumb->setSpeed(0.6f); | 149 m_hthumb->setSpeed(0.6f); |
148 connect(m_hthumb, SIGNAL(valueChanged(int)), this, | 150 connect(m_hthumb, SIGNAL(valueChanged(int)), this, |
149 SLOT(horizontalThumbwheelMoved(int))); | 151 SLOT(horizontalThumbwheelMoved(int))); |
150 connect(m_hthumb, SIGNAL(mouseEntered()), this, SLOT(mouseEnteredWidget())); | 152 connect(m_hthumb, SIGNAL(mouseEntered()), this, SLOT(mouseEnteredWidget())); |
151 connect(m_hthumb, SIGNAL(mouseLeft()), this, SLOT(mouseLeftWidget())); | 153 connect(m_hthumb, SIGNAL(mouseLeft()), this, SLOT(mouseLeftWidget())); |
152 | 154 |
153 m_vpan = new Panner; | 155 m_vpan = new Panner; |
154 m_vpan->setCursor(Qt::ArrowCursor); | 156 m_vpan->setCursor(Qt::ArrowCursor); |
155 layout->addWidget(m_vpan, 0, 1); | 157 layout->addWidget(m_vpan, 0, 1); |
156 m_vpan->setFixedWidth(12); | 158 m_vpan->setFixedWidth(m_manager->scalePixelSize(12)); |
157 m_vpan->setFixedHeight(70); | 159 m_vpan->setFixedHeight(m_manager->scalePixelSize(70)); |
158 m_vpan->setAlpha(80, 130); | 160 m_vpan->setAlpha(80, 130); |
159 connect(m_vpan, SIGNAL(rectExtentsChanged(float, float, float, float)), | 161 connect(m_vpan, SIGNAL(rectExtentsChanged(float, float, float, float)), |
160 this, SLOT(verticalPannerMoved(float, float, float, float))); | 162 this, SLOT(verticalPannerMoved(float, float, float, float))); |
161 connect(m_vpan, SIGNAL(doubleClicked()), | 163 connect(m_vpan, SIGNAL(doubleClicked()), |
162 this, SLOT(editVerticalPannerExtents())); | 164 this, SLOT(editVerticalPannerExtents())); |
165 | 167 |
166 m_vthumb = new Thumbwheel(Qt::Vertical); | 168 m_vthumb = new Thumbwheel(Qt::Vertical); |
167 m_vthumb->setObjectName(tr("Vertical Zoom")); | 169 m_vthumb->setObjectName(tr("Vertical Zoom")); |
168 m_vthumb->setCursor(Qt::ArrowCursor); | 170 m_vthumb->setCursor(Qt::ArrowCursor); |
169 layout->addWidget(m_vthumb, 0, 2); | 171 layout->addWidget(m_vthumb, 0, 2); |
170 m_vthumb->setFixedWidth(16); | 172 m_vthumb->setFixedWidth(m_manager->scalePixelSize(16)); |
171 m_vthumb->setFixedHeight(70); | 173 m_vthumb->setFixedHeight(m_manager->scalePixelSize(70)); |
172 connect(m_vthumb, SIGNAL(valueChanged(int)), this, | 174 connect(m_vthumb, SIGNAL(valueChanged(int)), this, |
173 SLOT(verticalThumbwheelMoved(int))); | 175 SLOT(verticalThumbwheelMoved(int))); |
174 connect(m_vthumb, SIGNAL(mouseEntered()), this, SLOT(mouseEnteredWidget())); | 176 connect(m_vthumb, SIGNAL(mouseEntered()), this, SLOT(mouseEnteredWidget())); |
175 connect(m_vthumb, SIGNAL(mouseLeft()), this, SLOT(mouseLeftWidget())); | 177 connect(m_vthumb, SIGNAL(mouseLeft()), this, SLOT(mouseLeftWidget())); |
176 | 178 |
180 } | 182 } |
181 | 183 |
182 m_reset = new NotifyingPushButton; | 184 m_reset = new NotifyingPushButton; |
183 m_reset->setFlat(true); | 185 m_reset->setFlat(true); |
184 m_reset->setCursor(Qt::ArrowCursor); | 186 m_reset->setCursor(Qt::ArrowCursor); |
185 m_reset->setFixedHeight(16); | 187 m_reset->setFixedHeight(m_manager->scalePixelSize(16)); |
186 m_reset->setFixedWidth(16); | 188 m_reset->setFixedWidth(m_manager->scalePixelSize(16)); |
187 m_reset->setIcon(QPixmap(":/icons/zoom-reset.png")); | 189 m_reset->setIcon(IconLoader().load("zoom-reset")); |
188 m_reset->setToolTip(tr("Reset zoom to default")); | 190 m_reset->setToolTip(tr("Reset zoom to default")); |
189 layout->addWidget(m_reset, 1, 2); | 191 layout->addWidget(m_reset, 1, 2); |
190 | 192 |
191 layout->setColumnStretch(0, 20); | 193 layout->setColumnStretch(0, 20); |
192 | 194 |
281 } | 283 } |
282 | 284 |
283 updateVerticalPanner(); | 285 updateVerticalPanner(); |
284 | 286 |
285 if (m_manager && m_manager->getZoomWheelsEnabled() && | 287 if (m_manager && m_manager->getZoomWheelsEnabled() && |
286 width() > 120 && height() > 100) { | 288 width() > m_manager->scalePixelSize(120) && |
289 height() > m_manager->scalePixelSize(100)) { | |
287 if (!m_headsUpDisplay->isVisible()) { | 290 if (!m_headsUpDisplay->isVisible()) { |
288 m_headsUpDisplay->show(); | 291 m_headsUpDisplay->show(); |
289 } | 292 } |
293 int shift = m_manager->scalePixelSize(86); | |
290 if (haveVThumb) { | 294 if (haveVThumb) { |
291 m_headsUpDisplay->setFixedHeight(m_vthumb->height() + m_hthumb->height()); | 295 m_headsUpDisplay->setFixedHeight(m_vthumb->height() + m_hthumb->height()); |
292 m_headsUpDisplay->move(width() - 86, height() - 86); | 296 m_headsUpDisplay->move(width() - shift, height() - shift); |
293 } else { | 297 } else { |
294 m_headsUpDisplay->setFixedHeight(m_hthumb->height()); | 298 m_headsUpDisplay->setFixedHeight(m_hthumb->height()); |
295 m_headsUpDisplay->move(width() - 86, height() - 16); | 299 m_headsUpDisplay->move(width() - shift, |
300 height() - m_manager->scalePixelSize(16)); | |
296 } | 301 } |
297 } else { | 302 } else { |
298 m_headsUpDisplay->hide(); | 303 m_headsUpDisplay->hide(); |
299 } | 304 } |
300 } | 305 } |
715 } | 720 } |
716 | 721 |
717 void | 722 void |
718 Pane::drawCentreLine(sv_samplerate_t sampleRate, QPainter &paint, bool omitLine) | 723 Pane::drawCentreLine(sv_samplerate_t sampleRate, QPainter &paint, bool omitLine) |
719 { | 724 { |
725 if (omitLine && m_manager->getMainModelSampleRate() == 0) { | |
726 return; | |
727 } | |
728 | |
720 int fontHeight = paint.fontMetrics().height(); | 729 int fontHeight = paint.fontMetrics().height(); |
721 int fontAscent = paint.fontMetrics().ascent(); | 730 int fontAscent = paint.fontMetrics().ascent(); |
722 | 731 |
723 QColor c = QColor(0, 0, 0); | 732 QColor c = QColor(0, 0, 0); |
724 if (!hasLightBackground()) { | 733 if (!hasLightBackground()) { |
771 .toText(true))); | 780 .toText(true))); |
772 | 781 |
773 int tw = paint.fontMetrics().width(text); | 782 int tw = paint.fontMetrics().width(text); |
774 int x = width()/2 - 4 - tw; | 783 int x = width()/2 - 4 - tw; |
775 | 784 |
776 drawVisibleText(paint, x, y, text, OutlinedText); | 785 PaintAssistant::drawVisibleText(this, paint, x, y, text, PaintAssistant::OutlinedText); |
777 } | 786 } |
778 | 787 |
779 QString text = QString("%1").arg(m_centreFrame); | 788 QString text = QString("%1").arg(m_centreFrame); |
780 | 789 |
781 int x = width()/2 + 4; | 790 int x = width()/2 + 4; |
782 | 791 |
783 drawVisibleText(paint, x, y, text, OutlinedText); | 792 PaintAssistant::drawVisibleText(this, paint, x, y, text, PaintAssistant::OutlinedText); |
784 } | 793 } |
785 } | 794 } |
786 | 795 |
787 void | 796 void |
788 Pane::drawModelTimeExtents(QRect r, QPainter &paint, const Model *model) | 797 Pane::drawModelTimeExtents(QRect r, QPainter &paint, const Model *model) |
860 if (r.top() > h + y || r.left() > w + m_scaleWidth + 5) { | 869 if (r.top() > h + y || r.left() > w + m_scaleWidth + 5) { |
861 paint.restore(); | 870 paint.restore(); |
862 return; | 871 return; |
863 } | 872 } |
864 | 873 |
865 drawVisibleText(paint, m_scaleWidth + 5, | 874 PaintAssistant::drawVisibleText(this, paint, m_scaleWidth + 5, |
866 paint.fontMetrics().ascent() + y, text, OutlinedText); | 875 paint.fontMetrics().ascent() + y, text, PaintAssistant::OutlinedText); |
867 | 876 |
868 paint.restore(); | 877 paint.restore(); |
869 } | 878 } |
870 | 879 |
871 void | 880 void |
899 if (r.top() > h + y || r.left() > w + m_scaleWidth + 5) { | 908 if (r.top() > h + y || r.left() > w + m_scaleWidth + 5) { |
900 paint.restore(); | 909 paint.restore(); |
901 return; | 910 return; |
902 } | 911 } |
903 | 912 |
904 drawVisibleText(paint, m_scaleWidth + 5, | 913 PaintAssistant::drawVisibleText(this, paint, m_scaleWidth + 5, |
905 paint.fontMetrics().ascent() + y, text, OutlinedText); | 914 paint.fontMetrics().ascent() + y, text, PaintAssistant::OutlinedText); |
906 | 915 |
907 paint.restore(); | 916 paint.restore(); |
908 } | 917 } |
909 | 918 |
910 void | 919 void |
913 int fontHeight = paint.fontMetrics().height(); | 922 int fontHeight = paint.fontMetrics().height(); |
914 int fontAscent = paint.fontMetrics().ascent(); | 923 int fontAscent = paint.fontMetrics().ascent(); |
915 | 924 |
916 int lly = height() - 6; | 925 int lly = height() - 6; |
917 if (m_manager->getZoomWheelsEnabled()) { | 926 if (m_manager->getZoomWheelsEnabled()) { |
918 lly -= 20; | 927 lly -= m_manager->scalePixelSize(20); |
919 } | 928 } |
920 | 929 |
921 if (r.y() + r.height() < lly - int(m_layerStack.size()) * fontHeight) { | 930 if (r.y() + r.height() < lly - int(m_layerStack.size()) * fontHeight) { |
922 return; | 931 return; |
923 } | 932 } |
935 int maxTextWidth = width() / 3; | 944 int maxTextWidth = width() / 3; |
936 texts = TextAbbrev::abbreviate(texts, paint.fontMetrics(), maxTextWidth); | 945 texts = TextAbbrev::abbreviate(texts, paint.fontMetrics(), maxTextWidth); |
937 | 946 |
938 int llx = width() - maxTextWidth - 5; | 947 int llx = width() - maxTextWidth - 5; |
939 if (m_manager->getZoomWheelsEnabled()) { | 948 if (m_manager->getZoomWheelsEnabled()) { |
940 llx -= 36; | 949 llx -= m_manager->scalePixelSize(36); |
941 } | 950 } |
942 | 951 |
943 if (r.x() + r.width() >= llx - fontAscent - 3) { | 952 if (r.x() + r.width() >= llx - fontAscent - 3) { |
944 | 953 |
945 for (int i = 0; i < texts.size(); ++i) { | 954 for (int i = 0; i < texts.size(); ++i) { |
948 | 957 |
949 if (i + 1 == texts.size()) { | 958 if (i + 1 == texts.size()) { |
950 paint.setPen(getForeground()); | 959 paint.setPen(getForeground()); |
951 } | 960 } |
952 | 961 |
953 drawVisibleText(paint, llx, | 962 PaintAssistant::drawVisibleText(this, paint, llx, |
954 lly - fontHeight + fontAscent, | 963 lly - fontHeight + fontAscent, |
955 texts[i], OutlinedText); | 964 texts[i], PaintAssistant::OutlinedText); |
956 | 965 |
957 if (!pixmaps[i].isNull()) { | 966 if (!pixmaps[i].isNull()) { |
958 paint.drawPixmap(llx - fontAscent - 3, | 967 paint.drawPixmap(llx - fontAscent - 3, |
959 lly - fontHeight + (fontHeight-fontAscent)/2, | 968 lly - fontHeight + (fontHeight-fontAscent)/2, |
960 pixmaps[i]); | 969 pixmaps[i]); |
1012 .arg(offsetText); | 1021 .arg(offsetText); |
1013 if (newStart >= origStart) { | 1022 if (newStart >= origStart) { |
1014 offsetText = tr("+%1").arg(offsetText); | 1023 offsetText = tr("+%1").arg(offsetText); |
1015 } | 1024 } |
1016 } | 1025 } |
1017 drawVisibleText(paint, p0 + 2, fontAscent + fontHeight + 4, startText, OutlinedText); | 1026 PaintAssistant::drawVisibleText(this, paint, p0 + 2, fontAscent + fontHeight + 4, startText, PaintAssistant::OutlinedText); |
1018 drawVisibleText(paint, p1 + 2, fontAscent + fontHeight + 4, endText, OutlinedText); | 1027 PaintAssistant::drawVisibleText(this, paint, p1 + 2, fontAscent + fontHeight + 4, endText, PaintAssistant::OutlinedText); |
1019 drawVisibleText(paint, p0 + 2, fontAscent + fontHeight*2 + 4, offsetText, OutlinedText); | 1028 PaintAssistant::drawVisibleText(this, paint, p0 + 2, fontAscent + fontHeight*2 + 4, offsetText, PaintAssistant::OutlinedText); |
1020 drawVisibleText(paint, p1 + 2, fontAscent + fontHeight*2 + 4, offsetText, OutlinedText); | 1029 PaintAssistant::drawVisibleText(this, paint, p1 + 2, fontAscent + fontHeight*2 + 4, offsetText, PaintAssistant::OutlinedText); |
1021 | 1030 |
1022 //!!! duplicating display policy with View::drawSelections | 1031 //!!! duplicating display policy with View::drawSelections |
1023 | 1032 |
1024 if (m_editingSelectionEdge < 0) { | 1033 if (m_editingSelectionEdge < 0) { |
1025 paint.drawLine(p0, 1, p1, 1); | 1034 paint.drawLine(p0, 1, p1, 1); |
1046 if (r.y() + r.height() < height() - fontHeight - 6) return; | 1055 if (r.y() + r.height() < height() - fontHeight - 6) return; |
1047 | 1056 |
1048 sv_samplerate_t modelRate = waveformModel->getSampleRate(); | 1057 sv_samplerate_t modelRate = waveformModel->getSampleRate(); |
1049 sv_samplerate_t nativeRate = waveformModel->getNativeRate(); | 1058 sv_samplerate_t nativeRate = waveformModel->getNativeRate(); |
1050 sv_samplerate_t playbackRate = m_manager->getPlaybackSampleRate(); | 1059 sv_samplerate_t playbackRate = m_manager->getPlaybackSampleRate(); |
1051 sv_samplerate_t outputRate = m_manager->getOutputSampleRate(); | |
1052 | 1060 |
1053 QString srNote = ""; | 1061 QString srNote = ""; |
1054 | 1062 |
1055 // Show (R) for waveform models that have been resampled or will | 1063 // Show (R) for waveform models that have been resampled during |
1056 // be resampled on playback, and (X) for waveform models that will | 1064 // load, and (X) for waveform models that will be played at the |
1057 // be played at the wrong rate because their rate differs from the | 1065 // wrong rate because their rate differs from the current playback |
1058 // current playback rate (which is not necessarily that of the | 1066 // rate (which is not necessarily that of the main model). |
1059 // main model). | 1067 |
1060 | 1068 if (modelRate != nativeRate) { |
1061 if (playbackRate != 0) { | 1069 if (playbackRate != 0 && modelRate != playbackRate) { |
1062 if (modelRate == playbackRate) { | |
1063 if (modelRate != outputRate || modelRate != nativeRate) { | |
1064 srNote = " " + tr("(R)"); | |
1065 } | |
1066 } else { | |
1067 srNote = " " + tr("(X)"); | 1070 srNote = " " + tr("(X)"); |
1071 } else { | |
1072 srNote = " " + tr("(R)"); | |
1068 } | 1073 } |
1069 } | 1074 } |
1070 | 1075 |
1071 QString desc = tr("%1 / %2Hz%3") | 1076 QString desc = tr("%1 / %2Hz%3") |
1072 .arg(RealTime::frame2RealTime(waveformModel->getEndFrame(), | 1077 .arg(RealTime::frame2RealTime(waveformModel->getEndFrame(), |
1078 int x = m_scaleWidth + 5; | 1083 int x = m_scaleWidth + 5; |
1079 int pbw = getProgressBarWidth(); | 1084 int pbw = getProgressBarWidth(); |
1080 if (x < pbw + 5) x = pbw + 5; | 1085 if (x < pbw + 5) x = pbw + 5; |
1081 | 1086 |
1082 if (r.x() < x + paint.fontMetrics().width(desc)) { | 1087 if (r.x() < x + paint.fontMetrics().width(desc)) { |
1083 drawVisibleText(paint, x, | 1088 PaintAssistant::drawVisibleText(this, paint, x, |
1084 height() - fontHeight + fontAscent - 6, | 1089 height() - fontHeight + fontAscent - 6, |
1085 desc, OutlinedText); | 1090 desc, PaintAssistant::OutlinedText); |
1086 } | 1091 } |
1087 } | 1092 } |
1088 | 1093 |
1089 bool | 1094 bool |
1090 Pane::render(QPainter &paint, int xorigin, sv_frame_t f0, sv_frame_t f1) | 1095 Pane::render(QPainter &paint, int xorigin, sv_frame_t f0, sv_frame_t f1) |
1116 | 1121 |
1117 return true; | 1122 return true; |
1118 } | 1123 } |
1119 | 1124 |
1120 QImage * | 1125 QImage * |
1121 Pane::toNewImage(sv_frame_t f0, sv_frame_t f1) | 1126 Pane::renderPartToNewImage(sv_frame_t f0, sv_frame_t f1) |
1122 { | 1127 { |
1123 int x0 = int(f0 / getZoomLevel()); | 1128 int x0 = int(f0 / getZoomLevel()); |
1124 int x1 = int(f1 / getZoomLevel()); | 1129 int x1 = int(f1 / getZoomLevel()); |
1125 | 1130 |
1126 QImage *image = new QImage(x1 - x0 + m_scaleWidth, | 1131 QImage *image = new QImage(x1 - x0 + m_scaleWidth, |
1155 return image; | 1160 return image; |
1156 } | 1161 } |
1157 } | 1162 } |
1158 | 1163 |
1159 QSize | 1164 QSize |
1160 Pane::getImageSize(sv_frame_t f0, sv_frame_t f1) | 1165 Pane::getRenderedPartImageSize(sv_frame_t f0, sv_frame_t f1) |
1161 { | 1166 { |
1162 QSize s = View::getImageSize(f0, f1); | 1167 QSize s = View::getRenderedPartImageSize(f0, f1); |
1163 QImage *image = new QImage(100, 100, QImage::Format_RGB32); | 1168 QImage *image = new QImage(100, 100, QImage::Format_RGB32); |
1164 QPainter paint(image); | 1169 QPainter paint(image); |
1165 | 1170 |
1166 int sw = 0; | 1171 int sw = 0; |
1167 if (m_manager && m_manager->shouldShowVerticalScale()) { | 1172 if (m_manager && m_manager->shouldShowVerticalScale()) { |
1941 m_clickPos, | 1946 m_clickPos, |
1942 e->pos(), | 1947 e->pos(), |
1943 true, // can move horiz | 1948 true, // can move horiz |
1944 canTopLayerMoveVertical(), // can move vert | 1949 canTopLayerMoveVertical(), // can move vert |
1945 canTopLayerMoveVertical() || (m_manager && m_manager->isPlaying()), // resist horiz | 1950 canTopLayerMoveVertical() || (m_manager && m_manager->isPlaying()), // resist horiz |
1946 !(m_manager && m_manager->isPlaying())); // resist vert | 1951 true); // resist vert |
1947 | 1952 |
1948 if (m_dragMode == HorizontalDrag || | 1953 if (m_dragMode == HorizontalDrag || |
1949 m_dragMode == FreeDrag) { | 1954 m_dragMode == FreeDrag) { |
1950 | 1955 |
1951 sv_frame_t frameOff = getFrameForX(e->x()) - getFrameForX(m_clickPos.x()); | 1956 sv_frame_t frameOff = getFrameForX(e->x()) - getFrameForX(m_clickPos.x()); |
2262 } | 2267 } |
2263 | 2268 |
2264 void | 2269 void |
2265 Pane::wheelEvent(QWheelEvent *e) | 2270 Pane::wheelEvent(QWheelEvent *e) |
2266 { | 2271 { |
2267 cerr << "wheelEvent, delta " << e->delta() << ", angleDelta " << e->angleDelta().x() << "," << e->angleDelta().y() << ", pixelDelta " << e->pixelDelta().x() << "," << e->pixelDelta().y() << ", modifiers " << e->modifiers() << endl; | 2272 // cerr << "wheelEvent, delta " << e->delta() << ", angleDelta " << e->angleDelta().x() << "," << e->angleDelta().y() << ", pixelDelta " << e->pixelDelta().x() << "," << e->pixelDelta().y() << ", modifiers " << e->modifiers() << endl; |
2268 | 2273 |
2274 e->accept(); // we never want wheel events on the pane to be propagated | |
2275 | |
2269 int dx = e->angleDelta().x(); | 2276 int dx = e->angleDelta().x(); |
2270 int dy = e->angleDelta().y(); | 2277 int dy = e->angleDelta().y(); |
2271 | 2278 |
2272 if (dx == 0 && dy == 0) { | 2279 if (dx == 0 && dy == 0) { |
2273 return; | 2280 return; |
2283 // treat a vertical wheel as horizontal | 2290 // treat a vertical wheel as horizontal |
2284 horizontal = true; | 2291 horizontal = true; |
2285 } | 2292 } |
2286 | 2293 |
2287 if (e->phase() == Qt::ScrollBegin || | 2294 if (e->phase() == Qt::ScrollBegin || |
2288 fabs(d) >= 120 || | 2295 std::abs(d) >= 120 || |
2289 (d > 0 && m_pendingWheelAngle < 0) || | 2296 (d > 0 && m_pendingWheelAngle < 0) || |
2290 (d < 0 && m_pendingWheelAngle > 0)) { | 2297 (d < 0 && m_pendingWheelAngle > 0)) { |
2291 m_pendingWheelAngle = d; | 2298 m_pendingWheelAngle = d; |
2292 } else { | 2299 } else { |
2293 m_pendingWheelAngle += d; | 2300 m_pendingWheelAngle += d; |
2310 // the first wheel event -- discard those entirely | 2317 // the first wheel event -- discard those entirely |
2311 if (abs(m_pendingWheelAngle) >= 600) { | 2318 if (abs(m_pendingWheelAngle) >= 600) { |
2312 m_pendingWheelAngle = 0; | 2319 m_pendingWheelAngle = 0; |
2313 return; | 2320 return; |
2314 } | 2321 } |
2315 | 2322 |
2316 while (abs(m_pendingWheelAngle) >= 120) { | 2323 while (abs(m_pendingWheelAngle) >= 120) { |
2317 | 2324 |
2318 int sign = (m_pendingWheelAngle < 0 ? -1 : 1); | 2325 int sign = (m_pendingWheelAngle < 0 ? -1 : 1); |
2319 | 2326 |
2320 if (horizontal) { | 2327 if (horizontal) { |
2329 } | 2336 } |
2330 | 2337 |
2331 void | 2338 void |
2332 Pane::wheelVertical(int sign, Qt::KeyboardModifiers mods) | 2339 Pane::wheelVertical(int sign, Qt::KeyboardModifiers mods) |
2333 { | 2340 { |
2334 cerr << "wheelVertical: sign = " << sign << endl; | 2341 // cerr << "wheelVertical: sign = " << sign << endl; |
2335 | 2342 |
2336 if (mods & Qt::ShiftModifier) { | 2343 if (mods & Qt::ShiftModifier) { |
2337 | 2344 |
2338 // Pan vertically | 2345 // Pan vertically |
2339 | 2346 |
2376 } | 2383 } |
2377 | 2384 |
2378 void | 2385 void |
2379 Pane::wheelHorizontal(int sign, Qt::KeyboardModifiers mods) | 2386 Pane::wheelHorizontal(int sign, Qt::KeyboardModifiers mods) |
2380 { | 2387 { |
2381 cerr << "wheelHorizontal: sign = " << sign << endl; | 2388 // cerr << "wheelHorizontal: sign = " << sign << endl; |
2382 | 2389 |
2383 // Scroll left or right, rapidly | 2390 // Scroll left or right, rapidly |
2384 | 2391 |
2385 wheelHorizontalFine((width() / 4) * sign, mods); | 2392 wheelHorizontalFine((width() / 4) * sign, mods); |
2386 } | 2393 } |
2387 | 2394 |
2388 void | 2395 void |
2389 Pane::wheelHorizontalFine(int pixels, Qt::KeyboardModifiers) | 2396 Pane::wheelHorizontalFine(int pixels, Qt::KeyboardModifiers) |
2390 { | 2397 { |
2391 cerr << "wheelHorizontalFine: pixels = " << pixels << endl; | 2398 // cerr << "wheelHorizontalFine: pixels = " << pixels << endl; |
2392 | 2399 |
2393 // Scroll left or right by a fixed number of pixels | 2400 // Scroll left or right by a fixed number of pixels |
2394 | 2401 |
2395 if (getStartFrame() < 0 && | 2402 if (getStartFrame() < 0 && |
2396 getEndFrame() >= getModelsEndFrame()) return; | 2403 getEndFrame() >= getModelsEndFrame()) return; |