diff --git a/src/com/jpexs/decompiler/flash/gui/ImagePanel.java b/src/com/jpexs/decompiler/flash/gui/ImagePanel.java index e23f1702d..816cff5cc 100644 --- a/src/com/jpexs/decompiler/flash/gui/ImagePanel.java +++ b/src/com/jpexs/decompiler/flash/gui/ImagePanel.java @@ -19,6 +19,7 @@ package com.jpexs.decompiler.flash.gui; import com.jpexs.decompiler.flash.SWF; import com.jpexs.decompiler.flash.exporters.commonshape.Matrix; import com.jpexs.decompiler.flash.gui.player.MediaDisplay; +import com.jpexs.decompiler.flash.gui.player.Zoom; import com.jpexs.decompiler.flash.tags.DefineButtonSoundTag; import com.jpexs.decompiler.flash.tags.base.BoundedTag; import com.jpexs.decompiler.flash.tags.base.ButtonTag; @@ -85,7 +86,7 @@ public final class ImagePanel extends JPanel implements ActionListener, MediaDis private final IconPanel iconPanel; private int time = 0; private int selectedDepth = -1; - private double zoom = 1.0; + private Zoom zoom = new Zoom(); private final Object delayObject = new Object(); private boolean drawReady; private final int drawWaitLimit = 50; // ms @@ -413,7 +414,7 @@ public final class ImagePanel extends JPanel implements ActionListener, MediaDis } @Override - public synchronized void zoom(double zoom) { + public synchronized void zoom(Zoom zoom) { this.zoom = zoom; shouldDraw.set(true); } @@ -446,6 +447,11 @@ public final class ImagePanel extends JPanel implements ActionListener, MediaDis } else { w = w2; } + + if (w1 <= Double.MIN_NORMAL) { + return 1.0; + } + return (double) w / (double) w1; } @@ -653,7 +659,7 @@ public final class ImagePanel extends JPanel implements ActionListener, MediaDis DepthState stateUnderCursor; int mouseButton; int selectedDepth; - double zoom; + Zoom zoom; SWF swf; synchronized (ImagePanel.class) { @@ -681,11 +687,12 @@ public final class ImagePanel extends JPanel implements ActionListener, MediaDis return; } - getOutlines(timelined, frame, time, zoom, stateUnderCursor, mouseButton, counter); + double zoomDouble = zoom.fit ? getZoomToFit() : zoom.value; + getOutlines(timelined, frame, time, zoomDouble, stateUnderCursor, mouseButton, counter); Matrix mat = new Matrix(); mat.translateX = swf.displayRect.Xmin; mat.translateY = swf.displayRect.Ymin; - SerializableImage img = getFrame(swf, frame, time, timelined, stateUnderCursor, mouseButton, selectedDepth, zoom); + SerializableImage img = getFrame(swf, frame, time, timelined, stateUnderCursor, mouseButton, selectedDepth, zoomDouble); List sounds = new ArrayList<>(); List soundClasses = new ArrayList<>(); timeline.getSounds(frame, time, stateUnderCursor, mouseButton, sounds, soundClasses); @@ -868,7 +875,7 @@ public final class ImagePanel extends JPanel implements ActionListener, MediaDis } @Override - public synchronized double getZoom() { + public synchronized Zoom getZoom() { return zoom; } } diff --git a/src/com/jpexs/decompiler/flash/gui/SoundTagPlayer.java b/src/com/jpexs/decompiler/flash/gui/SoundTagPlayer.java index 974b777c8..885a30c0a 100644 --- a/src/com/jpexs/decompiler/flash/gui/SoundTagPlayer.java +++ b/src/com/jpexs/decompiler/flash/gui/SoundTagPlayer.java @@ -19,6 +19,7 @@ package com.jpexs.decompiler.flash.gui; import com.jpexs.decompiler.flash.SWF; import com.jpexs.decompiler.flash.SWFInputStream; import com.jpexs.decompiler.flash.gui.player.MediaDisplay; +import com.jpexs.decompiler.flash.gui.player.Zoom; import com.jpexs.decompiler.flash.tags.Tag; import com.jpexs.decompiler.flash.tags.base.SoundTag; import java.awt.Color; @@ -193,8 +194,7 @@ public class SoundTagPlayer implements MediaDisplay { } @Override - public void zoom(double zoom) { - + public void zoom(Zoom zoom) { } @Override @@ -208,8 +208,8 @@ public class SoundTagPlayer implements MediaDisplay { } @Override - public double getZoom() { - return 0; + public Zoom getZoom() { + return null; } @Override diff --git a/src/com/jpexs/decompiler/flash/gui/locales/MainFrame.properties b/src/com/jpexs/decompiler/flash/gui/locales/MainFrame.properties index d1d7e1f34..9eb845014 100644 --- a/src/com/jpexs/decompiler/flash/gui/locales/MainFrame.properties +++ b/src/com/jpexs/decompiler/flash/gui/locales/MainFrame.properties @@ -541,3 +541,4 @@ error.text.invalid.continue = Invalid text: %text% on line %line%. Do you want t #after version 4.0.5 contextmenu.copyTag = Copy tag to +fit = fit diff --git a/src/com/jpexs/decompiler/flash/gui/locales/MainFrame_hu.properties b/src/com/jpexs/decompiler/flash/gui/locales/MainFrame_hu.properties index e691cddb1..6856e224c 100644 --- a/src/com/jpexs/decompiler/flash/gui/locales/MainFrame_hu.properties +++ b/src/com/jpexs/decompiler/flash/gui/locales/MainFrame_hu.properties @@ -541,3 +541,4 @@ error.text.invalid.continue = Hib\u00e1s sz\u00f6veg: %text% a %line%. sorban. F #after version 4.0.5 contextmenu.copyTag = M\u00e1sol\u00e1s ide +fit = kit\u00f6lt diff --git a/src/com/jpexs/decompiler/flash/gui/player/FlashPlayerPanel.java b/src/com/jpexs/decompiler/flash/gui/player/FlashPlayerPanel.java index c0baefd7f..6ba1a66d0 100644 --- a/src/com/jpexs/decompiler/flash/gui/player/FlashPlayerPanel.java +++ b/src/com/jpexs/decompiler/flash/gui/player/FlashPlayerPanel.java @@ -65,15 +65,16 @@ public class FlashPlayerPanel extends Panel implements Closeable, MediaDisplay { } @Override - public double getZoom() { - return 0; + public Zoom getZoom() { + return null; } private double zoom = 1.0; @Override - public synchronized void zoom(double zoom) { - int zoomint = (int) Math.round(100 / (zoom / this.zoom)); + public synchronized void zoom(Zoom zoom) { + double zoomDouble = zoom.fit ? getZoomToFit() : zoom.value; + int zoomint = (int) Math.round(100 / (zoomDouble / this.zoom)); if (zoomint == 0) { zoomint = 1; } diff --git a/src/com/jpexs/decompiler/flash/gui/player/MediaDisplay.java b/src/com/jpexs/decompiler/flash/gui/player/MediaDisplay.java index 70688ca3b..21bc5f83b 100644 --- a/src/com/jpexs/decompiler/flash/gui/player/MediaDisplay.java +++ b/src/com/jpexs/decompiler/flash/gui/player/MediaDisplay.java @@ -29,7 +29,7 @@ public interface MediaDisplay { public int getTotalFrames(); - public void zoom(double zoom); + public void zoom(Zoom zoom); public void pause(); @@ -55,5 +55,5 @@ public interface MediaDisplay { public double getZoomToFit(); - public double getZoom(); + public Zoom getZoom(); } diff --git a/src/com/jpexs/decompiler/flash/gui/player/PlayerControls.java b/src/com/jpexs/decompiler/flash/gui/player/PlayerControls.java index 51531a022..fdfa7bcfa 100644 --- a/src/com/jpexs/decompiler/flash/gui/player/PlayerControls.java +++ b/src/com/jpexs/decompiler/flash/gui/player/PlayerControls.java @@ -95,6 +95,7 @@ public class PlayerControls extends JPanel implements ActionListener { private final JPanel graphicControls; private final JPanel playbackControls; private final JPanel frameControls; + private boolean zoomToFit = false; private double realZoom = 1.0; private final JButton zoomFitButton; @@ -324,9 +325,10 @@ public class PlayerControls extends JPanel implements ActionListener { View.execInEventDispatch(new Runnable() { @Override public void run() { - double zoom = display.getZoom(); - zoomFitButton.setVisible(zoom != 0.0); - percentLabel.setVisible(zoom != 0.0); + updateZoom(); + Zoom zoom = display.getZoom(); + zoomFitButton.setVisible(zoom != null); + percentLabel.setVisible(zoom != null); zoomPanel.setVisible(display.zoomAvailable()); graphicControls.setVisible(display.screenAvailable()); totalFrameLabel.setVisible(display.screenAvailable()); @@ -385,14 +387,25 @@ public class PlayerControls extends JPanel implements ActionListener { } private void updateZoom() { - double pctzoom = roundZoom(realZoom * 100, 3); + double pctzoom = roundZoom(getRealZoom() * 100, 3); String r = Double.toString(pctzoom); double zoom = pctzoom / 100.0; if (r.endsWith(".0")) { r = r.substring(0, r.length() - 2); } - percentLabel.setText(r + "%"); - display.zoom(zoom); + + r += "%"; + + if (zoomToFit) { + percentLabel.setText(AppStrings.translate("fit") + " (" + r + ")"); + } else { + percentLabel.setText(r); + } + + Zoom zoomObj = new Zoom(); + zoomObj.value = zoom; + zoomObj.fit = zoomToFit; + display.zoom(zoomObj); } @Override @@ -476,19 +489,23 @@ public class PlayerControls extends JPanel implements ActionListener { }); break; case ACTION_ZOOMIN: - realZoom *= ZOOM_MULTIPLIER; + realZoom = getRealZoom() * ZOOM_MULTIPLIER; + zoomToFit = false; updateZoom(); break; case ACTION_ZOOMOUT: - realZoom /= ZOOM_MULTIPLIER; + realZoom = getRealZoom() / ZOOM_MULTIPLIER; + zoomToFit = false; updateZoom(); break; case ACTION_ZOOMNONE: realZoom = 1.0; + zoomToFit = false; updateZoom(); break; case ACTION_ZOOMFIT: - realZoom = display.getZoomToFit(); + realZoom = 1.0; + zoomToFit = true; updateZoom(); break; case ACTION_SNAPSHOT: @@ -497,6 +514,14 @@ public class PlayerControls extends JPanel implements ActionListener { } } + private double getRealZoom() { + if (zoomToFit) { + return display.getZoomToFit(); + } + + return realZoom; + } + private class TransferableImage implements Transferable { Image img; diff --git a/src/com/jpexs/decompiler/flash/gui/player/Zoom.java b/src/com/jpexs/decompiler/flash/gui/player/Zoom.java new file mode 100644 index 000000000..6c5341f55 --- /dev/null +++ b/src/com/jpexs/decompiler/flash/gui/player/Zoom.java @@ -0,0 +1,32 @@ +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.gui.player; + +/** + * + * @author JPEXS + */ +public class Zoom { + + public double value = 1.0; + + public boolean fit = false; + + public Zoom() { + } + +}