Skip to content

Commit

Permalink
Fixes for issue JAM-Software#677 (DPI awareness with different monito…
Browse files Browse the repository at this point in the history
…r DPIs):

* TBaseVirtualTree.ChangeScale() now scales the node heights too
* TBaseVirtualTree.ChangeScale() now uses DefaultScalingFlags in case of a dpi scaling, just like TControl.ChangeScale() does it.
* TBaseVirtualTree.ChangeScale() now calls AutoScale() after calling inherited, to ensure that the Font has been updated.
# Conflicts:
#	Source/VirtualTrees.pas
  • Loading branch information
Joachim Marder authored and ValtsS committed Jan 24, 2019
1 parent 7150410 commit 4ea4b7f
Showing 1 changed file with 27 additions and 13 deletions.
40 changes: 27 additions & 13 deletions Source/VirtualTrees.pas
Original file line number Diff line number Diff line change
Expand Up @@ -19878,22 +19878,36 @@ procedure TBaseVirtualTree.Change(Node: PVirtualNode);
//----------------------------------------------------------------------------------------------------------------------

procedure TBaseVirtualTree.ChangeScale(M, D: Integer);

var
Flags: TScalingFlags;
Run: PVirtualNode;
begin
inherited;
if (toAutoChangeScale in FOptions.FAutoOptions) then
begin
if (M <> D) then
begin
if sfHeight in ScalingFlags then begin
// It is important to evaluate the TScalingFlags before calling inherited, becuase they are differetn afterwards!
if csLoading in ComponentState then
Flags := ScalingFlags
else
Flags := DefaultScalingFlags; // Important for #677
if (sfHeight in Flags) then begin
FHeader.ChangeScale(M, D);
SetDefaultNodeHeight(MulDiv(FDefaultNodeHeight, M, D));
end;
if sfHeight in ScalingFlags then
Indent := MulDiv(Indent, M, D);
// Scale also node heights
Run := GetFirstInitialized;
while Assigned(Run) do
begin
Run.NodeHeight := MulDiv(Run.NodeHeight, M, D);
Run := GetNextInitialized(Run);
end; // while
end;//if sfHeight
end;// if M<>D
AutoScale(M <> D);
end;//if toAutoChangeScale
// It is important to do this call after calling inherited, so that the Font has been updated.
AutoScale(M <> D);
end;

//----------------------------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -21048,15 +21062,15 @@ procedure TBaseVirtualTree.DoColumnResize(Column: TColumnIndex);

begin
if not (csLoading in ComponentState) and HandleAllocated then
begin
// Reset all vsHeightMeasured flags if we are in multiline mode.
Run := GetFirstInitialized;
while Assigned(Run) do
begin
// Reset all vsHeightMeasured flags if we are in multiline mode.
Run := GetFirstInitialized;
while Assigned(Run) do
begin
if vsMultiline in Run.States then
Exclude(Run.States, vsHeightMeasured);
Run := GetNextInitialized(Run);
end;
Exclude(Run.States, vsHeightMeasured);
Run := GetNextInitialized(Run);
end;

UpdateHorizontalScrollBar(True);
if Column > NoColumn then
Expand Down Expand Up @@ -27305,7 +27319,7 @@ procedure TBaseVirtualTree.AutoScale(isDpiChange: Boolean);
lTextHeight := Canvas.TextHeight('Tg');
// By default, we only ensure that DefaultNodeHeight is large enough.
// If the form's dpi has changed, we scale up and down the DefaultNodeHeight, See issue #677.
if (lTextHeight > Self.DefaultNodeHeight) or (isDpiChange and (lTextHeight <> Self.DefaultNodeHeight)) then
if (lTextHeight > Self.DefaultNodeHeight) then
Self.DefaultNodeHeight := lTextHeight;
end;
end;
Expand Down

0 comments on commit 4ea4b7f

Please sign in to comment.