diff --git a/src/main/java/codechicken/lib/gui/modular/elements/GuiElement.java b/src/main/java/codechicken/lib/gui/modular/elements/GuiElement.java index 1282998c..a94c1909 100644 --- a/src/main/java/codechicken/lib/gui/modular/elements/GuiElement.java +++ b/src/main/java/codechicken/lib/gui/modular/elements/GuiElement.java @@ -134,6 +134,7 @@ protected void applyQueuedChildUpdates() { if (!addedQueue.isEmpty()) { childElements.addAll(addedQueue); + addedQueue.forEach(ConstrainedGeometry::clearGeometryCache); addedQueue.clear(); } } diff --git a/src/main/java/codechicken/lib/gui/modular/elements/GuiManipulable.java b/src/main/java/codechicken/lib/gui/modular/elements/GuiManipulable.java index 239ec6e5..336dacdc 100644 --- a/src/main/java/codechicken/lib/gui/modular/elements/GuiManipulable.java +++ b/src/main/java/codechicken/lib/gui/modular/elements/GuiManipulable.java @@ -86,7 +86,7 @@ public class GuiManipulable extends GuiElement implements Conten public GuiManipulable(@NotNull GuiParent parent) { super(parent); - this.contentElement = new GuiElement<>(this) + this.contentElement = new ContentElement(this) .constrain(LEFT, Constraint.dynamic(() -> (double) xMin)) .constrain(RIGHT, Constraint.dynamic(() -> (double) xMax)) .constrain(TOP, Constraint.dynamic(() -> (double) yMin)) @@ -335,34 +335,6 @@ public void startDragging() { dragPos = true; } - @Override - public boolean mouseClicked(double mouseX, double mouseY, int button) { - if (super.mouseClicked(mouseX, mouseY, button)) return true; - - boolean posFlag = moveHandle != null && moveHandle.isMouseOver(); - boolean topFlag = topHandle != null && topHandle.isMouseOver(); - boolean leftFlag = leftHandle != null && leftHandle.isMouseOver(); - boolean bottomFlag = bottomHandle != null && bottomHandle.isMouseOver(); - boolean rightFlag = rightHandle != null && rightHandle.isMouseOver(); - - if (posFlag || topFlag || leftFlag || bottomFlag || rightFlag) { - dragXOffset = (int) (mouseX - xMin); - dragYOffset = (int) (mouseY - yMin); - isDragging = true; - if (posFlag) { - dragPos = true; - } else { - dragTop = topFlag; - dragLeft = leftFlag; - dragBottom = bottomFlag; - dragRight = rightFlag; - } - return true; - } - - return false; - } - @Override public void mouseMoved(double mouseX, double mouseY) { if (isDragging) { @@ -454,4 +426,39 @@ public boolean isResizing() { public interface PositionRestraint { void restrainPosition(GuiManipulable draggable); } + + private class ContentElement extends GuiElement { + + public ContentElement(@NotNull GuiParent parent) { + super(parent); + } + + @Override + public boolean mouseClicked(double mouseX, double mouseY, int button) { + if (super.mouseClicked(mouseX, mouseY, button)) return true; + + boolean posFlag = moveHandle != null && moveHandle.isMouseOver(); + boolean topFlag = topHandle != null && topHandle.isMouseOver(); + boolean leftFlag = leftHandle != null && leftHandle.isMouseOver(); + boolean bottomFlag = bottomHandle != null && bottomHandle.isMouseOver(); + boolean rightFlag = rightHandle != null && rightHandle.isMouseOver(); + + if (posFlag || topFlag || leftFlag || bottomFlag || rightFlag) { + dragXOffset = (int) (mouseX - xMin); + dragYOffset = (int) (mouseY - yMin); + isDragging = true; + if (posFlag) { + dragPos = true; + } else { + dragTop = topFlag; + dragLeft = leftFlag; + dragBottom = bottomFlag; + dragRight = rightFlag; + } + return true; + } + + return false; + } + } }