shared_ptr<Cursor> Cursor::get_other_cursor() const
{
- const CursorPair &cursors = view_.cursors();
- return (cursors.first().get() == this) ?
- cursors.second() : cursors.first();
+ const shared_ptr<CursorPair> cursors(view_.cursors());
+ assert(cursors);
+ return (cursors->first().get() == this) ?
+ cursors->second() : cursors->first();
}
} // namespace view
QPainter p(this);
p.setRenderHint(QPainter::Antialiasing);
+ // 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);
- }
+ if (view_.cursors_shown())
+ view_.cursors()->draw_markers(p, r);
}
void CursorHeader::mouseMoveEvent(QMouseEvent *e)
clear_selection();
if (view_.cursors_shown()) {
- CursorPair &cursors = view_.cursors();
- if (cursors.first()->get_label_rect(
+ shared_ptr<CursorPair> cursors(view_.cursors());
+ if (cursors->first()->get_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()->get_label_rect(
rect()).contains(e->pos()))
- grabbed_marker_ = cursors.second();
+ grabbed_marker_ = cursors->second();
}
if (shared_ptr<TimeMarker> m = grabbed_marker_.lock())
tick_period_(0.0),
tick_prefix_(0),
show_cursors_(false),
- cursors_(*this),
+ cursors_(new CursorPair(*this)),
hover_point_(-1, -1)
{
connect(horizontalScrollBar(), SIGNAL(valueChanged(int)),
connect(&session_, SIGNAL(frame_ended()),
this, SLOT(data_updated()));
- connect(cursors_.first().get(), SIGNAL(time_changed()),
+ connect(cursors_->first().get(), SIGNAL(time_changed()),
this, SLOT(marker_time_changed()));
- connect(cursors_.second().get(), SIGNAL(time_changed()),
+ connect(cursors_->second().get(), SIGNAL(time_changed()),
this, SLOT(marker_time_changed()));
connect(header_, SIGNAL(signals_moved()),
vector< shared_ptr<TimeItem> > View::time_items() const
{
vector< shared_ptr<TimeItem> > items;
- items.push_back(cursors_.first());
- items.push_back(cursors_.second());
+ items.push_back(cursors_->first());
+ items.push_back(cursors_->second());
return items;
}
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);
+ cursors_->first()->set_time(offset_ + time_width * 0.4);
+ cursors_->second()->set_time(offset_ + time_width * 0.6);
cursorheader_->update();
viewport_->update();
}
-CursorPair& View::cursors()
-{
- return cursors_;
-}
-
-const CursorPair& View::cursors() const
+std::shared_ptr<CursorPair> View::cursors() const
{
return cursors_;
}
/**
* Returns a reference to the pair of cursors.
*/
- CursorPair& cursors();
-
- /**
- * Returns a reference to the pair of cursors.
- */
- const CursorPair& cursors() const;
+ std::shared_ptr<CursorPair> cursors() const;
const QPoint& hover_point() const;
unsigned int tick_prefix_;
bool show_cursors_;
- CursorPair cursors_;
+ std::shared_ptr<CursorPair> cursors_;
QPoint hover_point_;
p.setRenderHint(QPainter::Antialiasing);
if (view_.cursors_shown())
- view_.cursors().draw_viewport_background(p, rect());
+ view_.cursors()->draw_viewport_background(p, rect());
const RowItemPaintParams pp(0, width(), view_.scale(), view_.offset());
r->paint_fore(p, pp);
if (view_.cursors_shown())
- view_.cursors().draw_viewport_foreground(p, rect());
+ view_.cursors()->draw_viewport_foreground(p, rect());
p.end();
}