comparison layer/SpectrogramLayer.cpp @ 1144:6eef0330ef12 spectrogram-minor-refactor

Make text labels on vertical scale ticks visible
author Chris Cannam
date Fri, 05 Aug 2016 14:36:28 +0100
parents c53ed1a6fcbd
children 17f999cd0a22
comparison
equal deleted inserted replaced
1143:c53ed1a6fcbd 1144:6eef0330ef12
2150 #endif 2150 #endif
2151 2151
2152 paint.drawText((cw + 6 - paint.fontMetrics().width("dBFS")) / 2, 2152 paint.drawText((cw + 6 - paint.fontMetrics().width("dBFS")) / 2,
2153 2 + textHeight + toff, "dBFS"); 2153 2 + textHeight + toff, "dBFS");
2154 2154
2155 // paint.drawText((cw + 6 - paint.fontMetrics().width(top)) / 2,
2156 paint.drawText(3 + cw - cbw - paint.fontMetrics().width(top), 2155 paint.drawText(3 + cw - cbw - paint.fontMetrics().width(top),
2157 2 + textHeight * topLines + toff + textHeight/2, top); 2156 2 + textHeight * topLines + toff + textHeight/2, top);
2158 2157
2159 paint.drawText(3 + cw - cbw - paint.fontMetrics().width(bottom), 2158 paint.drawText(3 + cw - cbw - paint.fontMetrics().width(bottom),
2160 h + toff - 3 - textHeight/2, bottom); 2159 h + toff - 3 - textHeight/2, bottom);
2174 paint.setPen(getRenderer(v)->getColour(value)); 2173 paint.setPen(getRenderer(v)->getColour(value));
2175 2174
2176 int y = textHeight * topLines + 4 + ch - i; 2175 int y = textHeight * topLines + 4 + ch - i;
2177 2176
2178 paint.drawLine(5 + cw - cbw, y, cw + 2, y); 2177 paint.drawLine(5 + cw - cbw, y, cw + 2, y);
2179 2178
2180 if (i == 0) { 2179 if (i == 0) {
2181 lasty = y; 2180 lasty = y;
2182 lastdb = idb; 2181 lastdb = idb;
2183 } else if (i < ch - paint.fontMetrics().ascent() && 2182 } else if (i < ch - paint.fontMetrics().ascent() &&
2184 idb != lastdb && 2183 idb != lastdb &&
2185 ((abs(y - lasty) > textHeight && 2184 ((abs(y - lasty) > textHeight &&
2186 idb % 10 == 0) || 2185 idb % 10 == 0) ||
2187 (abs(y - lasty) > paint.fontMetrics().ascent() && 2186 (abs(y - lasty) > paint.fontMetrics().ascent() &&
2188 idb % 5 == 0))) { 2187 idb % 5 == 0))) {
2189 paint.setPen(v->getBackground()); 2188 paint.setPen(v->getForeground());
2190 QString text = QString("%1").arg(idb); 2189 QString text = QString("%1").arg(idb);
2191 paint.drawText(3 + cw - cbw - paint.fontMetrics().width(text), 2190 paint.drawText(3 + cw - cbw - paint.fontMetrics().width(text),
2192 y + toff + textHeight/2, text); 2191 y + toff + textHeight/2, text);
2193 paint.setPen(v->getForeground());
2194 paint.drawLine(5 + cw - cbw, y, 8 + cw - cbw, y); 2192 paint.drawLine(5 + cw - cbw, y, 8 + cw - cbw, y);
2195 lasty = y; 2193 lasty = y;
2196 lastdb = idb; 2194 lastdb = idb;
2197 } 2195 }
2198 } 2196 }