Pārlūkot izejas kodu

continue refactor tools

brush, grid, pressure
johann 5 gadi atpakaļ
vecāks
revīzija
1bd28c3449

+ 23 - 11
lazpaint/lazpaintmainform.pas

@@ -677,6 +677,8 @@ type
     procedure ComboBox_PenStyleDrawSelectedItem(Sender: TObject;
       const ABGRA: TBGRABitmap; AState: TBCButtonState; ARect: TRect);
     function GetImage: TLazPaintImage;
+    procedure ManagerBrushChanged(Sender: TObject);
+    procedure ManagerBrushListChanged(Sender: TObject);
     procedure ManagerDeformationGridSizeChanged(Sender: TObject);
     procedure ManagerEraserChanged(Sender: TObject);
     procedure ManagerFloodFillOptionChanged(Sender: TObject);
@@ -715,9 +717,9 @@ type
 
     FLoadInitialDir, FSaveInitialDir: string;
     FSaveSelectionInitialFilename: string;
-    FInTextFont, FInPenWidthChange, FInEraserOption,
-    FInGridNb, FInFloodfillOption, FInSplineStyleChange,
-    FInTolerance, FInPerspective : Boolean;
+    FInPenWidthChange, FInBrush, FInEraserOption,
+    FInSplineStyleChange, FInFloodfillOption, FInTolerance,
+    FInTextFont, FInPerspective, FInGridNb: Boolean;
     FOnlineUpdater: TLazPaintCustomOnlineUpdater;
     initialized: boolean;
     shouldArrangeOnResize: boolean;
@@ -776,6 +778,7 @@ type
     function ShowOpenBrushDialog: boolean;
     function TextSpinEditFocused: boolean;
     procedure UpdateBrush;
+    procedure UpdateBrushList;
 
     procedure CreateMenuAndToolbar;
     function GetToolManager: TToolManager;
@@ -1002,6 +1005,8 @@ begin
     if ToolManager.OnTextureChanged = @ManagerTextureChanged then ToolManager.OnTextureChanged := nil;
     if ToolManager.OnEraserChanged = @ManagerEraserChanged then ToolManager.OnEraserChanged := nil;
     if ToolManager.OnPenWidthChanged = @ManagerPenWidthChanged then ToolManager.OnPenWidthChanged := nil;
+    if ToolManager.OnBrushChanged = @ManagerBrushChanged then ToolManager.OnBrushChanged := nil;
+    if ToolManager.OnBrushListChanged = @ManagerBrushListChanged then ToolManager.OnBrushListChanged := nil;
     if ToolManager.OnPenStyleChanged = @ManagerPenStyleChanged then ToolManager.OnPenStyleChanged := nil;
     if ToolManager.OnJoinStyleChanged = @ManagerJoinStyleChanged then ToolManager.OnJoinStyleChanged := nil;
     if ToolManager.OnShapeOptionChanged = @ManagerShapeOptionChanged then ToolManager.OnShapeOptionChanged := nil;
@@ -1014,7 +1019,7 @@ 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.OnDeformationGridChanged = @ManagerDeformationGridSizeChanged then ToolManager.OnDeformationGridChanged := nil;
     if ToolManager.OnFloodFillOptionChanged = @ManagerFloodFillOptionChanged then ToolManager.OnFloodFillOptionChanged := nil;
     if ToolManager.OnPerspectiveOptionChanged = @ManagerPerspectiveOptionChanged then ToolManager.OnPerspectiveOptionChanged := nil;
   end;
@@ -1079,6 +1084,8 @@ begin
   ToolManager.OnTextureChanged := @ManagerTextureChanged;
   ToolManager.OnEraserChanged:=@ManagerEraserChanged;
   ToolManager.OnPenWidthChanged:= @ManagerPenWidthChanged;
+  ToolManager.OnBrushChanged:=@ManagerBrushChanged;
+  ToolManager.OnBrushListChanged:=@ManagerBrushListChanged;
   ToolManager.OnPenStyleChanged:= @ManagerPenStyleChanged;
   ToolManager.OnJoinStyleChanged:= @ManagerJoinStyleChanged;
   ToolManager.OnShapeOptionChanged:=@ManagerShapeOptionChanged;
