From 186adf61300baa45a774f268ce61305d5029a382 Mon Sep 17 00:00:00 2001 From: Tomas Slusny Date: Mon, 7 May 2018 22:48:28 +0200 Subject: [PATCH] Restore min width when keeping window size small Restore minimum width after closing sidebar when keeping window size but window size was too small. Signed-off-by: Tomas Slusny --- .../runelite/client/ui/ContainableFrame.java | 28 ++++++++++--------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/ui/ContainableFrame.java b/runelite-client/src/main/java/net/runelite/client/ui/ContainableFrame.java index 0b73e7c4d0..f168baffa0 100644 --- a/runelite-client/src/main/java/net/runelite/client/ui/ContainableFrame.java +++ b/runelite-client/src/main/java/net/runelite/client/ui/ContainableFrame.java @@ -151,23 +151,25 @@ public class ContainableFrame extends JFrame } revalidateMinimumSize(); + final Rectangle screenBounds = getGraphicsConfiguration().getBounds(); + final boolean wasCloseToLeftEdge = Math.abs(getX() - screenBounds.getX()) <= SCREEN_EDGE_CLOSE_DISTANCE; + int newWindowX = getX(); + int newWindowWidth = getWidth() - value; - if (expandResizeType == ExpandResizeType.KEEP_GAME_SIZE) + if (isFrameCloseToRightEdge() && (expandedClientOppositeDirection || !wasCloseToLeftEdge)) { - final int newWindowWidth = getWidth() - value; - final Rectangle screenBounds = getGraphicsConfiguration().getBounds(); - final boolean wasCloseToLeftEdge = Math.abs(getX() - screenBounds.getX()) <= SCREEN_EDGE_CLOSE_DISTANCE; - int newWindowX = getX(); - - if (isFrameCloseToRightEdge() && (expandedClientOppositeDirection || !wasCloseToLeftEdge)) - { - // Keep the distance to the right edge - newWindowX += value; - } - - setBounds(newWindowX, getY(), newWindowWidth, getHeight()); + // Keep the distance to the right edge + newWindowX += value; } + if (expandResizeType == ExpandResizeType.KEEP_WINDOW_SIZE && newWindowWidth > getMinimumSize().width) + { + // The sidebar fits inside the window, do not resize and move + newWindowWidth = getWidth(); + newWindowX = getX(); + } + + setBounds(newWindowX, getY(), newWindowWidth, getHeight()); expandedClientOppositeDirection = false; }