Skip to content

Commit

Permalink
Add constants for pixel history colors
Browse files Browse the repository at this point in the history
  • Loading branch information
w-pearson committed Jul 31, 2023
1 parent d19013d commit b5517f5
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions qrenderdoc/Windows/PixelHistoryView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,10 @@ class PixelHistoryItemModel : public QAbstractItemModel
}
}

const QColor GRAY_BACKGROUND = QColor::fromRgb(235, 235, 235);
const QColor GREEN_BACKGROUND = QColor::fromRgb(235, 255, 235);
const QColor RED_BACKGROUND = QColor::fromRgb(255, 235, 235);

// text backgrounds marking pass/fail
if(role == Qt::BackgroundRole && !isColorColumn(col))
{
Expand All @@ -456,24 +460,22 @@ class PixelHistoryItemModel : public QAbstractItemModel

if(mods[0].directShaderWrite &&
mods[0].preMod.col.uintValue == mods[0].postMod.col.uintValue)
return QBrush(QColor::fromRgb(235, 235, 235));
return QBrush(GRAY_BACKGROUND);

return passed ? QBrush(QColor::fromRgb(235, 255, 235))
: QBrush(QColor::fromRgb(255, 235, 235));
return passed ? QBrush(GREEN_BACKGROUND) : QBrush(RED_BACKGROUND);
}
else
{
if(!getMod(index).Passed())
return QBrush(QColor::fromRgb(255, 235, 235));
return QBrush(RED_BACKGROUND);
}
}

// Since we change the background color for some cells, also change the foreground color to
// ensure contrast with all UI themes
if(role == Qt::ForegroundRole && !isColorColumn(col))
{
QColor textColor =
contrastingColor(QColor::fromRgb(235, 235, 235), m_Palette.color(QPalette::Text));
QColor textColor = contrastingColor(GRAY_BACKGROUND, m_Palette.color(QPalette::Text));
if(isEvent(index))
{
return QBrush(textColor);
Expand Down

0 comments on commit b5517f5

Please sign in to comment.