Prechádzať zdrojové kódy

refactoring tool manager

johann 5 rokov pred
rodič
commit
e46be1232e

+ 30 - 4
lazpaint/lazpaintmainform.pas

@@ -677,10 +677,13 @@ type
     procedure ComboBox_PenStyleDrawSelectedItem(Sender: TObject;
       const ABGRA: TBGRABitmap; AState: TBCButtonState; ARect: TRect);
     function GetImage: TLazPaintImage;
+    procedure ManagerDeformationGridSizeChanged(Sender: TObject);
     procedure ManagerEraserChanged(Sender: TObject);
+    procedure ManagerFloodFillOptionChanged(Sender: TObject);
     procedure ManagerGradientChanged(Sender: TObject);
     procedure ManagerJoinStyleChanged(Sender: TObject);
     procedure ManagerLineCapChanged(Sender: TObject);
+    procedure ManagerPerspectiveOptionChanged(Sender: TObject);
     procedure ManagerPhongShapeChanged(Sender: TObject);
     procedure ManagerPenStyleChanged(Sender: TObject);
     procedure ManagerPenWidthChanged(Sender: TObject);
@@ -712,9 +715,9 @@ type
 
     FLoadInitialDir, FSaveInitialDir: string;
     FSaveSelectionInitialFilename: string;
-    FInTextFont: boolean;
-    FInPenWidthChange: boolean;
-    FInEraserOption: Boolean;
+    FInTextFont, FInPenWidthChange, FInEraserOption,
+    FInGridNb, FInFloodfillOption, FInSplineStyleChange,
+    FInTolerance, FInPerspective : Boolean;
     FOnlineUpdater: TLazPaintCustomOnlineUpdater;
     initialized: boolean;
     shouldArrangeOnResize: boolean;
@@ -742,7 +745,6 @@ type
     FLastPaintDate: TDateTime;
     FUpdateStackWhenIdle: boolean;
     FToolbarElementsInitDone: boolean;
-    FInSplineStyleChange: Boolean;
 
     function GetCurrentPressure: single;
     function GetDarkTheme: boolean;
@@ -768,6 +770,9 @@ type
     procedure UpdatePenWidthToolbar;
     procedure UpdatePhongToolbar;
     procedure UpdateToleranceToolbar;
+    procedure UpdateDeformationGridToolbar;
+    procedure UpdateFloodfillToolbar;
+    procedure UpdatePerspectiveToolbar;
     function ShowOpenBrushDialog: boolean;
     function TextSpinEditFocused: boolean;
     procedure UpdateBrush;
@@ -1009,6 +1014,9 @@ begin
     if ToolManager.OnGradientChanged = @ManagerGradientChanged then ToolManager.OnGradientChanged := nil;
     if ToolManager.OnPhongShapeChanged = @ManagerPhongShapeChanged then ToolManager.OnPhongShapeChanged := nil;
     if ToolManager.OnToleranceChanged = @ManagerToleranceChanged then ToolManager.OnToleranceChanged := nil;
+    if ToolManager.OnDeformationGridSizeChanged = @ManagerDeformationGridSizeChanged then ToolManager.OnDeformationGridSizeChanged := nil;
+    if ToolManager.OnFloodFillOptionChanged = @ManagerFloodFillOptionChanged then ToolManager.OnFloodFillOptionChanged := nil;
+    if ToolManager.OnPerspectiveOptionChanged = @ManagerPerspectiveOptionChanged then ToolManager.OnPerspectiveOptionChanged := nil;
   end;
   FreeAndNil(Zoom);
   FreeAndNil(FOnlineUpdater);
@@ -1083,6 +1091,9 @@ begin
   ToolManager.OnGradientChanged:=@ManagerGradientChanged;
   ToolManager.OnPhongShapeChanged:=@ManagerPhongShapeChanged;
   ToolManager.OnToleranceChanged:=@ManagerToleranceChanged;
