From 77694d65bccf7a2333a7fbdfc911ba61f9d8ae33 Mon Sep 17 00:00:00 2001 From: Adam Date: Fri, 7 Feb 2020 10:36:28 -0500 Subject: [PATCH] api: add both normal and dragging bounds to widgetitem --- .../net/runelite/api/widgets/WidgetItem.java | 30 ++++++++++++++++--- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/runelite-api/src/main/java/net/runelite/api/widgets/WidgetItem.java b/runelite-api/src/main/java/net/runelite/api/widgets/WidgetItem.java index 1d868e62b6..ccf89812b5 100644 --- a/runelite-api/src/main/java/net/runelite/api/widgets/WidgetItem.java +++ b/runelite-api/src/main/java/net/runelite/api/widgets/WidgetItem.java @@ -25,6 +25,7 @@ package net.runelite.api.widgets; import java.awt.Rectangle; +import javax.annotation.Nullable; import lombok.AllArgsConstructor; import lombok.Getter; import lombok.ToString; @@ -64,19 +65,40 @@ public class WidgetItem */ private final Widget widget; /** - * Whether or not this widget item is being dragged. + * The canvas bounds for the widget, if it is being dragged. */ - private final boolean dragging; + @Nullable + private final Rectangle draggingCanvasBounds; + + /** + * Get the area where the widget item is drawn on the canvas, accounting for drag + * @return + */ + public Rectangle getCanvasBounds() + { + return draggingCanvasBounds == null ? canvasBounds : draggingCanvasBounds; + } + + /** + * Get the area where the widget item is drawn on the canvas + * @param dragging whether the returned area should account for widget drag + * @return + */ + public Rectangle getCanvasBounds(boolean dragging) + { + return dragging ? draggingCanvasBounds : canvasBounds; + } /** * Gets the upper-left coordinate of where the widget is being drawn - * on the canvas. + * on the canvas, accounting for drag. * * @return the upper-left coordinate of where this widget is drawn */ public Point getCanvasLocation() { - return new Point((int) canvasBounds.getX(), (int) canvasBounds.getY()); + Rectangle bounds = getCanvasBounds(); + return new Point((int) bounds.getX(), (int) bounds.getY()); } }