Changeset 473 for trunk/Settings.pas


Ignore:
Timestamp:
Dec 4, 2023, 12:13:15 PM (12 months ago)
Author:
chronos
Message:
  • Added: Custom DPI configuration in Settings dialog.
  • Fixed: Better High DPI support.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Settings.pas

    r471 r473  
    1414  TSettingsDlg = class(TDrawDlg)
    1515    ButtonFullscreen: TButtonC;
    16     Down2Btn: TButtonC;
     16    ButtonCustomDpi: TButtonC;
     17    ButtonGammaDown: TButtonC;
     18    ButtonDpiDown: TButtonC;
    1719    EditShortCutPrimary: TEdit;
    1820    EditShortCutSecondary: TEdit;
     
    2224    ButtonCancel: TButtonA;
    2325    ButtonReset: TButtonA;
    24     Up2Btn: TButtonC;
     26    ButtonGammaUp: TButtonC;
     27    ButtonDpiUp: TButtonC;
     28    procedure ButtonCustomDpiClick(Sender: TObject);
     29    procedure ButtonDpiDownClick(Sender: TObject);
     30    procedure ButtonDpiUpClick(Sender: TObject);
    2531    procedure ButtonFullscreenClick(Sender: TObject);
    2632    procedure ButtonCancelClick(Sender: TObject);
    2733    procedure ButtonResetClick(Sender: TObject);
    28     procedure Down2BtnClick(Sender: TObject);
     34    procedure ButtonGammaDownClick(Sender: TObject);
    2935    procedure EditShortCutPrimaryKeyUp(Sender: TObject; var Key: Word;
    3036      Shift: TShiftState);
     
    3844    procedure ListKeyBindingsSelectionChange(Sender: TObject; User: Boolean);
    3945    procedure ButtonOkClick(Sender: TObject);
    40     procedure Up2BtnClick(Sender: TObject);
     46    procedure ButtonGammaUpClick(Sender: TObject);
    4147  private
    4248    LocalGamma: Integer;
    4349    LocalKeyBindings: TKeyBindings;
    4450    CurrentKeyBinding: TKeyBinding;
     51    LocalDpi: Integer;
    4552    procedure UpdateShortCutItem;
     53    function GetLocalCustomDpiEnabled: Boolean;
    4654  public
    4755    procedure LoadData;
     
    6270var
    6371  SFullScreen, SGamma, SRestartMsg, SShortCutPrimary, SShortCutSecondary,
    64   SLanguages, SKeyBindings: string;
     72  SLanguages, SKeyBindings, SCustomDpi, SDpi: string;
    6573
    6674procedure ReloadLanguages;
     
    7381  SLanguages := Phrases.Lookup('SETTINGS', 5);
    7482  SKeyBindings := Phrases.Lookup('SETTINGS', 6);
     83  SCustomDpi := Phrases.Lookup('SETTINGS', 7);
     84  SDpi := Phrases.Lookup('SETTINGS', 8);
    7585end;
    7686
     
    108118end;
    109119
    110 procedure TSettingsDlg.Down2BtnClick(Sender: TObject);
     120procedure TSettingsDlg.ButtonGammaDownClick(Sender: TObject);
    111121begin
    112122  if LocalGamma > 50 then
     
    156166end;
    157167
     168procedure TSettingsDlg.ButtonDpiDownClick(Sender: TObject);
     169begin
     170  if LocalDpi >= 105 then
     171  begin
     172    Dec(LocalDpi, 5);
     173    Invalidate;
     174  end;
     175end;
     176
     177procedure TSettingsDlg.ButtonCustomDpiClick(Sender: TObject);
     178begin
     179  ButtonCustomDpi.ButtonIndex := ButtonCustomDpi.ButtonIndex xor 1;
     180end;
     181
     182procedure TSettingsDlg.ButtonDpiUpClick(Sender: TObject);
     183begin
     184  if LocalDpi <= 495 then begin
     185    Inc(LocalDpi, 5);
     186    Invalidate;
     187  end;
     188end;
     189
    158190procedure TSettingsDlg.FormDestroy(Sender: TObject);
    159191begin
     
    163195procedure TSettingsDlg.FormPaint(Sender: TObject);
    164196begin
    165   PaintBackground(self, 3, 3, ClientWidth - 6, ClientHeight - 6);
     197  PaintBackground(Self, 3, 3, ClientWidth - 6, ClientHeight - 6);
    166198  Frame(Canvas, 0, 0, ClientWidth - 1, ClientHeight - 1, 0, 0);
    167199  Frame(Canvas, 1, 1, ClientWidth - 2, ClientHeight - 2,
     
    178210    ButtonFullscreen.Left + 12, ButtonFullscreen.Top + 12, MainTexture.ColorBevelShade,
    179211    MainTexture.ColorBevelLight);
     212  {$IFDEF DPI}
     213  RFrame(Canvas, ButtonCustomDpi.Left - 1, ButtonCustomDpi.Top - 1,
     214    ButtonCustomDpi.Left + 12, ButtonCustomDpi.Top + 12, MainTexture.ColorBevelShade,
     215    MainTexture.ColorBevelLight);
     216  LoweredTextOut(Canvas, -2, MainTexture, ButtonCustomDpi.Left + 32,
     217    ButtonCustomDpi.Top - 4, SCustomDpi);
     218  UnderlinedTitleValue(Canvas, SDpi, IntToStr(LocalDpi) + '%',
     219    ButtonDpiUp.Left - 150 - 4, ButtonDpiUp.Top + 2, 150);
     220  {$ENDIF}
    180221
    181222  LoweredTextOut(Canvas, -2, MainTexture, ListLanguages.Left,
     
    186227    ButtonFullscreen.Top - 4, SFullScreen);
    187228  UnderlinedTitleValue(Canvas, SGamma, IntToStr(LocalGamma) + '%',
    188     Up2Btn.Left - 150 - 4, Up2Btn.Top + 2, 150);
     229    ButtonGammaUp.Left - 150 - 4, ButtonGammaUp.Top + 2, 150);
    189230  LoweredTextOut(Canvas, -2, MainTexture, EditShortCutPrimary.Left,
    190231    EditShortCutPrimary.Top - 26, SShortCutPrimary);
     
    204245  EditShortCutPrimary.Font.Color := MainTexture.ColorMark;
    205246  EditShortCutSecondary.Font.Color := MainTexture.ColorMark;
     247  {$IFDEF DPI}
     248  ButtonCustomDpi.Visible := True;
     249  ButtonDpiDown.Visible := True;
     250  ButtonDpiUp.Visible := True;
     251  {$ELSE}
     252  ButtonCustomDpi.Visible := False;
     253  ButtonDpiDown.Visible := False;
     254  ButtonDpiUp.Visible := False;
     255  {$ENDIF}
    206256end;
    207257
     
    241291end;
    242292
    243 procedure TSettingsDlg.Up2BtnClick(Sender: TObject);
     293procedure TSettingsDlg.ButtonGammaUpClick(Sender: TObject);
    244294begin
    245295  if LocalGamma < 150 then begin
     
    262312end;
    263313
     314function TSettingsDlg.GetLocalCustomDpiEnabled: Boolean;
     315begin
     316  Result := (ButtonCustomDpi.ButtonIndex and 1) = 1;
     317end;
     318
    264319procedure TSettingsDlg.LoadData;
    265320begin
     
    272327  LocalGamma := Gamma;
    273328  LocalKeyBindings.Assign(KeyBindings.KeyBindings);
     329  {$IFDEF DPI}
     330  if CustomDpiEnabled then ButtonCustomDpi.ButtonIndex := 3
     331    else ButtonCustomDpi.ButtonIndex := 2;
     332  LocalDpi := Round(CustomDpi * 100 / 96);
     333  {$ENDIF}
    274334end;
    275335
     
    278338  NeedRestart: Boolean;
    279339begin
    280   NeedRestart := Gamma <> LocalGamma;
     340  NeedRestart := (Gamma <> LocalGamma) or (CustomDpiEnabled <> GetLocalCustomDpiEnabled) or
     341    ((GetLocalCustomDpiEnabled and (LocalDpi <> CustomDpi)));
    281342  if ListLanguages.ItemIndex <> -1 then begin
    282343    StartDlg.Translator.Language := TLanguage(ListLanguages.Items.Objects[ListLanguages.ItemIndex]);
     
    288349  FullScreen := (ButtonFullscreen.ButtonIndex and 1) = 1;
    289350  Gamma := LocalGamma;
     351  ScreenTools.CustomDpiEnabled := CustomDpiEnabled;
    290352  if NeedRestart then SimpleMessage(SRestartMsg);
    291353  KeyBindings.KeyBindings.Assign(LocalKeyBindings);
     354  {$IFDEF DPI}
     355  CustomDpiEnabled := GetLocalCustomDpiEnabled;
     356  CustomDpi := Round(LocalDpi * 96 / 100);
     357  {$ENDIF}
    292358end;
    293359
Note: See TracChangeset for help on using the changeset viewer.