From fe85b72348dc31119e1bb60cd21884bea7b10eee Mon Sep 17 00:00:00 2001 From: extio-de Date: Sat, 3 Oct 2026 19:21:32 +0200 Subject: [PATCH] fix(ScrollArea): synchronize renderingBoIds and add scroll position documentation --- .../renderer/container/ScrollArea.java | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/main/java/de/extio/game_engine/renderer/container/ScrollArea.java b/src/main/java/de/extio/game_engine/renderer/container/ScrollArea.java index 546692f..fb8be0c 100644 --- a/src/main/java/de/extio/game_engine/renderer/container/ScrollArea.java +++ b/src/main/java/de/extio/game_engine/renderer/container/ScrollArea.java @@ -1,5 +1,6 @@ package de.extio.game_engine.renderer.container; +import java.util.Collections; import java.util.HashSet; import java.util.Objects; import java.util.Set; @@ -38,15 +39,15 @@ public class ScrollArea implements WindowComponent { protected final MutableCoordI2 contentDimension = MutableCoordI2.create(); - protected final Set renderingBoIds = new HashSet<>(); + protected final Set renderingBoIds = Collections.synchronizedSet(new HashSet<>()); protected final Area2 relativeArea = new Area2(ImmutableCoordI2.zero(), ImmutableCoordI2.one()); protected Window parent; - protected double scrollPositionVertical = 1.0; + protected double scrollPositionVertical = 1.0; // 1.0 = top, 0.0 = bottom - protected double scrollPositionHorizontal = 0.0; + protected double scrollPositionHorizontal = 0.0; // 0.0 = left, 1.0 = right protected int verticalScrollInputRevision = 0; @@ -180,6 +181,11 @@ public class ScrollArea implements WindowComponent { this.parent.removeRenderingBo(renderingBoId); } + /** + * Returns the vertical scroll position of this scroll area. + * + * @return the vertical scroll position, where 1.0 is the top and 0.0 is the bottom + */ public double getScrollPositionVertical() { return this.scrollPositionVertical; } @@ -212,6 +218,11 @@ public class ScrollArea implements WindowComponent { this.draw(); } + /** + * Sets the vertical scroll position of this scroll area. + * + * @param scrollPositionVertical the vertical scroll position, where 1.0 is the top and 0.0 is the bottom + */ public void setScrollPositionVertical(final double scrollPositionVertical) { this.updateVerticalScrollPosition(scrollPositionVertical, false); this.draw();