]> sigrok.org Git - pulseview.git/commitdiff
Bring the cursors into view when they are shown
authorJoel Holdsworth <redacted>
Tue, 23 Apr 2013 22:22:24 +0000 (23:22 +0100)
committerJoel Holdsworth <redacted>
Tue, 23 Apr 2013 22:22:24 +0000 (23:22 +0100)
pv/mainwindow.cpp
pv/view/view.cpp
pv/view/view.h

index 66bed74896ae4f8edf7e3327999dd6b0f6de97bb..3326b9b1af47967d0de0603a4bef3cdb4d4684f1 100644 (file)
@@ -287,7 +287,12 @@ void MainWindow::on_actionViewZoomOut_triggered()
 void MainWindow::on_actionViewShowCursors_triggered()
 {
        assert(_view);
 void MainWindow::on_actionViewShowCursors_triggered()
 {
        assert(_view);
-       _view->show_cursors(_action_view_show_cursors->isChecked());
+
+       const bool show = !_view->cursors_shown();
+       if(show)
+               _view->centre_cursors();
+
+       _view->show_cursors(show);
 }
 
 void MainWindow::on_actionAbout_triggered()
 }
 
 void MainWindow::on_actionAbout_triggered()
index 9c793bb8e635c4443c7b762186f1969df0752886..6ea8cc0af30eea06c6fbc9e7523bf1e8ca257c1c 100644 (file)
@@ -161,6 +161,15 @@ void View::show_cursors(bool show)
        _viewport->update();
 }
 
        _viewport->update();
 }
 
+void View::centre_cursors()
+{
+       const double time_width = _scale * _viewport->width();
+       _cursors.first().set_time(_offset + time_width * 0.4);
+       _cursors.second().set_time(_offset + time_width * 0.6);
+       _ruler->update();
+       _viewport->update();
+}
+
 CursorPair& View::cursors()
 {
        return _cursors;
 CursorPair& View::cursors()
 {
        return _cursors;
index 4eb255a2da7a0ec131df8daf6ea6286df8442074..0f5e254da4f12681dfff1f10621c91c0af1b9422 100644 (file)
@@ -96,6 +96,11 @@ public:
         */
        void show_cursors(bool show = true);
 
         */
        void show_cursors(bool show = true);
 
+       /**
+        * Moves the cursors to a convenient position in the view.
+        */
+       void centre_cursors();
+
        /**
         * Returns a reference to the pair of cursors.
         */
        /**
         * Returns a reference to the pair of cursors.
         */