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);
}
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_);
}
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);
}
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);
}
}
Aggregations