Sit the info panel's link in the viewport's corner

It overlapped the scroll bar; the viewport is what the scroll bars have
already been taken out of. The layered pane also has to report a size now,
or the split pane above it has nothing to size the panel from.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
2026-08-20 08:11:29 +00:00
parent 5a00015824
commit 02533b543d

View File

@@ -16,7 +16,7 @@ import javax.swing.JScrollPane;
import java.awt.BorderLayout;
import java.awt.Cursor;
import java.awt.Dimension;
import java.awt.Insets;
import java.awt.Rectangle;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.io.File;
@@ -41,9 +41,6 @@ public final class InfoPanel extends JPanel {
void setPanelHidden(boolean hidden);
}
/** Gap between the floating link and the panel's edges. */
private static final int TOGGLE_MARGIN = 6;
private final JEditorPane pane = HtmlStyles.pane("font-family:sans-serif; font-size:11px;");
private final JScrollPane scroll = new JScrollPane(pane);
/** Floats over the bottom-right corner of the details, out of the text's way. */
@@ -83,10 +80,25 @@ public final class InfoPanel extends JPanel {
@Override
public void doLayout() {
scroll.setBounds(0, 0, getWidth(), getHeight());
Insets in = scroll.getInsets();
// Lay the scroll pane out first: the link goes in the corner of the
// viewport, which is where the scroll bars have already been taken out.
scroll.doLayout();
Rectangle view = scroll.getViewport().getBounds();
Dimension d = toggle.getPreferredSize();
toggle.setBounds(getWidth() - in.right - TOGGLE_MARGIN - d.width,
getHeight() - in.bottom - TOGGLE_MARGIN - d.height, d.width, d.height);
toggle.setBounds(view.x + view.width - d.width, view.y + view.height - d.height,
d.width, d.height);
}
// Without a layout manager we have no size of our own, and the split pane
// above us sizes the panel from it.
@Override
public Dimension getPreferredSize() {
return scroll.getPreferredSize();
}
@Override
public Dimension getMinimumSize() {
return scroll.getMinimumSize();
}
};
layers.add(scroll, JLayeredPane.DEFAULT_LAYER);