mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-89555 Autopositioning quick documentation popup if there are not anough free space at bottom of IDE
This commit is contained in:
@@ -485,10 +485,30 @@ public class AbstractPopup implements JBPopup {
|
||||
show(relativePointWithDominantRectangle(layeredPane, dominantArea));
|
||||
}
|
||||
else {
|
||||
show(JBPopupFactory.getInstance().guessBestPopupLocation(editor));
|
||||
show(guessBestPopupLocation(editor));
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private RelativePoint guessBestPopupLocation(@NotNull Editor editor) {
|
||||
RelativePoint preferredLocation = JBPopupFactory.getInstance().guessBestPopupLocation(editor);
|
||||
if (myDimensionServiceKey == null) {
|
||||
return preferredLocation;
|
||||
}
|
||||
Dimension preferredSize = DimensionService.getInstance().getSize(myDimensionServiceKey, myProject);
|
||||
if (preferredSize == null) {
|
||||
return preferredLocation;
|
||||
}
|
||||
Rectangle preferredBounds = new Rectangle(preferredLocation.getScreenPoint(), preferredSize);
|
||||
Rectangle adjustedBounds = new Rectangle(preferredBounds);
|
||||
ScreenUtil.moveRectangleToFitTheScreen(adjustedBounds);
|
||||
if (preferredBounds.y - adjustedBounds.y <= 0) {
|
||||
return preferredLocation;
|
||||
}
|
||||
int adjustedY = preferredBounds.y - (editor.getLineHeight() * 3 / 2) - preferredSize.height;
|
||||
return adjustedY >= 0 ? RelativePoint.fromScreen(new Point(preferredBounds.x, adjustedY)) : preferredLocation;
|
||||
}
|
||||
|
||||
public void addPopupListener(JBPopupListener listener) {
|
||||
myListeners.add(listener);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user