mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-12-17 01:21:07 +01:00
lcl: TControl: highDPI: scale margins and constraints.
git-svn-id: trunk@53576 -
This commit is contained in:
parent
6b37ddd73e
commit
110955f1da
@ -622,6 +622,7 @@ type
|
|||||||
function EffectiveMaxHeight: integer; virtual;
|
function EffectiveMaxHeight: integer; virtual;
|
||||||
function MinMaxWidth(Width: integer): integer;
|
function MinMaxWidth(Width: integer): integer;
|
||||||
function MinMaxHeight(Height: integer): integer;
|
function MinMaxHeight(Height: integer): integer;
|
||||||
|
procedure AutoAdjustLayout(const AXProportion, AYProportion: Double);
|
||||||
public
|
public
|
||||||
property MaxInterfaceHeight: integer read FMaxInterfaceHeight;
|
property MaxInterfaceHeight: integer read FMaxInterfaceHeight;
|
||||||
property MaxInterfaceWidth: integer read FMaxInterfaceWidth;
|
property MaxInterfaceWidth: integer read FMaxInterfaceWidth;
|
||||||
@ -742,6 +743,7 @@ type
|
|||||||
procedure GetSpaceAround(var SpaceAround: TRect); virtual;
|
procedure GetSpaceAround(var SpaceAround: TRect); virtual;
|
||||||
function GetSideSpace(Kind: TAnchorKind): Integer; // Around+GetSpace
|
function GetSideSpace(Kind: TAnchorKind): Integer; // Around+GetSpace
|
||||||
function GetSpace(Kind: TAnchorKind): Integer; virtual;
|
function GetSpace(Kind: TAnchorKind): Integer; virtual;
|
||||||
|
procedure AutoAdjustLayout(const AXProportion, AYProportion: Double);
|
||||||
public
|
public
|
||||||
property Control: TControl read FControl;
|
property Control: TControl read FControl;
|
||||||
property Space[Kind: TAnchorKind]: integer read GetSpace write SetSpace;
|
property Space[Kind: TAnchorKind]: integer read GetSpace write SetSpace;
|
||||||
@ -3643,6 +3645,37 @@ begin
|
|||||||
Dest.Assign(Self);
|
Dest.Assign(Self);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TControlBorderSpacing.AutoAdjustLayout(const AXProportion,
|
||||||
|
AYProportion: Double);
|
||||||
|
|
||||||
|
procedure Scale(var Value: Integer; const Proportion: Double; var Changed: Boolean);
|
||||||
|
begin
|
||||||
|
if Value<>0 then
|
||||||
|
begin
|
||||||
|
Value := Round(Value * Proportion);
|
||||||
|
Changed := True;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
var
|
||||||
|
InnerChanged, OuterChanged: Boolean;
|
||||||
|
begin
|
||||||
|
InnerChanged := False;
|
||||||
|
OuterChanged := False;
|
||||||
|
|
||||||
|
Scale(FAround, AXProportion, OuterChanged);
|
||||||
|
Scale(FInnerBorder, AXProportion, InnerChanged);
|
||||||
|
Scale(FLeft, AXProportion, OuterChanged);
|
||||||
|
Scale(FTop, AYProportion, OuterChanged);
|
||||||
|
Scale(FRight, AXProportion, OuterChanged);
|
||||||
|
Scale(FBottom, AYProportion, OuterChanged);
|
||||||
|
|
||||||
|
if OuterChanged or InnerChanged then
|
||||||
|
begin
|
||||||
|
if Control<>nil then Control.InvalidatePreferredSize;
|
||||||
|
Change(InnerChanged);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
function TControlBorderSpacing.IsEqual(Spacing: TControlBorderSpacing
|
function TControlBorderSpacing.IsEqual(Spacing: TControlBorderSpacing
|
||||||
): boolean;
|
): boolean;
|
||||||
begin
|
begin
|
||||||
|
|||||||
@ -2981,6 +2981,8 @@ begin
|
|||||||
// Apply the changes
|
// Apply the changes
|
||||||
if AMode in [lapAutoAdjustWithoutHorizontalScrolling, lapAutoAdjustForDPI] then
|
if AMode in [lapAutoAdjustWithoutHorizontalScrolling, lapAutoAdjustForDPI] then
|
||||||
begin
|
begin
|
||||||
|
|
||||||
|
// Dimensions
|
||||||
AAWidth := False;
|
AAWidth := False;
|
||||||
AAHeight := False;
|
AAHeight := False;
|
||||||
NewLeft := Left;
|
NewLeft := Left;
|
||||||
@ -3054,6 +3056,9 @@ begin
|
|||||||
NewTop := NewTop-NewHeight+OldHeight;
|
NewTop := NewTop-NewHeight+OldHeight;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
BorderSpacing.AutoAdjustLayout(AXProportion, AYProportion);
|
||||||
|
Constraints.AutoAdjustLayout(AXProportion, AYProportion);
|
||||||
|
|
||||||
SetBounds(NewLeft, NewTop, NewWidth, NewHeight);
|
SetBounds(NewLeft, NewTop, NewWidth, NewHeight);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|||||||
@ -264,4 +264,29 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TSizeConstraints.AutoAdjustLayout(const AXProportion,
|
||||||
|
AYProportion: Double);
|
||||||
|
|
||||||
|
procedure Scale(var Value: Integer; const Proportion: Double; var Changed: Boolean);
|
||||||
|
begin
|
||||||
|
if Value<>0 then
|
||||||
|
begin
|
||||||
|
Value := Round(Value * Proportion);
|
||||||
|
Changed := True;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
var
|
||||||
|
Changed: Boolean;
|
||||||
|
begin
|
||||||
|
Changed := False;
|
||||||
|
|
||||||
|
Scale(FMaxWidth, AXProportion, Changed);
|
||||||
|
Scale(FMinWidth, AXProportion, Changed);
|
||||||
|
Scale(FMaxHeight, AYProportion, Changed);
|
||||||
|
Scale(FMinHeight, AYProportion, Changed);
|
||||||
|
|
||||||
|
if Changed then
|
||||||
|
Change;
|
||||||
|
end;
|
||||||
|
|
||||||
// included by controls.pp
|
// included by controls.pp
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user