+  ToolManager.OnDeformationGridSizeChanged:=@ManagerDeformationGridSizeChanged;
+  ToolManager.OnFloodFillOptionChanged:=@ManagerFloodFillOptionChanged;
+  ToolManager.OnPerspectiveOptionChanged:=@ManagerPerspectiveOptionChanged;
 
   InitToolbarElements;
 
@@ -4243,11 +4254,21 @@ begin
   result := LazPaintInstance.Image;
 end;
 
+procedure TFMain.ManagerDeformationGridSizeChanged(Sender: TObject);
+begin
+  UpdateDeformationGridToolbar;
+end;
+
 procedure TFMain.ManagerEraserChanged(Sender: TObject);
 begin
   UpdateEraserToolbar;
 end;
 
+procedure TFMain.ManagerFloodFillOptionChanged(Sender: TObject);
+begin
+  UpdateFloodFillToolbar;
+end;
+
 procedure TFMain.ManagerGradientChanged(Sender: TObject);
 begin
   UpdateGradientToolbar;
@@ -4263,6 +4284,11 @@ begin
   UpdateLineCapToolbar;
 end;
 
+procedure TFMain.ManagerPerspectiveOptionChanged(Sender: TObject);
+begin
+  UpdatePerspectiveToolbar;
+end;
+
 procedure TFMain.ManagerPhongShapeChanged(Sender: TObject);
 begin
   UpdatePhongToolbar;

+ 52 - 10
lazpaint/maintoolbar.inc

@@ -353,9 +353,30 @@ end;
 
 procedure TFMain.UpdateToleranceToolbar;
 begin
+  if FInTolerance then exit;
   SpinEdit_Tolerance.Value:= ToolManager.Tolerance;
 end;
 
+procedure TFMain.UpdateDeformationGridToolbar;
+begin
+  if FInGridNb then exit;
+  SpinEdit_GridNbX.Value := ToolManager.DeformationGridNbX-1;
+  SpinEdit_GridNbY.Value := ToolManager.DeformationGridNbY-1;
+end;
+
+procedure TFMain.UpdateFloodfillToolbar;
+begin
+  if FInFloodfillOption then exit;
+  Tool_ProgressiveFloodfill.Down := ffProgressive in ToolManager.FloodFillOptions;
+end;
+
+procedure TFMain.UpdatePerspectiveToolbar;
+begin
+  if FInPerspective then exit;
+  Perspective_Repeat.Down := poRepeat in ToolManager.PerspectiveOptions;
+  Perspective_TwoPlanes.Down := poTwoPlanes in ToolManager.PerspectiveOptions;
+end;
+
 procedure TFMain.UpdateJoinStyleToolbar;
 begin
   case ToolManager.JoinStyle of
@@ -439,17 +460,17 @@ begin
   end;
   UpdateLineCapToolbar;
   UpdateToolOptions;
-  SpinEdit_Eraser.Value := ToolManager.EraserAlpha;
-  SpinEdit_Tolerance.Value := ToolManager.Tolerance;
-  Tool_ProgressiveFloodfill.Down := ToolManager.ToolFloodFillOptionProgressive;
+  UpdateEraserToolbar;
+  UpdateToleranceToolbar;
+  UpdateFloodfillToolbar;
+  UpdatePerspectiveToolbar;
   UpdateGradientToolbar;
   Tool_GridMoveWithoutDeformation.Down := ToolManager.ToolDeformationGridMoveWithoutDeformation;
-  SpinEdit_GridNbX.Value := ToolManager.DeformationGridNbX-1;
-  SpinEdit_GridNbY.Value := ToolManager.DeformationGridNbY-1;
+  UpdateDeformationGridToolbar;
   UpdateSplineStyleToolbar;
   UpdateCurveModeToolbar;
   UpdateTextOutlineToolbar;
-  Tool_TextPhong.Down := ToolManager.TextPhong;
+  UpdateTextPhongToolbar;
   UpdateTextFontToolbar;
   UpdateTextShadowToolbar;
   SpinEdit_TextureOpacity.Value := ToolManager.TextureOpacity;
