RPTools / maptool

Virtual Tabletop for playing roleplaying games with remote players or face to face.

Home Page:http://rptools.net

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Feature]: Support trackpad gestures for zooming/panning

DanielHeath opened this issue · comments

Describe the Problem

In most software I use with my laptop, a two-finger swipe on the trackpad is used to pan/scroll, whereas a pinch gesture is used to zoom in / out.

However, in MapTool, a two-finger swipe zooms in / out, and a pinch gesture has no effect

The Solution you'd like

When using a trackpad with gesture support, use pinch for zoom & swipe to scroll.

Alternatives that you've considered.

No response

Additional Context

Is your feature request related to a problem? Please describe.

Describe the solution you'd like

Additional context

Currently, the 'pinch' gesture does nothing, while the 'scroll' gesture zooms in / out.

Java Swing does not natively do exciting touch gestures across the board, although apparently it will for MacOs.
JavaFX does, although according to this you need to embed your Swing bits inside a JavaFX Scene to catch the events.
Like this only something that works:

Stage primaryStage = new Stage();
JFrame jf = MapTool.getFrame();
JPanel swingContent = new JPanel();
swingContent.add(jf);

BorderPane content = new BorderPane();
SwingNode swingNode = new SwingNode();
swingNode.setContent(swingContent);
content.setCenter(swingNode);
Scene scene = new Scene(content);
scene.setOnTouchPressed(
    (e) -> {
      System.out.println(e);
    });
primaryStage.setScene(scene);
primaryStage.show();

All it needs is someone who is competent in JavaFX to see to the how.

Java Swing does not natively do exciting touch gestures across the board, although apparently it will for MacOs. JavaFX does, although according to this you need to embed your Swing bits inside a JavaFX Scene to catch the events. Like this only something that works:

This approach would not work as the map would still be a swing control and not get the JavaFX events. JavaFX is too slow for the map component, and even if you could somehow pass the JavaFX events on to the Swing map there is a significant loss of performance for swing controls rendered within JavaFX which would mean the rendering of the map suffers greatly.

Had a bit of a search for libraries to add multi-touch support to Swing. There are some simple libraries that cover basic gestures; (pinch, pan, rotate) and some more fully featured implementations. The TUIO specification has some Java libraries. Not sure if it is the canonical spec though.
Biggest issue I had was the age of the repos. Most haven't been touched in 10 years. This could be because they just work, or it could be everyone lost interest. Either way, it would take a proper coder to find one that would be easy to implement and stick it in.

I did some work for that before. See https://github.com/thelsing/maptool/tree/feature-multitouch I added a TUIO server and refactored the PointerTool class to support multitouch events.

I did some work for that before. See https://github.com/thelsing/maptool/tree/feature-multitouch I added a TUIO server and refactored the PointerTool class to support multitouch events.

Sounds like there is kudos for you in finishing it up and merging it :)