UI refactoring
This commit is contained in:
@@ -47,6 +47,11 @@ type
|
||||
function GetChildrenMatrix(var Matrix: TMatrix; var Simple: Boolean): Boolean; override;
|
||||
function Zoom(Factor: Single): Boolean;
|
||||
|
||||
// Neue Public Methoden, damit Nodes das Panning steuern können
|
||||
procedure ExternalMouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Single);
|
||||
procedure ExternalMouseMove(Shift: TShiftState; X, Y: Single);
|
||||
procedure ExternalMouseUp(Button: TMouseButton; Shift: TShiftState; X, Y: Single);
|
||||
|
||||
published
|
||||
property Align;
|
||||
property Anchors;
|
||||
@@ -88,8 +93,8 @@ implementation
|
||||
uses
|
||||
System.Math,
|
||||
FMX.Platform,
|
||||
Myc.Fmx.AstEditor.Core, // Enthält TAstViewNode Interfaces
|
||||
Myc.Fmx.AstEditor.Visualizer; // Enthält TAstVisualizer
|
||||
Myc.Fmx.AstEditor.Core,
|
||||
Myc.Fmx.AstEditor.Visualizer;
|
||||
|
||||
{ TPinConnection }
|
||||
|
||||
@@ -112,7 +117,6 @@ var
|
||||
visu: IAstVisualizer;
|
||||
node: TAstViewNode;
|
||||
begin
|
||||
// Erstelle den Visualizer mit diesem Workspace als Kontext
|
||||
visu := TAstVisualizer.Create(Self, Self, 0);
|
||||
node := visu.CallAccept(RootNode);
|
||||
if Assigned(node) then
|
||||
@@ -132,23 +136,43 @@ begin
|
||||
Result := True;
|
||||
end;
|
||||
|
||||
// --- Interne Event Handler ---
|
||||
|
||||
procedure TAstWorkspace.MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Single);
|
||||
begin
|
||||
inherited;
|
||||
if (Button = TMouseButton.mbLeft) and (ObjectAtPoint(LocalToScreen(TPointF.Create(X, Y))) = Self as IControl) then
|
||||
ExternalMouseDown(Button, Shift, X, Y);
|
||||
end;
|
||||
|
||||
procedure TAstWorkspace.MouseMove(Shift: TShiftState; X, Y: Single);
|
||||
begin
|
||||
inherited;
|
||||
ExternalMouseMove(Shift, X, Y);
|
||||
end;
|
||||
|
||||
procedure TAstWorkspace.MouseUp(Button: TMouseButton; Shift: TShiftState; X, Y: Single);
|
||||
begin
|
||||
inherited;
|
||||
ExternalMouseUp(Button, Shift, X, Y);
|
||||
end;
|
||||
|
||||
// --- Externe Steuerung für Nodes ---
|
||||
|
||||
procedure TAstWorkspace.ExternalMouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Single);
|
||||
begin
|
||||
if (Button = TMouseButton.mbLeft) then
|
||||
begin
|
||||
Capture;
|
||||
FIsPanning := True;
|
||||
FLastPanPos := TPointF.Create(X, Y);
|
||||
Cursor := crHandPoint;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TAstWorkspace.MouseMove(Shift: TShiftState; X, Y: Single);
|
||||
procedure TAstWorkspace.ExternalMouseMove(Shift: TShiftState; X, Y: Single);
|
||||
var
|
||||
delta: TPointF;
|
||||
begin
|
||||
inherited;
|
||||
|
||||
if FIsPanning then
|
||||
begin
|
||||
delta := TPointF.Create(X - FLastPanPos.X, Y - FLastPanPos.Y);
|
||||
@@ -161,11 +185,11 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TAstWorkspace.MouseUp(Button: TMouseButton; Shift: TShiftState; X, Y: Single);
|
||||
procedure TAstWorkspace.ExternalMouseUp(Button: TMouseButton; Shift: TShiftState; X, Y: Single);
|
||||
begin
|
||||
inherited;
|
||||
if (Button = TMouseButton.mbLeft) and (FIsPanning) then
|
||||
begin
|
||||
ReleaseCapture;
|
||||
FIsPanning := False;
|
||||
Cursor := crDefault;
|
||||
end;
|
||||
@@ -200,26 +224,21 @@ begin
|
||||
|
||||
for connection in FConnections do
|
||||
begin
|
||||
// Output Pin Calculation
|
||||
pinCenter := TPointF.Create(connection.OutputPin.Width / 2, connection.OutputPin.Height / 2);
|
||||
absoluteStart := connection.OutputPin.LocalToAbsolute(pinCenter);
|
||||
|
||||
// Input Pin Calculation
|
||||
pinCenter := TPointF.Create(connection.InputPin.Width / 2, connection.InputPin.Height / 2);
|
||||
absoluteEnd := connection.InputPin.LocalToAbsolute(pinCenter);
|
||||
|
||||
// Convert to Workspace Local Coordinates
|
||||
startPoint := AbsoluteToLocal(absoluteStart);
|
||||
endPoint := AbsoluteToLocal(absoluteEnd);
|
||||
|
||||
// Determine Color based on TagString (naive check)
|
||||
str := connection.InputPin.TagString;
|
||||
if Pos('data', str) = 0 then
|
||||
Canvas.Stroke.Color := cExecPinColor
|
||||
else
|
||||
Canvas.Stroke.Color := cDataPinColor;
|
||||
|
||||
// Draw Curve
|
||||
path := TPathData.Create;
|
||||
try
|
||||
controlOffset := Max(25, 0.5 * endPoint.Distance(startPoint));
|
||||
|
||||
Reference in New Issue
Block a user