summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
inline | side by side (from parent 1:
3309499)
The baseline offset was used to keep 5px of distance between
the tip of the arrow and the scroll area. This way, the shadow
that is drawn around the arrow when it's selected won't get
cropped.
However, we can do this differently: instead of always keeping
the empty space around, we make the arrows align at the edge
of the widget space as they should and when they're selected,
we push them aside to the left so the shadow can still be
painted without cropping.
Logically, one would assume that the arrow's label also should
be moving left but I decided against it because this way it
looks as if the arrow didn't actually move, keeping all arrow
labels lined up.
namespace TraceView {
const int Header::Padding = 12;
namespace TraceView {
const int Header::Padding = 12;
-const int Header::BaselineOffset = 5;
static bool item_selected(shared_ptr<TraceTreeItem> r)
{
static bool item_selected(shared_ptr<TraceTreeItem> r)
{
for (auto &i : items)
if (i->enabled())
max_rect = max_rect.united(i->label_rect(QRect()));
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
}
QSize Header::extended_size_hint() const
shared_ptr<ViewItem> Header::get_mouse_over_item(const QPoint &pt)
{
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++)
const vector<shared_ptr<TraceTreeItem>> items(
view_.list_by_type<TraceTreeItem>());
for (auto i = items.rbegin(); i != items.rend(); i++)
void Header::paintEvent(QPaintEvent*)
{
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>());
vector< shared_ptr<RowItem> > items(view_.list_by_type<RowItem>());
*/
QSize extended_size_hint() const;
*/
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.
private:
/**
* Gets the row items.
const QRectF r = label_rect(rect);
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;
// 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)
ruler_ = new Ruler(*this);
header_ = new Header(*this);
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
// 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