From ebeb99b327a60f360e0d086f87dcbf7a3e73ca54 Mon Sep 17 00:00:00 2001 From: Juliette ELSASS Date: Sun, 2 Jun 2024 12:33:33 +0200 Subject: [PATCH] #543 warn about opacity = 0 --- lazpaint/tools/utool.pas | 3 ++- lazpaint/tools/utoolbasic.pas | 21 ++++++++++++++++----- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/lazpaint/tools/utool.pas b/lazpaint/tools/utool.pas index c5b46788..a7159900 100644 --- a/lazpaint/tools/utool.pas +++ b/lazpaint/tools/utool.pas @@ -170,7 +170,7 @@ TToolClass = class of TGenericTool; tpmReturnValides, tpmBackspaceRemoveLastPoint, tpmRightClickFinishShape, tpmHoldKeyRestrictRotation, tpmHoldKeysScaleMode, tpmCurveModeHint, tpmBlendOpBackground, tpmRightClickForSource, tpmNothingToBeDeformed, tpmRightClickForTransformCenter, - tpmLayerEmpty); + tpmLayerEmpty, tpmOpacity0); TOnToolChangedHandler = procedure(sender: TToolManager; ANewToolType: TPaintToolType) of object; TOnPopupToolHandler = procedure(sender: TToolManager; APopupMessage: TToolPopupMessage; AKey: Word; AAlways: boolean) of object; @@ -774,6 +774,7 @@ function ToolPopupMessageToStr(AMessage: TToolPopupMessage; AKey: Word = 0): str tpmNothingToBeDeformed: result := rsNothingToBeDeformed; tpmRightClickForTransformCenter: result := rsRightClickForTransformCenter; tpmLayerEmpty: result := rsEmptyLayer; + tpmOpacity0: result := rsOpacity + ' = 0'; else result := ''; end; diff --git a/lazpaint/tools/utoolbasic.pas b/lazpaint/tools/utoolbasic.pas index 06d910e3..9c105a91 100644 --- a/lazpaint/tools/utoolbasic.pas +++ b/lazpaint/tools/utoolbasic.pas @@ -348,6 +348,8 @@ function TToolPen.ContinueDrawing(toolDest: TBGRABitmap; originF, destF: TPointF function TToolPen.DoToolDown(toolDest: TBGRABitmap; pt: TPoint; ptF: TPointF; rightBtn: boolean): TRect; +var + b: TUniversalBrush; begin if ssSnap in ShiftState then ptF := PointF(pt.X,pt.Y); if not penDrawing then @@ -359,11 +361,20 @@ function TToolPen.DoToolDown(toolDest: TBGRABitmap; pt: TPoint; ptF: TPointF; shiftClickingRight := rightBtn; end else begin - toolDest.PenStyle := psSolid; - penDrawing := true; - penDrawingRight := rightBtn; - result := StartDrawing(toolDest,ptF,rightBtn); - penOrigin := ptF; + b := GetUniversalBrush(rightBtn); + if b.DoesNothing then + begin + Manager.ToolPopup(tpmOpacity0, 0, true); + result := EmptyRect; + end + else + begin + toolDest.PenStyle := psSolid; + penDrawing := true; + penDrawingRight := rightBtn; + result := StartDrawing(toolDest,ptF,rightBtn); + penOrigin := ptF; + end; end; end else result := EmptyRect;