X-Git-Url: http://git.code-monkey.de/?a=blobdiff_plain;f=pv%2Fview%2Ftimemarker.cpp;h=614275cf98e04d1d559d211cae6bf9740f595b15;hb=8b855030926f6c271b650392d34444fd917ec764;hp=ed9df36064f74407b1a1ee81f80d11378adbc81c;hpb=98cfe4e8dadad2cf710eb46fd5c85d9d0520a875;p=pulseview.git diff --git a/pv/view/timemarker.cpp b/pv/view/timemarker.cpp index ed9df36..614275c 100644 --- a/pv/view/timemarker.cpp +++ b/pv/view/timemarker.cpp @@ -40,7 +40,6 @@ namespace pv { namespace view { const int TimeMarker::ArrowSize = 4; -const int TimeMarker::Offset = 1; TimeMarker::TimeMarker(View &view, const QColor &colour, double time) : TimeItem(view), @@ -82,25 +81,19 @@ QPoint TimeMarker::point() const QRectF TimeMarker::label_rect(const QRectF &rect) const { - const float x = (time_ - view_.offset()) / view_.scale(); - QFontMetrics m(QApplication::font()); - const float text_width = - max(m.boundingRect(get_text()).size().width(), ArrowSize); - const float text_height = m.boundingRect("Tg").size().height(); - - const QSizeF label_size( - text_width + View::LabelPadding.width() * 2, - text_height + View::LabelPadding.height() * 2); + const QSizeF text_size( + max(m.boundingRect(get_text()).size().width(), ArrowSize), + m.height()); + const QSizeF label_size(text_size + LabelPadding * 2); const float top = rect.height() - label_size.height() - - TimeMarker::Offset - TimeMarker::ArrowSize - 0.5f; - const float height = label_size.height(); + TimeMarker::ArrowSize - 0.5f; + const float x = (time_ - view_.offset()) / view_.scale(); - return QRectF(x - label_size.width() / 2, top, - label_size.width(), height); + return QRectF(QPointF(x - label_size.width() / 2, top), label_size); } -void TimeMarker::paint_label(QPainter &p, const QRect &rect) +void TimeMarker::paint_label(QPainter &p, const QRect &rect, bool hover) { if (!enabled()) return; @@ -136,7 +129,7 @@ void TimeMarker::paint_label(QPainter &p, const QRect &rect) } p.setPen(Qt::transparent); - p.setBrush(colour_); + p.setBrush(hover ? colour_.lighter() : colour_); p.drawPolygon(points, countof(points)); p.setPen(colour_.lighter());