@@ -1091,7 +1098,7 @@ begin
   ToolManager.OnGradientChanged:=@ManagerGradientChanged;
   ToolManager.OnPhongShapeChanged:=@ManagerPhongShapeChanged;
   ToolManager.OnToleranceChanged:=@ManagerToleranceChanged;
-  ToolManager.OnDeformationGridSizeChanged:=@ManagerDeformationGridSizeChanged;
+  ToolManager.OnDeformationGridChanged:=@ManagerDeformationGridSizeChanged;
   ToolManager.OnFloodFillOptionChanged:=@ManagerFloodFillOptionChanged;
   ToolManager.OnPerspectiveOptionChanged:=@ManagerPerspectiveOptionChanged;
 
@@ -3351,11 +3358,7 @@ procedure TFMain.BrushCreateGeometricExecute(Sender: TObject);
 var b: TLazPaintBrush;
 begin
   b := ShowGeometricBrushDialog(LazPaintInstance);
-  if Assigned(b) then
-  begin
-    ToolManager.AddBrush(b);
-    UpdateBrush;
-  end;
+  if Assigned(b) then ToolManager.AddBrush(b);
 end;
 
 procedure TFMain.BrushCreateGeometricUpdate(Sender: TObject);
@@ -3914,7 +3917,6 @@ begin
         FreeAndNil(newBrushBmp);
         ToolManager.AddBrush(newBrush);
         result := true;
-        UpdateBrush;
         Config.SetDefaultBrushDirectory(ExtractFilePath(brushFilename));
       except
         on ex:Exception do
@@ -4254,6 +4256,16 @@ begin
   result := LazPaintInstance.Image;
 end;
 
+procedure TFMain.ManagerBrushChanged(Sender: TObject);
+begin
+  UpdateBrush;
+end;
+
+procedure TFMain.ManagerBrushListChanged(Sender: TObject);
+begin
+  UpdateBrushList;
+end;
+
 procedure TFMain.ManagerDeformationGridSizeChanged(Sender: TObject);
 begin
   UpdateDeformationGridToolbar;

+ 22 - 11
lazpaint/maintoolbar.inc

@@ -362,6 +362,7 @@ begin
   if FInGridNb then exit;
   SpinEdit_GridNbX.Value := ToolManager.DeformationGridNbX-1;
   SpinEdit_GridNbY.Value := ToolManager.DeformationGridNbY-1;
+  Tool_GridMoveWithoutDeformation.Down := ToolManager.DeformationGridMoveWithoutDeformation;
 end;
 
 procedure TFMain.UpdateFloodfillToolbar;
@@ -465,7 +466,6 @@ begin
   UpdateFloodfillToolbar;
   UpdatePerspectiveToolbar;
   UpdateGradientToolbar;
-  Tool_GridMoveWithoutDeformation.Down := ToolManager.ToolDeformationGridMoveWithoutDeformation;
   UpdateDeformationGridToolbar;
   UpdateSplineStyleToolbar;
   UpdateCurveModeToolbar;
@@ -622,6 +622,14 @@ begin
 end;
 
 procedure TFMain.UpdateBrush;
+begin
+  if FInBrush then exit;
+  SpinEdit_BrushSpacing.Value:= ToolManager.BrushSpacing;
+  if (ToolManager.BrushIndex >= 0) and (ToolManager.BrushIndex < ComboBox_BrushSelect.Items.Count) then
+    ComboBox_BrushSelect.ItemIndex := ToolManager.BrushIndex;
+end;
+
+procedure TFMain.UpdateBrushList;
 var oldInit: boolean;
   i: Integer;
 begin
@@ -632,9 +640,9 @@ begin
     ComboBox_BrushSelect.Clear;
     for i := 0 to ToolManager.BrushCount-1 do
       ComboBox_BrushSelect.Items.Add(inttostr(i));
-    if (ToolManager.ToolBrushInfoIndex >= 0) and
-      (ToolManager.ToolBrushInfoIndex < ComboBox_BrushSelect.Items.Count) then
-      ComboBox_BrushSelect.ItemIndex := ToolManager.ToolBrushInfoIndex;
+    if (ToolManager.BrushIndex >= 0) and
+      (ToolManager.BrushIndex < ComboBox_BrushSelect.Items.Count) then
+      ComboBox_BrushSelect.ItemIndex := ToolManager.BrushIndex;
   except
     on ex:exception do
       LazPaintInstance.ShowError(rsLazPaint,ex.Message);
