Skip to content

Commit

Permalink
Add icons to webviews (#759)
Browse files Browse the repository at this point in the history
* Add icons to webviews

* Use class for icon sourcing

- Use the UriIcon constructor to create icon uris

* Remove unused icon

- Removes the search.svg icon, as open-preview.svg was used instead
  • Loading branch information
ElianHugh authored Aug 19, 2021
1 parent 22b784f commit 415a2a3
Show file tree
Hide file tree
Showing 16 changed files with 67 additions and 12 deletions.
3 changes: 3 additions & 0 deletions images/icons/dark/globe.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions images/icons/dark/graph.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions images/icons/dark/help.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions images/icons/dark/open-preview.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions images/icons/dark/preview.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions images/icons/light/globe.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions images/icons/light/graph.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions images/icons/light/help.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions images/icons/light/open-preview.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions images/icons/light/preview.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export async function activate(context: vscode.ExtensionContext): Promise<apiImp
// assign session watcher setting to global variable
enableSessionWatcher = util.config().get<boolean>('sessionWatcher');


// register commands specified in package.json
const commands = {
// create R terminal
Expand Down
11 changes: 5 additions & 6 deletions src/helpViewer/panel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ import * as vscode from 'vscode';
import * as cheerio from 'cheerio';

import { HelpFile, RHelp } from '.';
import { setContext } from '../util';

import { setContext, UriIcon } from '../util';

//// Declaration of interfaces used/implemented by the Help Panel class
// specified when creating a new help panel
Expand Down Expand Up @@ -73,7 +72,6 @@ export class HelpPanel {
preserveFocus: preserveFocus
};
this.panel = vscode.window.createWebviewPanel('rhelp', 'R Help', showOptions, webViewOptions);

this.initializePanel();
}

Expand All @@ -82,8 +80,9 @@ export class HelpPanel {

return this.panel.webview;
}

private initializePanel(){

private initializePanel() {
this.panel.iconPath = new UriIcon('help');
// virtual uris used to access local files
this.webviewScriptUri = this.panel.webview.asWebviewUri(this.webviewScriptFile);
this.webviewStyleUri = this.panel.webview.asWebviewUri(this.webviewStyleFile);
Expand All @@ -109,7 +108,7 @@ export class HelpPanel {
void this.setContextValues();
});
}


public async setContextValues(): Promise<void> {
await setContext('r.helpPanel.active', !!this.panel?.active);
Expand Down
7 changes: 4 additions & 3 deletions src/plotViewer/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import * as path from 'path';
import * as fs from 'fs';
import * as ejs from 'ejs';

import { config, setContext } from '../util';
import { config, setContext, UriIcon } from '../util';

import { extensionContext } from '../extension';

Expand Down Expand Up @@ -272,7 +272,7 @@ export class HttpgdViewer implements IHttpgdViewer {

readonly defaultPreviewPlotLayout: PreviewPlotLayout = 'multirow';
previewPlotLayout: PreviewPlotLayout;

readonly defaultFullWindow: boolean = false;
fullWindow: boolean;

Expand Down Expand Up @@ -480,7 +480,7 @@ export class HttpgdViewer implements IHttpgdViewer {
};
this.postWebviewMessage(msg);
}

public toggleFullWindow(force?: boolean): void {
this.fullWindow = force ?? !this.fullWindow;
const msg: ToggleFullWindowMessage = {
Expand Down Expand Up @@ -745,6 +745,7 @@ export class HttpgdViewer implements IHttpgdViewer {
showOptions || this.showOptions,
this.webviewOptions
);
webviewPanel.iconPath = new UriIcon('graph');
webviewPanel.onDidDispose(() => this.webviewPanel = undefined);
webviewPanel.onDidChangeViewState(() => {
void this.setContextValues();
Expand Down
5 changes: 4 additions & 1 deletion src/rmarkdown/preview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import path = require('path');
import crypto = require('crypto');


import { config, doWithProgress, getRpath, readContent, setContext, escapeHtml } from '../util';
import { config, doWithProgress, getRpath, readContent, setContext, escapeHtml, UriIcon } from '../util';
import { extensionContext, tmpDir } from '../extension';

class RMarkdownPreview extends vscode.Disposable {
Expand Down Expand Up @@ -377,6 +377,7 @@ export class RMarkdownPreviewManager {
}

private openPreview(outputUri: vscode.Uri, filePath: string, title: string, cp: cp.ChildProcessWithoutNullStreams, viewer: vscode.ViewColumn, resourceViewColumn: vscode.ViewColumn, autoRefresh: boolean): void {

const panel = vscode.window.createWebviewPanel(
'previewRmd',
`Preview ${title}`,
Expand All @@ -391,6 +392,8 @@ export class RMarkdownPreviewManager {
localResourceRoots: [vscode.Uri.file(tmpDir())],
});

panel.iconPath = new UriIcon('preview');

// Push the new rmd webview to the open proccesses array,
// to keep track of running child processes
// (primarily used in killing the child process, but also
Expand Down
Loading

0 comments on commit 415a2a3

Please sign in to comment.