Changeset 581 for Common/Theme.pas


Ignore:
Timestamp:
Dec 10, 2024, 4:50:34 PM (12 days ago)
Author:
chronos
Message:
  • Modified: Improved Common package.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • Common/Theme.pas

    r563 r581  
    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.