@@ -1023,13 +1031,12 @@ end;
 
 procedure TFMain.BrushRemoveCurrentExecute(Sender: TObject);
 begin
-  ToolManager.RemoveBrushAt(ToolManager.ToolBrushInfoIndex);
-  UpdateBrush;
+  ToolManager.RemoveBrushAt(ToolManager.BrushIndex);
 end;
 
 procedure TFMain.BrushRemoveCurrentUpdate(Sender: TObject);
 begin
-  BrushRemoveCurrent.Enabled := ToolManager.ToolBrushInfoIndex > 0;
+  BrushRemoveCurrent.Enabled := ToolManager.BrushIndex > 0;
 end;
 
 procedure TFMain.ComboBox_PenStyleChange(Sender: TObject);
@@ -1151,7 +1158,7 @@ end;
 procedure TFMain.Tool_GridMoveWithoutDeformationClick(Sender: TObject);
 begin
     if initialized then
-      ToolManager.ToolDeformationGridMoveWithoutDeformation :=
+      ToolManager.DeformationGridMoveWithoutDeformation :=
         Tool_GridMoveWithoutDeformation.Down;
 end;
 
@@ -1700,7 +1707,9 @@ procedure TFMain.ComboBox_BrushSelectChange(Sender: TObject);
 begin
   if initialized then
   begin
-    ToolManager.ToolBrushInfoIndex := ComboBox_BrushSelect.ItemIndex;
+    FInBrush := true;
+    ToolManager.BrushIndex := ComboBox_BrushSelect.ItemIndex;
+    FInBrush := false;
     Panel_PenWidthPreview.Invalidate;
   end;
 end;
@@ -1709,8 +1718,10 @@ procedure TFMain.SpinEdit_BrushSpacingChange(Sender: TObject; AByUser: boolean);
 begin
   if AByUser and initialized then
   begin
-    if ToolManager.ToolBrushSpacing = SpinEdit_BrushSpacing.Value then exit;
-    ToolManager.ToolBrushSpacing := SpinEdit_BrushSpacing.Value;
+    if ToolManager.BrushSpacing = SpinEdit_BrushSpacing.Value then exit;
+    FInBrush := true;
+    ToolManager.BrushSpacing := SpinEdit_BrushSpacing.Value;
+    FInBrush := false;
   end;
 end;
 

+ 61 - 23
lazpaint/tools/utool.pas

@@ -147,6 +147,7 @@ type
     FShouldExitTool: boolean;
     FImage: TLazPaintImage;
     FBlackAndWhite: boolean;
+    FToolPressure: single;
     FCurrentTool : TGenericTool;
     FCurrentToolType : TPaintToolType;
     FToolCurrentCursorPos: TPointF;
@@ -164,6 +165,8 @@ type
     FTextureOpactiy: byte;
     FBrushInfoList: TList;
     FBrushInfoListChanged: boolean;
+    FBrushIndex: integer;
+    FBrushSpacing: integer;
     FPenStyle: TPenStyle;
     FJoinStyle: TPenJoinStyle;
     FNormalPenWidth, FEraserWidth: Single;
@@ -184,6 +187,7 @@ type
     FPhongShapeBorderSize: integer;
     FPhongShapeKind: TPhongShapeKind;
     FDeformationGridNbX,FDeformationGridNbY: integer;
+    FDeformationGridMoveWithoutDeformation: boolean;
     FTolerance: byte;
     FFloodFillOptions: TFloodFillOptions;
     FPerspectiveOptions: TPerspectiveOptions;
@@ -195,6 +199,7 @@ type
     FOnLineCapChanged: TNotifyEvent;
     FOnPenStyleChanged: TNotifyEvent;
     FOnPenWidthChanged: TNotifyEvent;
+    FOnBrushChanged, FOnBrushListChanged: TNotifyEvent;
     FOnPhongShapeChanged: TNotifyEvent;
     FOnSplineStyleChanged: TNotifyEvent;
     FOnTextFontChanged: TNotifyEvent;
@@ -203,7 +208,7 @@ type
     FOnTextShadowChanged: TNotifyEvent;
     FOnTextureChanged: TNotifyEvent;
     FOnShapeOptionChanged: TNotifyEvent;
