Skip to content

Commit

Permalink
Introduced new alias type TNodeHeight and set it to TNativeInt to fix…
Browse files Browse the repository at this point in the history
… issue #1260.
  • Loading branch information
joachimmarder committed Jun 30, 2024
1 parent 239928b commit 8642274
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
12 changes: 6 additions & 6 deletions Source/VirtualTrees.BaseTree.pas
Original file line number Diff line number Diff line change
Expand Up @@ -757,7 +757,7 @@ TBaseVirtualTree = class abstract(TVTBaseAncestor)
function GetFullyVisible(Node: PVirtualNode): Boolean;
function GetHasChildren(Node: PVirtualNode): Boolean;
function GetMultiline(Node: PVirtualNode): Boolean;
function GetNodeHeight(Node: PVirtualNode): TDimension;
function GetNodeHeight(Node: PVirtualNode): TNodeHeight;
function GetNodeParent(Node: PVirtualNode): PVirtualNode;
function GetOffsetXY: TPoint;
function GetRootNodeCount: Cardinal;
Expand Down Expand Up @@ -814,7 +814,7 @@ TBaseVirtualTree = class abstract(TVTBaseAncestor)
procedure SetMultiline(Node: PVirtualNode; const Value: Boolean);
procedure SetNodeAlignment(const Value: TVTNodeAlignment);
procedure SetNodeDataSize(Value: Integer);
procedure SetNodeHeight(Node: PVirtualNode; Value: TDimension);
procedure SetNodeHeight(Node: PVirtualNode; Value: TNodeHeight);
procedure SetNodeParent(Node: PVirtualNode; const Value: PVirtualNode);
procedure SetOffsetX(const Value: TDimension);
procedure SetOffsetXY(const Value: TPoint);
Expand Down Expand Up @@ -1606,7 +1606,7 @@ TBaseVirtualTree = class abstract(TVTBaseAncestor)
property IsFiltered[Node: PVirtualNode]: Boolean read GetFiltered write SetFiltered;
property IsVisible[Node: PVirtualNode]: Boolean read GetVisible write SetVisible;
property MultiLine[Node: PVirtualNode]: Boolean read GetMultiline write SetMultiline;
property NodeHeight[Node: PVirtualNode]: TDimension read GetNodeHeight write SetNodeHeight;
property NodeHeight[Node: PVirtualNode]: TNodeHeight read GetNodeHeight write SetNodeHeight;
property NodeParent[Node: PVirtualNode]: PVirtualNode read GetNodeParent write SetNodeParent;
property OffsetX: TDimension read FOffsetX write SetOffsetX;
property OffsetXY: TPoint read GetOffsetXY write SetOffsetXY;
Expand Down Expand Up @@ -3289,7 +3289,7 @@ function TBaseVirtualTree.GetMultiline(Node: PVirtualNode): Boolean;

//----------------------------------------------------------------------------------------------------------------------

function TBaseVirtualTree.GetNodeHeight(Node: PVirtualNode): TDimension;
function TBaseVirtualTree.GetNodeHeight(Node: PVirtualNode): TNodeHeight;

begin
if Assigned(Node) and (Node <> FRoot) then
Expand Down Expand Up @@ -4468,7 +4468,7 @@ procedure TBaseVirtualTree.SetChildCount(Node: PVirtualNode; NewChildCount: Card
Index: Cardinal;
Child: PVirtualNode;
Count: Integer;
NewHeight: TDimension;
NewHeight: TNodeHeight;
begin
if not (toReadOnly in FOptions.MiscOptions) then
begin
Expand Down Expand Up @@ -5052,7 +5052,7 @@ procedure TBaseVirtualTree.SetNodeDataSize(Value: Integer);

//----------------------------------------------------------------------------------------------------------------------

procedure TBaseVirtualTree.SetNodeHeight(Node: PVirtualNode; Value: TDimension);
procedure TBaseVirtualTree.SetNodeHeight(Node: PVirtualNode; Value: TNodeHeight);

var
Difference: TDimension;
Expand Down
15 changes: 8 additions & 7 deletions Source/VirtualTrees.Types.pas
Original file line number Diff line number Diff line change
Expand Up @@ -127,14 +127,16 @@ interface
{$IFDEF VT_FMX}
TDimension = Single;
PDimension = ^Single;
TNodeHeight = Single;
TVTCursor = TCursor;
TVTDragDataObject = TDragObject;
TVTBackground = TBitmap;
TVTPaintContext = TCanvas;
TVTBrush = TBrush;
{$ELSE}
TDimension = Integer; // For Firemonkey support, see #841
TDimension = Integer; // Introduced for Firemonkey support, see #841
PDimension = ^Integer;
TNodeHeight = NativeInt;
TVTCursor = HCURSOR;
IDataObject= WinApi.ActiveX.IDataObject;
TVTDragDataObject = IDataObject;
Expand Down Expand Up @@ -889,16 +891,15 @@ TScrollBarOptions = class(TPersistent)
private
fIndex: Cardinal; // index of node with regard to its parent
fChildCount: Cardinal; // number of child nodes
fNodeHeight: TDimension; // height in pixels
fNodeHeight: TNodeHeight; // height in pixels
public
States: TVirtualNodeStates; // states describing various properties of the node (expanded, initialized etc.)
Align: Byte; // line/button alignment
CheckState: TCheckState; // indicates the current check state (e.g. checked, pressed etc.)
CheckType: TCheckType; // indicates which check type shall be used for this node
Dummy: Byte; // dummy value to fill DWORD boundary
TotalCount: Cardinal; // sum of this node, all of its child nodes and their child nodes etc.
TotalHeight: TDimension; // height in pixels this node covers on screen including the height of all of its
// children
TotalHeight: TNodeHeight;// height in pixels this node covers on screen including the height of all of its children.
_Filler: TDWordFiller; // Ensure 8 Byte alignment of following pointers for 64bit builds. Issue #1136
// Note: Some copy routines require that all pointers (as well as the data area) in a node are
// located at the end of the node! Hence if you want to add new member fields (except pointers to internal
Expand All @@ -919,14 +920,14 @@ TScrollBarOptions = class(TPersistent)
procedure SetLastChild(const pLastChild: PVirtualNode); inline; //internal method, do not call directly
procedure SetIndex(const pIndex: Cardinal); inline; //internal method, do not call directly.
procedure SetChildCount(const pCount: Cardinal); inline; //internal method, do not call directly.
procedure SetNodeHeight(const pNodeHeight: TDimension); inline; //internal method, do not call directly.
procedure SetNodeHeight(const pNodeHeight: TNodeHeight); inline; //internal method, do not call directly.
property Index: Cardinal read fIndex;
property ChildCount: Cardinal read fChildCount;
property Parent: PVirtualNode read fParent;
property PrevSibling: PVirtualNode read fPrevSibling;
property NextSibling: PVirtualNode read fNextSibling;
property LastChild: PVirtualNode read fLastChild;
property NodeHeight: TDimension read fNodeHeight;
property NodeHeight: TNodeHeight read fNodeHeight;
private
Data: record end; // this is a placeholder, each node gets extra data determined by NodeDataSize
public
Expand Down Expand Up @@ -1153,7 +1154,7 @@ function TVirtualNode.IsAssigned: Boolean;
Exit(@Self <> nil);
end;

procedure TVirtualNode.SetNodeHeight(const pNodeHeight: TDimension);
procedure TVirtualNode.SetNodeHeight(const pNodeHeight: TNodeHeight);
begin
fNodeHeight := pNodeHeight;
end;
Expand Down

0 comments on commit 8642274

Please sign in to comment.