@@ -675,8 +696,10 @@ end;
 procedure TFMain.GridNb_SpinEditChange(Sender: TObject; AByUser: boolean);
 begin
   if not AByUser or not initialized then exit;
+  FInGridNb := true;
   if ToolManager.SetDeformationGridSize(Size(SpinEdit_GridNbX.Value+1,SpinEdit_GridNbY.Value+1)) then
     image.OnImageChanged.NotifyObservers;
+  FInGridNb := false;
 end;
 
 procedure TFMain.SpinEdit_GridNbExit(Sender: TObject);
@@ -733,7 +756,12 @@ procedure TFMain.Perspective_RepeatClick(Sender: TObject);
 begin
   if initialized then
   begin
-    ToolManager.ToolPerspectiveRepeat := Perspective_Repeat.Down;
+    FInPerspective:= true;
+    if Perspective_Repeat.Down then
+      ToolManager.PerspectiveOptions := ToolManager.PerspectiveOptions + [poRepeat]
+    else
+      ToolManager.PerspectiveOptions := ToolManager.PerspectiveOptions - [poRepeat];
+    FInPerspective:= false;
     UpdateEditPicture;
   end;
 end;
@@ -742,7 +770,12 @@ procedure TFMain.Perspective_TwoPlanesClick(Sender: TObject);
 begin
   if initialized then
   begin
-    ToolManager.ToolPerspectiveTwoPlanes := Perspective_TwoPlanes.Down;
+    FInPerspective:= true;
+    if Perspective_Repeat.Down then
+      ToolManager.PerspectiveOptions := ToolManager.PerspectiveOptions + [poTwoPlanes]
+    else
+      ToolManager.PerspectiveOptions := ToolManager.PerspectiveOptions - [poTwoPlanes];
+    FInPerspective:= false;
     UpdateEditPicture;
   end;
 end;
@@ -828,7 +861,9 @@ begin
   if AByUser and initialized then
   begin
     if ToolManager.Tolerance = SpinEdit_Tolerance.Value then exit;
+    FInTolerance:= true;
     ToolManager.Tolerance := SpinEdit_Tolerance.Value;
+    FInTolerance:= false;
   end;
 end;
 
@@ -1218,8 +1253,15 @@ end;
 
 procedure TFMain.Tool_ProgressiveFloodfillClick(Sender: TObject);
 begin
-     if initialized then
-       ToolManager.ToolFloodFillOptionProgressive := Tool_ProgressiveFloodfill.Down;
+  if initialized then
+  begin
+    FInFloodfillOption:= true;
+    if Tool_ProgressiveFloodfill.Down then
+      ToolManager.FloodFillOptions := ToolManager.FloodFillOptions + [ffProgressive]
+    else
+      ToolManager.FloodFillOptions := ToolManager.FloodFillOptions - [ffProgressive];
+    FInFloodfillOption:= true;
+  end;
 end;
 
 procedure TFMain.ShowPenPreview(ShouldRepaint: boolean);

+ 27 - 15
lazpaint/tools/utool.pas

@@ -86,7 +86,6 @@ type
     procedure ValidateActionPartially;
     procedure CancelAction;
     procedure CancelActionPartially;
-    procedure BeforeGridSizeChange; virtual;
     procedure AfterGridSizeChange(NewNbX,NewNbY: Integer); virtual;
     function ToolUpdate: TRect;
     function ToolDown(X,Y: single; rightBtn: boolean): TRect;
@@ -134,6 +133,12 @@ type
   TShapeOption = (toAliasing, toDrawShape, toFillShape, toCloseShape);
   TShapeOptions = set of TShapeOption;
 
+  TFloodFillOption = (ffProgressive, ffFillAll);
+  TFloodFillOptions = set of TFloodFillOption;
+
+  TPerspectiveOption = (poRepeat, poTwoPlanes);
+  TPerspectiveOptions = set of TPerspectiveOption;
+
   { TToolManager }
 
   TToolManager = class
