diff --git a/CHANGELOG.md b/CHANGELOG.md index bf558e945..d507a88a8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,6 +25,8 @@ All notable changes to this project will be documented in this file. - Shape not clipped when clip area ouside of view - Sound tag player now uses less memory / threads - does not use Clip sound class - Freetransform tool dragging not always started on mousedown +- [#1695] Freetransform tool vs zooming +- [#1752] Freetransform tool on sprites with offset ### Changed - AS3 integer values are internally (e.g. in the lib) handled as java int type instead of long. @@ -2399,6 +2401,8 @@ All notable changes to this project will be documented in this file. [#1829]: https://www.free-decompiler.com/flash/issues/1829 [#1828]: https://www.free-decompiler.com/flash/issues/1828 [#1771]: https://www.free-decompiler.com/flash/issues/1771 +[#1695]: https://www.free-decompiler.com/flash/issues/1695 +[#1752]: https://www.free-decompiler.com/flash/issues/1752 [#270]: https://www.free-decompiler.com/flash/issues/270 [#1718]: https://www.free-decompiler.com/flash/issues/1718 [#1801]: https://www.free-decompiler.com/flash/issues/1801 diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineSpriteTag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineSpriteTag.java index cc028be23..1e5592807 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineSpriteTag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineSpriteTag.java @@ -158,6 +158,10 @@ public class DefineSpriteTag extends DrawableTag implements Timelined { @Override public void resetTimeline() { + Cache cache = swf == null ? null : swf.getRectCache(); + if (cache != null) { + cache.remove(this); + } if (timeline != null) { timeline.reset(swf, this, spriteId, getRect()); } diff --git a/src/com/jpexs/decompiler/flash/gui/ImagePanel.java b/src/com/jpexs/decompiler/flash/gui/ImagePanel.java index d7408623f..90cda522d 100644 --- a/src/com/jpexs/decompiler/flash/gui/ImagePanel.java +++ b/src/com/jpexs/decompiler/flash/gui/ImagePanel.java @@ -271,6 +271,7 @@ public final class ImagePanel extends JPanel implements MediaDisplay { m.scale(zoom); Matrix eMatrix = Matrix.getScaleInstance(1 / SWF.unitDivisor).concatenate(m).inverse(); + eMatrix.translate(_rect.x < 0 ? -_rect.x : 0, _rect.y < 0 ? -_rect.y : 0); return transform.preConcatenate(eMatrix).toMATRIX(); } @@ -549,12 +550,12 @@ public final class ImagePanel extends JPanel implements MediaDisplay { if (transform == null) { return; } - double zoomDouble = zoom.fit ? getZoomToFit() : zoom.value; - int ex = e.getX() - _rect.x - (int) (_viewRect.xMin * zoomDouble / SWF.unitDivisor); - int ey = e.getY() - _rect.y - (int) (_viewRect.yMin * zoomDouble / SWF.unitDivisor); - int dsx = dragStart.x - _rect.x - (int) (_viewRect.xMin * zoomDouble / SWF.unitDivisor); - int dsy = dragStart.y - _rect.y - (int) (_viewRect.yMin * zoomDouble / SWF.unitDivisor); + int ex = e.getX() - (_rect.x < 0 ? 0 : _rect.x); + int ey = e.getY() - (_rect.y < 0 ? 0 : _rect.y); + int dsx = dragStart.x - (_rect.x < 0 ? 0 : _rect.x); + int dsy = dragStart.y - (_rect.y < 0 ? 0 : _rect.y); + if (mode == MODE_SHEAR_N) { double shearX = -(ex - dsx) / (bounds.getHeight()); @@ -996,9 +997,8 @@ public final class ImagePanel extends JPanel implements MediaDisplay { return; } - double zoomDouble = zoom.fit ? getZoomToFit() : zoom.value; - int ex = e.getX() - _rect.x - (int) (_viewRect.xMin * zoomDouble / SWF.unitDivisor); - int ey = e.getY() - _rect.y - (int) (_viewRect.yMin * zoomDouble / SWF.unitDivisor); + int ex = e.getX() - (_rect.x < 0 ? 0 : _rect.x); + int ey = e.getY() - (_rect.y < 0 ? 0 : _rect.y); boolean left = ex >= bounds.getX() - TOLERANCE_SCALESHEAR && ex <= bounds.getX() + TOLERANCE_SCALESHEAR; boolean right = ex >= bounds.getX() + bounds.getWidth() - TOLERANCE_SCALESHEAR && ex <= bounds.getX() + bounds.getWidth() + TOLERANCE_SCALESHEAR; @@ -2112,8 +2112,7 @@ public final class ImagePanel extends JPanel implements MediaDisplay { this.prevFrame = this.frame; cursorPosition = this.cursorPosition; - if (cursorPosition - != null) { + if (cursorPosition != null) { cursorPosition = iconPanel.toImagePoint(cursorPosition); } diff --git a/src/com/jpexs/decompiler/flash/gui/PreviewPanel.java b/src/com/jpexs/decompiler/flash/gui/PreviewPanel.java index fc9509b99..d9bbbd07f 100644 --- a/src/com/jpexs/decompiler/flash/gui/PreviewPanel.java +++ b/src/com/jpexs/decompiler/flash/gui/PreviewPanel.java @@ -722,6 +722,7 @@ public class PreviewPanel extends JPersistentSplitPane implements TagEditorPanel placeEditButton.setEnabled(true); placeSaveButton.setVisible(false); placeCancelButton.setVisible(false); + placeFreeTransformButton.setVisible(true); } public void setImageReplaceButtonVisible(boolean show, boolean showAlpha) { @@ -742,7 +743,7 @@ public class PreviewPanel extends JPersistentSplitPane implements TagEditorPanel if (treeItem instanceof SWF) { SWF swf = (SWF) treeItem; - try (FileOutputStream fos = new FileOutputStream(extTempFile)) { + try ( FileOutputStream fos = new FileOutputStream(extTempFile)) { swf.saveTo(fos); } } else { @@ -765,7 +766,7 @@ public class PreviewPanel extends JPersistentSplitPane implements TagEditorPanel } SWFHeader header; - try (OutputStream fos = new BufferedOutputStream(new FileOutputStream(extTempFile))) { + try ( OutputStream fos = new BufferedOutputStream(new FileOutputStream(extTempFile))) { header = new PreviewExporter().exportSwf(fos, treeItem, backgroundColor, fontPageNum, true); } } @@ -803,7 +804,7 @@ public class PreviewPanel extends JPersistentSplitPane implements TagEditorPanel } SWFHeader header; - try (OutputStream fos = new BufferedOutputStream(new FileOutputStream(tempFile))) { + try ( OutputStream fos = new BufferedOutputStream(new FileOutputStream(tempFile))) { header = new PreviewExporter().exportSwf(fos, treeItem, backgroundColor, fontPageNum, false); } @@ -835,19 +836,19 @@ public class PreviewPanel extends JPersistentSplitPane implements TagEditorPanel } try { tempFile = File.createTempFile("ffdec_view_", ".swf"); - try (OutputStream fos = new BufferedOutputStream(new FileOutputStream(tempFile))) { + try ( OutputStream fos = new BufferedOutputStream(new FileOutputStream(tempFile))) { swf.saveTo(fos, false); } //Inject Loader if (swf.isAS3() && Configuration.autoOpenLoadedSWFs.get() && Configuration.useAdobeFlashPlayerForPreviews.get() && !DebuggerTools.hasDebugger(swf)) { SWF instrSWF; - try (InputStream fis = new BufferedInputStream(new FileInputStream(tempFile))) { + try ( InputStream fis = new BufferedInputStream(new FileInputStream(tempFile))) { instrSWF = new SWF(fis, false, false); } DebuggerTools.switchDebugger(instrSWF); DebuggerTools.injectDebugLoader(instrSWF); - try (OutputStream fos = new BufferedOutputStream(new FileOutputStream(tempFile))) { + try ( OutputStream fos = new BufferedOutputStream(new FileOutputStream(tempFile))) { instrSWF.saveTo(fos); } }