Ast list nodes

This commit is contained in:
Michael Schimmel
2025-11-29 18:59:16 +01:00
parent 250f950a68
commit 851f56c63f
24 changed files with 1819 additions and 863 deletions
+30 -1
View File
@@ -110,6 +110,9 @@ constructor TAstWorkspace.Create(AOwner: TComponent);
begin
inherited;
FZoom := 1.0;
// Standard-Eigenschaften für einen Arbeitsbereich
ClipChildren := True;
HitTest := True;
end;
procedure TAstWorkspace.Build(const RootNode: IAstNode; const Position: TPointF);
@@ -117,10 +120,20 @@ var
visu: IAstVisualizer;
node: TAstViewNode;
begin
// Löscht alle bestehenden visuellen Knoten
DeleteChildren;
FConnections := nil;
if not Assigned(RootNode) then
Exit;
// Erstellt den Visualizer mit dem Workspace als Kontext
visu := TAstVisualizer.Create(Self, Self, 0);
node := visu.CallAccept(RootNode);
if Assigned(node) then
begin
node.Position.Point := Position;
end;
end;
procedure TAstWorkspace.DoDeleteChildren;
@@ -204,7 +217,12 @@ end;
procedure TAstWorkspace.DblClick;
begin
inherited;
Zoom(1.0);
// Reset Zoom/Pan on double click
FZoom := 1.0;
FPanning := TSizeF.Create(0, 0);
RecalcAbsolute;
RecalcUpdateRect;
Repaint;
end;
procedure TAstWorkspace.Paint;
@@ -224,6 +242,13 @@ begin
for connection in FConnections do
begin
// Safety check if pins are still valid/visible
if (connection.OutputPin = nil)
or (connection.InputPin = nil)
or (connection.OutputPin.Root <> Self.Root)
or (connection.InputPin.Root <> Self.Root) then
continue;
pinCenter := TPointF.Create(connection.OutputPin.Width / 2, connection.OutputPin.Height / 2);
absoluteStart := connection.OutputPin.LocalToAbsolute(pinCenter);
@@ -263,9 +288,13 @@ begin
begin
mousePos := ScreenToLocal(mouseService.GetMousePos);
Factor := Max(0.2, Min(3.0, Factor));
// Adjust panning to zoom towards mouse position
FPanning.cx := mousePos.X * (1 - Factor / FZoom) + FPanning.cx * (Factor / FZoom);
FPanning.cy := mousePos.Y * (1 - Factor / FZoom) + FPanning.cy * (Factor / FZoom);
FZoom := Factor;
RecalcAbsolute;
RecalcUpdateRect;
Repaint;