@@ -180,6 +185,8 @@ type
     FPhongShapeKind: TPhongShapeKind;
     FDeformationGridNbX,FDeformationGridNbY: integer;
     FTolerance: byte;
+    FFloodFillOptions: TFloodFillOptions;
+    FPerspectiveOptions: TPerspectiveOptions;
 
     FOnColorChanged: TNotifyEvent;
     FOnEraserChanged: TNotifyEvent;
@@ -196,7 +203,10 @@ type
     FOnTextShadowChanged: TNotifyEvent;
     FOnTextureChanged: TNotifyEvent;
     FOnShapeOptionChanged: TNotifyEvent;
+    FOnDeformationGridSizeChanged: TNotifyEvent;
     FOnToleranceChanged: TNotifyEvent;
+    FOnFloodFillOptionChanged: TNotifyEvent;
+    FOnPerspectiveOptionChanged: TNotifyEvent;
 
     function GetCursor: TCursor;
     function GetBackColor: TBGRAPixel;
@@ -220,6 +230,7 @@ type
     procedure SetBackColor(AValue: TBGRAPixel);
     procedure SetEraserAlpha(AValue: byte);
     procedure SetEraserMode(AValue: TEraserMode);
+    procedure SetFloodFillOptions(AValue: TFloodFillOptions);
     procedure SetForeColor(AValue: TBGRAPixel);
     procedure SetGradientColorspace(AValue: TBGRAColorInterpolation);
     procedure SetGradientSine(AValue: boolean);
@@ -255,8 +266,6 @@ type
     BrushControls, RatioControls: TList;
 
     //tools configuration
-    ToolFloodFillOptionProgressive: boolean;
-    ToolPerspectiveRepeat,ToolPerspectiveTwoPlanes: boolean;
     ToolDeformationGridMoveWithoutDeformation: boolean;
     TextShadowBlurRadius: single;
     TextShadowOffset: TPoint;
@@ -369,6 +378,8 @@ type
     property DeformationGridNbY: integer read FDeformationGridNbY;
     property DeformationGridSize: TSize read GetDeformationGridSize write SetDeformationGridSizeProc;
     property Tolerance: byte read FTolerance write SetTolerance;
+    property FloodFillOptions: TFloodFillOptions read FFloodFillOptions write SetFloodFillOptions;
+    property PerspectiveOptions: TPerspectiveOptions read FPerspectiveOptions write FPerspectiveOptions;
 
     property OnToolChanged: TOnToolChangedHandler read FOnToolChangedHandler write FOnToolChangedHandler;
     property OnPopup: TOnPopupToolHandler read FOnPopupToolHandler write FOnPopupToolHandler;
@@ -387,7 +398,10 @@ type
     property OnSplineStyleChanged: TNotifyEvent read FOnSplineStyleChanged write FOnSplineStyleChanged;
     property OnGradientChanged: TNotifyEvent read FOnGradientChanged write FOnGradientChanged;
     property OnPhongShapeChanged: TNotifyEvent read FOnPhongShapeChanged write FOnPhongShapeChanged;
+    property OnDeformationGridSizeChanged: TNotifyEvent read FOnDeformationGridSizeChanged write FOnDeformationGridSizeChanged;
     property OnToleranceChanged: TNotifyEvent read FOnToleranceChanged write FOnToleranceChanged;
+    property OnFloodFillOptionChanged: TNotifyEvent read FOnFloodFillOptionChanged write FOnFloodFillOptionChanged;
+    property OnPerspectiveOptionChanged: TNotifyEvent read FOnPerspectiveOptionChanged write FOnPerspectiveOptionChanged;
   end;
 
 procedure RegisterTool(ATool: TPaintToolType; AClass: TToolClass);
@@ -659,12 +673,6 @@ begin
   end;
 end;
 