-    FOnDeformationGridSizeChanged: TNotifyEvent;
+    FOnDeformationGridChanged: TNotifyEvent;
     FOnToleranceChanged: TNotifyEvent;
     FOnFloodFillOptionChanged: TNotifyEvent;
     FOnPerspectiveOptionChanged: TNotifyEvent;
@@ -223,11 +228,14 @@ type
     function GetTextFontSize: integer;
     function GetTextFontStyle: TFontStyles;
     function GetTextureOpacity: byte;
+    procedure SetBrushIndex(AValue: integer);
+    procedure SetBrushSpacing(AValue: integer);
     procedure SetControlsVisible(Controls: TList; Visible: Boolean);
     procedure SetArrowEnd(AValue: TArrowKind);
     procedure SetArrowSize(AValue: TPointF);
     procedure SetArrowStart(AValue: TArrowKind);
     procedure SetBackColor(AValue: TBGRAPixel);
+    procedure SetDeformationGridMoveWithoutDeformation(AValue: boolean);
     procedure SetEraserAlpha(AValue: byte);
     procedure SetEraserMode(AValue: TEraserMode);
     procedure SetFloodFillOptions(AValue: TFloodFillOptions);
@@ -266,15 +274,11 @@ type
     BrushControls, RatioControls: TList;
 
     //tools configuration
-    ToolDeformationGridMoveWithoutDeformation: boolean;
     TextShadowBlurRadius: single;
     TextShadowOffset: TPoint;
+    ToolTextAlign: TAlignment;
     LightPosition: TPointF;
     LightAltitude: integer;
-    ToolTextAlign: TAlignment;
-    ToolBrushInfoIndex: integer;
-    ToolBrushSpacing: integer;
-    ToolPressure: single;
     ToolRatio: Single;
 
     constructor Create(AImage: TLazPaintImage; AConfigProvider: IConfigProvider; ABitmapToVirtualScreen: TBitmapToVirtualScreenFunction = nil; ABlackAndWhite : boolean = false);
@@ -284,6 +288,7 @@ type
     procedure ReloadBrushes;
     procedure SaveBrushes;
     function ApplyPressure(AColor: TBGRAPixel): TBGRAPixel;
+    function ApplyPressure(AOpacity: byte): byte;
     procedure SetPressure(APressure: single);
 
     function GetCurrentToolType: TPaintToolType;
@@ -356,6 +361,8 @@ type
     property BrushInfo: TLazPaintBrush read GetBrushInfo;
     property BrushAt[AIndex: integer]: TLazPaintBrush read GetBrushAt;
     property BrushCount: integer read GetBrushCount;
+    property BrushIndex: integer read FBrushIndex write SetBrushIndex;
+    property BrushSpacing: integer read FBrushSpacing write SetBrushSpacing;
     property TextFontName: string read GetTextFontName;
     property TextFontSize: integer read GetTextFontSize;
     property TextFontStyle: TFontStyles read GetTextFontStyle;
@@ -377,6 +384,7 @@ type
     property DeformationGridNbX: integer read FDeformationGridNbX;
     property DeformationGridNbY: integer read FDeformationGridNbY;
     property DeformationGridSize: TSize read GetDeformationGridSize write SetDeformationGridSizeProc;
+    property DeformationGridMoveWithoutDeformation: boolean read FDeformationGridMoveWithoutDeformation write SetDeformationGridMoveWithoutDeformation;
     property Tolerance: byte read FTolerance write SetTolerance;
     property FloodFillOptions: TFloodFillOptions read FFloodFillOptions write SetFloodFillOptions;
     property PerspectiveOptions: TPerspectiveOptions read FPerspectiveOptions write FPerspectiveOptions;
@@ -387,6 +395,8 @@ type
     property OnTextureChanged: TNotifyEvent read FOnTextureChanged write FOnTextureChanged;
     property OnColorChanged: TNotifyEvent read FOnColorChanged write FOnColorChanged;
     property OnPenWidthChanged: TNotifyEvent read FOnPenWidthChanged write FOnPenWidthChanged;
