#include <QApplication>
#include <QBrush>
+#include <QMenu>
#include <QPainter>
#include <QPointF>
#include <QRect>
#include <cstdio>
#include <limits>
-using std::abs; // Force usage of std::abs() instead of C's abs().
+using std::abs; // NOLINT. Force usage of std::abs() instead of C's abs().
using std::shared_ptr;
namespace pv {
namespace views {
namespace trace {
-const QColor Cursor::FillColour(52, 101, 164);
+const QColor Cursor::FillColor(52, 101, 164);
Cursor::Cursor(View &view, double time) :
- TimeMarker(view, FillColour, time)
+ TimeMarker(view, FillColor, time)
{
}
const pv::util::Timestamp& diff = abs(time_ - other->time_);
return Ruler::format_time_with_distance(
- diff, time_, view_.tick_prefix(), view_.time_unit(), view_.tick_precision());
+ diff, view_.ruler()->get_ruler_time_from_absolute_time(time_),
+ view_.tick_prefix(), view_.time_unit(), view_.tick_precision());
}
QRectF Cursor::label_rect(const QRectF &rect) const
return QRectF(x - label_size.width(), top, label_size.width(), height);
}
+QMenu *Cursor::create_header_context_menu(QWidget *parent)
+{
+ QMenu *const menu = new QMenu(parent);
+
+ QAction *const snap_disable = new QAction(tr("Disable snapping"), this);
+ snap_disable->setCheckable(true);
+ snap_disable->setChecked(snapping_disabled_);
+ connect(snap_disable, &QAction::toggled, this, [=](bool checked){snapping_disabled_ = checked;});
+ menu->addAction(snap_disable);
+
+ return menu;
+}
+
shared_ptr<Cursor> Cursor::get_other_cursor() const
{
const shared_ptr<CursorPair> cursors(view_.cursors());