-procedure TGenericTool.BeforeGridSizeChange;
-begin
-  //nothing
-end;
-
-{$hints off}
 function TGenericTool.DoToolUpdate(toolDest: TBGRABitmap): TRect;
 begin
   result := EmptyRect;
@@ -687,8 +695,6 @@ begin
  //nothing
 end;
 
-{$hints on}
-
 function TGenericTool.ToolUpdate: TRect;
 var toolDest :TBGRABitmap;
 begin
@@ -915,6 +921,13 @@ begin
   if Assigned(FOnEraserChanged) then FOnEraserChanged(self);
 end;
 
+procedure TToolManager.SetFloodFillOptions(AValue: TFloodFillOptions);
+begin
+  if FFloodFillOptions=AValue then Exit;
+  FFloodFillOptions:=AValue;
+  if Assigned(FOnFloodFillOptionChanged) then FOnFloodFillOptionChanged(self);
+end;
+
 procedure TToolManager.SetForeColor(AValue: TBGRAPixel);
 begin
   if (AValue.red = FForeColor.red) and
@@ -1222,7 +1235,7 @@ begin
   GradientType := gtLinear;
   GradientSine := false;
   GradientColorspace := ciLinearRGB;
-  ToolFloodFillOptionProgressive := true;
+  FFloodFillOptions := [ffProgressive];
   LineCap := pecRound;
   JoinStyle := pjsRound;
   ArrowStart := akNone;
@@ -1246,8 +1259,7 @@ begin
   FPhongShapeAltitude := 50;
   FPhongShapeBorderSize := 20;
   FPhongShapeKind := pskRectangle;
-  ToolPerspectiveRepeat := false;
-  ToolPerspectiveTwoPlanes := false;
+  FPerspectiveOptions:= [poRepeat];
 
   FDeformationGridNbX := 5;
   FDeformationGridNbY := 5;
@@ -1578,9 +1590,9 @@ begin
   if ASize.cy < 3 then ASize.cy := 3;
   if (ASize.cx <> DeformationGridNbX) or (ASize.cy <> DeformationGridNbY) then
   begin
-    CurrentTool.BeforeGridSizeChange;
     FDeformationGridNbX := ASize.cx;
     FDeformationGridNbY := ASize.cy;
+    if Assigned(FOnDeformationGridSizeChanged) then FOnDeformationGridSizeChanged(self);
     CurrentTool.AfterGridSizeChange(ASize.cx,ASize.cy);
     result := true;
   end;

+ 26 - 29
lazpaint/tools/utooldeformationgrid.pas

@@ -35,7 +35,6 @@ type
     function ToolUp: TRect; override;
     function GetContextualToolbars: TContextualToolbars; override;
     function Render(VirtualScreen: TBGRABitmap; {%H-}VirtualScreenWidth, {%H-}VirtualScreenHeight: integer; BitmapToVirtualScreen: TBitmapToVirtualScreenFunction): TRect; override;
-    procedure BeforeGridSizeChange; override;
     procedure AfterGridSizeChange({%H-}NewNbX,{%H-}NewNbY: Integer); override;
     function ToolCommand(ACommand: TToolCommand): boolean; override;
     function ToolProvideCommand(ACommand: TToolCommand): boolean; override;
@@ -264,7 +263,7 @@ begin
     if tex <> nil then
     begin
 
-      if Manager.ToolPerspectiveRepeat then
+      if poRepeat in Manager.PerspectiveOptions then
         FCurrentBounds := rect(0,0,Manager.Image.Width,Manager.Image.Height)
       else
         FCurrentBounds := GetShapeBounds([quad[0],quad[1],quad[2],quad[3]],1);
@@ -282,11 +281,11 @@ begin
         dest.ClipRect := FCurrentBounds;
       end;
 
-      if Manager.ToolPerspectiveRepeat then
+      if poRepeat in Manager.PerspectiveOptions then
       begin
         persp := TBGRAPerspectiveScannerTransform.Create(tex,[PointF(-0.5,-0.5),PointF(tex.Width-0.5,-0.5),
           PointF(tex.Width-0.5,tex.Height-0.5),PointF(-0.5,tex.Height-0.5)],quadHQ);
