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

Merge pull request #42 from bgrabitmap/dev-lazpaint

Dev lazpaint 7.0.6
circular17 6 жил өмнө
parent
commit
7725ace78f

+ 1 - 0
.gitignore

@@ -33,3 +33,4 @@ lazpaint/image/backup/
 
 lazpaint/dialog/backup/
 .DS_Store
+lazpaint/release/bin/lazpaint.app

+ 1 - 1
lazpaint.logic

@@ -9,5 +9,5 @@ echo "Don't forget to UPDATE changelog file"
 copy release/changelog release/debian/linux32/DEBIAN/changelog
 copy release/changelog release/debian/linux64/DEBIAN/changelog
 text release/macOS/makedmg.sh "appversion=$(Version)"
-plist release/macOS/LazPaint.app/Contents/Info.plist
+bundle release/macOS/LazPaint.app
 copy ../resources/icon/lazpaint.icns release/macOS/LazPaint.app/Contents/Resources/lazpaint.icns

+ 13 - 1
lazpaint/image/uimage.pas

@@ -1852,10 +1852,22 @@ begin
 end;
 
 procedure TLazPaintImage.MergeLayerOver;
+var
+  remove: TCustomImageDifference;
+  nextId: LongInt;
 begin
+  if CurrentLayerIndex = 0 then exit;
   if not CheckNoAction then exit;
   try
-    AddUndo(FCurrentState.MergerLayerOver(CurrentLayerIndex));
+    if LayerBitmap[CurrentLayerIndex].Empty then
+    begin
+      nextId := LayerId[CurrentLayerIndex-1];
+      remove := FCurrentState.RemoveLayer;
+      if remove is TRemoveLayerStateDifference then
+        TRemoveLayerStateDifference(remove).nextActiveLayerId:= nextId;
+      AddUndo(remove);
+    end else
+      AddUndo(FCurrentState.MergerLayerOver(CurrentLayerIndex));
   except on ex: exception do NotifyException('MergeLayerOver',ex);
   end;
   ImageMayChangeCompletely;

+ 2 - 2
lazpaint/image/uimageaction.pas

@@ -274,8 +274,8 @@ end;
 procedure TImageActions.Undo;
 begin
   try
-    if CurrentTool in[ptTextureMapping,ptLayerMapping,ptMoveSelection,ptRotateSelection] then
-      ChooseTool(ptHand);
+    if CurrentTool in[ptMoveSelection,ptRotateSelection] then ChooseTool(ptHand);
+    if ToolManager.ToolProvideCommand(tcFinish) then ToolManager.ToolCommand(tcFinish);
     if image.CanUndo then
     begin
       ToolManager.ToolCloseDontReopen;

+ 14 - 13
lazpaint/image/uimagediff.pas

@@ -272,8 +272,8 @@ type
 
   TRemoveLayerStateDifference = class(TCustomImageDifference)
   protected
-    content: TStoredLayer;
-    nextActiveLayerId: integer;
+    FContent: TStoredLayer;
+    FNextActiveLayerId: integer;
     function GetImageDifferenceKind: TImageDifferenceKind; override;
   public
     function UsedMemory: int64; override;
@@ -282,6 +282,7 @@ type
     procedure UnapplyTo(AState: TState); override;
     constructor Create(AState: TState);
     destructor Destroy; override;
+    property nextActiveLayerId: integer read FNextActiveLayerId write FNextActiveLayerId;
   end;
 
   { TReplaceLayerByOriginalDifference }
@@ -2022,15 +2023,15 @@ end;
 
 function TRemoveLayerStateDifference.UsedMemory: int64;
 begin
-  if Assigned(content) then
-    result := content.UsedMemory
+  if Assigned(FContent) then
+    result := FContent.UsedMemory
   else
     result := 0;
 end;
 
 function TRemoveLayerStateDifference.TryCompress: boolean;
 begin
-  Result:= content.Compress;
+  Result:= FContent.Compress;
 end;
 
 procedure TRemoveLayerStateDifference.ApplyTo(AState: TState);
@@ -2039,10 +2040,10 @@ begin
   inherited ApplyTo(AState);
   with AState as TImageState do
   begin
-    idx := LayeredBitmap.GetLayerIndexFromId(content.LayerId);
+    idx := LayeredBitmap.GetLayerIndexFromId(FContent.LayerId);
     LayeredBitmap.RemoveLayer(idx);
     LayeredBitmap.RemoveUnusedOriginals;
-    SelectedImageLayerIndex := LayeredBitmap.GetLayerIndexFromId(self.nextActiveLayerId);
+    SelectedImageLayerIndex := LayeredBitmap.GetLayerIndexFromId(self.FNextActiveLayerId);
   end;
 end;
 
@@ -2051,8 +2052,8 @@ begin
   inherited UnapplyTo(AState);
   with AState as TImageState do
   begin
