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 <slusnucky@gmail.com>
This commit is contained in:
@@ -151,23 +151,25 @@ public class ContainableFrame extends JFrame
|
|||||||
}
|
}
|
||||||
|
|
||||||
revalidateMinimumSize();
|
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;
|
// Keep the distance to the right edge
|
||||||
final Rectangle screenBounds = getGraphicsConfiguration().getBounds();
|
newWindowX += value;
|
||||||
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());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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;
|
expandedClientOppositeDirection = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user