-        persp.IncludeOppositePlane := Manager.ToolPerspectiveTwoPlanes;
+        persp.IncludeOppositePlane := poTwoPlanes in Manager.PerspectiveOptions;
         dest.FillRect(0,0,dest.Width,dest.Height,persp,dmDrawWithTransparency);
         persp.Free;
       end else
@@ -313,7 +312,7 @@ function TToolTextureMapping.GetAdaptedTexture: TBGRABitmap;
 var tx,ty: integer;
   precisionFactor: single;
 begin
-  if Manager.ToolPerspectiveRepeat then //cannot optimize size
+  if poRepeat in Manager.PerspectiveOptions then //cannot optimize size
   begin
     result := GetTexture;
     exit;
@@ -709,7 +708,7 @@ begin
   end;
   if quadMoving then
   begin
-    redraw := not Manager.ToolPerspectiveRepeat;
+    redraw := not (poRepeat in Manager.PerspectiveOptions);
     if quadMovingBounds then
     begin
       oldBounds := ComputeBoundsPoints;
@@ -823,28 +822,26 @@ begin
       result := false;
       exit;
     end;
-    setlength(DeformationGrid,Manager.DeformationGridNbY,Manager.DeformationGridNbX);
-    setlength(DeformationGridTexCoord,Manager.DeformationGridNbY,Manager.DeformationGridNbX);
-    for yb := 0 to Manager.DeformationGridNbY-1 do
-      for xb := 0 to Manager.DeformationGridNbX-1 do
+    deformationGridNbX:= Manager.DeformationGridNbX;
+    deformationGridNbY:= Manager.DeformationGridNbY;
+    SetLength(DeformationGrid, deformationGridNbY, deformationGridNbX);
+    SetLength(DeformationGridTexCoord, deformationGridNbY, deformationGridNbX);
+    for yb := 0 to deformationGridNbY-1 do
+      for xb := 0 to deformationGridNbX-1 do
       begin
-        DeformationGridTexCoord[yb,xb] := PointF(xb/(Manager.DeformationGridNbX-1)*layer.Width-0.5,
-                                                     yb/(Manager.DeformationGridNbY-1)*layer.Height-0.5);
+        DeformationGridTexCoord[yb,xb] := PointF(xb/(deformationGridNbX-1)*layer.Width-0.5,
+                                                     yb/(deformationGridNbY-1)*layer.Height-0.5);
         DeformationGrid[yb,xb] :=DeformationGridTexCoord[yb,xb];
       end;
   end;
   result := true;
 end;
 
-procedure TToolDeformationGrid.BeforeGridSizeChange;
+procedure TToolDeformationGrid.AfterGridSizeChange(NewNbX,NewNbY: Integer);
 begin
   ReleaseGrid;
   DeformationGrid := nil;
   DeformationGridTexCoord := nil;
-end;
-
-procedure TToolDeformationGrid.AfterGridSizeChange(NewNbX,NewNbY: Integer);
-begin
   //grid will be created when needed
 end;
 
@@ -884,8 +881,8 @@ begin
   begin
     ValidateAction;
     DoingDeformation := false;
-    for yb := 0 to Manager.DeformationGridNbY-2 do
-      for xb := 0 to Manager.DeformationGridNbX-2 do
+    for yb := 0 to deformationGridNbY-2 do
+      for xb := 0 to deformationGridNbX-2 do
         DeformationGridTexCoord[yb,xb] := DeformationGrid[yb,xb];
   end;
 end;
@@ -913,8 +910,8 @@ begin
   deformationGridY := 1;
   if DeformationGrid <> nil then
   begin
