use of org.rstudio.core.client.Point in project rstudio by rstudio.
the class SatelliteManager method forceReopenSatellite.
// Forcefully reopen a satellite window. This refreshes the window and
// pushes it to the front in Chrome. It should be used as a last resort;
// if responding to a UI event, use openSatellite instead, since Chrome
// permits window.open to reactivate windows in that context.
public void forceReopenSatellite(final String name, final JavaScriptObject params, boolean activate) {
Size preferredSize = null;
Point preferredPos = null;
for (ActiveSatellite satellite : satellites_) {
if (satellite.getName().equals(name) && !satellite.getWindow().isClosed()) {
// save the window's geometry so we can restore it after the window
// is destroyed
final WindowEx win = satellite.getWindow();
Document doc = win.getDocument();
preferredSize = new Size(doc.getClientWidth(), doc.getClientHeight());
preferredPos = new Point(win.getLeft(), win.getTop());
callNotifyPendingReactivate(win);
satellite.close();
break;
}
}
// didn't find an open window to reopen
if (preferredSize == null)
return;
// open a new window with the same geometry as the one we just destroyed,
// but with the newly supplied set of parameters
final Size windowSize = preferredSize;
final Point windowPos = preferredPos;
openSatellite(name, params, windowSize, false, windowPos, activate);
}
use of org.rstudio.core.client.Point in project rstudio by rstudio.
the class DesktopWindowOpener method openSatelliteWindow.
@Override
public void openSatelliteWindow(GlobalDisplay globalDisplay, String mode, int width, int height, NewWindowOptions options) {
String windowName = SatelliteUtils.getSatelliteWindowName(mode);
// default to desktop-assigned location, but if a specific position was
// assigned, use it
int x = -1;
int y = -1;
Point pos = options.getPosition();
if (pos != null) {
x = pos.getX();
y = pos.getY();
}
Desktop.getFrame().prepareForSatelliteWindow(windowName, x, y, width, height);
super.openSatelliteWindow(globalDisplay, mode, width, height, options);
}
use of org.rstudio.core.client.Point in project rstudio by rstudio.
the class DoubleClickState method checkForDoubleClick.
public boolean checkForDoubleClick(NativeEvent event) {
if (event.getButton() != NativeEvent.BUTTON_LEFT) {
lastClickPos_ = null;
lastClickTime_ = null;
return false;
}
Date now = new Date();
if (!isDoubleClick(event, now)) {
lastClickPos_ = new Point(event.getClientX(), event.getClientY());
lastClickTime_ = now;
return false;
} else {
// Prevent three clicks from generating two double clicks
lastClickPos_ = null;
lastClickTime_ = null;
return true;
}
}
use of org.rstudio.core.client.Point in project rstudio by rstudio.
the class DomUtils method getRelativePosition.
public static Point getRelativePosition(Element container, Element child) {
int left = 0, top = 0;
while (child != null && child != container) {
left += child.getOffsetLeft();
top += child.getOffsetTop();
child = child.getOffsetParent();
}
return new Point(left, top);
}
use of org.rstudio.core.client.Point in project rstudio by rstudio.
the class MiniPopupPanel method positionNearRange.
public void positionNearRange(DocDisplay display, Range range) {
Rectangle bounds = display.getRangeBounds(range);
Point center = bounds.center();
int pageX = center.getX() - (getOffsetWidth() / 2);
// prefer displaying popup below associated text, but place above text
// if it won't fit below
int pageY = bounds.getBottom() + 10;
if (pageY + getOffsetHeight() > display.getBounds().getBottom()) {
pageY = bounds.getTop() - 10 - getOffsetHeight();
}
// avoid leaking off left side of page
pageX = Math.max(20, pageX);
pageY = Math.max(20, pageY);
setPopupPosition(pageX, pageY);
}
Aggregations