From 824188d047b8778db0d5179dbf935535f923b8f2 Mon Sep 17 00:00:00 2001 From: Steve Karolewics Date: Tue, 7 Jan 2020 15:41:26 -0800 Subject: [PATCH] Fix text contrast in pixel history view with dark UI theme --- qrenderdoc/Windows/PixelHistoryView.cpp | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/qrenderdoc/Windows/PixelHistoryView.cpp b/qrenderdoc/Windows/PixelHistoryView.cpp index 735e4ecdd..3afe5246d 100644 --- a/qrenderdoc/Windows/PixelHistoryView.cpp +++ b/qrenderdoc/Windows/PixelHistoryView.cpp @@ -42,8 +42,8 @@ class PixelHistoryItemModel : public QAbstractItemModel { public: PixelHistoryItemModel(ICaptureContext &ctx, ResourceId tex, const TextureDisplay &display, - QObject *parent) - : QAbstractItemModel(parent), m_Ctx(ctx) + const QPalette &palette, QObject *parent) + : QAbstractItemModel(parent), m_Ctx(ctx), m_Palette(palette) { m_Tex = m_Ctx.GetTexture(tex); m_Display = display; @@ -367,6 +367,23 @@ public: } } + // 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 && (col == 0 || col == 1 || col == 3)) + { + QColor textColor = + contrastingColor(QColor::fromRgb(235, 235, 235), m_Palette.color(QPalette::Text)); + if(isEvent(index)) + { + return QBrush(textColor); + } + else + { + if(getMod(index).shaderDiscarded) + return QBrush(textColor); + } + } + if(role == Qt::UserRole) { EventTag tag; @@ -404,6 +421,8 @@ private: QVector> m_History; QVector m_ModList; + const QPalette &m_Palette; + // mask for top bit of quintptr static const quintptr eventTagMask = 1ULL << (Q_PROCESSOR_WORDSIZE * 8 - 1); @@ -610,7 +629,7 @@ PixelHistoryView::PixelHistoryView(ICaptureContext &ctx, ResourceId id, QPoint p ui->eventsHidden->setVisible(false); - m_Model = new PixelHistoryItemModel(ctx, id, display, this); + m_Model = new PixelHistoryItemModel(ctx, id, display, palette(), this); ui->events->setModel(m_Model); ui->events->hideBranches();