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;
}
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);
}
}
}
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);
}
}
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);
}
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);
}
}
Aggregations