]> sigrok.org Git - pulseview.git/blobdiff - pv/view/cursorheader.cpp
RowItem: Renamed get_v_offset to v_offset
[pulseview.git] / pv / view / cursorheader.cpp
index 861cd70f535249209268e6cc24b078e6a4f1ba62..a9b709f2ecc30966a70e86350133d00bce340b4f 100644 (file)
@@ -20,6 +20,7 @@
 
 #include "cursorheader.h"
 
+#include "ruler.h"
 #include "view.h"
 
 #include <QApplication>
@@ -34,6 +35,7 @@ namespace pv {
 namespace view {
 
 const int CursorHeader::Padding = 20;
+const int CursorHeader::BaselineOffset = 5;
 
 int CursorHeader::calculateTextHeight()
 {
@@ -52,7 +54,7 @@ CursorHeader::CursorHeader(View &parent) :
 
 QSize CursorHeader::sizeHint() const
 {
-       return QSize(0, _textHeight + Padding);
+       return QSize(0, _textHeight + Padding + BaselineOffset);
 }
 
 void CursorHeader::clear_selection()
@@ -68,9 +70,16 @@ void CursorHeader::paintEvent(QPaintEvent*)
        QPainter p(this);
        p.setRenderHint(QPainter::Antialiasing);
 
+       unsigned int prefix = pv::view::Ruler::calculate_tick_spacing(
+               p, _view.scale(), _view.offset()).second;
+
        // Draw the cursors
        if (_view.cursors_shown()) {
-               _view.cursors().draw_markers(p, rect(), 0); //prefix);
+               // The cursor labels are not drawn with the arrows exactly on the
+               // bottom line of the widget, because then the selection shadow
+               // would be clipped away.
+               const QRect r = rect().adjusted(0, 0, 0, -BaselineOffset);
+               _view.cursors().draw_markers(p, r, prefix);
        }
 }
 
@@ -123,8 +132,8 @@ void CursorHeader::mouseReleaseEvent(QMouseEvent *)
        if (!_dragging)
                if (shared_ptr<TimeMarker> m = _grabbed_marker.lock()) {
                        Popup *const p = m->create_popup(&_view);
-                       p->set_position(mapToGlobal(QPoint(m->get_x(),
-                               height())), Popup::Bottom);
+                       const QPoint arrpos(m->get_x(), height() - BaselineOffset);
+                       p->set_position(mapToGlobal(arrpos), Popup::Bottom);
                        p->show();
                }