From 94ff26f3d82eb4ef60ef7bc53f0bf1b2fb3f45ef Mon Sep 17 00:00:00 2001 From: Adam Date: Tue, 11 Feb 2020 18:36:39 -0500 Subject: [PATCH] widgetitemoverlay: clip dragged items when outside of parent bounds Since dragged items are not moved until after the drag is complete, the item still gets queued to be drawn, even if dragged outside of the parent layer. --- .../client/ui/overlay/WidgetItemOverlay.java | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/ui/overlay/WidgetItemOverlay.java b/runelite-client/src/main/java/net/runelite/client/ui/overlay/WidgetItemOverlay.java index c234a0d4dd..b351dcf808 100644 --- a/runelite-client/src/main/java/net/runelite/client/ui/overlay/WidgetItemOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/ui/overlay/WidgetItemOverlay.java @@ -89,12 +89,26 @@ public abstract class WidgetItemOverlay extends Overlay Widget parent = widget.getParent(); Rectangle parentBounds = parent.getBounds(); Rectangle itemCanvasBounds = widgetItem.getCanvasBounds(); + boolean dragging = widgetItem.getDraggingCanvasBounds() != null; boolean shouldClip; - shouldClip = itemCanvasBounds.y < parentBounds.y && itemCanvasBounds.y + itemCanvasBounds.height >= parentBounds.y; - shouldClip |= itemCanvasBounds.y < parentBounds.y + parentBounds.height && itemCanvasBounds.y + itemCanvasBounds.height >= parentBounds.y + parentBounds.height; - shouldClip |= itemCanvasBounds.x < parentBounds.x && (itemCanvasBounds.x + itemCanvasBounds.width) >= parentBounds.x; - shouldClip |= itemCanvasBounds.x < parentBounds.x + parentBounds.width && itemCanvasBounds.x + itemCanvasBounds.width >= parentBounds.x + parentBounds.width; + if (dragging) + { + // If dragging, clip if the dragged item is outside of the parent bounds + shouldClip = itemCanvasBounds.x < parentBounds.x; + shouldClip |= itemCanvasBounds.x + itemCanvasBounds.width >= parentBounds.x + parentBounds.width; + shouldClip |= itemCanvasBounds.y < parentBounds.y; + shouldClip |= itemCanvasBounds.y + itemCanvasBounds.height >= parentBounds.y + parentBounds.height; + } + else + { + // Otherwise, we only need to clip the overlay if it intersects the parent bounds, + // since items completely outside of the parent bounds are not drawn + shouldClip = itemCanvasBounds.y < parentBounds.y && itemCanvasBounds.y + itemCanvasBounds.height >= parentBounds.y; + shouldClip |= itemCanvasBounds.y < parentBounds.y + parentBounds.height && itemCanvasBounds.y + itemCanvasBounds.height >= parentBounds.y + parentBounds.height; + shouldClip |= itemCanvasBounds.x < parentBounds.x && itemCanvasBounds.x + itemCanvasBounds.width >= parentBounds.x; + shouldClip |= itemCanvasBounds.x < parentBounds.x + parentBounds.width && itemCanvasBounds.x + itemCanvasBounds.width >= parentBounds.x + parentBounds.width; + } if (shouldClip) { if (curClipParent != parent)