Search in sources :

Example 1 with Rectangle

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());
        }
    });
}
Also used : PositionCallback(com.google.gwt.user.client.ui.PopupPanel.PositionCallback) Rectangle(org.rstudio.core.client.Rectangle)

Example 2 with Rectangle

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);
}
Also used : Rectangle(org.rstudio.core.client.Rectangle)

Example 3 with Rectangle

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);
}
Also used : InputEditorPosition(org.rstudio.studio.client.workbench.views.console.shell.editor.InputEditorPosition) SourcePosition(org.rstudio.studio.client.workbench.views.source.model.SourcePosition) Rectangle(org.rstudio.core.client.Rectangle) ScreenCoordinates(org.rstudio.studio.client.workbench.views.source.editors.text.ace.Renderer.ScreenCoordinates) Breakpoint(org.rstudio.studio.client.common.debugging.model.Breakpoint)

Example 4 with Rectangle

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);
    }
}
Also used : Scope(org.rstudio.studio.client.workbench.views.source.editors.text.Scope) Rectangle(org.rstudio.core.client.Rectangle)

Example 5 with Rectangle

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);
        }
    });
}
Also used : PositionCallback(com.google.gwt.user.client.ui.PopupPanel.PositionCallback) Rectangle(org.rstudio.core.client.Rectangle)

Aggregations

Rectangle (org.rstudio.core.client.Rectangle)13 ElementEx (org.rstudio.core.client.dom.ElementEx)3 ScreenCoordinates (org.rstudio.studio.client.workbench.views.source.editors.text.ace.Renderer.ScreenCoordinates)3 PositionCallback (com.google.gwt.user.client.ui.PopupPanel.PositionCallback)2 Point (org.rstudio.core.client.Point)2 ScheduledCommand (com.google.gwt.core.client.Scheduler.ScheduledCommand)1 Document (com.google.gwt.dom.client.Document)1 Element (com.google.gwt.dom.client.Element)1 SpanElement (com.google.gwt.dom.client.SpanElement)1 com.google.gwt.event.dom.client (com.google.gwt.event.dom.client)1 Command (com.google.gwt.user.client.Command)1 IFrameElementEx (org.rstudio.core.client.dom.IFrameElementEx)1 WindowEx (org.rstudio.core.client.dom.WindowEx)1 Breakpoint (org.rstudio.studio.client.common.debugging.model.Breakpoint)1 InputEditorPosition (org.rstudio.studio.client.workbench.views.console.shell.editor.InputEditorPosition)1 Scope (org.rstudio.studio.client.workbench.views.source.editors.text.Scope)1 SourcePosition (org.rstudio.studio.client.workbench.views.source.model.SourcePosition)1