Search in sources :

Example 1 with PinnedLineWidget

use of org.rstudio.studio.client.workbench.views.source.editors.text.PinnedLineWidget in project rstudio by rstudio.

the class MathJax method removeChunkOutputWidget.

private void removeChunkOutputWidget(final ChunkOutputWidget widget) {
    final PinnedLineWidget plw = cowToPlwMap_.get(widget);
    if (plw == null)
        return;
    FadeOutAnimation anim = new FadeOutAnimation(widget, new Command() {

        @Override
        public void execute() {
            cowToPlwMap_.remove(widget);
            lwToPlwMap_.remove(plw.getLineWidget());
            plw.detach();
        }
    });
    anim.run(400);
}
Also used : FadeOutAnimation(org.rstudio.core.client.layout.FadeOutAnimation) Command(com.google.gwt.user.client.Command) ForEachCommand(org.rstudio.core.client.MapUtil.ForEachCommand) ScheduledCommand(com.google.gwt.core.client.Scheduler.ScheduledCommand) PinnedLineWidget(org.rstudio.studio.client.workbench.views.source.editors.text.PinnedLineWidget)

Example 2 with PinnedLineWidget

use of org.rstudio.studio.client.workbench.views.source.editors.text.PinnedLineWidget in project rstudio by rstudio.

the class ChunkContextUi method createToolbar.

private void createToolbar(int row) {
    toolbar_ = new ChunkContextToolbar(this, dark_, !isSetup_, engine_);
    toolbar_.setHeight("0px");
    lineWidget_ = new PinnedLineWidget(ChunkContextToolbar.LINE_WIDGET_TYPE, target_.getDocDisplay(), toolbar_, row, null, host_);
}
Also used : PinnedLineWidget(org.rstudio.studio.client.workbench.views.source.editors.text.PinnedLineWidget)

Example 3 with PinnedLineWidget

use of org.rstudio.studio.client.workbench.views.source.editors.text.PinnedLineWidget in project rstudio by rstudio.

the class MathJax method createMathJaxLineWidget.

private void createMathJaxLineWidget(int row, boolean bare, final CommandWithArg<LineWidget> onAttached) {
    final FlowPanel panel = createMathJaxContainerWidget();
    ChunkOutputHost host = new ChunkOutputHost() {

        private int lastHeight_ = Integer.MAX_VALUE;

        @Override
        public void onOutputRemoved(final ChunkOutputWidget widget) {
            removeChunkOutputWidget(widget);
        }

        @Override
        public void onOutputHeightChanged(ChunkOutputWidget widget, int height, boolean ensureVisible) {
            final PinnedLineWidget plw = cowToPlwMap_.get(widget);
            if (plw == null)
                return;
            // munge the size of the frame, to avoid issues where the
            // frame's size changes following a collapse + expand
            boolean isExpansion = lastHeight_ <= height;
            if (isExpansion)
                widget.getFrame().setHeight((height + 4) + "px");
            lastHeight_ = height;
            // update the height and report to doc display
            LineWidget lineWidget = plw.getLineWidget();
            lineWidget.setPixelHeight(height);
            docDisplay_.onLineWidgetChanged(lineWidget);
        }
    };
    final ChunkOutputWidget outputWidget = new ChunkOutputWidget(StringUtil.makeRandomId(8), StringUtil.makeRandomId(8), RmdChunkOptions.create(), ChunkOutputWidget.EXPANDED, // can close
    false, host, bare ? ChunkOutputSize.Bare : ChunkOutputSize.Default);
    outputWidget.setRootWidget(panel);
    outputWidget.hideSatellitePopup();
    PinnedLineWidget plWidget = new PinnedLineWidget(LINE_WIDGET_TYPE, docDisplay_, outputWidget, row, null, new PinnedLineWidget.Host() {

        @Override
        public void onLineWidgetRemoved(LineWidget widget) {
        // no action necessary here; this is taken care of by the
        // hosting chunk (see onOutputRemoved)
        }

        @Override
        public void onLineWidgetAdded(LineWidget widget) {
            onAttached.execute(widget);
        }
    });
    cowToPlwMap_.put(outputWidget, plWidget);
    lwToPlwMap_.put(plWidget.getLineWidget(), outputWidget);
}
Also used : ChunkOutputHost(org.rstudio.studio.client.workbench.views.source.editors.text.rmd.ChunkOutputHost) ChunkOutputWidget(org.rstudio.studio.client.workbench.views.source.editors.text.ChunkOutputWidget) FlowPanel(com.google.gwt.user.client.ui.FlowPanel) PinnedLineWidget(org.rstudio.studio.client.workbench.views.source.editors.text.PinnedLineWidget) LineWidget(org.rstudio.studio.client.workbench.views.source.editors.text.ace.LineWidget) PinnedLineWidget(org.rstudio.studio.client.workbench.views.source.editors.text.PinnedLineWidget)

Example 4 with PinnedLineWidget

use of org.rstudio.studio.client.workbench.views.source.editors.text.PinnedLineWidget in project rstudio by rstudio.

the class MathJax method renderLatexLineWidget.

private void renderLatexLineWidget(final Range range, final String text, final MathJaxTypesetCallback callback) {
    // end a previous render session if necessary (e.g. if a popup is showing)
    endRender();
    // bail if we already have a pinned line widget here
    final int row = range.getEnd().getRow();
    LineWidget widget = docDisplay_.getLineWidgetForRow(row);
    if (widget == null) {
        // (ie a previous render is pending here)
        for (Map.Entry<ChunkOutputWidget, PinnedLineWidget> entry : cowToPlwMap_.entrySet()) if (entry.getValue().getRow() == row)
            return;
        // if we don't have a widget, create one and render the LaTeX once
        // the widget is attached to the editor
        createMathJaxLineWidget(row, // render bare output if start and end are on the same line
        range.getStart().getRow() == range.getEnd().getRow(), new CommandWithArg<LineWidget>() {

            @Override
            public void execute(LineWidget w) {
                renderLatexLineWidget(w, range, text, callback);
            }
        });
    } else {
        renderLatexLineWidget(widget, range, text, callback);
    }
}
Also used : ChunkOutputWidget(org.rstudio.studio.client.workbench.views.source.editors.text.ChunkOutputWidget) PinnedLineWidget(org.rstudio.studio.client.workbench.views.source.editors.text.PinnedLineWidget) LineWidget(org.rstudio.studio.client.workbench.views.source.editors.text.ace.LineWidget) PinnedLineWidget(org.rstudio.studio.client.workbench.views.source.editors.text.PinnedLineWidget) Map(java.util.Map) SafeMap(org.rstudio.core.client.container.SafeMap)

Aggregations

PinnedLineWidget (org.rstudio.studio.client.workbench.views.source.editors.text.PinnedLineWidget)4 ChunkOutputWidget (org.rstudio.studio.client.workbench.views.source.editors.text.ChunkOutputWidget)2 LineWidget (org.rstudio.studio.client.workbench.views.source.editors.text.ace.LineWidget)2 ScheduledCommand (com.google.gwt.core.client.Scheduler.ScheduledCommand)1 Command (com.google.gwt.user.client.Command)1 FlowPanel (com.google.gwt.user.client.ui.FlowPanel)1 Map (java.util.Map)1 ForEachCommand (org.rstudio.core.client.MapUtil.ForEachCommand)1 SafeMap (org.rstudio.core.client.container.SafeMap)1 FadeOutAnimation (org.rstudio.core.client.layout.FadeOutAnimation)1 ChunkOutputHost (org.rstudio.studio.client.workbench.views.source.editors.text.rmd.ChunkOutputHost)1