const QSizeF label_size(
_text_size.width() + View::LabelPadding.width() * 2,
_text_size.height() + View::LabelPadding.height() * 2);
- return QRectF(x - label_size.width() / 2 - 0.5f,
- rect.height() - label_size.height() - Offset - ArrowSize - 0.5f,
- label_size.width() + 1, label_size.height() + 1);
+ const float top = rect.height() - label_size.height() -
+ Cursor::Offset - Cursor::ArrowSize - 0.5f;
+ const float height = label_size.height() + 1;
+
+ if (_time > _other.time())
+ return QRectF(x, top, label_size.width(), height);
+ else
+ return QRectF(x - label_size.width(), top,
+ label_size.width(), height);
}
void Cursor::paint_label(QPainter &p, const QRect &rect,
p.setPen(Qt::NoPen);
p.setBrush(QBrush(View::CursorAreaColour));
- const float x1 = (_first.time() - _view.offset()) / _view.scale();
- const float x2 = (_second.time() - _view.offset()) / _view.scale();
- const int l = (int)max(min(x1, x2), 0.0f);
- const int r = (int)min(max(x1, x2), (float)rect.width());
+ const pair<float, float> offsets(get_cursor_offsets());
+ const int l = (int)max(min(
+ offsets.first, offsets.second), 0.0f);
+ const int r = (int)min(max(
+ offsets.first, offsets.second), (float)rect.width());
p.drawRect(l, 0, r - l, rect.height());
}
_second.paint(p, rect);
}
+pair<float, float> CursorPair::get_cursor_offsets() const
+{
+ return pair<float, float>(
+ (_first.time() - _view.offset()) / _view.scale(),
+ (_second.time() - _view.offset()) / _view.scale());
+}
+
} // namespace view
} // namespace pv