namespace TraceView {
const int Header::Padding = 12;
-const int Header::BaselineOffset = 5;
static bool item_selected(shared_ptr<TraceTreeItem> r)
{
for (auto &i : items)
if (i->enabled())
max_rect = max_rect.united(i->label_rect(QRect()));
- return QSize(max_rect.width() + Padding + BaselineOffset, 0);
+ return QSize(max_rect.width() + Padding, 0);
}
QSize Header::extended_size_hint() const
shared_ptr<ViewItem> Header::get_mouse_over_item(const QPoint &pt)
{
- const QRect r(0, 0, width() - BaselineOffset, height());
+ const QRect r(0, 0, width(), height());
const vector<shared_ptr<TraceTreeItem>> items(
view_.list_by_type<TraceTreeItem>());
for (auto i = items.rbegin(); i != items.rend(); i++)
void Header::paintEvent(QPaintEvent*)
{
- // The trace labels are not drawn with the arrows exactly on the
- // left edge of the widget, because then the selection shadow
- // would be clipped away.
- const QRect rect(0, 0, width() - BaselineOffset, height());
+ const QRect rect(0, 0, width(), height());
vector< shared_ptr<RowItem> > items(view_.list_by_type<RowItem>());
*/
QSize extended_size_hint() const;
- /**
- * The horizontal offset, relative to the left edge of the widget,
- * where the arrows of the trace labels end.
- */
- static const int BaselineOffset;
-
private:
/**
* Gets the row items.
const QRectF r = label_rect(rect);
+ // When selected, move the arrow to the left so that the border can show
+ const QPointF offs = (selected()) ? QPointF(-2, 0) : QPointF(0, 0);
+
// Paint the label
const float label_arrow_length = r.height() / 2;
- const QPointF points[] = {
- r.topLeft(),
- QPointF(r.right() - label_arrow_length, r.top()),
- QPointF(r.right(), y),
- QPointF(r.right() - label_arrow_length, r.bottom()),
- r.bottomLeft()
+ QPointF points[] = {
+ offs + r.topLeft(),
+ offs + QPointF(r.right() - label_arrow_length, r.top()),
+ offs + QPointF(r.right(), y),
+ offs + QPointF(r.right() - label_arrow_length, r.bottom()),
+ offs + r.bottomLeft()
};
- const QPointF highlight_points[] = {
- QPointF(r.left() + 1, r.top() + 1),
- QPointF(r.right() - label_arrow_length, r.top() + 1),
- QPointF(r.right() - 1, y),
- QPointF(r.right() - label_arrow_length, r.bottom() - 1),
- QPointF(r.left() + 1, r.bottom() - 1)
+ QPointF highlight_points[] = {
+ offs + QPointF(r.left() + 1, r.top() + 1),
+ offs + QPointF(r.right() - label_arrow_length, r.top() + 1),
+ offs + QPointF(r.right() - 1, y),
+ offs + QPointF(r.right() - label_arrow_length, r.bottom() - 1),
+ offs + QPointF(r.left() + 1, r.bottom() - 1)
};
if (selected()) {
ruler_ = new Ruler(*this);
header_ = new Header(*this);
- header_->setMinimumWidth(15); // So that the arrow tips show at least
+ header_->setMinimumWidth(10); // So that the arrow tips show at least
// We put the header into a simple layout so that we can add the top margin,
// allowing us to make it line up with the bottom of the ruler