+    property OnBrushChanged: TNotifyEvent read FOnBrushChanged write FOnBrushChanged;
+    property OnBrushListChanged: TNotifyEvent read FOnBrushListChanged write FOnBrushListChanged;
     property OnPenStyleChanged: TNotifyEvent read FOnPenStyleChanged write FOnPenStyleChanged;
     property OnJoinStyleChanged: TNotifyEvent read FOnJoinStyleChanged write FOnJoinStyleChanged;
     property OnShapeOptionChanged: TNotifyEvent read FOnShapeOptionChanged write FOnShapeOptionChanged;
@@ -398,7 +408,7 @@ 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 OnDeformationGridChanged: TNotifyEvent read FOnDeformationGridChanged write FOnDeformationGridChanged;
     property OnToleranceChanged: TNotifyEvent read FOnToleranceChanged write FOnToleranceChanged;
     property OnFloodFillOptionChanged: TNotifyEvent read FOnFloodFillOptionChanged write FOnFloodFillOptionChanged;
     property OnPerspectiveOptionChanged: TNotifyEvent read FOnPerspectiveOptionChanged write FOnPerspectiveOptionChanged;
@@ -907,6 +917,13 @@ begin
   if Assigned(FOnColorChanged) then FOnColorChanged(self);
 end;
 
+procedure TToolManager.SetDeformationGridMoveWithoutDeformation(AValue: boolean);
+begin
+  if FDeformationGridMoveWithoutDeformation=AValue then Exit;
+  FDeformationGridMoveWithoutDeformation:=AValue;
+  if Assigned(FOnDeformationGridChanged) then FOnDeformationGridChanged(self);
+end;
+
 procedure TToolManager.SetEraserAlpha(AValue: byte);
 begin
   if FEraserAlpha=AValue then Exit;
@@ -1126,12 +1143,12 @@ end;
 
 function TToolManager.GetBrushInfo: TLazPaintBrush;
 begin
-  if (ToolBrushInfoIndex < 0) or (ToolBrushInfoIndex > FBrushInfoList.Count) then
-    ToolBrushInfoIndex := 0;
-  if ToolBrushInfoIndex > FBrushInfoList.Count then
+  if (FBrushIndex < 0) or (FBrushIndex > FBrushInfoList.Count) then
+    FBrushIndex := 0;
+  if FBrushIndex > FBrushInfoList.Count then
     result := nil
   else
-    result := TObject(FBrushInfoList[ToolBrushInfoIndex]) as TLazPaintBrush;
+    result := TObject(FBrushInfoList[FBrushIndex]) as TLazPaintBrush;
 end;
 
 function TToolManager.GetCursor: TCursor;
@@ -1210,6 +1227,20 @@ begin
   result := FTextureOpactiy;
 end;
 
+procedure TToolManager.SetBrushIndex(AValue: integer);
+begin
+  if FBrushIndex=AValue then Exit;
+  FBrushIndex:=AValue;
+  if Assigned(FOnBrushChanged) then FOnBrushChanged(self);
+end;
+
+procedure TToolManager.SetBrushSpacing(AValue: integer);
+begin
+  if FBrushSpacing=AValue then Exit;
+  FBrushSpacing:=AValue;
+  if Assigned(FOnBrushChanged) then FOnBrushChanged(self);
+end;
+
 constructor TToolManager.Create(AImage: TLazPaintImage; AConfigProvider: IConfigProvider; ABitmapToVirtualScreen: TBitmapToVirtualScreenFunction; ABlackAndWhite : boolean);
 begin
   FImage:= AImage;
@@ -1229,7 +1260,7 @@ begin
   Tolerance := 64;
   FBlackAndWhite := ABlackAndWhite;
 
-  ToolBrushSpacing := 1;
+  FBrushSpacing := 1;
   ReloadBrushes;
 
   GradientType := gtLinear;
@@ -1263,7 +1294,7 @@ begin
 
   FDeformationGridNbX := 5;
   FDeformationGridNbY := 5;
-  ToolDeformationGridMoveWithoutDeformation := false;
+  FDeformationGridMoveWithoutDeformation := false;
 
   PenWidthControls := TList.Create;
   AliasingControls := TList.Create;
@@ -1452,7 +1483,7 @@ end;
 function TToolManager.ApplyPressure(AColor: TBGRAPixel): TBGRAPixel;
 var alpha: integer;
 begin
