comparison base/View.cpp @ 34:aaf73f7309f2

* Add "Export Audio File" option * Make note layer align in frequency with any spectrogram layer on the same view (if it's set to frequency mode) * Start to implement mouse editing for ranges of points by dragging the selection * First scrappy attempt at a vertical scale for time value layer
author Chris Cannam
date Mon, 27 Feb 2006 17:34:41 +0000
parents 51e158b505da
children 935a2419a77c
comparison
equal deleted inserted replaced
33:51e158b505da 34:aaf73f7309f2
1009 i != nonScrollables.end(); ++i) { 1009 i != nonScrollables.end(); ++i) {
1010 if ((*i)->isLayerOpaque()) { 1010 if ((*i)->isLayerOpaque()) {
1011 selectionCacheable = false; 1011 selectionCacheable = false;
1012 break; 1012 break;
1013 } 1013 }
1014 }
1015 }
1016
1017 if (selectionCacheable) {
1018 QPoint localPos;
1019 bool closeToLeft, closeToRight;
1020 if (shouldIlluminateLocalSelection(localPos, closeToLeft, closeToRight)) {
1021 selectionCacheable = false;
1014 } 1022 }
1015 } 1023 }
1016 1024
1017 #ifdef DEBUG_VIEW_WIDGET_PAINT 1025 #ifdef DEBUG_VIEW_WIDGET_PAINT
1018 std::cerr << "View(" << this << ")::paintEvent: have " << scrollables.size() 1026 std::cerr << "View(" << this << ")::paintEvent: have " << scrollables.size()
1235 selections.insert(inProgressSelection); 1243 selections.insert(inProgressSelection);
1236 } 1244 }
1237 } 1245 }
1238 1246
1239 paint.save(); 1247 paint.save();
1240 paint.setPen(QColor(150, 150, 255));
1241 paint.setBrush(QColor(150, 150, 255, 80)); 1248 paint.setBrush(QColor(150, 150, 255, 80));
1242 1249
1243 int sampleRate = getModelsSampleRate(); 1250 int sampleRate = getModelsSampleRate();
1251
1252 QPoint localPos;
1253 long illuminateFrame = -1;
1254 bool closeToLeft, closeToRight;
1255
1256 if (shouldIlluminateLocalSelection(localPos, closeToLeft, closeToRight)) {
1257 illuminateFrame = getFrameForX(localPos.x());
1258 }
1244 1259
1245 const QFontMetrics &metrics = paint.fontMetrics(); 1260 const QFontMetrics &metrics = paint.fontMetrics();
1246 1261
1247 for (MultiSelection::SelectionList::iterator i = selections.begin(); 1262 for (MultiSelection::SelectionList::iterator i = selections.begin();
1248 i != selections.end(); ++i) { 1263 i != selections.end(); ++i) {
1254 1269
1255 #ifdef DEBUG_VIEW_WIDGET_PAINT 1270 #ifdef DEBUG_VIEW_WIDGET_PAINT
1256 std::cerr << "View::drawSelections: " << p0 << ",-1 [" << (p1-p0) << "x" << (height()+1) << "]" << std::endl; 1271 std::cerr << "View::drawSelections: " << p0 << ",-1 [" << (p1-p0) << "x" << (height()+1) << "]" << std::endl;
1257 #endif 1272 #endif
1258 1273
1274 bool illuminateThis =
1275 (illuminateFrame >= 0 && i->contains(illuminateFrame));
1276
1277 paint.setPen(QColor(150, 150, 255));
1259 paint.drawRect(p0, -1, p1 - p0, height() + 1); 1278 paint.drawRect(p0, -1, p1 - p0, height() + 1);
1279
1280 if (illuminateThis) {
1281 paint.save();
1282 if (hasLightBackground()) {
1283 paint.setPen(QPen(Qt::black, 2));
1284 } else {
1285 paint.setPen(QPen(Qt::white, 2));
1286 }
1287 if (closeToLeft) {
1288 paint.drawLine(p0, 1, p1, 1);
1289 paint.drawLine(p0, 0, p0, height());
1290 paint.drawLine(p0, height() - 1, p1, height() - 1);
1291 } else if (closeToRight) {
1292 paint.drawLine(p0, 1, p1, 1);
1293 paint.drawLine(p1, 0, p1, height());
1294 paint.drawLine(p0, height() - 1, p1, height() - 1);
1295 } else {
1296 paint.setBrush(Qt::NoBrush);
1297 paint.drawRect(p0, 1, p1 - p0, height() - 2);
1298 }
1299 paint.restore();
1300 }
1260 1301
1261 if (sampleRate && shouldLabelSelections()) { 1302 if (sampleRate && shouldLabelSelections()) {
1262 1303
1263 QString startText = QString("%1 / %2") 1304 QString startText = QString("%1 / %2")
1264 .arg(QString::fromStdString 1305 .arg(QString::fromStdString