use of org.rstudio.core.client.Rectangle in project rstudio by rstudio.
the class DiagnosticsBackgroundPopup method showPopup.
private void showPopup(String text, Range range) {
hidePopup();
popup_ = new DiagnosticsPopupPanel(text, range);
final Rectangle coords = editor_.toScreenCoordinates(range);
popup_.setTitle("Diagnostics");
popup_.setPopupPositionAndShow(new PositionCallback() {
@Override
public void setPosition(int offsetWidth, int offsetHeight) {
popup_.setPopupPosition(coords.getRight() + 10, coords.getBottom());
}
});
}
use of org.rstudio.core.client.Rectangle in project rstudio by rstudio.
the class HistoryTableWithToolbar method highlightRows.
public void highlightRows(int offset, int length) {
historyTable_.clearSelection();
historyTable_.setSelected(offset, length, true);
Rectangle rect = historyTable_.getSelectionRect();
if (rect == null)
return;
int height = scrollPanel_.getOffsetHeight();
if (rect.getHeight() > height)
scrollPanel_.setVerticalScrollPosition(rect.getTop());
else
scrollPanel_.setVerticalScrollPosition(rect.getTop() - (height - rect.getHeight()) / 2);
}
use of org.rstudio.core.client.Rectangle in project rstudio by rstudio.
the class AceEditor method getRangeBounds.
@Override
public Rectangle getRangeBounds(Range range) {
range = Range.toOrientedRange(range);
Renderer renderer = widget_.getEditor().getRenderer();
if (!range.isMultiLine()) {
ScreenCoordinates start = documentPositionToScreenCoordinates(range.getStart());
ScreenCoordinates end = documentPositionToScreenCoordinates(range.getEnd());
int width = (end.getPageX() - start.getPageX()) + (int) renderer.getCharacterWidth();
int height = (end.getPageY() - start.getPageY()) + (int) renderer.getLineHeight();
return new Rectangle(start.getPageX(), start.getPageY(), width, height);
}
Position startPos = range.getStart();
Position endPos = range.getEnd();
int startRow = startPos.getRow();
int endRow = endPos.getRow();
// figure out top left coordinates
ScreenCoordinates topLeft = documentPositionToScreenCoordinates(Position.create(startRow, 0));
// figure out bottom right coordinates (need to walk rows to figure out longest line)
ScreenCoordinates bottomRight = documentPositionToScreenCoordinates(Position.create(endPos));
for (int row = startRow; row <= endRow; row++) {
Position rowEndPos = Position.create(row, getLength(row));
ScreenCoordinates coords = documentPositionToScreenCoordinates(rowEndPos);
if (coords.getPageX() > bottomRight.getPageX())
bottomRight = ScreenCoordinates.create(coords.getPageX(), bottomRight.getPageY());
}
// construct resulting range
int width = (bottomRight.getPageX() - topLeft.getPageX()) + (int) renderer.getCharacterWidth();
int height = (bottomRight.getPageY() - topLeft.getPageY()) + (int) renderer.getLineHeight();
return new Rectangle(topLeft.getPageX(), topLeft.getPageY(), width, height);
}
use of org.rstudio.core.client.Rectangle in project rstudio by rstudio.
the class ChunkOutputUi method ensureVisible.
public void ensureVisible() {
// we want to be sure the user can see the row beneath the output
// (this is just a convenient way to determine whether the entire
// output is visible)
int targetRow = Math.min(display_.getRowCount() - 1, getCurrentRow() + 1);
// close to the bottom of the screen
if (!outputWidget_.isVisible()) {
targetRow = Math.min(display_.getRowCount() - 1, targetRow + 1);
}
// do any auto-scrolling
if (display_.getLastVisibleRow() <= targetRow && display_.getFirstVisibleRow() >= getScope().getPreamble().getRow()) {
return;
}
// scroll into view if the output is not visible (in either direction)
if (display_.getLastVisibleRow() < targetRow || display_.getFirstVisibleRow() > getCurrentRow()) {
Scope chunk = getScope();
Rectangle bounds = display_.getPositionBounds(chunk.getPreamble());
// compute the distance we need to scroll
int delta = bounds.getTop() - (display_.getBounds().getTop() + 60);
// scroll!
display_.scrollToY(display_.getScrollTop() + delta, 400);
}
}
use of org.rstudio.core.client.Rectangle in project rstudio by rstudio.
the class SignatureToolTipManager method setTooltipPosition.
private void setTooltipPosition(Position position) {
final Rectangle bounds = docDisplay_.getPositionBounds(position);
tooltipPosition_ = position;
toolTip_.setPopupPositionAndShow(new PositionCallback() {
@Override
public void setPosition(int offsetWidth, int offsetHeight) {
int left = bounds.getLeft();
boolean verticalOverflow = bounds.getBottom() + offsetHeight >= Window.getClientHeight() - 20;
int top = verticalOverflow ? bounds.getTop() - offsetHeight - 10 : bounds.getBottom() + 10;
toolTip_.setPopupPosition(left, top);
}
});
}
Aggregations