-  alpha := round(AColor.alpha*ToolPressure);
+  alpha := round(AColor.alpha*FToolPressure);
   if alpha <= 0 then
     result := BGRAPixelTransparent
   else if alpha >= 255 then
@@ -1464,14 +1495,19 @@ begin
   end;
 end;
 
+function TToolManager.ApplyPressure(AOpacity: byte): byte;
+begin
+  result := round(AOpacity*FToolPressure);
+end;
+
 procedure TToolManager.SetPressure(APressure: single);
 begin
   if APressure <= 0 then
-    ToolPressure := 0
+    FToolPressure := 0
   else if APressure >= 1 then
-    ToolPressure := 1
+    FToolPressure := 1
   else
-    ToolPressure:= APressure;
+    FToolPressure:= APressure;
 end;
 
 procedure TToolManager.InternalSetCurrentToolType(tool: TPaintToolType);
@@ -1592,7 +1628,7 @@ begin
   begin
     FDeformationGridNbX := ASize.cx;
     FDeformationGridNbY := ASize.cy;
-    if Assigned(FOnDeformationGridSizeChanged) then FOnDeformationGridSizeChanged(self);
+    if Assigned(FOnDeformationGridChanged) then FOnDeformationGridChanged(self);
     CurrentTool.AfterGridSizeChange(ASize.cx,ASize.cy);
     result := true;
   end;
@@ -1655,8 +1691,9 @@ end;
 
 procedure TToolManager.AddBrush(brush: TLazPaintBrush);
 begin
-  ToolBrushInfoIndex := FBrushInfoList.Add(brush);
+  FBrushIndex := FBrushInfoList.Add(brush);
   FBrushInfoListChanged := true;
+  if Assigned(FOnBrushListChanged) then FOnBrushListChanged(self);
 end;
 
 procedure TToolManager.RemoveBrushAt(index: integer);
@@ -1667,13 +1704,14 @@ begin
     begin
       BrushAt[index].Free;
       FBrushInfoList.Delete(index);
-      if index < ToolBrushInfoIndex then dec(ToolBrushInfoIndex)
-      else if index = ToolBrushInfoIndex then
+      if index < FBrushIndex then dec(FBrushIndex)
+      else if index = FBrushIndex then
         begin
-          if ToolBrushInfoIndex >= BrushCount then
-            dec(ToolBrushInfoIndex);
+          if FBrushIndex >= BrushCount then
+            dec(FBrushIndex);
         end;
       FBrushInfoListChanged := true;
+      if Assigned(FOnBrushListChanged) then FOnBrushListChanged(self);
     end;
   end;
 end;

+ 7 - 7
lazpaint/tools/utoolbasic.pas

@@ -134,7 +134,7 @@ begin
     begin
       ix := round(ptF.X);
       iy := round(ptF.Y);
-      toolDest.ErasePixel(ix,iy,round(Manager.EraserAlpha*Manager.ToolPressure));
+      toolDest.ErasePixel(ix,iy,Manager.ApplyPressure(Manager.EraserAlpha));
       result := rect(ix,iy,ix+1,iy+1);
     end
     else
@@ -145,9 +145,9 @@ begin
       begin
         r := rect(round(ptF.X-Manager.PenWidth/2+0.5),round(ptF.Y-Manager.PenWidth/2+0.5),
              round(ptF.X+Manager.PenWidth/2+0.5),round(ptF.Y+Manager.PenWidth/2+0.5));
-        toolDest.EraseEllipseInRect(r,round(Manager.EraserAlpha*Manager.ToolPressure));
+        toolDest.EraseEllipseInRect(r,Manager.ApplyPressure(Manager.EraserAlpha));
       end else
-        toolDest.EraseEllipseAntialias(ptF.X,ptF.Y,Manager.PenWidth/2,Manager.PenWidth/2,round(Manager.EraserAlpha*Manager.ToolPressure));
+        toolDest.EraseEllipseAntialias(ptF.X,ptF.Y,Manager.PenWidth/2,Manager.PenWidth/2,Manager.ApplyPressure(Manager.EraserAlpha));
       toolDest.NoClip;
     end;
   end;
@@ -189,23 +189,23 @@ begin
   begin
     if Manager.PenWidth = 1 then
     begin
