import com.intellij.ui.speedSearch.SpeedSearchUtil;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.containers.FList;
-import com.intellij.util.ui.EmptyIcon;
-import com.intellij.util.ui.GraphicsUtil;
-import com.intellij.util.ui.UIUtil;
+import com.intellij.util.ui.*;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
myLookup = lookup;
myNameComponent = new MySimpleColoredComponent();
- myNameComponent.setIpad(new Insets(0, 0, 0, 0));
+ myNameComponent.setIpad(JBUI.insetsLeft(2));
+ myNameComponent.setMyBorder(null);
myTailComponent = new MySimpleColoredComponent();
myTailComponent.setIpad(new Insets(0, 0, 0, 0));
final Color background = nonFocusedSelection ? SELECTED_NON_FOCUSED_BACKGROUND_COLOR :
isSelected ? SELECTED_BACKGROUND_COLOR : BACKGROUND_COLOR;
- int allowedWidth = list.getWidth() - AFTER_TAIL - AFTER_TYPE - getIconIndent();
+ int allowedWidth = list.getWidth() - AFTER_TAIL - AFTER_TYPE - getTextIndent();
FontMetrics normalMetrics = getRealFontMetrics(item, false);
FontMetrics boldMetrics = getRealFontMetrics(item, true);
return RealLookupElementPresentation.calculateWidth(p, getRealFontMetrics(item, false), getRealFontMetrics(item, true)) + AFTER_TAIL + AFTER_TYPE;
}
- public int getIconIndent() {
- return myNameComponent.getIconTextGap() + myEmptyIcon.getIconWidth();
+ public int getTextIndent() {
+ return myNameComponent.getIpad().left + myEmptyIcon.getIconWidth() + myNameComponent.getIconTextGap();
}
-
private static class MySimpleColoredComponent extends SimpleColoredComponent {
private MySimpleColoredComponent() {
setFocusBorderAroundIcon(true);
import com.intellij.util.ui.AbstractLayoutManager;
import com.intellij.util.ui.ButtonlessScrollBarUI;
import com.intellij.util.ui.JBUI;
+import com.intellij.util.ui.UIUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
// in layered pane coordinate system.
Rectangle calculatePosition() {
- Dimension dim = myLookup.getComponent().getPreferredSize();
+ final JComponent lookupComponent = myLookup.getComponent();
+ Dimension dim = lookupComponent.getPreferredSize();
int lookupStart = myLookup.getLookupStart();
Editor editor = myLookup.getEditor();
if (lookupStart < 0 || lookupStart > editor.getDocument().getTextLength()) {
LogicalPosition pos = editor.offsetToLogicalPosition(lookupStart);
Point location = editor.logicalPositionToXY(pos);
location.y += editor.getLineHeight();
- location.x -= myLookup.myCellRenderer.getIconIndent() + myLookup.getComponent().getInsets().left;
+ location.x -= myLookup.myCellRenderer.getTextIndent();
+ // extra check for other borders
+ final Window window = UIUtil.getWindow(lookupComponent);
+ if (window != null) {
+ final Point point = SwingUtilities.convertPoint(lookupComponent, 0, 0, window);
+ location.x -= point.x;
+ }
SwingUtilities.convertPointToScreen(location, editor.getContentComponent());
final Rectangle screenRectangle = ScreenUtil.getScreenRectangle(location);
setLayout(new AbstractLayoutManager() {
@Override
public Dimension preferredLayoutSize(@Nullable Container parent) {
- int maxCellWidth = myLookup.myLookupTextWidth + myLookup.myCellRenderer.getIconIndent();
+ int maxCellWidth = myLookup.myLookupTextWidth + myLookup.myCellRenderer.getTextIndent();
int scrollBarWidth = myScrollPane.getPreferredSize().width - myScrollPane.getViewport().getPreferredSize().width;
int listWidth = Math.min(scrollBarWidth + maxCellWidth, UISettings.getInstance().MAX_LOOKUP_WIDTH2);