-    content.Restore(LayeredBitmap);
-    SelectedImageLayerIndex := content.LayerIndex;
+    FContent.Restore(LayeredBitmap);
+    SelectedImageLayerIndex := FContent.LayerIndex;
   end;
 end;
 
@@ -2069,15 +2070,15 @@ begin
   idx := imgState.SelectedImageLayerIndex;
   if idx = -1 then
     raise exception.Create('No layer selected');
-  self.content := TStoredLayer.Create(imgState.LayeredBitmap, idx);
+  self.FContent := TStoredLayer.Create(imgState.LayeredBitmap, idx);
   if idx+1 < imgState.NbLayers then
     nextIdx := idx+1 else nextIdx := idx-1;
-  self.nextActiveLayerId := imgState.LayeredBitmap.LayerUniqueId[nextIdx];
+  self.FNextActiveLayerId := imgState.LayeredBitmap.LayerUniqueId[nextIdx];
 end;
 
 destructor TRemoveLayerStateDifference.Destroy;
 begin
-  self.content.Free;
+  self.FContent.Free;
   inherited Destroy;
 end;
 
@@ -2282,7 +2283,7 @@ begin
   begin
     self.sourceLayerId := LayeredBitmap.LayerUniqueId[SelectedImageLayerIndex];
     self.duplicateId := LayeredBitmap.ProduceLayerUniqueId;
-    self.duplicateOriginal := useOriginal and (LayeredBitmap.OriginalClass[SelectedImageLayerIndex]=TVectorOriginal);
+    self.duplicateOriginal := useOriginal and (LayeredBitmap.LayerOriginalClass[SelectedImageLayerIndex]=TVectorOriginal);
     if self.duplicateOriginal then
       CreateGUID(duplicateGuid);
   end;

+ 1 - 0
lazpaint/image/ustatetype.pas

@@ -1101,6 +1101,7 @@ begin
     end else
     begin
       tempIdx := ALayeredImage.AddOwnedLayer(GetBitmap);
+      ALayeredImage.LayerOffset[tempIdx] := FInfo.Offset;
       ALayeredImage.LayerOriginalGuid[tempIdx] := ALayeredImage.OriginalGuid[idxOrig];
       ALayeredImage.LayerOriginalMatrix[tempIdx] := FOriginalMatrix;
       ALayeredImage.LayerOriginalRenderStatus[tempIdx] := FOriginalRenderStatus;

+ 1 - 1
lazpaint/lazpaint.lpi

@@ -21,7 +21,7 @@
     <VersionInfo>
       <UseVersionInfo Value="True"/>
       <MajorVersionNr Value="7"/>
-      <RevisionNr Value="5"/>
+      <RevisionNr Value="6"/>
       <CharSet Value="04B0"/>
       <StringTable CompanyName="http://sourceforge.net/projects/lazpaint/" ProductName="LazPaint" InternalName="lazpaint" OriginalFilename="lazpaint.exe"/>
     </VersionInfo>

+ 1 - 1
lazpaint/lazpaintembeddedpack.lpk

@@ -26,7 +26,7 @@
         </Debugging>
       </Linking>
     </CompilerOptions>
-    <Version Major="7" Release="5"/>
+    <Version Major="7" Release="6"/>
     <Files Count="94">
       <Item1>
         <Filename Value="lazpaintinstance.pas"/>

+ 16 - 8
lazpaint/lazpaintmainform.pas

@@ -539,8 +539,7 @@ type
     procedure SpinEdit_TextureOpacityChange(Sender: TObject; AByUser: boolean);
     procedure SpinEdit_TextBlurChange(Sender: TObject; AByUser: boolean);
     procedure GridNb_SpinEditChange(Sender: TObject; AByUser: boolean);
-    procedure Image_CurrentTextureMouseDown(Sender: TObject;
-      {%H-}Button: TMouseButton; {%H-}Shift: TShiftState; {%H-}X, {%H-}Y: Integer);
+    procedure Image_CurrentTextureClick(Sender: TObject);
     procedure PaintBox_PenPreviewPaint(Sender: TObject);
     procedure PaintBox_PictureMouseDown(Sender: TObject; Button: TMouseButton;
       Shift: TShiftState; X, Y: Integer);
