2
0
Эх сурвалжийг харах

fill autofit when creating polygon

johann 5 жил өмнө
parent
commit
ad12c49f00

+ 2 - 2
lazpaint/tools/utoolvectorial.pas

@@ -2131,9 +2131,9 @@ begin
   tcFinish: result := not IsIdle;
   tcForeAdjustToShape, tcBackAdjustToShape: result := not IsSelectingTool and Assigned(FShape) and not FQuickDefine;
   tcForeEditGradTexPoints: result := not IsSelectingTool and Assigned(FShape) and not FQuickDefine and
-                            (vsuEditPenFill in FShape.Usermodes);
+                            (vsuEditPenFill in FShape.Usermodes) and not (FShape.Usermode = vsuCreate);
   tcBackEditGradTexPoints: result := not IsSelectingTool and Assigned(FShape) and not FQuickDefine and
-                            (vsuEditPenFill in FShape.Usermodes);
+                            (vsuEditPenFill in FShape.Usermodes) and not (FShape.Usermode = vsuCreate);
   tcShapeToSpline: result:= not IsSelectingTool and not FQuickDefine and Assigned(FShape)
                             and TCurveShape.CanCreateFrom(FShape);
   tcAlignLeft..tcAlignBottom: Result:= not FQuickDefine and Assigned(FShape);

+ 13 - 0
lazpaintcontrols/lcvectororiginal.pas

@@ -197,6 +197,7 @@ type
     destructor Destroy; override;
     procedure BeginUpdate(ADiffHandler: TVectorShapeDiffAny=nil);
     procedure EndUpdate;
+    procedure FillFit;
     procedure QuickDefine(const APoint1,APoint2: TPointF); virtual; abstract;
     //one of the two Render functions must be overriden
     procedure Render(ADest: TBGRABitmap; AMatrix: TAffineMatrix; ADraft: boolean); virtual;
@@ -1593,6 +1594,18 @@ begin
   end;
 end;
 
+procedure TVectorShape.FillFit;
+var
+  box: TAffineBox;
+begin
+  BeginUpdate;
+  box := SuggestGradientBox(AffineMatrixIdentity);
+  if vsfPenFill in Fields then PenFill.FitGeometry(box);
+  if vsfBackFill in Fields then BackFill.FitGeometry(box);
+  if vsfOutlineFill in Fields then OutlineFill.FitGeometry(box);
+  EndUpdate;
+end;
+
 procedure TVectorShape.BeginEditingUpdate;
 begin
   inc(FUpdateEditingCount);

+ 4 - 0
lazpaintcontrols/lcvectorpolyshapes.pas

@@ -828,10 +828,13 @@ begin
   FMousePos := PointF(X,Y);
   if FAddingPoint then
   begin
+    BeginUpdate;
     if (PointCount = 1) and (FMousePos <> Points[PointCount-1]) then
       Points[PointCount] := FMousePos
     else
       Points[PointCount-1] := FMousePos;
+    FillFit;
+    EndUpdate;
     AHandled:= true;
   end;
 end;
@@ -857,6 +860,7 @@ begin
       AddPoint(EmptyPointF);
       FMousePos := PointF(X,Y);
       AddPoint(FMousePos);
+      FillFit;
       EndUpdate;
       USerMode := vsuCreate;
       AHandled:= true;