Search in sources :

Example 76 with RelativePoint

use of com.intellij.ui.awt.RelativePoint in project android by JetBrains.

the class WidgetNavigatorPanel method createPopup.

public static JBPopup createPopup(DesignSurface surface) {
    WidgetNavigatorPanel navigatorPanel = new WidgetNavigatorPanel(surface);
    final Dimension minSize = new Dimension(navigatorPanel.getSize());
    JBPopup builder = JBPopupFactory.getInstance().createComponentPopupBuilder(navigatorPanel, navigatorPanel).setTitle(TITLE).setMinSize(minSize).setResizable(false).setMovable(true).setRequestFocus(true).setLocateWithinScreenBounds(true).setCancelButton(CANCEL_BUTTON).setShowBorder(true).setShowShadow(true).setCancelOnClickOutside(false).setCancelOnWindowDeactivation(false).setCancelOnOtherWindowOpen(true).addListener(navigatorPanel).createPopup();
    final int x = surface.getWidth() - PREFERRED_SIZE.width - surface.getScrollPane().getVerticalScrollBar().getWidth();
    final int y = NlConstants.RULER_SIZE_PX;
    RelativePoint position = new RelativePoint(surface, new Point(x, y));
    builder.show(position);
    return builder;
}
Also used : RelativePoint(com.intellij.ui.awt.RelativePoint) RelativePoint(com.intellij.ui.awt.RelativePoint) RelativePoint(com.intellij.ui.awt.RelativePoint)

Example 77 with RelativePoint

use of com.intellij.ui.awt.RelativePoint in project intellij-community by JetBrains.

the class TooltipController method showTooltipByMouseMove.

public void showTooltipByMouseMove(@NotNull final Editor editor, @NotNull final RelativePoint point, final TooltipRenderer tooltipObject, final boolean alignToRight, @NotNull final TooltipGroup group, @NotNull HintHint hintHint) {
    LightweightHint currentTooltip = myCurrentTooltip;
    if (currentTooltip == null || !currentTooltip.isVisible()) {
        if (currentTooltip != null) {
            if (!IdeTooltipManager.getInstance().isQueuedToShow(currentTooltip.getCurrentIdeTooltip())) {
                myCurrentTooltipObject = null;
            }
        } else {
            myCurrentTooltipObject = null;
        }
    }
    if (Comparing.equal(tooltipObject, myCurrentTooltipObject)) {
        IdeTooltipManager.getInstance().cancelAutoHide();
        return;
    }
    hideCurrentTooltip();
    if (tooltipObject != null) {
        final Point p = point.getPointOn(editor.getComponent().getRootPane().getLayeredPane()).getPoint();
        if (!hintHint.isAwtTooltip()) {
            p.x += alignToRight ? -10 : 10;
        }
        Project project = editor.getProject();
        if (project != null && !project.isOpen())
            return;
        if (editor.getContentComponent().isShowing()) {
            showTooltip(editor, p, tooltipObject, alignToRight, group, hintHint);
        }
    }
}
Also used : Project(com.intellij.openapi.project.Project) LightweightHint(com.intellij.ui.LightweightHint) RelativePoint(com.intellij.ui.awt.RelativePoint)

Example 78 with RelativePoint

use of com.intellij.ui.awt.RelativePoint in project intellij-community by JetBrains.

the class LightweightHint method fitsLayeredPane.

