{
}
+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());
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,
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.
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);
#include <QFontMetrics>
#include <QPainter>
-#include <pv/util.hpp>
#include <pv/widgets/popup.hpp>
using std::max;
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,
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)
*/
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.