From 1f86a2b0165822c23d7040efdd443a7388cb01a9 Mon Sep 17 00:00:00 2001 From: Niki Roo Date: Mon, 4 May 2020 00:55:32 +0200 Subject: [PATCH] image viewer: control + mousewheel = zoom --- changelog-fr.md | 2 ++ changelog.md | 2 ++ .../fanfix_swing/gui/viewer/ViewerImages.java | 17 +++++++++++++++++ 3 files changed, 21 insertions(+) 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 -- 2.27.0