image viewer: control + mousewheel = zoom
authorNiki Roo <niki@nikiroo.be>
Sun, 3 May 2020 22:55:32 +0000 (00:55 +0200)
committerNiki Roo <niki@nikiroo.be>
Sun, 3 May 2020 22:55:32 +0000 (00:55 +0200)
changelog-fr.md
changelog.md
src/be/nikiroo/fanfix_swing/gui/viewer/ViewerImages.java

index ebb651eb2f44541ba3e1789ed8e678de902d948c..df4cbaca5d32a2704a411b89459ba98777d11ba0 100644 (file)
@@ -2,6 +2,8 @@
 
 # Version WIP
 
+- new: l'afficheur d'images peut zoomer avec la molette de la souris et control
+
 # Version 1.1.1
 
 - fix: récupère maintenant correctement les hitsoires sans chaptitres
index 50b306a2556615f82cf8dfb66d1702ed802c9647..5694ba33463327d42f961689cde70da1dd0878e7 100644 (file)
@@ -2,6 +2,8 @@
 
 # Version WIP
 
+- new: ithe image viewer now zooms on mousewheel + control
+
 # Version 1.1.1
 
 - fix: now correctly retrieve stories without chapters
index be9ec05866b9d5665d1c04f006b0852c8386c0d5..0abd459a228d5814e6b2701f4512d1fbe1d94330 100644 (file)
@@ -12,6 +12,8 @@ import java.awt.event.KeyAdapter;
 import java.awt.event.KeyEvent;
 import java.awt.event.MouseAdapter;
 import java.awt.event.MouseEvent;
+import java.awt.event.MouseWheelEvent;
+import java.awt.event.MouseWheelListener;
 import java.awt.image.BufferedImage;
 import java.util.ArrayList;
 import java.util.List;
@@ -469,6 +471,21 @@ public class ViewerImages extends JFrame {
                                }
                        }
                });
+               final MouseWheelListener wheeling = scroll.getMouseWheelListeners()[0];
+               scroll.removeMouseWheelListener(wheeling);
+               area.addMouseWheelListener(new MouseAdapter() {
+                       @Override
+                       public void mouseWheelMoved(MouseWheelEvent e) {
+                               if (e.isControlDown()) {
+                                       double diff = -0.1 * e.getWheelRotation();
+                                       setZoom(currentZoom + diff, zoomSnapWidth);
+                                       e.consume();
+                               } else {
+                                       wheeling.mouseWheelMoved(e);
+                               }
+                               super.mouseWheelMoved(e);
+                       }
+               });
                final Point origin[] = new Point[1];
                area.addMouseListener(new MouseAdapter() {
                        @Override