瀏覽代碼

#509 don't reopen shape

circular17 3 年之前
父節點
當前提交
da0aeab6e1
共有 1 個文件被更改,包括 20 次插入1 次删除
  1. 20 1
      lazpaint/tools/utoolpolygon.pas

+ 20 - 1
lazpaint/tools/utoolpolygon.pas

@@ -37,6 +37,7 @@ type
     function CreateShape: TVectorShape; override;
     function ShouldCloseShape: boolean; virtual;
     procedure UpdateManagerCloseShape({%H-}AClose: boolean); virtual;
+    procedure AssignShapeStyleClosed(AShape: TVectorShape); virtual;
     procedure AssignShapeStyle(AMatrix: TAffineMatrix; AAlwaysFit: boolean); override;
     procedure UpdateUserMode; virtual;
     procedure ShapeValidated; override;
@@ -51,7 +52,9 @@ type
 
   TToolPolyline = class(TToolPolygon)
   protected
+    function CreateShape: TVectorShape; override;
     function ShouldCloseShape: boolean; override;
+    procedure AssignShapeStyleClosed(AShape: TVectorShape); override;
     procedure UpdateManagerCloseShape({%H-}AClose: boolean); override;
     function GetManagerShapeOptions: TShapeOptions; override;
     function HasBrush: boolean; override;
@@ -131,11 +134,22 @@ end;
 
 { TToolPolyline }
 
+function TToolPolyline.CreateShape: TVectorShape;
+begin
+  Result:=inherited CreateShape;
+  inherited AssignShapeStyleClosed(Result);
+end;
+
 function TToolPolyline.ShouldCloseShape: boolean;
 begin
   result := false;
 end;
 
+procedure TToolPolyline.AssignShapeStyleClosed(AShape: TVectorShape);
+begin
+  //nothing
+end;
+
 procedure TToolPolyline.UpdateManagerCloseShape(AClose: boolean);
 begin
   //nothing
@@ -290,10 +304,15 @@ begin
   Manager.ShapeOptions:= opt;
 end;
 
+procedure TToolPolygon.AssignShapeStyleClosed(AShape: TVectorShape);
+begin
+  (AShape as TCustomPolypointShape).Closed := ShouldCloseShape;
+end;
+
 procedure TToolPolygon.AssignShapeStyle(AMatrix: TAffineMatrix; AAlwaysFit: boolean);
 begin
   inherited AssignShapeStyle(AMatrix, AAlwaysFit);
-  TCustomPolypointShape(FShape).Closed := ShouldCloseShape;
+  AssignShapeStyleClosed(TCustomPolypointShape(FShape));
   TCustomPolypointShape(FShape).ArrowStartKind := Manager.ArrowStart;
   TCustomPolypointShape(FShape).ArrowEndKind := Manager.ArrowEnd;
   TCustomPolypointShape(FShape).ArrowSize := Manager.ArrowSize;