Skip to content

Commit

Permalink
Fix: Viewport zoom not working when hovering over a mask
Browse files Browse the repository at this point in the history
  • Loading branch information
SonarSonic committed Oct 21, 2024
1 parent 7c240bb commit 3e7ea16
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/main/java/drawingbot/render/viewport/ViewportSkin.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import drawingbot.javafx.FXController;
import drawingbot.javafx.util.JFXUtils;
import javafx.beans.binding.Bindings;
import javafx.event.Event;
import javafx.geometry.Point2D;
import javafx.scene.control.ScrollPane;
import javafx.scene.control.SkinBase;
Expand Down Expand Up @@ -61,6 +62,11 @@ public ViewportSkin(Viewport control) {
backgroundOverlays.getStylesheets().add(FXController.class.getResource(STYLESHEET_VIEWPORT_OVERLAYS).toExternalForm());
EasyBind.listBind(backgroundOverlays.getChildren(), getSkinnable().getBackgroundOverlayNodes());

backgroundOverlays.setOnScroll(e -> {
//HACK: Solid overlays will block passing the zoom event, so we send the event down if we didn't use it
Event.fireEvent(viewportScrollPane.getContent(), e.copyFor(e.getSource(), viewportScrollPane.getContent()));
e.consume();
});

Rectangle foregroundClip = new Rectangle(1, 1,0,0); //x/y of 1 to keep the ScrollPanes border
foregroundClip.widthProperty().bind(getSkinnable().viewportWidthProperty()); //14 = subtract the scrollbars
Expand All @@ -75,6 +81,11 @@ public ViewportSkin(Viewport control) {
foregroundOverlays.getStylesheets().add(FXController.class.getResource(STYLESHEET_VIEWPORT_OVERLAYS).toExternalForm());
EasyBind.listBind(foregroundOverlays.getChildren(), getSkinnable().getForegroundOverlayNodes());

foregroundOverlays.setOnScroll(e -> {
//HACK: Solid overlays will block passing the zoom event, so we send the event down if we didn't use it
Event.fireEvent(backgroundOverlays, e.copyFor(e.getSource(), backgroundOverlays));
e.consume();
});

//Wrap the viewport & overlay
viewport = new VBox();
Expand Down

0 comments on commit 3e7ea16

Please sign in to comment.