X-Git-Url: http://git.code-monkey.de/?a=blobdiff_plain;f=pv%2Fview%2Fcursorheader.cpp;h=2835750b9647bcd2a5fd41a490cb13dadbafb7db;hb=689dea92f288564260ef521f6f499e03e3cdbbd2;hp=3f25e2123b5aa87043d53285ebcffde4353a130d;hpb=8dbbc7f0b9ea59d0f0d62225772f8a56eee125f5;p=pulseview.git diff --git a/pv/view/cursorheader.cpp b/pv/view/cursorheader.cpp index 3f25e21..2835750 100644 --- a/pv/view/cursorheader.cpp +++ b/pv/view/cursorheader.cpp @@ -18,18 +18,19 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "cursorheader.h" +#include "cursorheader.hpp" -#include "ruler.h" -#include "view.h" +#include "ruler.hpp" +#include "view.hpp" #include #include #include -#include +#include using std::shared_ptr; +using std::vector; namespace pv { namespace view { @@ -59,9 +60,9 @@ QSize CursorHeader::sizeHint() const void CursorHeader::clear_selection() { - CursorPair &cursors = view_.cursors(); - cursors.first()->select(false); - cursors.second()->select(false); + const vector< shared_ptr > items(view_.time_items()); + for (auto &i : items) + i->select(false); update(); } @@ -70,17 +71,14 @@ 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; + // 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); // Draw the cursors - if (view_.cursors_shown()) { - // 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); - } + if (view_.cursors_shown()) + view_.cursors()->draw_markers(p, r); } void CursorHeader::mouseMoveEvent(QMouseEvent *e) @@ -109,13 +107,13 @@ void CursorHeader::mousePressEvent(QMouseEvent *e) clear_selection(); if (view_.cursors_shown()) { - CursorPair &cursors = view_.cursors(); - if (cursors.first()->get_label_rect( + shared_ptr cursors(view_.cursors()); + if (cursors->first()->label_rect( rect()).contains(e->pos())) - grabbed_marker_ = cursors.first(); - else if (cursors.second()->get_label_rect( + grabbed_marker_ = cursors->first(); + else if (cursors->second()->label_rect( rect()).contains(e->pos())) - grabbed_marker_ = cursors.second(); + grabbed_marker_ = cursors->second(); } if (shared_ptr m = grabbed_marker_.lock())