From a0aa55ae52815d7cb2777d6c2fa9cbeae3fbea43 Mon Sep 17 00:00:00 2001 From: Axel Howind Date: Sun, 5 Jan 2025 11:35:43 +0100 Subject: [PATCH] add scrollTo() overloads --- .../java/com/dua3/utility/fx/controls/PinBoard.java | 13 +++++++++++++ .../com/dua3/utility/fx/controls/PinBoardSkin.java | 13 +++++++++++++ 2 files changed, 26 insertions(+) diff --git a/utility-fx-controls/src/main/java/com/dua3/utility/fx/controls/PinBoard.java b/utility-fx-controls/src/main/java/com/dua3/utility/fx/controls/PinBoard.java index 42a2d8ef..3c57f1f9 100644 --- a/utility-fx-controls/src/main/java/com/dua3/utility/fx/controls/PinBoard.java +++ b/utility-fx-controls/src/main/java/com/dua3/utility/fx/controls/PinBoard.java @@ -231,6 +231,19 @@ public void scrollTo(PositionInItem pos) { } } + /** + * Scrolls the PinBoard to the specified position within an item. + * + * @param pos the position within an item to scroll to + * @param relativeXinVP the relative position inside the viewport, a value between 0 and 1, i.e., 0 left, 1 right + * @param relativeYinVP the relative position inside the viewport, a value between 0 and 1, i.e., 0 top, 1 bottom + */ + public void scrollTo(PositionInItem pos, double relativeXinVP, double relativeYinVP) { + if (getSkin() instanceof PinBoardSkin skin) { + skin.scrollTo(pos, relativeXinVP, relativeYinVP); + } + } + /** * Scrolls the PinBoard the specified position into view. * diff --git a/utility-fx-controls/src/main/java/com/dua3/utility/fx/controls/PinBoardSkin.java b/utility-fx-controls/src/main/java/com/dua3/utility/fx/controls/PinBoardSkin.java index 35c45bfa..cb562e53 100644 --- a/utility-fx-controls/src/main/java/com/dua3/utility/fx/controls/PinBoardSkin.java +++ b/utility-fx-controls/src/main/java/com/dua3/utility/fx/controls/PinBoardSkin.java @@ -217,6 +217,19 @@ public void scrollTo(PinBoard.PositionInItem pos) { scrollTo(toBoardPosition(pos)); } + /** + * Scrolls the PinBoard to the position specified by {@link PinBoard.PositionInItem}. + * + * @param pos the position within an item on the PinBoard. This includes the item information + * and its coordinates, relative to its area on the board. + * @param relativeXinVP the relative position inside the viewport, a value between 0 and 1, i.e., 0 left, 1 right + * @param relativeYinVP the relative position inside the viewport, a value between 0 and 1, i.e., 0 top, 1 bottom + */ + public void scrollTo(PinBoard.PositionInItem pos, double relativeXinVP, double relativeYinVP) { + PinBoard.BoardPosition bp = toBoardPosition(pos); + scrollTo(bp.x(), bp.y(), relativeXinVP, relativeYinVP); + } + /** * Scrolls the specified position relative to an item into the visible area of the PinBoard. * The method internally converts the given position to a board position and scrolls it into view.