Skip to content

Commit

Permalink
Issue #8: optimize readability in grid, by using a calculated color f…
Browse files Browse the repository at this point in the history
…or selected cells, based on the theme window color
  • Loading branch information
ansgarbecker committed Dec 7, 2018
1 parent b571bca commit 1b9f543
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions source/main.pas
Expand Up @@ -8688,8 +8688,6 @@ procedure TMainForm.AnyGridPaintText(Sender: TBaseVirtualTree; const TargetCanva
// Do not apply any color on a selected, highlighted cell to keep readability // Do not apply any color on a selected, highlighted cell to keep readability
if (vsSelected in Node.States) and (Node = Sender.FocusedNode) and (Column = Sender.FocusedColumn) then if (vsSelected in Node.States) and (Node = Sender.FocusedNode) and (Column = Sender.FocusedColumn) then
cl := GetThemeColor(clHighlightText) cl := GetThemeColor(clHighlightText)
else if vsSelected in Node.States then
cl := clBlack
else if r.IsNull(Column) then else if r.IsNull(Column) then
cl := DatatypeCategories[r.DataType(Column).Category].NullColor cl := DatatypeCategories[r.DataType(Column).Category].NullColor
else else
Expand Down Expand Up @@ -9208,6 +9206,7 @@ procedure TMainForm.AnyGridBeforeCellPaint(Sender: TBaseVirtualTree;
RowNumber: PInt64; RowNumber: PInt64;
isEven, FocusedIsNull, CurrentIsNull: Boolean; isEven, FocusedIsNull, CurrentIsNull: Boolean;
FieldText, FocusedFieldText: String; FieldText, FocusedFieldText: String;
VT: TVirtualStringTree;
begin begin
if Column = -1 then if Column = -1 then
Exit; Exit;
Expand All @@ -9219,6 +9218,7 @@ procedure TMainForm.AnyGridBeforeCellPaint(Sender: TBaseVirtualTree;
Exit; Exit;
end; end;


VT := Sender as TVirtualStringTree;
RowNumber := Sender.GetNodeData(Node); RowNumber := Sender.GetNodeData(Node);
r.RecNo := RowNumber^; r.RecNo := RowNumber^;


Expand All @@ -9232,11 +9232,17 @@ procedure TMainForm.AnyGridBeforeCellPaint(Sender: TBaseVirtualTree;
else else
cl := clNone; cl := clNone;


if (vsSelected in Node.States) and (Node = Sender.FocusedNode) and (Column = Sender.FocusedColumn) then if (vsSelected in Node.States) and (Node = Sender.FocusedNode) and (Column = Sender.FocusedColumn) then begin
// Focused cell
cl := GetThemeColor(clHighlight) cl := GetThemeColor(clHighlight)
else if vsSelected in Node.States then end else if vsSelected in Node.States then begin
cl := $00DDDDDD // Selected but not focused cell
else if r.IsNull(Column) then begin if VT.Color > ColorAdjustBrightness(clWhite, -19) then
cl := ColorAdjustBrightness(VT.Color, -19)
else
cl := ColorAdjustBrightness(VT.Color, 19);
end else if r.IsNull(Column) then begin
// Cell with NULL value
clNull := AppSettings.ReadInt(asFieldNullBackground); clNull := AppSettings.ReadInt(asFieldNullBackground);
if clNull <> clNone then if clNull <> clNone then
cl := clNull; cl := clNull;
Expand Down

0 comments on commit 1b9f543

Please sign in to comment.