mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-12-10 00:17:18 +01:00
ide, designer: high-DPI: scale non-visual components. Issue #31812
git-svn-id: trunk@54932 -
This commit is contained in:
parent
6a48f71755
commit
be04a6d474
@ -3577,10 +3577,7 @@ begin
|
||||
FOnGetNonVisualCompIcon(Self, AComponent, Icon);
|
||||
if Icon <> nil then
|
||||
begin
|
||||
inc(IconRect.Left, (NonVisualCompIconWidth - Icon.Width) div 2);
|
||||
inc(IconRect.Top, (NonVisualCompIconWidth - Icon.Height) div 2);
|
||||
IconRect.Right := IconRect.Left + Icon.Width;
|
||||
IconRect.Bottom := IconRect.Top + Icon.Height;
|
||||
InflateRect(IconRect, -2 * NonVisualCompBorder, -2 * NonVisualCompBorder);
|
||||
FSurface.Canvas.StretchDraw(IconRect, Icon);
|
||||
end;
|
||||
end;
|
||||
|
||||
@ -84,7 +84,6 @@ type
|
||||
const
|
||||
NonVisualCompIconWidth = ComponentPaletteImageWidth;
|
||||
NonVisualCompBorder = 2;
|
||||
NonVisualCompWidth = NonVisualCompIconWidth + 2 * NonVisualCompBorder;
|
||||
|
||||
|
||||
type
|
||||
@ -93,6 +92,7 @@ type
|
||||
var
|
||||
OnComponentIsInvisible: TOnComponentIsInvisible;
|
||||
|
||||
function NonVisualCompWidth: integer;
|
||||
function GetParentLevel(AControl: TControl): integer;
|
||||
function ControlIsInDesignerVisible(AControl: TControl): boolean;
|
||||
function ComponentIsInvisible(AComponent: TComponent): boolean;
|
||||
@ -118,6 +118,9 @@ procedure InvalidateDesignerRect(aHandle: HWND; ARect: pRect);
|
||||
procedure WriteComponentStates(aComponent: TComponent; Recursive: boolean;
|
||||
const Prefix: string = '');
|
||||
|
||||
procedure ScaleNonVisual(const aParent: TComponent;
|
||||
const AFromPPI, AToPPI: Integer);
|
||||
|
||||
implementation
|
||||
|
||||
|
||||
@ -327,6 +330,31 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure ScaleNonVisual(const aParent: TComponent; const AFromPPI,
|
||||
AToPPI: Integer);
|
||||
var
|
||||
I: Integer;
|
||||
Comp: TComponent;
|
||||
DsgnInfo: LongInt;
|
||||
begin
|
||||
for I := 0 to aParent.ComponentCount-1 do
|
||||
begin
|
||||
Comp := aParent.Components[I];
|
||||
DsgnInfo := Comp.DesignInfo;
|
||||
LongRec(DsgnInfo).Lo:=MulDiv(LongRec(DsgnInfo).Lo, AToPPI, AFromPPI);
|
||||
LongRec(DsgnInfo).Hi:=MulDiv(LongRec(DsgnInfo).Hi, AToPPI, AFromPPI);
|
||||
Comp.DesignInfo := DsgnInfo;
|
||||
end;
|
||||
end;
|
||||
|
||||
function NonVisualCompWidth: integer;
|
||||
begin
|
||||
if Application.Scaled then
|
||||
Result := MulDiv(NonVisualCompIconWidth, Screen.PixelsPerInch, 96) + 2 * NonVisualCompBorder
|
||||
else
|
||||
Result := NonVisualCompIconWidth + 2 * NonVisualCompBorder
|
||||
end;
|
||||
|
||||
function GetParentLevel(AControl: TControl): integer;
|
||||
begin
|
||||
Result:=0;
|
||||
|
||||
@ -53,7 +53,7 @@ uses
|
||||
ControlSelection, FormEditor, EmptyMethodsDlg, BaseDebugManager, TransferMacros,
|
||||
BuildManager, EditorMacroListViewer, FindRenameIdentifier, GenericCheckList,
|
||||
ViewUnit_Dlg, DiskDiffsDialog, InputHistory, CheckLFMDlg, PublishModule, etMessagesWnd,
|
||||
ConvCodeTool, BasePkgManager, PackageDefs, PackageSystem, Designer;
|
||||
ConvCodeTool, BasePkgManager, PackageDefs, PackageSystem, Designer, DesignerProcs;
|
||||
|
||||
type
|
||||
|
||||
@ -6251,6 +6251,7 @@ var
|
||||
ARestoreVisible: Boolean;
|
||||
AncestorClass: TComponentClass;
|
||||
DsgControl: TCustomDesignControl;
|
||||
DsgDataModule: TDataModule;
|
||||
begin
|
||||
{$IFDEF IDE_DEBUG}
|
||||
debugln('TLazSourceFileManager.LoadLFM A ',AnUnitInfo.Filename,' IsPartOfProject=',dbgs(AnUnitInfo.IsPartOfProject),' ');
|
||||
@ -6433,10 +6434,30 @@ begin
|
||||
begin
|
||||
DsgControl := TCustomDesignControl(NewComponent);
|
||||
if Project1.Scaled and DsgControl.Scaled and (DsgControl.DesignTimePPI<>Screen.PixelsPerInch) then
|
||||
begin
|
||||
DsgControl.AutoAdjustLayout(lapAutoAdjustForDPI, DsgControl.DesignTimePPI, Screen.PixelsPerInch, 0, 0);
|
||||
DesignerProcs.ScaleNonVisual(DsgControl, DsgControl.DesignTimePPI, Screen.PixelsPerInch);
|
||||
end;
|
||||
DsgControl.DesignTimePPI := Screen.PixelsPerInch;
|
||||
DsgControl.PixelsPerInch := Screen.PixelsPerInch;
|
||||
end;
|
||||
{$IFDEF DataModulePPI} // To-Do: replace with an FPC version after DesignPPI has been applied to FPC
|
||||
if NewComponent is TDataModule then
|
||||
begin
|
||||
DsgDataModule := TDataModule(NewComponent);
|
||||
if (DsgDataModule.DesignPPI<>Screen.PixelsPerInch) then
|
||||
begin
|
||||
DesignerProcs.ScaleNonVisual(DsgDataModule, DsgDataModule.DesignPPI, Screen.PixelsPerInch);
|
||||
DsgDataModule.DesignOffset := Point(
|
||||
MulDiv(DsgDataModule.DesignOffset.x, Screen.PixelsPerInch, DsgDataModule.DesignPPI),
|
||||
MulDiv(DsgDataModule.DesignOffset.y, Screen.PixelsPerInch, DsgDataModule.DesignPPI));
|
||||
DsgDataModule.DesignSize := Point(
|
||||
MulDiv(DsgDataModule.DesignSize.x, Screen.PixelsPerInch, DsgDataModule.DesignPPI),
|
||||
MulDiv(DsgDataModule.DesignSize.y, Screen.PixelsPerInch, DsgDataModule.DesignPPI));
|
||||
DsgDataModule.DesignPPI := Screen.PixelsPerInch;
|
||||
end;
|
||||
end;
|
||||
{$ENDIF}
|
||||
|
||||
if NewComponent is TFrame then
|
||||
AnUnitInfo.ResourceBaseClass:=pfcbcFrame
|
||||
|
||||
Loading…
Reference in New Issue
Block a user