Mercurial > hg > svgui
comparison view/Pane.cpp @ 1203:ff042979331b 3.0-integration
Merge from branch svg, and thus (in some subrepos) from levelpanwidget
author | Chris Cannam |
---|---|
date | Mon, 19 Dec 2016 16:34:38 +0000 |
parents | 6828735468c9 |
children | f91cf4a60ad6 |
comparison
equal
deleted
inserted
replaced
1185:f32828ea63d9 | 1203:ff042979331b |
---|---|
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 } |
918 int fontHeight = paint.fontMetrics().height(); | 922 int fontHeight = paint.fontMetrics().height(); |
919 int fontAscent = paint.fontMetrics().ascent(); | 923 int fontAscent = paint.fontMetrics().ascent(); |
920 | 924 |
921 int lly = height() - 6; | 925 int lly = height() - 6; |
922 if (m_manager->getZoomWheelsEnabled()) { | 926 if (m_manager->getZoomWheelsEnabled()) { |
923 lly -= 20; | 927 lly -= m_manager->scalePixelSize(20); |
924 } | 928 } |
925 | 929 |
926 if (r.y() + r.height() < lly - int(m_layerStack.size()) * fontHeight) { | 930 if (r.y() + r.height() < lly - int(m_layerStack.size()) * fontHeight) { |
927 return; | 931 return; |
928 } | 932 } |
940 int maxTextWidth = width() / 3; | 944 int maxTextWidth = width() / 3; |
941 texts = TextAbbrev::abbreviate(texts, paint.fontMetrics(), maxTextWidth); | 945 texts = TextAbbrev::abbreviate(texts, paint.fontMetrics(), maxTextWidth); |
942 | 946 |
943 int llx = width() - maxTextWidth - 5; | 947 int llx = width() - maxTextWidth - 5; |
944 if (m_manager->getZoomWheelsEnabled()) { | 948 if (m_manager->getZoomWheelsEnabled()) { |
945 llx -= 36; | 949 llx -= m_manager->scalePixelSize(36); |
946 } | 950 } |
947 | 951 |
948 if (r.x() + r.width() >= llx - fontAscent - 3) { | 952 if (r.x() + r.width() >= llx - fontAscent - 3) { |
949 | 953 |
950 for (int i = 0; i < texts.size(); ++i) { | 954 for (int i = 0; i < texts.size(); ++i) { |
1117 | 1121 |
1118 return true; | 1122 return true; |
1119 } | 1123 } |
1120 | 1124 |
1121 QImage * | 1125 QImage * |
1122 Pane::toNewImage(sv_frame_t f0, sv_frame_t f1) | 1126 Pane::renderPartToNewImage(sv_frame_t f0, sv_frame_t f1) |
1123 { | 1127 { |
1124 int x0 = int(f0 / getZoomLevel()); | 1128 int x0 = int(f0 / getZoomLevel()); |
1125 int x1 = int(f1 / getZoomLevel()); | 1129 int x1 = int(f1 / getZoomLevel()); |
1126 | 1130 |
1127 QImage *image = new QImage(x1 - x0 + m_scaleWidth, | 1131 QImage *image = new QImage(x1 - x0 + m_scaleWidth, |
1156 return image; | 1160 return image; |
1157 } | 1161 } |
1158 } | 1162 } |
1159 | 1163 |
1160 QSize | 1164 QSize |
1161 Pane::getImageSize(sv_frame_t f0, sv_frame_t f1) | 1165 Pane::getRenderedPartImageSize(sv_frame_t f0, sv_frame_t f1) |
1162 { | 1166 { |
1163 QSize s = View::getImageSize(f0, f1); | 1167 QSize s = View::getRenderedPartImageSize(f0, f1); |
1164 QImage *image = new QImage(100, 100, QImage::Format_RGB32); | 1168 QImage *image = new QImage(100, 100, QImage::Format_RGB32); |
1165 QPainter paint(image); | 1169 QPainter paint(image); |
1166 | 1170 |
1167 int sw = 0; | 1171 int sw = 0; |
1168 if (m_manager && m_manager->shouldShowVerticalScale()) { | 1172 if (m_manager && m_manager->shouldShowVerticalScale()) { |