]> sigrok.org Git - pulseview.git/commitdiff
TimeMarker: Added get_text
authorJoel Holdsworth <redacted>
Sun, 30 Nov 2014 15:31:10 +0000 (15:31 +0000)
committerUwe Hermann <redacted>
Wed, 10 Dec 2014 17:06:15 +0000 (18:06 +0100)
pv/view/cursor.cpp
pv/view/cursor.hpp
pv/view/logicsignal.cpp
pv/view/timemarker.cpp
pv/view/timemarker.hpp

index d5b0a641f075a5b9c5d7f4ddd0cb511102aee08a..6a4733112fbb6882edf3d281aed570cd5f19f538 100644 (file)
@@ -45,6 +45,11 @@ Cursor::Cursor(View &view, double time) :
 {
 }
 
+QString Cursor::get_text() const
+{
+       return pv::util::format_time(time_, view_.tick_prefix(), 2);
+}
+
 QRectF Cursor::get_label_rect(const QRect &rect) const
 {
        const shared_ptr<Cursor> other(get_other_cursor());
@@ -53,8 +58,7 @@ QRectF Cursor::get_label_rect(const QRect &rect) const
        const float x = (time_ - view_.offset()) / view_.scale();
 
        QFontMetrics m(QApplication::font());
-       QSize text_size = m.boundingRect(
-               pv::util::format_time(time_, view_.tick_prefix(), 2)).size();
+       QSize text_size = m.boundingRect(get_text()).size();
 
        const QSizeF label_size(
                text_size.width() + View::LabelPadding.width() * 2,
index 9f0adeddbd8eb0bdd20e16ded2fd16d6036533cc..fab7497e18830c53128277be14a801742105afb4 100644 (file)
@@ -48,6 +48,11 @@ public:
        Cursor(View &view, double time);
 
 public:
+       /**
+        * Gets the text to show in the marker.
+        */
+       QString get_text() const;
+
        /**
         * Gets the marker label rectangle.
         * @param rect The rectangle of the ruler client area.
index 48d2debcf2a9df1ccd204d71b6ad486bc335d585..4a8939d14eadaa6f298aa5f1e682c783685f9ffb 100644 (file)
@@ -246,15 +246,15 @@ void LogicSignal::paint_fore(QPainter &p, const RowItemPaintParams &pp)
                if (!pixmap)
                        continue;
 
-               const int pad = TriggerMarkerPadding;
+               const float pad = TriggerMarkerPadding - 0.5f;
                const QSize size = pixmap->size();
                const QPoint point(
                        pp.right() - size.width() - pad * 2,
                        y - (SignalHeight + size.height()) / 2);
 
-               p.setPen(QPen(Qt::NoPen));
+               p.setPen(QPen(TriggerMarkerBackgroundColour.darker()));
                p.setBrush(TriggerMarkerBackgroundColour);
-               p.drawRoundedRect(QRect(point, size).adjusted(
+               p.drawRoundedRect(QRectF(point, size).adjusted(
                        -pad, -pad, pad, pad), pad, pad);
                p.drawPixmap(point, *pixmap);
 
index d4bd7140e92fba17cdf300495c35331cfa24ac1f..7e23806896d5ed010d090412b03cd9fc877daac8 100644 (file)
@@ -31,7 +31,6 @@
 #include <QFontMetrics>
 #include <QPainter>
 
-#include <pv/util.hpp>
 #include <pv/widgets/popup.hpp>
 
 using std::max;
@@ -93,8 +92,7 @@ QRectF TimeMarker::get_label_rect(const QRect &rect) const
        const float x = (time_ - view_.offset()) / view_.scale();
 
        QFontMetrics m(QApplication::font());
-       QSize text_size = m.boundingRect(
-               pv::util::format_time(time_, view_.tick_prefix(), 2)).size();
+       QSize text_size = m.boundingRect(get_text()).size();
 
        const QSizeF label_size(
                text_size.width() + View::LabelPadding.width() * 2,
@@ -152,8 +150,7 @@ void TimeMarker::paint_label(QPainter &p, const QRect &rect)
        p.drawPolygon(points, countof(points));
 
        p.setPen(select_text_colour(colour_));
-       p.drawText(r, Qt::AlignCenter | Qt::AlignVCenter,
-               pv::util::format_time(time_, view_.tick_prefix(), 2));
+       p.drawText(r, Qt::AlignCenter | Qt::AlignVCenter, get_text());
 }
 
 pv::widgets::Popup* TimeMarker::create_popup(QWidget *parent)
index ae54749e4e58055e5c73db88cbf0b28526f4511b..93c7dc90940928c74f208784b290c6a50b3b5b77 100644 (file)
@@ -79,6 +79,11 @@ public:
         */
        virtual void paint(QPainter &p, const QRect &rect);
 
+       /**
+        * Gets the text to show in the marker.
+        */
+       virtual QString get_text() const = 0;
+
        /**
         * Gets the marker label rectangle.
         * @param rect The rectangle of the ruler client area.