-      toolDest.EraseLine(round(destF.X),round(destF.Y),round(originF.X),round(originF.Y),round(Manager.EraserAlpha*Manager.ToolPressure),false);
+      toolDest.EraseLine(round(destF.X),round(destF.Y),round(originF.X),round(originF.Y),Manager.ApplyPressure(Manager.EraserAlpha),false);
       result := GetShapeBounds([destF,originF],1);
     end else
     begin
       pts := toolDest.Pen.ComputePolyline([PointF(destF.X,destF.Y),PointF(originF.X,originF.Y)],Manager.PenWidth,BGRAPixelTransparent,False);
-      toolDest.ErasePoly(pts, round(Manager.EraserAlpha*Manager.ToolPressure));
+      toolDest.ErasePoly(pts, Manager.ApplyPressure(Manager.EraserAlpha));
       result := GetShapeBounds([destF,originF],Manager.PenWidth);
     end;
   end else
   begin
     if snapToPixel and (Manager.PenWidth = 1) then
     begin
-      toolDest.EraseLineAntialias(round(destF.X),round(destF.Y),round(originF.X),round(originF.Y),round(Manager.EraserAlpha*Manager.ToolPressure),false);
+      toolDest.EraseLineAntialias(round(destF.X),round(destF.Y),round(originF.X),round(originF.Y),Manager.ApplyPressure(Manager.EraserAlpha),false);
       result := GetShapeBounds([destF,originF],1);
     end else
     begin
-      toolDest.EraseLineAntialias(destF.X,destF.Y,originF.X,originF.Y,round(Manager.EraserAlpha*Manager.ToolPressure),Manager.PenWidth,False);
+      toolDest.EraseLineAntialias(destF.X,destF.Y,originF.X,originF.Y,Manager.ApplyPressure(Manager.EraserAlpha),Manager.PenWidth,False);
       result := GetShapeBounds([destF,originF],Manager.PenWidth);
     end;
   end;

+ 4 - 4
lazpaint/tools/utoolbrush.pas

@@ -109,7 +109,7 @@ begin
     end;
     toolDest.ClipRect := result;
     source.ScanOffset := Point(sourcePosition.x, sourcePosition.y);
-    toolDest.FillMask(round(x),round(y),BrushInfo.BrushImage,source,dmDrawWithTransparency,round(Manager.ToolPressure*255));
+    toolDest.FillMask(round(x),round(y),BrushInfo.BrushImage,source,dmDrawWithTransparency,Manager.ApplyPressure(255));
     source.ScanOffset := Point(0,0);
     toolDest.NoClip;
   end;
@@ -191,9 +191,9 @@ begin
   result := rect(floor(x-0.5),floor(y-0.5),ceil(x+0.5)+coloredBrushImage.Width,ceil(y+0.5)+coloredBrushImage.Height);
   toolDest.ClipRect := result;
   if not SubPixelAccuracy then
-    toolDest.PutImage(round(x),round(y),coloredBrushImage,dmDrawWithTransparency,GetBrushAlpha(round(Manager.ToolPressure*255)))
+    toolDest.PutImage(round(x),round(y),coloredBrushImage,dmDrawWithTransparency,GetBrushAlpha(Manager.ApplyPressure(255)))
   else
-    toolDest.PutImageSubpixel(x,y,coloredBrushImage,GetBrushAlpha(round(Manager.ToolPressure*255)));
+    toolDest.PutImageSubpixel(x,y,coloredBrushImage,GetBrushAlpha(Manager.ApplyPressure(255)));
   toolDest.NoClip;
 end;
 
@@ -268,7 +268,7 @@ begin
     minLen := round(power(BrushInfo.Size/10,0.8));
     if minLen < 1 then minLen := 1;
     if minLen > 5 then minLen := 5;
-    minLen *=Manager.ToolBrushSpacing;
+    minLen *=Manager.BrushSpacing;
     if len >= minLen then
     begin
       v := v*(1/len)*minLen;

+ 1 - 1
lazpaint/tools/utooldeformationgrid.pas

@@ -955,7 +955,7 @@ begin
   Manager.HintReturnValidates;
 
   if not deformationGridMoving then exit;
-  if Manager.ToolDeformationGridMoveWithoutDeformation then
+  if Manager.DeformationGridMoveWithoutDeformation then
   begin
     ReleaseGrid;
     DeformationGrid[deformationGridY,deformationGridX] := PointF(