mirror of
https://git.vladimir.cc/vladimir/ewsdr.git
synced 2026-08-25 20:37:33 +00:00
fix(ui): DPI-масштабирование SettingsForm/DeviceForm + общий DpiScale
Вся раскладка окон, построенных кодом (SettingsForm, DeviceForm), была захардкожена в пикселях под неявные 96 DPI — на Windows 125-200% или HiDPI-десктопах контролы физически не росли вместе с укрупнившимся шрифтом. Добавлено масштабирование SetBounds через MulDiv(V, Screen.PixelsPerInch, 96) на каждой листовой точке потребления (const-блоки раскладки не трогались). Общий DpiScale вынесен в новый юнит DpiUtils.pas — убрана дублированная копия одноимённого приватного метода в 9 классах (FlatCheckBox, FlatComboBox, FlatListBox, FlatSpinEdit, FlatFloatSpinEdit, FlatEdit, FlatRadioButton, FlatPopupMenu, SettingsForm, DeviceForm) и инлайн-MulDiv без обёртки в MainForm.pas/PanafallPanel.pas. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
+2
-10
@@ -9,7 +9,7 @@ interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, Controls, Graphics, Forms, LCLType, LMessages, Types,
|
||||
Math, AppTheme;
|
||||
Math, AppTheme, DpiUtils;
|
||||
|
||||
type
|
||||
TFlatComboBox = class;
|
||||
@@ -52,7 +52,6 @@ type
|
||||
FClrPopupBG: TColor;
|
||||
FClrPopupHot: TColor;
|
||||
FClrPopupSel: TColor;
|
||||
function DpiScale(V: Integer): Integer;
|
||||
function ItemHeight: Integer;
|
||||
function ArrowWidth: Integer;
|
||||
procedure ItemsChanged(Sender: TObject);
|
||||
@@ -162,7 +161,7 @@ begin
|
||||
Canvas.Brush.Style := bsClear;
|
||||
Canvas.Font.Color := FCombo.FClrText;
|
||||
TextY := Y + (FCombo.ItemHeight - Canvas.TextHeight('Ag')) div 2;
|
||||
Canvas.TextOut(FCombo.DpiScale(BASE_PAD), TextY, FCombo.Items[ItemIdx]);
|
||||
Canvas.TextOut(DpiScale(BASE_PAD), TextY, FCombo.Items[ItemIdx]);
|
||||
Canvas.Brush.Style := bsSolid;
|
||||
end;
|
||||
|
||||
@@ -288,13 +287,6 @@ begin
|
||||
FClrPopupSel := TColor($00183618);
|
||||
end;
|
||||
|
||||
function TFlatComboBox.DpiScale(V: Integer): Integer;
|
||||
begin
|
||||
Result := MulDiv(V, Screen.PixelsPerInch, 96);
|
||||
if (V > 0) and (Result < 1) then
|
||||
Result := 1;
|
||||
end;
|
||||
|
||||
function TFlatComboBox.ItemHeight: Integer;
|
||||
begin
|
||||
Result := DpiScale(BASE_ITEM_H);
|
||||
|
||||
Reference in New Issue
Block a user