Mercurial > hg > svgui
changeset 630:c3593bb2de6b
Use italic for value labels (as opposed to label labels)
author | Chris Cannam |
---|---|
date | Tue, 16 Apr 2013 10:06:10 +0100 |
parents | 355fa700ce70 |
children | f69e08be3379 |
files | layer/TimeValueLayer.cpp view/View.cpp view/View.h |
diffstat | 3 files changed, 17 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/layer/TimeValueLayer.cpp Mon Apr 15 10:54:02 2013 +0100 +++ b/layer/TimeValueLayer.cpp Tue Apr 16 10:06:10 2013 +0100 @@ -1137,16 +1137,21 @@ } QString label = p.label; + bool italic = false; if (label == "" && (m_plotStyle == PlotPoints || m_plotStyle == PlotSegmentation)) { - label = QString("%1").arg(p.value); //??? but use italic? + label = QString("%1").arg(p.value); + italic = true; } if (label != "") { if (!haveNext || nx > x + 6 + paint.fontMetrics().width(p.label)) { - v->drawVisibleText(paint, x + 5, textY, label, View::OutlinedText); + v->drawVisibleText(paint, x + 5, textY, label, + italic ? + View::OutlinedItalicText : + View::OutlinedText); } }
--- a/view/View.cpp Mon Apr 15 10:54:02 2013 +0100 +++ b/view/View.cpp Tue Apr 16 10:06:10 2013 +0100 @@ -731,10 +731,16 @@ void View::drawVisibleText(QPainter &paint, int x, int y, QString text, TextStyle style) const { - if (style == OutlinedText) { + if (style == OutlinedText || style == OutlinedItalicText) { paint.save(); + if (style == OutlinedItalicText) { + QFont f(paint.font()); + f.setItalic(true); + paint.setFont(f); + } + QColor penColour, surroundColour, boxColour; penColour = getForeground(); @@ -744,6 +750,7 @@ paint.setPen(Qt::NoPen); paint.setBrush(boxColour); + QRect r = paint.fontMetrics().boundingRect(text); r.translate(QPoint(x, y)); // std::cerr << "drawVisibleText: r = " << r.x() << "," <<r.y() << " " << r.width() << "x" << r.height() << std::endl;