Skip to content

Commit

Permalink
Blend pixel history widget background color with selection color
Browse files Browse the repository at this point in the history
Before, if a row was selected, the color was completely replaced, which
makes the color preview column completely useless for that row.

This change also fixes some inconsistencies with how the selection hover
works on tree widgets; previously part of the row was not highlighted.
  • Loading branch information
w-pearson authored and baldurk committed Aug 10, 2023
1 parent 71e886c commit afb4d76
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 15 deletions.
22 changes: 19 additions & 3 deletions qrenderdoc/Styles/RDStyle/RDStyle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1551,9 +1551,25 @@ void RDStyle::drawPrimitive(PrimitiveElement element, const QStyleOption *opt, Q
group = QPalette::Inactive;

if(viewitem->state & QStyle::State_Selected)
p->fillRect(viewitem->rect, viewitem->palette.brush(group, QPalette::Highlight));
else if(viewitem->backgroundBrush.style() != Qt::NoBrush)
p->fillRect(viewitem->rect, viewitem->backgroundBrush);
{
if(viewitem->backgroundBrush.style() != Qt::NoBrush)
{
p->fillRect(viewitem->rect, viewitem->backgroundBrush);
// If we have a custom color, use the selection color at half opacity over the custom color
QColor col = viewitem->palette.color(group, QPalette::Highlight);
col.setAlphaF(0.5f);
p->fillRect(viewitem->rect, QBrush(col));
}
else
{
p->fillRect(viewitem->rect, viewitem->palette.brush(group, QPalette::Highlight));
}
}
else
{
if(viewitem->backgroundBrush.style() != Qt::NoBrush)
p->fillRect(viewitem->rect, viewitem->backgroundBrush);
}

return;
}
Expand Down
17 changes: 5 additions & 12 deletions qrenderdoc/Widgets/Extended/RDTreeView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -771,18 +771,11 @@ void RDTreeView::drawBranches(QPainter *painter, const QRect &rect, const QModel
idx = idx.parent();
}

opt.rect = rect;
opt.rect.setWidth(depth * indentation());
opt.rect = allLinesRect;
opt.showDecorationSelected = true;
opt.backgroundBrush = index.data(Qt::BackgroundRole).value<QBrush>();
style()->drawPrimitive(QStyle::PE_PanelItemViewItem, &opt, painter, this);

QBrush back = index.data(Qt::BackgroundRole).value<QBrush>();

if(!selectionModel()->isSelected(index) && back.style() != Qt::NoBrush)
{
painter->fillRect(allLinesRect, back);
}

if(m_VisibleBranches)
{
QTreeView::drawBranches(painter, rect, index);
Expand Down Expand Up @@ -821,12 +814,12 @@ void RDTreeView::drawBranches(QPainter *painter, const QRect &rect, const QModel
{
parent = parents.pop();

back = parent.data(RDTreeView::TreeLineColorRole).value<QBrush>();
QBrush line = parent.data(RDTreeView::TreeLineColorRole).value<QBrush>();

if(back.style() != Qt::NoBrush)
if(line.style() != Qt::NoBrush)
{
// draw a centred pen vertically down the middle of branchRect
painter->setPen(QPen(QBrush(back), m_treeColorLineWidth));
painter->setPen(QPen(line, m_treeColorLineWidth));

QPoint topCentre = QRect(branchRect).center();
QPoint bottomCentre = topCentre;
Expand Down

0 comments on commit afb4d76

Please sign in to comment.