Changeset 113


Ignore:
Timestamp:
Dec 10, 2024, 4:51:28 PM (11 days ago)
Author:
chronos
Message:
  • Fixed: Dark theme detection for board colors.
Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Game.pas

    r112 r113  
    151151
    152152uses
    153   Core, MetaCanvas, PixelPointer;
     153  Core, MetaCanvas, PixelPointer, Theme;
    154154
    155155procedure Translate;
     
    11461146  Color: TPixel32;
    11471147begin
    1148   if Core.Core.ThemeManager1.Theme.Name = 'Dark' then begin
     1148  if (Core.Core.ThemeManager1.Theme.Name = ThemeNameDark) or
     1149  ((Core.Core.ThemeManager1.Theme.Name = ThemeNameSystem) and
     1150  Core.Core.ThemeManager1.IsDarkTheme)
     1151  then begin
    11491152    case Value of
    11501153      0: Result := $222629;
  • 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.