diff options
| author | Moulberry <james.jenour@student.scotch.wa.edu.au> | 2020-07-17 05:57:11 +0800 |
|---|---|---|
| committer | Moulberry <james.jenour@student.scotch.wa.edu.au> | 2020-07-17 05:57:11 +0800 |
| commit | f7d3491def0f7498d7bf0d547445f75f0c515912 (patch) | |
| tree | 7aa7cea0da7cdca2fdea55fffcbf746d22734b1c /src/main/java/io/github/moulberry/notenoughupdates/mbgui/MBGuiGroupFloating.java | |
| parent | f90f0b2f1f234d08742a4f0dd8afcd4b80e26d05 (diff) | |
| download | notenoughupdates-f7d3491def0f7498d7bf0d547445f75f0c515912.tar.gz notenoughupdates-f7d3491def0f7498d7bf0d547445f75f0c515912.tar.bz2 notenoughupdates-f7d3491def0f7498d7bf0d547445f75f0c515912.zip | |
REL-1.0.0
Diffstat (limited to 'src/main/java/io/github/moulberry/notenoughupdates/mbgui/MBGuiGroupFloating.java')
| -rw-r--r-- | src/main/java/io/github/moulberry/notenoughupdates/mbgui/MBGuiGroupFloating.java | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/mbgui/MBGuiGroupFloating.java b/src/main/java/io/github/moulberry/notenoughupdates/mbgui/MBGuiGroupFloating.java new file mode 100644 index 00000000..91cca2d7 --- /dev/null +++ b/src/main/java/io/github/moulberry/notenoughupdates/mbgui/MBGuiGroupFloating.java @@ -0,0 +1,42 @@ +package io.github.moulberry.notenoughupdates.mbgui; + +import org.lwjgl.util.vector.Vector2f; + +import java.util.*; + +public class MBGuiGroupFloating extends MBGuiGroup { + + private LinkedHashMap<MBGuiElement, MBAnchorPoint> children; + + public MBGuiGroupFloating(int width, int height, LinkedHashMap<MBGuiElement, MBAnchorPoint> children) { + this.width = width; + this.height = height; + this.children = children; + recalculate(); + } + + public Map<MBGuiElement, MBAnchorPoint> getChildrenMap() { + return Collections.unmodifiableMap(children); + } + + @Override + public void recalculate() { + for(MBGuiElement child : children.keySet()) { + child.recalculate(); + } + + for(Map.Entry<MBGuiElement, MBAnchorPoint> entry : children.entrySet()) { + MBGuiElement child = entry.getKey(); + MBAnchorPoint anchorPoint = entry.getValue(); + float x = anchorPoint.anchorPoint.x * width - anchorPoint.anchorPoint.x * child.getWidth() + anchorPoint.offset.x; + float y = anchorPoint.anchorPoint.y * height - anchorPoint.anchorPoint.y * child.getHeight() + anchorPoint.offset.y; + childrenPosition.put(child, new Vector2f(x, y)); + } + } + + @Override + public Collection<MBGuiElement> getChildren() { + return children.keySet(); + } + +} |
