From 6ea771038006ca1ac862b297b2feee07758bb48a Mon Sep 17 00:00:00 2001 From: Jake Turner Date: Sun, 12 Nov 2023 12:36:29 +0000 Subject: [PATCH] Use a contrasting fore ground colour for BufferFormat error style This makes it automatically work for Light or Dark theme --- qrenderdoc/Widgets/BufferFormatSpecifier.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/qrenderdoc/Widgets/BufferFormatSpecifier.cpp b/qrenderdoc/Widgets/BufferFormatSpecifier.cpp index 96399ee263..0072af51ed 100644 --- a/qrenderdoc/Widgets/BufferFormatSpecifier.cpp +++ b/qrenderdoc/Widgets/BufferFormatSpecifier.cpp @@ -86,9 +86,13 @@ BufferFormatSpecifier::BufferFormatSpecifier(QWidget *parent) QColor base = formatText->palette().color(QPalette::Base); - QColor col = QColor::fromHslF(0.0f, 1.0f, qBound(0.1, base.lightnessF(), 0.9)); + QColor backCol = QColor::fromHslF(0.0f, 1.0f, qBound(0.1, base.lightnessF(), 0.9)); + QColor foreCol = contrastingColor(backCol, QColor(0, 0, 0)); - formatText->styleSetBack(ERROR_STYLE, SCINTILLA_COLOUR(col.red(), col.green(), col.blue())); + formatText->styleSetBack(ERROR_STYLE, + SCINTILLA_COLOUR(backCol.red(), backCol.green(), backCol.blue())); + formatText->styleSetFore(ERROR_STYLE, + SCINTILLA_COLOUR(foreCol.red(), foreCol.green(), foreCol.blue())); ConfigureSyntax(formatText, SCLEX_BUFFER);