diff --git a/ASTPlayground/ASTPlayground.dpr b/ASTPlayground/ASTPlayground.dpr index 78aad6c..d04cda8 100644 --- a/ASTPlayground/ASTPlayground.dpr +++ b/ASTPlayground/ASTPlayground.dpr @@ -26,7 +26,6 @@ uses Myc.Ast.Debugger in '..\Src\AST\Myc.Ast.Debugger.pas', Myc.Ast.Analysis.Purity in '..\Src\AST\Myc.Ast.Analysis.Purity.pas', Myc.Ast.Identities in '..\Src\AST\Myc.Ast.Identities.pas', - Myc.Fmx.AstEditor.Handlers in '..\Src\AST\Myc.Fmx.AstEditor.Handlers.pas', Myc.Fmx.AstEditor.Visualizer in '..\Src\AST\Myc.Fmx.AstEditor.Visualizer.pas', Myc.Fmx.AstEditor.Workspace in '..\Src\AST\Myc.Fmx.AstEditor.Workspace.pas', Myc.Fmx.AstEditor.Layout in '..\Src\AST\Myc.Fmx.AstEditor.Layout.pas', diff --git a/ASTPlayground/ASTPlayground.dproj b/ASTPlayground/ASTPlayground.dproj index a55bf4b..181de27 100644 --- a/ASTPlayground/ASTPlayground.dproj +++ b/ASTPlayground/ASTPlayground.dproj @@ -156,7 +156,6 @@ - diff --git a/Src/AST/Myc.Fmx.AstEditor.Handlers.Pipes.pas b/Src/AST/Myc.Fmx.AstEditor.Handlers.Pipes.pas index 992e427..616c11b 100644 --- a/Src/AST/Myc.Fmx.AstEditor.Handlers.Pipes.pas +++ b/Src/AST/Myc.Fmx.AstEditor.Handlers.Pipes.pas @@ -9,8 +9,7 @@ uses Myc.Ast, Myc.Ast.Nodes, Myc.Fmx.AstEditor.Render, - Myc.Fmx.AstEditor.Node, - Myc.Fmx.AstEditor.Handlers; + Myc.Fmx.AstEditor.Node; type // --- Pipe Container Handler --- diff --git a/Src/AST/Myc.Fmx.AstEditor.Handlers.pas b/Src/AST/Myc.Fmx.AstEditor.Handlers.pas deleted file mode 100644 index cc528a0..0000000 --- a/Src/AST/Myc.Fmx.AstEditor.Handlers.pas +++ /dev/null @@ -1,147 +0,0 @@ -unit Myc.Fmx.AstEditor.Handlers; - -interface - -uses - System.SysUtils, - System.Generics.Collections, - System.UITypes, - Myc.Ast.Nodes, - Myc.Ast.Identities, - Myc.Fmx.AstEditor.Render, - Myc.Fmx.AstEditor.Node; - -type - // --- Abstract List Base --- - // Implements IReorderable to support drag & drop reordering within the virtual tree. - // Now operates on the untyped ITupleNode. - TNodeListHandler = class(TBaseNodeHandler, IReorderable) - protected - FChildNodes: TList; - function GetOrientation: TLayoutOrientation; virtual; abstract; - function GetAlignment: TLayoutAlignment; virtual; - public - constructor Create(const ANode: ITupleNode); - destructor Destroy; override; - procedure BuildUI(OwnerNode: TAstViewNode); override; - function ReconstructAst(OwnerNode: TAstViewNode): IAstNode; override; abstract; - - // IReorderable Implementation - function CanDrag(Child: TVisualNode): Boolean; - procedure MoveChild(SourceIndex, TargetIndex: Integer); - end; - -implementation - -{ TNodeListHandler } - -constructor TNodeListHandler.Create(const ANode: ITupleNode); -begin - inherited Create(ANode); - FChildNodes := TList.Create; -end; - -destructor TNodeListHandler.Destroy; -begin - FChildNodes.Free; - inherited; -end; - -function TNodeListHandler.GetAlignment: TLayoutAlignment; -begin - Result := TLayoutAlignment.laCenter; -end; - -procedure TNodeListHandler.BuildUI(OwnerNode: TAstViewNode); -var - visu: IAstVisualizer; - i: Integer; - childView: TAstViewNode; - openTok, closeTok, sep: string; - listId: IListIdentity; - elements: TArray; -begin - if (FNode.Identity <> nil) and (FNode.Identity.Kind = ikList) then - begin - listId := FNode.Identity.AsList; - openTok := listId.OpenToken; - closeTok := listId.CloseToken; - sep := listId.Separator; - end - else - begin - openTok := ''; - closeTok := ''; - sep := ' '; - end; - - visu := OwnerNode.Visualizer.Clone(OwnerNode, OwnerNode.Visualizer.ExprDepth); - - // No BeginUpdate/EndUpdate needed for TVisualNode, just property setting - OwnerNode.Frameless := True; - OwnerNode.Orientation := GetOrientation; - OwnerNode.Alignment := GetAlignment; - - if openTok <> '' then - OwnerNode.AddLabel(OwnerNode, openTok); - - // Optimization: Access Elements array directly from ITupleNode - elements := FNode.Elements; - - for i := 0 to High(elements) do - begin - childView := visu.CallAccept(elements[i]); - FChildNodes.Add(childView); - - if (i < High(elements)) and (sep <> '') and (sep <> ' ') then - OwnerNode.AddLabel(OwnerNode, sep); - end; - - if closeTok <> '' then - OwnerNode.AddLabel(OwnerNode, closeTok); - - if Length(elements) = 0 then - begin - if (openTok = '') and (closeTok = '') then - begin - var lbl := OwnerNode.AddLabel(OwnerNode, 'ø'); - lbl.Opacity := 0.5; - end; - end; -end; - -// IReorderable Implementation - -function TNodeListHandler.CanDrag(Child: TVisualNode): Boolean; -begin - // Only allow dragging if the child is one of our managed ViewNodes - if Child is TAstViewNode then - Result := FChildNodes.Contains(TAstViewNode(Child)) - else - Result := False; -end; - -procedure TNodeListHandler.MoveChild(SourceIndex, TargetIndex: Integer); -var - item: TAstViewNode; -begin - if (SourceIndex < 0) or (SourceIndex >= FChildNodes.Count) then - Exit; - if (TargetIndex < 0) or (TargetIndex > FChildNodes.Count) then - Exit; - - // Adjust target index if moving downwards (since removing source shifts indices) - if SourceIndex < TargetIndex then - Dec(TargetIndex); - - if SourceIndex = TargetIndex then - Exit; - - item := FChildNodes[SourceIndex]; - FChildNodes.Delete(SourceIndex); - FChildNodes.Insert(TargetIndex, item); - - // The visual order update happens via the controller's compilation cycle -end; - -end. diff --git a/Src/AST/Myc.Fmx.AstEditor.Visualizer.pas b/Src/AST/Myc.Fmx.AstEditor.Visualizer.pas index 696fe46..e236c2a 100644 --- a/Src/AST/Myc.Fmx.AstEditor.Visualizer.pas +++ b/Src/AST/Myc.Fmx.AstEditor.Visualizer.pas @@ -94,7 +94,6 @@ implementation uses System.StrUtils, - Myc.Fmx.AstEditor.Handlers, Myc.Fmx.AstEditor.Handlers.Data, Myc.Fmx.AstEditor.Handlers.Control, Myc.Fmx.AstEditor.Handlers.Primitives,