30 #include <QApplication>
31 #include <QFormLayout>
32 #include <QFontMetrics>
50 value_action_(nullptr),
51 value_widget_(nullptr),
52 updating_value_widget_(false)
81 return QPoint(
get_x(), rect.bottom());
86 QFontMetrics m(QApplication::font());
87 const QSizeF text_size(
91 const float top = rect.height() - label_size.height() -
92 TimeMarker::ArrowSize - 0.5f;
93 const float x =
get_x();
95 return QRectF(QPointF(x - label_size.width() / 2, top), label_size);
100 const float x =
get_x();
101 const float h = QFontMetrics(QApplication::font()).height();
102 return QRectF(x - h / 2.0f, pp.
top(), h, pp.
height());
113 const QPointF points[] = {
116 QPointF(max(r.left(), x -
ArrowSize), r.bottom()),
117 QPointF(x, rect.bottom()),
118 QPointF(min(r.right(), x +
ArrowSize), r.bottom()),
123 const QPointF highlight_points[] = {
124 QPointF(r.left() + 1, r.top() + 1),
125 QPointF(r.left() + 1, r.bottom() - 1),
126 QPointF(max(r.left() + 1, x -
ArrowSize), r.bottom() - 1),
127 QPointF(min(max(r.left() + 1, x), r.right() - 1),
129 QPointF(min(r.right() - 1, x +
ArrowSize), r.bottom() - 1),
130 QPointF(r.right() - 1, r.bottom() - 1),
131 QPointF(r.right() - 1, r.top() + 1),
136 p.setBrush(Qt::transparent);
137 p.drawPolygon(points,
countof(points));
140 p.setPen(Qt::transparent);
142 p.drawPolygon(points,
countof(points));
145 p.setBrush(Qt::transparent);
146 p.drawPolygon(highlight_points,
countof(highlight_points));
149 p.setBrush(Qt::transparent);
150 p.drawPolygon(points,
countof(points));
153 p.drawText(r, Qt::AlignCenter | Qt::AlignVCenter,
get_text());
161 const float x =
get_x();
163 p.drawLine(QPointF(x, pp.
top()), QPointF(x, pp.
bottom()));
170 Popup *
const popup =
new Popup(parent);
171 popup->set_position(parent->mapToGlobal(
172 point(parent->rect())), Popup::Bottom);
174 QFormLayout *
const form =
new QFormLayout(popup);
175 popup->setLayout(form);
static const QSizeF LabelPadding
void paint_fore(QPainter &p, const ViewItemPaintParams &pp)
void paint_label(QPainter &p, const QRect &rect, bool hover)
virtual QString get_text() const =0
virtual bool enabled() const =0
static const int ArrowSize
virtual pv::widgets::Popup * create_popup(QWidget *parent)
void time_item_appearance_changed(bool label, bool content)
static QColor select_text_colour(QColor background)
pv::widgets::TimestampSpinBox * value_widget_
pv::util::Timestamp time_
const pv::util::Timestamp & time() const
QRectF label_rect(const QRectF &rect) const
bool updating_value_widget_
QPoint point(const QRect &rect) const
QRectF hit_box_rect(const ViewItemPaintParams &pp) const
TimeMarker(View &view, const QColor &colour, const pv::util::Timestamp &time)
void set_time(const pv::util::Timestamp &time) override
const pv::util::Timestamp & offset() const
boost::multiprecision::number< boost::multiprecision::cpp_dec_float< 24 >, boost::multiprecision::et_off > Timestamp
Timestamp type providing yoctosecond resolution.
static QPen highlight_pen()
void on_value_changed(const pv::util::Timestamp &value)