Search in sources :

Example 11 with Rectangle

use of org.rstudio.core.client.Rectangle in project rstudio by rstudio.

the class AceEditor method toScreenCoordinates.

public Rectangle toScreenCoordinates(Range range) {
    Renderer renderer = widget_.getEditor().getRenderer();
    ScreenCoordinates start = renderer.textToScreenCoordinates(range.getStart().getRow(), range.getStart().getColumn());
    ScreenCoordinates end = renderer.textToScreenCoordinates(range.getEnd().getRow(), range.getEnd().getColumn());
    return new Rectangle(start.getPageX(), start.getPageY(), end.getPageX() - start.getPageX(), renderer.getLineHeight());
}
Also used : Rectangle(org.rstudio.core.client.Rectangle) ScreenCoordinates(org.rstudio.studio.client.workbench.views.source.editors.text.ace.Renderer.ScreenCoordinates)

Example 12 with Rectangle

use of org.rstudio.core.client.Rectangle in project rstudio by rstudio.

the class DesktopExport method export.

public static void export(final ExportPlotSizeEditor sizeEditor, final OperationWithInput<Rectangle> exporter, final Operation onCompleted) {
    sizeEditor.prepareForExport(new Command() {

        @Override
        public void execute() {
            // hide gripper
            sizeEditor.setGripperVisible(false);
            // get zoom level
            double zoomLevel = BrowseCap.isMacintoshDesktop() ? getSafariZoomFactor() : Desktop.getFrame().getZoomLevel();
            // get the preview iframe rect
            ElementEx iframe = sizeEditor.getPreviewIFrame().<ElementEx>cast();
            final Rectangle viewerRect = new Rectangle((int) Math.ceil(zoomLevel * iframe.getClientLeft()), (int) Math.ceil(zoomLevel * iframe.getClientTop()), (int) Math.ceil(zoomLevel * iframe.getClientWidth()), (int) Math.ceil(zoomLevel * iframe.getClientHeight())).inflate(-1);
            // perform the export
            Scheduler.get().scheduleDeferred(new ScheduledCommand() {

                @Override
                public void execute() {
                    exporter.execute(viewerRect);
                    // show gripper
                    sizeEditor.setGripperVisible(true);
                    // call onCompleted
                    if (onCompleted != null)
                        onCompleted.execute();
                }
            });
        }
    });
}
Also used : ScheduledCommand(com.google.gwt.core.client.Scheduler.ScheduledCommand) Command(com.google.gwt.user.client.Command) ScheduledCommand(com.google.gwt.core.client.Scheduler.ScheduledCommand) ElementEx(org.rstudio.core.client.dom.ElementEx) Rectangle(org.rstudio.core.client.Rectangle)

Example 13 with Rectangle

use of org.rstudio.core.client.Rectangle in project rstudio by rstudio.

the class SpellingDialog method setEditorSelectionBounds.

@Override
public void setEditorSelectionBounds(Rectangle selectionBounds) {
    // Inflate the bounds by 10 pixels to add a little air
    boundsToAvoid_ = selectionBounds.inflate(10);
    if (isShowing()) {
        Rectangle screen = new Rectangle(0, 0, Window.getClientWidth(), Window.getClientHeight());
        Rectangle bounds = new Rectangle(getPopupLeft(), getPopupTop(), getOffsetWidth(), getOffsetHeight());
        // In case user moved the dialog off the screen
        bounds = bounds.attemptToMoveInto(screen, FailureMode.NO_CHANGE);
        // Now avoid the selected word
        move(bounds.avoidBounds(boundsToAvoid_, screen), true);
    }
}
Also used : 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