summaryrefslogtreecommitdiff
path: root/src/settings.cpp
diff options
context:
space:
mode:
authorMikaël Capelle <capelle.mikael@gmail.com>2021-01-08 17:41:10 +0100
committerMikaël Capelle <capelle.mikael@gmail.com>2021-01-10 10:27:30 +0100
commit7b684f4d15fa8f75fe802f9dd1534cf4ee2c25ea (patch)
tree71a56125c5ccab03c34c6b95f0e208f8f56d95fc /src/settings.cpp
parentd923730452e129260dc08a2a909c897eb9475ce7 (diff)
Tentative fix for automatic text color when markers or separator colors are used.
Diffstat (limited to 'src/settings.cpp')
-rw-r--r--src/settings.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/settings.cpp b/src/settings.cpp
index 251e2b15..488a9b01 100644
--- a/src/settings.cpp
+++ b/src/settings.cpp
@@ -1326,12 +1326,12 @@ void ColorSettings::setColorSeparatorScrollbar(bool b)
QColor ColorSettings::idealTextColor(const QColor& rBackgroundColor)
{
- if (rBackgroundColor.alpha() == 0)
+ if (rBackgroundColor.alpha() < 50)
return QColor(Qt::black);
- const int THRESHOLD = 106 * 255.0f / rBackgroundColor.alpha();
- int BackgroundDelta = (rBackgroundColor.red() * 0.299) + (rBackgroundColor.green() * 0.587) + (rBackgroundColor.blue() * 0.114);
- return QColor((255 - BackgroundDelta <= THRESHOLD) ? Qt::black : Qt::white);
+ // "inverse' of luminance of the background
+ int iLuminance = (rBackgroundColor.red() * 0.299) + (rBackgroundColor.green() * 0.587) + (rBackgroundColor.blue() * 0.114);
+ return QColor(iLuminance >= 128 ? Qt::black : Qt::white);
}