Ignore:
Timestamp:
Dec 10, 2024, 4:51:28 PM (12 days ago)
Author:
chronos
Message:
  • Fixed: Dark theme detection for board colors.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Packages/Common/Theme.pas

    r85 r113  
    3030  private
    3131    FTheme: TTheme;
     32    function Gray(C: TColor): Byte;
    3233    procedure SetTheme(AValue: TTheme);
    3334    procedure SetThemeName(AValue: TTheme);
     
    3536    Used: Boolean;
    3637    Themes: TThemes;
     38    function IsDarkTheme: Boolean;
    3739    procedure ApplyTheme(Component: TComponent);
    3840    constructor Create(AOwner: TComponent); override;
     
    9395    Strings.EndUpdate;
    9496  end;
     97end;
     98
     99{ TThemeManager }
     100
     101function TThemeManager.Gray(C: TColor): Byte;
     102begin
     103  Result := Trunc(Red(C) * 0.3 + Green(C) * 0.59 + Blue(C) * 0.11);
     104end;
     105
     106function TThemeManager.IsDarkTheme: Boolean;
     107begin
     108  Result := Gray(ColorToRGB(clWindow)) < Gray(ColorToRGB(clWindowText));
    95109end;
    96110
Note: See TracChangeset for help on using the changeset viewer.