connect(create_marker, SIGNAL(triggered()), this, SLOT(on_createMarker()));
menu->addAction(create_marker);
+ QAction *const set_zero_position = new QAction(tr("Set as zero point"), this);
+ connect(set_zero_position, SIGNAL(triggered()), this, SLOT(on_setZeroPosition()));
+ menu->addAction(set_zero_position);
+
QAction *const toggle_hover_marker = new QAction(this);
connect(toggle_hover_marker, SIGNAL(triggered()), this, SLOT(on_toggleHoverMarker()));
menu->addAction(toggle_hover_marker);
view_.add_flag(get_time_from_x_pos(mouse_down_point_.x()));
}
+void Ruler::on_setZeroPosition()
+{
+ view_.set_zero_position(get_time_from_x_pos(mouse_down_point_.x()));
+}
+
void Ruler::on_toggleHoverMarker()
{
GlobalSettings settings;
return ruler_offset_;
}
-void View::set_zero_position(pv::util::Timestamp& position)
+void View::set_zero_position(const pv::util::Timestamp& position)
{
- ruler_shift_ = -position;
+ // ruler shift is a negative offset and the new zero position is relative
+ // to the current offset. Hence, we adjust the ruler shift only by the
+ // difference.
+ ruler_shift_ = -(position + (-ruler_shift_));
// Force an immediate update of the offsets
set_offset(offset_, true);
*/
const pv::util::Timestamp& ruler_offset() const;
- void set_zero_position(pv::util::Timestamp& position);
+ void set_zero_position(const pv::util::Timestamp& position);
void reset_zero_position();