+pv::util::Timestamp Ruler::get_time_from_x_pos(uint32_t x) const
+{
+ return view_.ruler_offset() + ((double)x + 0.5) * view_.scale();
+}
+
+void Ruler::contextMenuEvent(QContextMenuEvent *event)
+{
+ context_menu_x_pos_ = event->pos().x();
+
+ QMenu *const menu = new QMenu(this);
+
+ QAction *const create_marker = new QAction(tr("Create marker here"), this);
+ connect(create_marker, SIGNAL(triggered()), this, SLOT(on_createMarker()));
+ menu->addAction(create_marker);
+
+ QAction *const toggle_hover_marker = new QAction(this);
+ connect(toggle_hover_marker, SIGNAL(triggered()), this, SLOT(on_toggleHoverMarker()));
+ menu->addAction(toggle_hover_marker);
+
+ GlobalSettings settings;
+ const bool hover_marker_shown =
+ settings.value(GlobalSettings::Key_View_ShowHoverMarker).toBool();
+ toggle_hover_marker->setText(hover_marker_shown ?
+ tr("Disable mouse hover marker") : tr("Enable mouse hover marker"));
+
+ menu->popup(event->globalPos());
+}
+
+void Ruler::resizeEvent(QResizeEvent*)
+{
+ // the tick calculation depends on the width of this widget
+ invalidate_tick_position_cache();
+}
+