private static boolean fitsLayeredPane(JLayeredPane pane, JComponent component, RelativePoint desiredLocation, HintHint hintHint) {
    if (hintHint.isAwtTooltip()) {
        Dimension size = component.getPreferredSize();
        Dimension paneSize = pane.getSize();
        Point target = desiredLocation.getPointOn(pane).getPoint();
        Balloon.Position pos = hintHint.getPreferredPosition();
        int pointer = BalloonImpl.getPointerLength(pos, false) + BalloonImpl.getNormalInset();
        if (pos == Balloon.Position.above || pos == Balloon.Position.below) {
            boolean heightFit = target.y - size.height - pointer > 0 || target.y + size.height + pointer < paneSize.height;
            return heightFit && size.width + pointer < paneSize.width;
        } else {
            boolean widthFit = target.x - size.width - pointer > 0 || target.x + size.width + pointer < paneSize.width;
            return widthFit && size.height + pointer < paneSize.height;
        }
    } else {
        final Rectangle lpRect = new Rectangle(pane.getLocationOnScreen().x, pane.getLocationOnScreen().y, pane.getWidth(), pane.getHeight());
        Rectangle componentRect = new Rectangle(desiredLocation.getScreenPoint().x, desiredLocation.getScreenPoint().y, component.getPreferredSize().width, component.getPreferredSize().height);
        return lpRect.contains(componentRect);
    }
}
Also used : Balloon(com.intellij.openapi.ui.popup.Balloon) RelativePoint(com.intellij.ui.awt.RelativePoint) RelativePoint(com.intellij.ui.awt.RelativePoint)

Example 79 with RelativePoint

use of com.intellij.ui.awt.RelativePoint in project intellij-community by JetBrains.

the class BalloonImpl method isInside.

@Override
public boolean isInside(@NotNull RelativePoint target) {
    if (myComp == null)
        return false;
    Component cmp = target.getOriginalComponent();
    if (!cmp.isShowing())
        return true;
    if (cmp instanceof MenuElement)
        return false;
    if (myActionButtons != null) {
        for (ActionButton button : myActionButtons) {
            if (cmp == button)
                return true;
        }
    }
    if (UIUtil.isDescendingFrom(cmp, myComp))
        return true;
    if (myComp == null || !myComp.isShowing())
        return false;
    Point point = target.getScreenPoint();
    SwingUtilities.convertPointFromScreen(point, myComp);
    return myComp.contains(point);
}
Also used : RelativePoint(com.intellij.ui.awt.RelativePoint)

Example 80 with RelativePoint

use of com.intellij.ui.awt.RelativePoint in project intellij-community by JetBrains.

the class BalloonImpl method revalidate.

@Override
public void revalidate(@NotNull PositionTracker<Balloon> tracker) {
    RelativePoint newPosition = tracker.recalculateLocation(this);
    if (newPosition != null) {
        myTargetPoint = myPosition.getShiftedPoint(newPosition.getPoint(myLayeredPane), myCalloutShift);
        myPosition.updateBounds(this);
    }
}
Also used : RelativePoint(com.intellij.ui.awt.RelativePoint)

Aggregations

RelativePoint (com.intellij.ui.awt.RelativePoint)127 Project (com.intellij.openapi.project.Project)16 Balloon (com.intellij.openapi.ui.popup.Balloon)15 JBPopup (com.intellij.openapi.ui.popup.JBPopup)15 NotNull (org.jetbrains.annotations.NotNull)15 MouseEvent (java.awt.event.MouseEvent)12 Nullable (org.jetbrains.annotations.Nullable)10 Editor (com.intellij.openapi.editor.Editor)9 VirtualFile (com.intellij.openapi.vfs.VirtualFile)9 PsiElement (com.intellij.psi.PsiElement)8 JBList (com.intellij.ui.components.JBList)8 Disposable (com.intellij.openapi.Disposable)7 BalloonBuilder (com.intellij.openapi.ui.popup.BalloonBuilder)7 BaseListPopupStep (com.intellij.openapi.ui.popup.util.BaseListPopupStep)7 ArrayList (java.util.ArrayList)7 JBPopupFactory (com.intellij.openapi.ui.popup.JBPopupFactory)6 ListPopup (com.intellij.openapi.ui.popup.ListPopup)6 PsiFile (com.intellij.psi.PsiFile)5 HintHint (com.intellij.ui.HintHint)5 DumbAwareAction (com.intellij.openapi.project.DumbAwareAction)4