From: Ben Soares Date: Thu, 1 Feb 2024 12:26:48 +0000 (+0000) Subject: JAL-4375 Improved trackpad user experience for wrapped format, with vertical scrollin... X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=ad0b88e1b80d4b6b6dcb3448ec98e62aa0109149;p=jalview.git JAL-4375 Improved trackpad user experience for wrapped format, with vertical scrolling thresholds for mousewheel/tackpad rotation and time-since-last-left-right-rotation reducing accidental up/down scrolls whilst using trackpad to scroll left/right. Thresholds can be adjusted in properties file. --- diff --git a/src/jalview/gui/SeqPanel.java b/src/jalview/gui/SeqPanel.java index ff69d61..423658d 100644 --- a/src/jalview/gui/SeqPanel.java +++ b/src/jalview/gui/SeqPanel.java @@ -44,6 +44,7 @@ import javax.swing.Timer; import javax.swing.ToolTipManager; import jalview.api.AlignViewportI; +import jalview.bin.Cache; import jalview.bin.Console; import jalview.commands.EditCommand; import jalview.commands.EditCommand.Action; @@ -162,6 +163,41 @@ public class SeqPanel extends JPanel } } + /** + * Rotation threshold for up/down trackpad/wheelmouse movement to register for + * an alignment in wrapped format. Up/down scrolling here results in a large + * jump so a larger threshold is appropriate, and reduces unintended up/down + * jumps when panning left/right. Should be at least 0.1 and less than 1.0 + * since some platforms only send a value of 1.0. + */ + private static double wrappedVerticalScrollRotationThreshold; + + /** + * Property name if user needs to change rotation threshold + */ + private static String WRAPPEDVERTICALSCROLLROTATIONTHRESHOLDPC = "WRAPPEDVERTICALSCROLLROTATIONTHRESHOLDPC"; + + /** + * Time threshold since last left/right trackpad/wheelmouse scroll for up/down + * trackpad/wheelmouse movement to register for an alignment in wrapped + * format. This reduces unintended up/down jumps when panning left/right. In + * ms. + */ + private static int wrappedVerticalScrollChangeTimeThreshold; + + /** + * Property name if user needs to change rotation threshold + */ + private static String WRAPPEDVERTICALSCROLLCHANGETIMETHRESHOLD = "WRAPPEDVERTICALSCROLLCHANGETIMETHRESHOLD "; + + static + { + wrappedVerticalScrollRotationThreshold = Cache.getDefault( + WRAPPEDVERTICALSCROLLROTATIONTHRESHOLDPC, 50) / 100.0; + wrappedVerticalScrollChangeTimeThreshold = Cache + .getDefault(WRAPPEDVERTICALSCROLLCHANGETIMETHRESHOLD, 200); + } + private static final int MAX_TOOLTIP_LENGTH = 300; public SeqCanvas seqCanvas; @@ -2222,6 +2258,11 @@ public class SeqPanel extends JPanel } /** + * recorded time of last left/right mousewheel/trackpad scroll in wrapped mode + */ + private long lastLeftRightWrappedScrollTime = 0; + + /** * Responds to a mouse wheel movement by scrolling the alignment *