From: Niki Roo Date: Sun, 3 May 2020 22:55:32 +0000 (+0200) Subject: image viewer: control + mousewheel = zoom X-Git-Tag: fanfix-swing-1.2.0~41 X-Git-Url: https://git.nikiroo.be/?a=commitdiff_plain;h=1f86a2b0165822c23d7040efdd443a7388cb01a9;p=fanfix-swing.git image viewer: control + mousewheel = zoom --- diff --git a/changelog-fr.md b/changelog-fr.md index ebb651eb..df4cbaca 100644 --- a/changelog-fr.md +++ b/changelog-fr.md @@ -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 diff --git a/changelog.md b/changelog.md index 50b306a2..5694ba33 100644 --- a/changelog.md +++ b/changelog.md @@ -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 diff --git a/src/be/nikiroo/fanfix_swing/gui/viewer/ViewerImages.java b/src/be/nikiroo/fanfix_swing/gui/viewer/ViewerImages.java index be9ec058..0abd459a 100644 --- a/src/be/nikiroo/fanfix_swing/gui/viewer/ViewerImages.java +++ b/src/be/nikiroo/fanfix_swing/gui/viewer/ViewerImages.java @@ -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