From 98c6019a1f699a544d1fc9b653775a451e66aba8 Mon Sep 17 00:00:00 2001 From: martin Date: Thu, 3 Jun 2010 16:23:32 +0000 Subject: [PATCH] fix/improve contrast detection Colorscheme / issue #16628 git-svn-id: trunk@25867 - --- ide/sourceeditprocs.pas | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/ide/sourceeditprocs.pas b/ide/sourceeditprocs.pas index 01fdf4ff27..906ac52204 100644 --- a/ide/sourceeditprocs.pas +++ b/ide/sourceeditprocs.pas @@ -144,13 +144,14 @@ var GreenDiff: integer; BlueDiff: integer; begin + NewColor := ColorToRGB(NewColor); FGRed:=(NewColor shr 16) and $ff; FGGreen:=(NewColor shr 8) and $ff; FGBlue:=NewColor and $ff; RedDiff:=Abs(FGRed-BGRed); GreenDiff:=Abs(FGGreen-BGGreen); - BlueDiff:=Abs(FGBlue-BGBlue); - if RedDiff*RedDiff + GreenDiff*GreenDiff + BlueDiff*BlueDiff<70000 then + BlueDiff:=Abs(FGBlue -BGBlue); + if RedDiff*RedDiff + GreenDiff*GreenDiff + BlueDiff*BlueDiff<30000 then begin NewColor:=InvertColor(NewColor); {IncreaseDiff(FGRed,BGRed); @@ -220,7 +221,7 @@ var ItemNode: TCodeTreeNode; SubNode: TCodeTreeNode; begin - ForegroundColor := ACanvas.Font.Color; + ForegroundColor := ColorToRGB(ACanvas.Font.Color); Result.X := 0; Result.Y := ACanvas.TextHeight('W'); if CurrentCompletionType=ctIdentCompletion then begin @@ -231,7 +232,7 @@ begin ACanvas.TextOut(x+1, y, 'PaintCompletionItem: BUG in codetools'); exit; end; - BackgroundColor:=ACanvas.Brush.Color; + BackgroundColor:=ColorToRGB(ACanvas.Brush.Color); BGRed:=(BackgroundColor shr 16) and $ff; BGGreen:=(BackgroundColor shr 8) and $ff; BGBlue:=BackgroundColor and $ff;