comparison layer/TimeValueLayer.cpp @ 631:f69e08be3379

Make mouseover highlights a bit more likely to appear and easier to see
author Chris Cannam
date Tue, 16 Apr 2013 14:25:22 +0100
parents c3593bb2de6b
children 9d8f6552014d
comparison
equal deleted inserted replaced
630:c3593bb2de6b 631:f69e08be3379
515 515
516 SparseTimeValueModel::PointList usePoints = prevPoints; 516 SparseTimeValueModel::PointList usePoints = prevPoints;
517 517
518 if (prevPoints.empty()) { 518 if (prevPoints.empty()) {
519 usePoints = nextPoints; 519 usePoints = nextPoints;
520 } else if (nextPoints.empty()) {
521 // stick with prevPoints
520 } else if (long(prevPoints.begin()->frame) < v->getStartFrame() && 522 } else if (long(prevPoints.begin()->frame) < v->getStartFrame() &&
521 !(nextPoints.begin()->frame > v->getEndFrame())) { 523 !(nextPoints.begin()->frame > v->getEndFrame())) {
522 usePoints = nextPoints; 524 usePoints = nextPoints;
523 } else if (nextPoints.begin()->frame - frame < 525 } else if (nextPoints.begin()->frame - frame <
524 frame - prevPoints.begin()->frame) { 526 frame - prevPoints.begin()->frame) {
527 529
528 if (!usePoints.empty()) { 530 if (!usePoints.empty()) {
529 int fuzz = 2; 531 int fuzz = 2;
530 int px = v->getXForFrame(usePoints.begin()->frame); 532 int px = v->getXForFrame(usePoints.begin()->frame);
531 if ((px > x && px - x > fuzz) || 533 if ((px > x && px - x > fuzz) ||
532 (px < x && x - px > fuzz + 1)) { 534 (px < x && x - px > fuzz + 3)) {
533 usePoints.clear(); 535 usePoints.clear();
534 } 536 }
535 } 537 }
536 538
537 return usePoints; 539 return usePoints;
968 (p.frame - prevFrame >= m_model->getResolution() * 2)); 970 (p.frame - prevFrame >= m_model->getResolution() * 2));
969 } 971 }
970 972
971 if (m_plotStyle != PlotSegmentation) { 973 if (m_plotStyle != PlotSegmentation) {
972 textY = y - paint.fontMetrics().height() 974 textY = y - paint.fontMetrics().height()
973 + paint.fontMetrics().ascent(); 975 + paint.fontMetrics().ascent() - 1;
974 if (textY < paint.fontMetrics().ascent() + 1) { 976 if (textY < paint.fontMetrics().ascent() + 1) {
975 textY = paint.fontMetrics().ascent() + 1; 977 textY = paint.fontMetrics().ascent() + 1;
976 } 978 }
977 } 979 }
978 980
1027 } else if (y > origin + 1) { 1029 } else if (y > origin + 1) {
1028 paint.drawLine(x + w/2, origin, x + w/2, y - 1); 1030 paint.drawLine(x + w/2, origin, x + w/2, y - 1);
1029 } 1031 }
1030 } 1032 }
1031 1033
1034 bool illuminate = false;
1035
1032 if (illuminateFrame == p.frame) { 1036 if (illuminateFrame == p.frame) {
1033 1037
1034 //!!! aside from the problem of choosing a colour, it'd be 1038 // not equipped to illuminate the right section in line
1035 //better to save the highlighted rects and draw them at 1039 // or curve mode
1036 //the end perhaps
1037
1038 //!!! not equipped to illuminate the right section in line
1039 //or curve mode
1040 1040
1041 if (m_plotStyle != PlotCurve && 1041 if (m_plotStyle != PlotCurve &&
1042 m_plotStyle != PlotDiscreteCurves && 1042 m_plotStyle != PlotDiscreteCurves &&
1043 m_plotStyle != PlotLines) { 1043 m_plotStyle != PlotLines) {
1044 paint.setPen(getForegroundQColor(v)); 1044 illuminate = true;
1045 } 1045 }
1046 } 1046 }
1047 1047
1048 if (m_plotStyle != PlotLines && 1048 if (m_plotStyle != PlotLines &&
1049 m_plotStyle != PlotCurve && 1049 m_plotStyle != PlotCurve &&
1050 m_plotStyle != PlotDiscreteCurves && 1050 m_plotStyle != PlotDiscreteCurves &&
1051 m_plotStyle != PlotSegmentation) { 1051 m_plotStyle != PlotSegmentation) {
1052 if (illuminate) {
1053 paint.save();
1054 paint.setPen(getForegroundQColor(v));
1055 paint.setBrush(getForegroundQColor(v));
1056 }
1052 if (m_plotStyle != PlotStems || 1057 if (m_plotStyle != PlotStems ||
1053 w > 1) { 1058 w > 1) {
1054 paint.drawRect(x, y - 1, w, 2); 1059 paint.drawRect(x, y - 1, w, 2);
1060 }
1061 if (illuminate) {
1062 paint.restore();
1055 } 1063 }
1056 } 1064 }
1057 1065
1058 if (m_plotStyle == PlotConnectedPoints || 1066 if (m_plotStyle == PlotConnectedPoints ||
1059 m_plotStyle == PlotLines || 1067 m_plotStyle == PlotLines ||
1123 1131
1124 if (nx <= x) continue; 1132 if (nx <= x) continue;
1125 1133
1126 paint.setPen(QPen(getForegroundQColor(v), 2)); 1134 paint.setPen(QPen(getForegroundQColor(v), 2));
1127 1135
1128 if (illuminateFrame != p.frame) { 1136 if (!illuminate) {
1129 if (!m_drawSegmentDivisions || 1137 if (!m_drawSegmentDivisions ||
1130 nx < x + 5 || 1138 nx < x + 5 ||
1131 x >= v->width() - 1) { 1139 x >= v->width() - 1) {
1132 paint.setPen(Qt::NoPen); 1140 paint.setPen(Qt::NoPen);
1133 } 1141 }
1139 QString label = p.label; 1147 QString label = p.label;
1140 bool italic = false; 1148 bool italic = false;
1141 1149
1142 if (label == "" && 1150 if (label == "" &&
1143 (m_plotStyle == PlotPoints || 1151 (m_plotStyle == PlotPoints ||
1144 m_plotStyle == PlotSegmentation)) { 1152 m_plotStyle == PlotSegmentation ||
1153 m_plotStyle == PlotConnectedPoints)) {
1145 label = QString("%1").arg(p.value); 1154 label = QString("%1").arg(p.value);
1146 italic = true; 1155 italic = true;
1147 } 1156 }
1148 1157
1149 if (label != "") { 1158 if (label != "") {
1150 if (!haveNext || nx > x + 6 + paint.fontMetrics().width(p.label)) { 1159 if (!haveNext || nx > x + 6 + paint.fontMetrics().width(label)) {
1151 v->drawVisibleText(paint, x + 5, textY, label, 1160 v->drawVisibleText(paint, x + 5, textY, label,
1152 italic ? 1161 italic ?
1153 View::OutlinedItalicText : 1162 View::OutlinedItalicText :
1154 View::OutlinedText); 1163 View::OutlinedText);
1155 } 1164 }