-void Viewport::mousePressEvent(QMouseEvent *event)
-{
- assert(event);
-
- if (event->button() == Qt::LeftButton) {
- mouse_down_point_ = event->pos();
- mouse_down_offset_ = view_.offset();
- mouse_down_valid_ = true;
- }
-}
-
-void Viewport::mouseReleaseEvent(QMouseEvent *event)
-{
- assert(event);
-
- if (event->button() == Qt::LeftButton)
- mouse_down_valid_ = false;
-}
-
-void Viewport::mouseMoveEvent(QMouseEvent *event)
-{
- assert(event);
-
- if (event->buttons() & Qt::LeftButton) {
- if (!mouse_down_valid_) {
- mouse_down_point_ = event->pos();
- mouse_down_offset_ = view_.offset();
- mouse_down_valid_ = true;
- }
-
- view_.set_scale_offset(view_.scale(),
- mouse_down_offset_ +
- (mouse_down_point_ - event->pos()).x() *
- view_.scale());
- }
-}
-