@@ -1146,7 +1145,7 @@ procedure TFMain.FormMouseDown(Sender: TObject; Button: TMouseButton;
 begin
   if not Assigned(FImageView) then exit;
   ReleaseMouseButtons(Shift);
-  if not (Button in[mbLeft,mbRight,mbMiddle]) then exit;
+  if not (Button in[mbLeft,mbRight,mbMiddle]) or not FImageView.PictureCoordsDefined then exit;
   CanCompressOrUpdateStack := false;
   Image.OnImageChanged.DelayedStackUpdate := True;
 
@@ -1193,7 +1192,13 @@ begin
   FormMouseMovePos := Point(X,Y);
   if InFormMouseMove then exit;
   InFormMouseMove := True;
-  //Application.ProcessMessages; //empty message stack
+  if not FImageView.PictureCoordsDefined then
+    Application.ProcessMessages; //empty message stack
+  if not FImageView.PictureCoordsDefined then
+  begin
+    InFormMouseMove:= false;
+    exit;
+  end;
 
   BmpPos := FImageView.FormToBitmap(FormMouseMovePos);
   FCoordinatesCaption := IntToStr(round(BmpPos.X))+','+IntToStr(round(BmpPos.Y));
@@ -1236,7 +1241,9 @@ begin
   if (btnLeftDown and (Button = mbLeft)) or (btnRightDown and (Button=mbRight))
     or (btnMiddleDown and (Button = mbMiddle)) then
   begin
-    redraw := ToolManager.ToolMove(FImageView.FormToBitmap(X,Y),CurrentPressure);
+    if FImageView.PictureCoordsDefined then
+      redraw := ToolManager.ToolMove(FImageView.FormToBitmap(X,Y),CurrentPressure)
+      else redraw := false;
     if ToolManager.ToolUp then redraw := true;
     btnLeftDown := false;
     btnRightDown := false;
@@ -1690,7 +1697,7 @@ end;
 
 procedure TFMain.EditUndoUpdate(Sender: TObject);
 begin
-  EditUndo.Enabled := image.CanUndo;
+  EditUndo.Enabled := image.CanUndo or ToolManager.ToolProvideCommand(tcFinish);
 end;
 
 procedure TFMain.EmbeddedCancelExecute(Sender: TObject);
@@ -2358,7 +2365,7 @@ end;
 procedure TFMain.FormMouseWheel(Sender: TObject; Shift: TShiftState;
   WheelDelta: Integer; MousePos: TPoint; var Handled: Boolean);
 begin
-  if not Assigned(FImageView) then exit;
+  if not Assigned(FImageView) or not FImageView.PictureCoordsDefined then exit;
   Zoom.SetPosition(FImageView.FormToBitmap(MousePos.X,MousePos.Y), MousePos);
   if WheelDelta > 0 then Zoom.ZoomIn(ssCtrl in Shift) else
   if WheelDelta < 0 then Zoom.ZoomOut(ssCtrl in Shift);
@@ -2520,7 +2527,8 @@ end;
 
 procedure TFMain.ToolNoTextureUpdate(Sender: TObject);
 begin
-  ToolNoTexture.Enabled := ToolManager.GetTexture <> nil;
+  ToolNoTexture.Enabled := (ToolManager.GetTexture <> nil)
+    and (CurrentTool <> ptTextureMapping);
 end;
 
 procedure TFMain.ViewColorsExecute(Sender: TObject);

+ 1 - 1
lazpaint/lazpainttype.pas

@@ -10,7 +10,7 @@ uses
   {$IFDEF LINUX}, InterfaceBase{$ENDIF};
 
 const
-  LazPaintVersion = 7000500;
+  LazPaintVersion = 7000600;
 
   function LazPaintVersionStr: string;
 

+ 2 - 4
lazpaint/maintoolbar.inc

@@ -10,7 +10,7 @@ begin
   Shape_PenColor.OnMouseDown := @Shape_PenColorMouseDown;
   Shape_BackColor.OnMouseDown := @Shape_BackColorMouseDown;
   Image_SwapColors.OnMouseDown := @Image_SwapColorsMouseDown;
-  Image_CurrentTexture.OnMouseDown := @Image_CurrentTextureMouseDown;
+  Image_CurrentTexture.OnClick := @Image_CurrentTextureClick;
   Tool_DrawShapeBorder.OnClick := @Tool_DrawShapeBorderClick;
   Tool_Aliasing.OnClick := @Tool_AliasingClick;
   Tool_FillShape.OnClick := @Tool_FillShapeClick;
@@ -546,7 +546,6 @@ begin
       Image_CurrentTool.Picture.Clear;
     previousToolImg := img;
   end;
-  Panel_Texture.Enabled := (CurrentTool <> ptTextureMapping);
 end;
 
 procedure TFMain.NoTextureIcon;
@@ -815,8 +814,7 @@ begin
   end;
 end;
 
-procedure TFMain.Image_CurrentTextureMouseDown(Sender: TObject;
-  Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
+procedure TFMain.Image_CurrentTextureClick(Sender: TObject);
 begin
   LazPaintInstance.EditTexture;
   UpdateEditPicture;

+ 12 - 0
lazpaint/release/changelog

@@ -75,3 +75,15 @@ lazpaint (7.0.5) stable; urgency=low
 
 -- circular <[email protected]>  Sun, 24 Aug 2019 11:46:00 +0100
 
+lazpaint (7.0.6) stable; urgency=low
+
+  * fix merge bitmap layer
+  * fix mouse scroll on MacOS
+  * clipboard image format with transparency
+  * allow undo when creating shape
+  * fix texture panel
+  * merging empty layer simply deletes it
+  * fix layer offset after undoing merge layer
+
+-- circular <[email protected]>  Wed, 11 Sep 2019 18:20:00 +0100
+

+ 12 - 0
lazpaint/release/debian/linux32/DEBIAN/changelog

@@ -75,3 +75,15 @@ lazpaint (7.0.5) stable; urgency=low
 
 -- circular <[email protected]>  Sun, 24 Aug 2019 11:46:00 +0100
 
+lazpaint (7.0.6) stable; urgency=low
+
+  * fix merge bitmap layer
+  * fix mouse scroll on MacOS
+  * clipboard image format with transparency
+  * allow undo when creating shape
+  * fix texture panel
+  * merging empty layer simply deletes it
+  * fix layer offset after undoing merge layer
+
+-- circular <[email protected]>  Wed, 11 Sep 2019 18:20:00 +0100
+

+ 1 - 1
lazpaint/release/debian/linux32/DEBIAN/control

@@ -1,5 +1,5 @@
 Package: lazpaint
-Version: 7.0.5
+Version: 7.0.6
 Section: base
 Priority: optional
 Architecture: i386

+ 12 - 0
lazpaint/release/debian/linux64/DEBIAN/changelog

@@ -75,3 +75,15 @@ lazpaint (7.0.5) stable; urgency=low
 
 -- circular <[email protected]>  Sun, 24 Aug 2019 11:46:00 +0100
 
+lazpaint (7.0.6) stable; urgency=low
+
+  * fix merge bitmap layer
+  * fix mouse scroll on MacOS
+  * clipboard image format with transparency
+  * allow undo when creating shape
+  * fix texture panel
+  * merging empty layer simply deletes it
+  * fix layer offset after undoing merge layer
+
+-- circular <[email protected]>  Wed, 11 Sep 2019 18:20:00 +0100
+

+ 1 - 1
lazpaint/release/debian/linux64/DEBIAN/control

@@ -1,5 +1,5 @@
 Package: lazpaint
-Version: 7.0.5
+Version: 7.0.6
 Section: base
 Priority: optional
 Architecture: amd64

+ 43 - 43
lazpaint/release/macOS/LazPaint.app/Contents/Info.plist

@@ -1,47 +1,47 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
 <plist version="1.0">
-<dict>
-	<key>CFBundleIconFile</key>
-	<string>lazpaint</string>
-	<key>CFBundleDevelopmentRegion</key>
-	<string>English</string>
-	<key>CFBundleExecutable</key>
-	<string>lazpaint</string>
-	<key>CFBundleName</key>
-	<string>LazPaint</string>
-	<key>CFBundleIdentifier</key>
-	<string>com.company.lazpaint</string>
-	<key>CFBundleInfoDictionaryVersion</key>
-	<string>6.0</string>
-	<key>CFBundlePackageType</key>
-	<string>APPL</string>
-	<key>CFBundleSignature</key>
-	<string>lazp</string>
-	<key>CFBundleShortVersionString</key>
-	<string>7.0.5</string>
-	<key>CFBundleVersion</key>
-	<string>7.0.5</string>
-	<key>CSResourcesFileMapped</key>
-	<true/>
-	<key>CFBundleDocumentTypes</key>
-	<array>
-		<dict>
-			<key>CFBundleTypeRole</key>
-			<string>Viewer</string>
-			<key>CFBundleTypeExtensions</key>
-			<array>
-				<string>*</string>
-			</array>
-			<key>CFBundleTypeOSTypes</key>
-			<array>
-				<string>fold</string>
-				<string>disk</string>
-				<string>****</string>
-			</array>
-		</dict>
-	</array>
-	<key>NSHighResolutionCapable</key>
-	<true/>
-</dict>
+  <dict>
+    <key>CFBundleIconFile</key>
+    <string>lazpaint</string>
+    <key>CFBundleDevelopmentRegion</key>
+    <string>English</string>
+    <key>CFBundleExecutable</key>
+    <string>lazpaint</string>
+    <key>CFBundleName</key>
+    <string>LazPaint</string>
+    <key>CFBundleIdentifier</key>
+    <string>com.company.lazpaint</string>
+    <key>CFBundleInfoDictionaryVersion</key>
+    <string>6.0</string>
+    <key>CFBundlePackageType</key>
+    <string>APPL</string>
+    <key>CFBundleSignature</key>
+    <string>lazp</string>
+    <key>CFBundleShortVersionString</key>
+    <string>7.0.6</string>
+    <key>CFBundleVersion</key>
+    <string>7.0.6</string>
+    <key>CSResourcesFileMapped</key>
+    <true/>
+    <key>CFBundleDocumentTypes</key>
+    <array>
+      <dict>
+        <key>CFBundleTypeRole</key>
+        <string>Viewer</string>
+        <key>CFBundleTypeExtensions</key>
+        <array>
+          <string>*</string>
+        </array>
+        <key>CFBundleTypeOSTypes</key>
+        <array>
+          <string>fold</string>
+          <string>disk</string>
+          <string>****</string>
+        </array>
+      </dict>
+    </array>
+    <key>NSHighResolutionCapable</key>
+    <true/>
+  </dict>
 </plist>

+ 1 - 1
lazpaint/release/macOS/makedmg.sh

@@ -12,7 +12,7 @@ fi
 
 
 appname=LazPaint
-appversion=7.0.5
+appversion=7.0.6
 pkgversion=0
 
 appnamenospaces=LazPaint

+ 1 - 1
lazpaint/release/windows/lazpaint.iss

@@ -1,7 +1,7 @@
 #define MyAppName "LazPaint"
 #define MyAppOutputName "lazpaint"
 #define MyInstallerSuffix "_setup_win32_win64"
-#define MyAppVersion "7.0.5"
+#define MyAppVersion "7.0.6"
 #define MyAppPublisher "Circular, Fabien Wang, Lainz and others"
 #define MyAppURL "http://sourceforge.net/projects/lazpaint/"
 #define MyAppExeName "lazpaint.exe"

+ 5 - 2
lazpaint/tools/utool.pas

@@ -44,7 +44,7 @@ type
   TBitmapToVirtualScreenFunction = function(PtF: TPointF): TPointF of object;
 
   TEraserMode = (emEraseAlpha, emSoften);
-  TToolCommand = (tcCut, tcCopy, tcPaste, tcDelete, tcMoveUp, tcMoveDown, tcMoveToFront, tcMoveToBack,
+  TToolCommand = (tcCut, tcCopy, tcPaste, tcDelete, tcFinish, tcMoveUp, tcMoveDown, tcMoveToFront, tcMoveToBack,
     tcAlignLeft, tcCenterHorizontally, tcAlignRight, tcAlignTop, tcCenterVertically, tcAlignBottom,
     tcShapeToSpline);
 
@@ -1732,7 +1732,10 @@ end;
 function TToolManager.ToolCommand(ACommand: TToolCommand): boolean;
 begin
   if Assigned(FCurrentTool) then
-    result := FCurrentTool.ToolCommand(ACommand)
+  begin
+    result := FCurrentTool.ToolCommand(ACommand);
+    CheckExitTool;
+  end
   else
     result := false;
 end;

+ 52 - 5
lazpaint/tools/utooldeformationgrid.pas

@@ -36,7 +36,9 @@ type
     function GetContextualToolbars: TContextualToolbars; override;
     function Render(VirtualScreen: TBGRABitmap; {%H-}VirtualScreenWidth, {%H-}VirtualScreenHeight: integer; BitmapToVirtualScreen: TBitmapToVirtualScreenFunction): TRect; override;
     procedure BeforeGridSizeChange; override;
-    procedure AfterGridSizeChange(NewNbX,NewNbY: Integer); override;
+    procedure AfterGridSizeChange({%H-}NewNbX,{%H-}NewNbY: Integer); override;
+    function ToolCommand(ACommand: TToolCommand): boolean; override;
+    function ToolProvideCommand(ACommand: TToolCommand): boolean; override;
     destructor Destroy; override;
   end;
 
@@ -84,6 +86,8 @@ type
     function ToolUp: TRect; override;
     function GetContextualToolbars: TContextualToolbars; override;
     function Render(VirtualScreen: TBGRABitmap; {%H-}VirtualScreenWidth, {%H-}VirtualScreenHeight: integer; BitmapToVirtualScreen: TBitmapToVirtualScreenFunction):TRect; override;
+    function ToolProvideCommand(ACommand: TToolCommand): boolean; override;
+    function ToolCommand(ACommand: TToolCommand): boolean; override;
     destructor Destroy; override;
   end;
 
@@ -717,6 +721,29 @@ begin
     DrawPoints(quad,192);
 end;
 
+function TToolTextureMapping.ToolProvideCommand(ACommand: TToolCommand
+  ): boolean;
+begin
+  case ACommand of
+    tcFinish: result := quadDefined;
+  else result := false;
+  end;
+end;
+
+function TToolTextureMapping.ToolCommand(ACommand: TToolCommand): boolean;
+begin
+  case ACommand of
+    tcFinish: if quadDefined then
+      begin
+        ValidateQuad;
+        Manager.QueryExitTool;
+        result := true;
+      end  else
+        result := false;
+  else result := false;
+  end;
+end;
+
 destructor TToolTextureMapping.Destroy;
 begin
   ValidateAction;
@@ -758,12 +785,32 @@ begin
   DeformationGridTexCoord := nil;
 end;
 
-{$hints off}
 procedure TToolDeformationGrid.AfterGridSizeChange(NewNbX,NewNbY: Integer);
 begin
   //grid will be created when needed
 end;
-{$hints on}
+
+function TToolDeformationGrid.ToolCommand(ACommand: TToolCommand): boolean;
+begin
+  case ACommand of
+    tcFinish: if DoingDeformation then
+      begin
+        ValidateDeformationGrid;
+        result := true;
+      end
+      else result := false;
+  else result := false;
+  end;
+end;
+
+function TToolDeformationGrid.ToolProvideCommand(ACommand: TToolCommand
+  ): boolean;
+begin
+  case ACommand of
+    tcFinish: result := DoingDeformation;
+  else result := false;
+  end;
+end;
 
 destructor TToolDeformationGrid.Destroy;
 begin
@@ -1012,7 +1059,7 @@ begin
   result := EmptyRect;
   if Key = VK_RETURN then
   begin
-    if Action <> nil then
+    if DoingDeformation then
     begin
       ValidateDeformationGrid;
       result := EmptyRect;
@@ -1022,7 +1069,7 @@ begin
   end else
   if Key = VK_ESCAPE then
   begin
-    if Action <> nil then
+    if DoingDeformation then
     begin
       CancelActionPartially;
       result := OnlyRenderChange;

+ 6 - 0
lazpaint/tools/utoolvectorial.pas

@@ -1884,6 +1884,11 @@ begin
       end else
         result := false;
     end;
+  tcFinish: begin
+            r := ValidateShape;
+            Action.NotifyChange(toolDest, r);
+            result := true;
+          end;
   tcAlignLeft..tcAlignBottom:
       if ToolProvideCommand(ACommand) then
         AlignShape(FShape, ACommand,
@@ -1898,6 +1903,7 @@ function TVectorialTool.ToolProvideCommand(ACommand: TToolCommand): boolean;
 begin
   case ACommand of
   tcCopy,tcCut: Result:= not IsSelectingTool and not FQuickDefine and Assigned(FShape);
+  tcFinish: result := not IsIdle;
   tcShapeToSpline: result:= not IsSelectingTool and not FQuickDefine and Assigned(FShape)
                             and TCurveShape.CanCreateFrom(FShape);
   tcAlignLeft..tcAlignBottom: Result:= not FQuickDefine and Assigned(FShape);

+ 104 - 74
lazpaint/uclipboard.pas

@@ -1,10 +1,19 @@
 unit UClipboard;
 
 {$mode objfpc}{$H+}
-{ $DEFINE DEBUG_CLIPBOARD}
+{$IFDEF DEBUG}
+  {$DEFINE DEBUG_CLIPBOARD}
+{$ENDIF}
 
+{$DEFINE HTML_CLIPBOARD_FORMAT}
 {$IFDEF DARWIN}
   {$DEFINE TIFF_CLIPBOARD_FORMAT}
+{$ELSE}
+  {$DEFINE BMP_CLIPBOARD_FORMAT}
+  {$DEFINE PNG_CLIPBOARD_FORMAT}
+{$ENDIF}
+{$IFDEF WINDOWS}
+  {$DEFINE PDN_CLIPBOARD_FORMAT}
 {$ENDIF}
 
 interface
@@ -18,8 +27,10 @@ function ClipboardContainsBitmap: boolean;
 
 implementation
 
-uses Dialogs, BGRABitmapTypes, Clipbrd, Graphics, LCLIntf, LCLType,
-    BGRADNetDeserial, math, GraphType, fphttpclient, FPWriteBMP;
+uses Dialogs, BGRABitmapTypes, Clipbrd, Graphics, LCLIntf, LCLType, GraphType
+    {$IFDEF PDN_CLIPBOARD_FORMAT}, math, BGRADNetDeserial{$ENDIF}
+    {$IFDEF BMP_CLIPBOARD_FORMAT}, FPWriteBMP{$ENDIF}
+    {$IFDEF HTML_CLIPBOARD_FORMAT}, fphttpclient{$ENDIF};
 
 {$IFDEF DEBUG_CLIPBOARD}
 const
@@ -31,9 +42,13 @@ const
 var
   tiffClipboardFormat: TClipboardFormat;
 {$ENDIF}
-
+{$IFDEF PNG_CLIPBOARD_FORMAT}
+var
+  pngClipboardFormat: TClipboardFormat;
+{$ENDIF}
+{$IFDEF PDN_CLIPBOARD_FORMAT}
 var
-  bgraClipboardFormat: TClipboardFormat;
+  pdnClipboardFormat: TClipboardFormat;
 
 function GetBitmapFromPaintDotNetMaskedSurface(deserial: TDotNetDeserialization): TBGRABitmap;
 var width,height: integer;
@@ -121,6 +136,11 @@ begin
     end;
   end;
 end;
+{$ENDIF}
+
+{$IFDEF HTML_CLIPBOARD_FORMAT}
+var
+  htmlClipboardFormat: TClipboardFormat;
 
 function WideStringToStr(data: string): string;
 var
@@ -330,38 +350,31 @@ begin
   end;
   tagTokens.Free;
 end;
-
-function SafeClipboardFormatToMimeType(FormatID: TClipboardFormat): string;
-begin
-  try
-    result := ClipboardFormatToMimeType(FormatID);
-  except
-    on ex: Exception do
-      result := '';
-  end;
-end;
+{$ENDIF}
 
 function GetBitmapFromClipboard: TBGRABitmap;
 var i: integer;
     Stream: TMemoryStream;
+    data: string;
 
 {$IFDEF DEBUG_CLIPBOARD}
     j: integer;
     pcf: TPredefinedClipboardFormat;
-    str: string;
+    mime, str: string;
 
     c: char;
     prevCok: boolean;
 {$ENDIF}
 
+{$IFDEF PDN_CLIPBOARD_FORMAT}
     deserial: TDotNetDeserialization;
-    mime, data: string;
+{$ENDIF}
 
 begin
   result := nil;
 
   {$IFDEF DEBUG_CLIPBOARD}
-  str := '';
+  str := 'clipboard.FormatCount = '+inttostr(clipboard.FormatCount)+lineending;
   for i := 0 to clipboard.FormatCount-1 do
   begin
     if str <> '' then str += ', ';
@@ -408,15 +421,13 @@ begin
       str += ']'+lineending;
     end;
     stream.Free;
-
   end;
   ShowMessage(str);
   {$ENDIF}
 
+  {$IFDEF PDN_CLIPBOARD_FORMAT}
   for i := 0 to clipboard.FormatCount-1 do
-  begin
-    mime := SafeClipboardFormatToMimeType(Clipboard.Formats[i]);
-    if mime = 'PaintDotNet.MaskedSurface' then
+    if Clipboard.Formats[i] = pdnClipboardFormat then
     begin
        Stream := TMemoryStream.Create;
        Clipboard.GetFormat(Clipboard.Formats[i],Stream);
@@ -430,8 +441,55 @@ begin
        end;
        deserial.Free;
        if result <> nil then exit;
-    end else
-    if mime = 'text/html' then
+    end;
+  {$ENDIF}
+
+  {$IFDEF TIFF_CLIPBOARD_FORMAT}
+  for i := 0 to clipboard.FormatCount-1 do
+    if Clipboard.Formats[i] = tiffClipboardFormat then
+    begin
+      Stream := TMemoryStream.Create;
+      Clipboard.GetFormat(Clipboard.Formats[i],Stream);
+      Stream.Position := 0;
+      try
+        result := TBGRABitmap.Create;
+        result.LoadFromStream(Stream);
+        if result.Empty then result.AlphaFill(255);
+      except
+        on ex:exception do
+        begin
+          result := nil;
+        end;
+      end;
+      Stream.Free;
+      if result <> nil then exit;
+    end;
+  {$ENDIF}
+
+  {$IFDEF PNG_CLIPBOARD_FORMAT}
+  for i := 0 to clipboard.FormatCount-1 do
+    if Clipboard.Formats[i] = pngClipboardFormat then
+    begin
+      Stream := TMemoryStream.Create;
+      Clipboard.GetFormat(Clipboard.Formats[i],Stream);
+      Stream.Position := 0;
+      try
+        result := TBGRABitmap.Create;
+        result.LoadFromStream(Stream);
+        if result.Empty then result.AlphaFill(255);
+      except
+        on ex:exception do
+        begin
+          result := nil;
+        end;
+      end;
+      Stream.Free;
+      if result <> nil then exit;
+    end;
+  {$ENDIF}
+
+  for i := 0 to clipboard.FormatCount-1 do
+    if Clipboard.Formats[i] = htmlClipboardFormat then
     begin
        Stream := TMemoryStream.Create;
        Clipboard.GetFormat(Clipboard.Formats[i],Stream);
@@ -447,26 +505,6 @@ begin
        end;
        if result <> nil then exit;
     end;
-  end;
-
-  for i := 0 to clipboard.FormatCount-1 do
-    if Clipboard.Formats[i] = bgraClipboardFormat then
-    begin
-       Stream := TMemoryStream.Create;
-       Clipboard.GetFormat(Clipboard.Formats[i],Stream);
-       stream.Position := 0;
-       result := TBGRABitmap.Create;
-       try
-         result.Deserialize(Stream);
-       except
-         on ex:exception do
-         begin
-           FreeAndNil(result);
-         end;
-       end;
-       Stream.Free;
-       if result <> nil then exit;
-    end;
 
   for i := 0 to clipboard.FormatCount-1 do
     if (Clipboard.Formats[i] = PredefinedClipboardFormat(pcfBitmap)) then
@@ -486,28 +524,6 @@ begin
        Stream.Free;
        if result <> nil then exit;
     end;
-
-  {$IFDEF TIFF_CLIPBOARD_FORMAT}
-  for i := 0 to clipboard.FormatCount-1 do
-    if Clipboard.Formats[i] = tiffClipboardFormat then
-    begin
-      Stream := TMemoryStream.Create;
-      Clipboard.GetFormat(Clipboard.Formats[i],Stream);
-      Stream.Position := 0;
-      try
-        result := TBGRABitmap.Create;
-        result.LoadFromStream(Stream);
-        if result.Empty then result.AlphaFill(255);
-      except
-        on ex:exception do
-        begin
-          result := nil;
-        end;
-      end;
-      Stream.Free;
-      if result <> nil then exit;
-    end;
-  {$ENDIF}
 end;
 
 function ClipboardContainsBitmap: boolean;
@@ -522,10 +538,13 @@ end;
 procedure CopyToClipboard(bmp: TBGRABitmap);
 var
   stream: TMemoryStream;
+  {$IFDEF BMP_CLIPBOARD_FORMAT}
   bmpWriter: TFPWriterBMP;
+  {$ENDIF}
 begin
   Clipboard.Clear;
 
+  {$IFDEF BMP_CLIPBOARD_FORMAT}
   stream := TMemoryStream.Create;
   bmpWriter := TFPWriterBMP.Create;
   bmpWriter.BitsPerPixel := 32;
@@ -533,11 +552,7 @@ begin
   bmpWriter.Free;
   Clipboard.AddFormat(PredefinedClipboardFormat(pcfBitmap), stream);
   stream.Free;
-
-  stream := TMemoryStream.Create;
-  bmp.Serialize(stream);
-  Clipboard.AddFormat(bgraClipboardFormat, stream);
-  stream.Free;
+  {$ENDIF}
 
   {$IFDEF TIFF_CLIPBOARD_FORMAT}
   stream := TMemoryStream.Create;
@@ -545,15 +560,30 @@ begin
   Clipboard.AddFormat(tiffClipboardFormat, stream);
   stream.Free;
   {$ENDIF}
+
+  {$IFDEF PNG_CLIPBOARD_FORMAT}
+  stream := TMemoryStream.Create;
+  bmp.SaveToStreamAs(stream, ifPng);
+  Clipboard.AddFormat(pngClipboardFormat, stream);
+  stream.Free;
+  {$ENDIF}
 end;
 
 initialization
 
-  bgraClipboardFormat := RegisterClipboardFormat('TBGRABitmap');
-
 {$IFDEF TIFF_CLIPBOARD_FORMAT}
-  tiffClipboardFormat := RegisterClipboardFormat('image/tiff');
+  tiffClipboardFormat := RegisterClipboardFormat({$IFDEF DARWIN}'public.tiff'{$ELSE}'image/tiff'{$ENDIF});
+{$ENDIF}
+{$IFDEF PNG_CLIPBOARD_FORMAT}
+  pngClipboardFormat := RegisterClipboardFormat({$IFDEF DARWIN}'public.png'{$ELSE}{$IFDEF WINDOWS}'PNG'{$ELSE}'image/png'{$ENDIF}{$ENDIF});
 {$ENDIF}
+{$IFDEF HTML_CLIPBOARD_FORMAT}
+  htmlClipboardFormat := RegisterClipboardFormat({$IFDEF DARWIN}'public.html'{$ELSE}'text/html'{$ENDIF});
+{$ENDIF}
+{$IFDEF PDN_CLIPBOARD_FORMAT}
+  pdnClipboardFormat := RegisterClipboardFormat('PaintDotNet.MaskedSurface');
+{$ENDIF}
+
 
 end.
 

+ 7 - 0
lazpaint/uimageview.pas

@@ -49,6 +49,7 @@ type
     procedure PictureSelectionChanged({%H-}sender: TLazPaintImage; const ARect: TRect);
     procedure PaintVirtualScreenCursor({%H-}ACanvasOfs: TPoint; {%H-}AWorkArea: TRect; {%H-}AWinControlOfs: TPoint; {%H-}AWinControl: TWinControl);
     function GetRectToInvalidate(AInvalidateAll: boolean; AWorkArea: TRect): TRect;
+    function GetPictureCoordsDefined: boolean;
   public
     constructor Create(AInstance: TLazPaintCustomInstance; AZoom: TZoom; ACanvas: TCanvas);
     destructor Destroy; override;
@@ -71,6 +72,7 @@ type
     property FillSelectionHighlight: boolean read GetFillSelectionHighlight write SetFillSelectionHighlight;
     property ShowSelection: boolean read FShowSelection write SetShowSelection;
     property WorkspaceColor: TColor read GetWorkspaceColor;
+    property PictureCoordsDefined: boolean read GetPictureCoordsDefined;
   end;
 
 implementation
@@ -101,6 +103,11 @@ begin
   Image.ImageMayChangeCompletely;
 end;
 
+function TImageView.GetPictureCoordsDefined: boolean;
+begin
+  result := FLastPictureParameters.defined;
+end;
+
 function TImageView.GetImage: TLazPaintImage;
 begin
   result := FInstance.Image;