From 83334fd2acbefd787a44af28155019ec6bf95487 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jindra=20Pet=C5=99=C3=ADk?= Date: Fri, 28 Oct 2022 18:40:48 +0200 Subject: [PATCH] Fixed Freetransform tool dragging not always started on mousedown --- CHANGELOG.md | 1 + .../decompiler/flash/gui/ImagePanel.java | 55 ++++++++++++------- 2 files changed, 36 insertions(+), 20 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 93eb006b4..bf558e945 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,7 @@ All notable changes to this project will be documented in this file. - [#1828] Closing path in shape strokes from last moveTo only - 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 ### Changed - AS3 integer values are internally (e.g. in the lib) handled as java int type instead of long. diff --git a/src/com/jpexs/decompiler/flash/gui/ImagePanel.java b/src/com/jpexs/decompiler/flash/gui/ImagePanel.java index e9db598e4..d7408623f 100644 --- a/src/com/jpexs/decompiler/flash/gui/ImagePanel.java +++ b/src/com/jpexs/decompiler/flash/gui/ImagePanel.java @@ -366,6 +366,14 @@ public final class ImagePanel extends JPanel implements MediaDisplay { private Point dragStart = null; + private synchronized Point getDragStart() { + return dragStart; + } + + private synchronized void setDragStart(Point dragStart) { + this.dragStart = dragStart; + } + private synchronized SerializableImage getImg() { return _img; } @@ -463,7 +471,8 @@ public final class ImagePanel extends JPanel implements MediaDisplay { @Override public void mousePressed(MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON1) { - dragStart = e.getPoint(); + mouseMoved(e); //to correctly calculate mode, because moseMoved event is not called during dragging + setDragStart(e.getPoint()); } requestFocusInWindow(); } @@ -485,6 +494,10 @@ public final class ImagePanel extends JPanel implements MediaDisplay { } } + private void stopDragging() { + + } + @Override public void mouseDragged(MouseEvent e) { if (dragStart != null && allowMove && mode == Cursor.DEFAULT_CURSOR) { @@ -1017,68 +1030,70 @@ public final class ImagePanel extends JPanel implements MediaDisplay { boolean shearY = ey > bounds.getY() && ey < bounds.getY() + bounds.getHeight(); Cursor cursor; + int newMode; if (top && left) { - mode = Cursor.NW_RESIZE_CURSOR; + newMode = Cursor.NW_RESIZE_CURSOR; cursor = resizeNWSECursor; } else if (bottom && left) { - mode = Cursor.SW_RESIZE_CURSOR; + newMode = Cursor.SW_RESIZE_CURSOR; cursor = resizeSWNECursor; } else if (top && right) { - mode = Cursor.NE_RESIZE_CURSOR; + newMode = Cursor.NE_RESIZE_CURSOR; cursor = resizeSWNECursor; } else if (bottom && right) { - mode = Cursor.SE_RESIZE_CURSOR; + newMode = Cursor.SE_RESIZE_CURSOR; cursor = resizeNWSECursor; } else if (top && xcenter) { - mode = Cursor.N_RESIZE_CURSOR; + newMode = Cursor.N_RESIZE_CURSOR; cursor = resizeYCursor; } else if (bottom && xcenter) { - mode = Cursor.S_RESIZE_CURSOR; + newMode = Cursor.S_RESIZE_CURSOR; cursor = resizeYCursor; } else if (left && ycenter) { - mode = Cursor.W_RESIZE_CURSOR; + newMode = Cursor.W_RESIZE_CURSOR; cursor = resizeXCursor; } else if (right && ycenter) { - mode = Cursor.E_RESIZE_CURSOR; + newMode = Cursor.E_RESIZE_CURSOR; cursor = resizeXCursor; } else if (registration) { - mode = Cursor.HAND_CURSOR; + newMode = Cursor.HAND_CURSOR; cursor = moveRegPointCursor; } else if (!inBounds && rightRotate && topRotate) { - mode = MODE_ROTATE_NE; + newMode = MODE_ROTATE_NE; cursor = rotateCursor; } else if (!inBounds && rightRotate && bottomRotate) { - mode = MODE_ROTATE_SE; + newMode = MODE_ROTATE_SE; cursor = rotateCursor; } else if (!inBounds && leftRotate && topRotate) { - mode = MODE_ROTATE_NW; + newMode = MODE_ROTATE_NW; cursor = rotateCursor; } else if (!inBounds && leftRotate && bottomRotate) { - mode = MODE_ROTATE_SW; + newMode = MODE_ROTATE_SW; cursor = rotateCursor; } else if (shearY && (left || right)) { if (left) { - mode = MODE_SHEAR_W; + newMode = MODE_SHEAR_W; } else { - mode = MODE_SHEAR_E; + newMode = MODE_SHEAR_E; } cursor = shearYCursor; } else if (shearX && (top || bottom)) { if (top) { - mode = MODE_SHEAR_N; + newMode = MODE_SHEAR_N; } else { - mode = MODE_SHEAR_S; + newMode = MODE_SHEAR_S; } cursor = shearXCursor; } else if (inBounds) { - mode = Cursor.MOVE_CURSOR; + newMode = Cursor.MOVE_CURSOR; cursor = moveCursor; } else { - mode = Cursor.DEFAULT_CURSOR; + newMode = Cursor.DEFAULT_CURSOR; cursor = selectCursor; } setCursor(cursor); + mode = newMode; } }