Mercurial > hg > svgui
comparison layer/PaintAssistant.cpp @ 1283:6e35062fc10a
Tidy
| author | Chris Cannam |
|---|---|
| date | Tue, 08 May 2018 14:07:22 +0100 |
| parents | a34a2a25907c |
| children | cca66ce390e0 |
comparison
equal
deleted
inserted
replaced
| 1282:f90a3c2f2930 | 1283:6e35062fc10a |
|---|---|
| 54 round = int(minVal + step * mult); | 54 round = int(minVal + step * mult); |
| 55 mult *= 10; | 55 mult *= 10; |
| 56 } while (!round && mult < limit); | 56 } while (!round && mult < limit); |
| 57 if (round) { | 57 if (round) { |
| 58 mult /= 10; | 58 mult /= 10; |
| 59 // cerr << "\n\nstep goes from " << step; | |
| 60 step = double(round) / mult; | 59 step = double(round) / mult; |
| 61 n = int(lrint((maxVal - minVal) / step)); | 60 n = int(lrint((maxVal - minVal) / step)); |
| 62 if (mult > 1) { | 61 if (mult > 1) { |
| 63 mult /= 10; | 62 mult /= 10; |
| 64 } | 63 } |
| 65 // cerr << " to " << step << " (n = " << n << ")" << endl; | |
| 66 } | 64 } |
| 67 } | 65 } |
| 68 | 66 |
| 69 for (int i = 0; i <= n; ++i) { | 67 for (int i = 0; i <= n; ++i) { |
| 70 | 68 |
| 115 abs(y - lastLabelledY) >= textHeight - 1); | 113 abs(y - lastLabelledY) >= textHeight - 1); |
| 116 | 114 |
| 117 if (spaceForLabel) { | 115 if (spaceForLabel) { |
| 118 | 116 |
| 119 int tx = 3; | 117 int tx = 3; |
| 120 // if (scale != LinearScale) { | |
| 121 if (paint.fontMetrics().width(text) < w - 10) { | 118 if (paint.fontMetrics().width(text) < w - 10) { |
| 122 tx = w - 10 - paint.fontMetrics().width(text); | 119 tx = w - 10 - paint.fontMetrics().width(text); |
| 123 } | 120 } |
| 124 | 121 |
| 125 int ty = y; | 122 int ty = y; |
| 126 | 123 |
| 127 if (ty < paint.fontMetrics().ascent()) { | 124 if (ty < paint.fontMetrics().ascent()) { |
| 128 ty = paint.fontMetrics().ascent(); | 125 ty = paint.fontMetrics().ascent(); |
| 129 // } else if (ty > rect.y() + h - paint.fontMetrics().descent()) { | |
| 130 // ty = rect.y() + h - paint.fontMetrics().descent(); | |
| 131 } else { | 126 } else { |
| 132 ty += toff; | 127 ty += toff; |
| 133 } | 128 } |
| 134 | 129 |
| 135 paint.drawText(tx, ty, text); | 130 paint.drawText(tx, ty, text); |
| 136 | 131 |
| 137 lastLabelledY = ty - toff; | 132 lastLabelledY = ty - toff; |
| 138 /* | 133 |
| 139 if (ny != y) { | |
| 140 ty = ny; | |
| 141 if (ty < paint.fontMetrics().ascent()) { | |
| 142 ty = paint.fontMetrics().ascent(); | |
| 143 } else if (ty > h - paint.fontMetrics().descent()) { | |
| 144 ty = h - paint.fontMetrics().descent(); | |
| 145 } else { | |
| 146 ty += toff; | |
| 147 } | |
| 148 paint.drawText(tx, ty, text); | |
| 149 } | |
| 150 */ | |
| 151 paint.drawLine(w - 7, y, w, y); | 134 paint.drawLine(w - 7, y, w, y); |
| 152 if (vy) vy->push_back(y); | 135 if (vy) vy->push_back(y); |
| 153 | 136 |
| 154 if (ny != y) { | 137 if (ny != y) { |
| 155 paint.drawLine(w - 7, ny, w, ny); | 138 paint.drawLine(w - 7, ny, w, ny); |
| 186 double minVal, double maxVal, | 169 double minVal, double maxVal, |
| 187 int minY, int height) | 170 int minY, int height) |
| 188 { | 171 { |
| 189 int vy = 0; | 172 int vy = 0; |
| 190 | 173 |
| 191 // int m = height/2; | |
| 192 // int my = minY + m; | |
| 193 | |
| 194 switch (scale) { | 174 switch (scale) { |
| 195 | 175 |
| 196 case LinearScale: | 176 case LinearScale: |
| 197 // vy = my - int(m * value); | |
| 198 vy = minY + height - int(((value - minVal) / (maxVal - minVal)) * height); | 177 vy = minY + height - int(((value - minVal) / (maxVal - minVal)) * height); |
| 199 break; | 178 break; |
| 200 | 179 |
| 201 case MeterScale: | 180 case MeterScale: |
| 202 // vy = my - AudioLevel::multiplier_to_preview(value, m); | |
| 203 vy = minY + height - AudioLevel::multiplier_to_preview | 181 vy = minY + height - AudioLevel::multiplier_to_preview |
| 204 ((value - minVal) / (maxVal - minVal), height); | 182 ((value - minVal) / (maxVal - minVal), height); |
| 205 break; | 183 break; |
| 206 | 184 |
| 207 case dBScale: | 185 case dBScale: |
| 237 paint.setPen(Qt::NoPen); | 215 paint.setPen(Qt::NoPen); |
| 238 paint.setBrush(boxColour); | 216 paint.setBrush(boxColour); |
| 239 | 217 |
| 240 QRect r = paint.fontMetrics().boundingRect(text); | 218 QRect r = paint.fontMetrics().boundingRect(text); |
| 241 r.translate(QPoint(x, y)); | 219 r.translate(QPoint(x, y)); |
| 242 // cerr << "drawVisibleText: r = " << r.x() << "," <<r.y() << " " << r.width() << "x" << r.height() << endl; | |
| 243 paint.drawRect(r); | 220 paint.drawRect(r); |
| 244 paint.setBrush(Qt::NoBrush); | 221 paint.setBrush(Qt::NoBrush); |
| 245 | 222 |
| 246 paint.setPen(surroundColour); | 223 paint.setPen(surroundColour); |
| 247 | 224 |