-    for yb := 1 to Manager.DeformationGridNbY-2 do
-      for xb := 1 to Manager.DeformationGridNbX-2 do
+    for yb := 1 to deformationGridNbY-2 do
+      for xb := 1 to deformationGridNbX-2 do
       begin
         curDist := sqr(ptF.x-DeformationGrid[yb,xb].x)+sqr(ptF.y-DeformationGrid[yb,xb].y);
         if curDist < minDist then
@@ -976,8 +973,8 @@ begin
 
     layer := GetToolDrawingLayer;
     backupLayer := GetBackupLayerIfExists;
-    NbX := Manager.DeformationGridNbX;
-    NbY := Manager.DeformationGridNbY;
+    NbX := deformationGridNbX;
+    NbY := deformationGridNbY;
 
     DeformationGrid[deformationGridY,deformationGridX] := PointF(
       DeformationGrid[deformationGridY,deformationGridX].X + ptF.X-deformationOrigin.X,
@@ -1069,14 +1066,14 @@ var curPt,rightPt,downPt: TPointF;
 begin
   result := EmptyRect;
   if not ToolDeformationGridNeeded then exit;
-  for xb := 0 to Manager.DeformationGridNbX-1 do
-    for yb := 0 to Manager.DeformationGridNbY-1 do
+  for xb := 0 to deformationGridNbX-1 do
+    for yb := 0 to deformationGridNbY-1 do
     begin
       curPt := BitmapToVirtualScreen(DeformationGrid[yb,xb]);
       if not deformationGridMoving or ((xb+1 >= deformationGridX) and (xb <= deformationGridX) and
         (yb >= deformationGridY-1) and (yb <= deformationGridY+1)) then
       begin
-        if (xb < Manager.DeformationGridNbX-1) and (yb > 0) and (yb < Manager.DeformationGridNbY-1) then
+        if (xb < deformationGridNbX-1) and (yb > 0) and (yb < deformationGridNbY-1) then
         begin
           rightPt := BitmapToVirtualScreen(DeformationGrid[yb,xb+1]);
           if Assigned(VirtualScreen) then NiceLine(VirtualScreen, curPt.X,curPt.Y, rightPt.X,rightPt.Y);
@@ -1089,7 +1086,7 @@ begin
       if not deformationGridMoving or ((xb >= deformationGridX-1) and (xb <= deformationGridX+1) and
         (yb+1 >= deformationGridY) and (yb <= deformationGridY)) then
       begin
-        if (yb < Manager.DeformationGridNbY-1) and (xb > 0) and (xb < Manager.DeformationGridNbX-1) then
+        if (yb < deformationGridNbY-1) and (xb > 0) and (xb < deformationGridNbX-1) then
         begin
           downPt := BitmapToVirtualScreen(DeformationGrid[yb+1,xb]);
           if Assigned(virtualScreen) then NiceLine(VirtualScreen, curPt.X,curPt.Y, downPt.X,downPt.Y);
@@ -1100,8 +1097,8 @@ begin
         end;
       end;
     end;
-  for xb := 1 to Manager.DeformationGridNbX-2 do
-    for yb := 1 to Manager.DeformationGridNbY-2 do
+  for xb := 1 to deformationGridNbX-2 do
+    for yb := 1 to deformationGridNbY-2 do
     begin
       if not deformationGridMoving or ((xb >= deformationGridX-1) and (xb <= deformationGridX+1) and
         (yb >= deformationGridY-1) and (yb <= deformationGridY+1)) then

+ 1 - 1
lazpaint/tools/utoolfloodfill.pas

@@ -140,7 +140,7 @@ begin
     floodFillMask.Free;
     floodFillTex.Free;
   end else
-    if Manager.ToolFloodFillOptionProgressive then
+    if ffProgressive in Manager.FloodFillOptions then
       toolDest.FloodFill(pt.X, pt.Y, penColor, fmProgressive, Manager.Tolerance) else
         toolDest.FloodFill(pt.X, pt.Y, penColor, fmDrawWithTransparency, Manager.Tolerance);
   Action.NotifyChange(toolDest, rect(0,0,toolDest.Width,toolDest.Height));