Skip to content
Snippets Groups Projects
Commit 8101ecad authored by Smit, P.J.M. (Peter, Student M-CS)'s avatar Smit, P.J.M. (Peter, Student M-CS)
Browse files

Added icon for reset poisition command and added zoom in and out buttons for dotview

parent bbd4211e
No related branches found
No related tags found
No related merge requests found
<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fill="white"><path fill-rule="evenodd" clip-rule="evenodd" d="M3.5 2v3.5L4 6h3.5V5H4.979l.941-.941a3.552 3.552 0 1 1 5.023 5.023L5.746 14.28l.72.72 5.198-5.198A4.57 4.57 0 0 0 5.2 3.339l-.7.7V2h-1z"/></svg>
\ No newline at end of file
<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fill="white"><path fill-rule="evenodd" clip-rule="evenodd" d="M12.027 6.149a5.52 5.52 0 0 1-1.27 3.908l4.26 4.26-.7.71-4.26-4.27a5.52 5.52 0 1 1 1.97-4.608zm-5.45 4.888a4.51 4.51 0 0 0 3.18-1.32l-.04.02a4.51 4.51 0 0 0 1.36-3.2 4.5 4.5 0 1 0-4.5 4.5zm2.44-4v-1h-2v-2h-1v2h-2v1h2v2h1v-2h2z"/></svg>
\ No newline at end of file
<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fill="white"><path fill-rule="evenodd" clip-rule="evenodd" d="M12.027 6.149a5.52 5.52 0 0 1-1.27 3.908l4.26 4.26-.7.71-4.26-4.27a5.52 5.52 0 1 1 1.97-4.608zm-5.45 4.888a4.51 4.51 0 0 0 3.18-1.32l-.04.02a4.51 4.51 0 0 0 1.36-3.2 4.5 4.5 0 1 0-4.5 4.5zm-2.54-4.98h5v1h-5v-1z"/></svg>
\ No newline at end of file
......@@ -22,6 +22,12 @@ window.addEventListener('message', event => {
svgImage.setAttribute('viewBox', `0 0 ${svgImage.clientWidth} ${svgImage.clientHeight}`);
}
break;
case 'zoomIn':
zoom(true);
break;
case 'zoomOut':
zoom(false);
break;
case 'svg':
const newSvg = event.data.svg;
if (svgImage === undefined) {
......@@ -46,6 +52,23 @@ window.addEventListener('resize', () => {
}
});
function zoom(zoomIn) {
if (svgImage !== null) {
var w = viewBox.w;
var h = viewBox.h;
var mx = svgImage.clientWidth / 2;//middle of screen
var my = svgImage.clientHeight / 2;
var dw = w * 0.15 * (zoomIn ? 1 : -1);
var dh = h * 0.15 * (zoomIn ? 1 : -1);
var svgSize = { w: svgImage.clientWidth, h: svgImage.clientHeight };
var dx = dw * mx / svgSize.w;
var dy = dh * my / svgSize.h;
viewBox = { x: viewBox.x + dx, y: viewBox.y + dy, w: viewBox.w - dw, h: viewBox.h - dh };
scale = svgSize.w / viewBox.w;
svgImage.setAttribute('viewBox', `${viewBox.x} ${viewBox.y} ${viewBox.w} ${viewBox.h}`);
}
}
svgContainer.onmousewheel = (e) => {
if (svgImage !== null) {
var w = viewBox.w;
......
<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fill="currentColor"><path fill-rule="evenodd" clip-rule="evenodd" d="M3.5 2v3.5L4 6h3.5V5H4.979l.941-.941a3.552 3.552 0 1 1 5.023 5.023L5.746 14.28l.72.72 5.198-5.198A4.57 4.57 0 0 0 5.2 3.339l-.7.7V2h-1z"/></svg>
\ No newline at end of file
<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fill="currentColor"><path fill-rule="evenodd" clip-rule="evenodd" d="M12.027 6.149a5.52 5.52 0 0 1-1.27 3.908l4.26 4.26-.7.71-4.26-4.27a5.52 5.52 0 1 1 1.97-4.608zm-5.45 4.888a4.51 4.51 0 0 0 3.18-1.32l-.04.02a4.51 4.51 0 0 0 1.36-3.2 4.5 4.5 0 1 0-4.5 4.5zm2.44-4v-1h-2v-2h-1v2h-2v1h2v2h1v-2h2z"/></svg>
\ No newline at end of file
<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fill="currentColor"><path fill-rule="evenodd" clip-rule="evenodd" d="M12.027 6.149a5.52 5.52 0 0 1-1.27 3.908l4.26 4.26-.7.71-4.26-4.27a5.52 5.52 0 1 1 1.97-4.608zm-5.45 4.888a4.51 4.51 0 0 0 3.18-1.32l-.04.02a4.51 4.51 0 0 0 1.36-3.2 4.5 4.5 0 1 0-4.5 4.5zm-2.54-4.98h5v1h-5v-1z"/></svg>
\ No newline at end of file
......@@ -46,7 +46,7 @@
"command": "analysisResults.copyItem",
"title": "Copy item"
},
{
{
"command": "analysisResults.highlight",
"title": "Highlight item"
},
......@@ -66,15 +66,15 @@
"command": "analysisResults.openInEditor",
"title": "Show value in editor"
},
{
"command": "analysisResults.openInCompView",
"title": "Show results in comparison view"
},
{
"command": "analysisResults.clear",
"title": "Clear view"
},
{
{
"command": "analysisResults.openInCompView",
"title": "Show results in comparison view"
},
{
"command": "analysisResults.clear",
"title": "Clear view"
},
{
"command": "analysisResultsCompView.load",
"title": "Open analysis results"
},
......@@ -86,73 +86,93 @@
"command": "analysisResultsCompView.openFileInEditor",
"title": "Show results in editor"
},
{
"command": "analysisResultsCompView.clearCompView",
"title": "Clear comparison view"
},
{
"command": "modest.viewDot",
"title": "Open DOT view",
"icon": {
"light": "media/light/open-preview.svg",
"dark": "media/dark/open-preview.svg"
}
},
{
"command": "modest.viewDotSameWindow",
"title": "Open DOT view in the current window",
"icon": {
"light": "media/light/preview.svg",
"dark": "media/dark/preview.svg"
}
},
{
"command": "modest.resetDotPosition",
"title": "Reset position"
}
{
"command": "analysisResultsCompView.clearCompView",
"title": "Clear comparison view"
},
{
"command": "modest.viewDot",
"title": "Open DOT view",
"icon": {
"light": "media/light/open-preview.svg",
"dark": "media/dark/open-preview.svg"
}
},
{
"command": "modest.viewDotSameWindow",
"title": "Open DOT view in the current window",
"icon": {
"light": "media/light/preview.svg",
"dark": "media/dark/preview.svg"
}
},
{
"command": "modest.resetDotPosition",
"title": "Reset position",
"icon": {
"light": "media/light/reset-location.svg",
"dark": "media/dark/reset-location.svg"
}
},
{
"command": "modest.dotZoomIn",
"title": "Zoom in",
"icon": {
"light": "media/light/zoom-in.svg",
"dark": "media/dark/zoom-in.svg"
}
},
{
"command": "modest.dotZoomOut",
"title": "Zoom out",
"icon": {
"light": "media/light/zoom-out.svg",
"dark": "media/dark/zoom-out.svg"
}
}
],
"menus": {
"view/title": [
{
"command": "analysisResults.load",
"when": "view == analysisResults",
"group": "file"
"group": "file"
},
{
"command": "analysisResults.export",
"when": "view == analysisResults",
"group": "file"
"group": "file"
},
{
"command": "analysisResults.openFileInEditor",
"when": "view == analysisResults",
"group": "show"
"group": "show"
},
{
{
"command": "analysisResults.openInCompView",
"when": "view == analysisResults",
"group": "show"
"group": "show"
},
{
{
"command": "analysisResults.clear",
"when": "view == analysisResults"
},
{
{
"command": "analysisResultsCompView.load",
"when": "view == analysisResultsCompView",
"group": "file"
"group": "file"
},
{
"command": "analysisResultsCompView.export",
"when": "view == analysisResultsCompView",
"group": "file"
"group": "file"
},
{
"command": "analysisResultsCompView.openFileInEditor",
"when": "view == analysisResultsCompView",
"group": "show"
"group": "show"
},
{
{
"command": "analysisResultsCompView.clearCompView",
"when": "view == analysisResultsCompView"
}
......@@ -166,35 +186,45 @@
{
"command": "analysisResults.copyValue",
"when": "view == analysisResults && viewItem != empty || view == analysisResultsCompView && viewItem != empty",
"group": "copy"
"group": "copy"
},
{
"command": "analysisResults.copyItem",
"when": "view == analysisResults || view == analysisResultsCompView",
"group": "copy"
"group": "copy"
},
{
"command": "analysisResults.openInEditor",
"when": "view == analysisResults && viewItem != empty || view == analysisResultsCompView && viewItem != empty"
},
{
"command": "analysisResults.highlight",
"when": "view == analysisResults || view == analysisResultsCompView"
}
{
"command": "analysisResults.highlight",
"when": "view == analysisResults || view == analysisResultsCompView"
}
],
"editor/title": [
{
"when": "resourceLangId == modest",
"command": "modest.viewDot",
"alt": "modest.viewDotSameWindow",
"group": "navigation"
},
{
"when": "modest:dotViewFocused",
"command": "modest.resetDotPosition",
"group": "navigation"
}
]
"editor/title": [
{
"when": "resourceLangId == modest",
"command": "modest.viewDot",
"alt": "modest.viewDotSameWindow",
"group": "navigation"
},
{
"when": "modest:dotViewFocused",
"command": "modest.resetDotPosition",
"group": "navigation"
},
{
"when": "modest:dotViewFocused",
"command": "modest.dotZoomOut",
"group": "navigation"
},
{
"when": "modest:dotViewFocused",
"command": "modest.dotZoomIn",
"group": "navigation"
}
]
},
"commandPalette": [
{
......@@ -204,10 +234,10 @@
{
"command": "modest.add-parameters"
},
{
"command": "modest.viewDot",
"when": "editorLangId == modest"
}
{
"command": "modest.viewDot",
"when": "editorLangId == modest"
}
],
"keybindings": [
{
......@@ -216,12 +246,12 @@
"mac": "alt+shift+s",
"when": "editorLangId == modest"
},
{
"command": "modest.viewDot",
"key": "alt+shift+d",
"mac": "alt+shift+d",
"when": "editorLangId == modest"
}
{
"command": "modest.viewDot",
"key": "alt+shift+d",
"mac": "alt+shift+d",
"when": "editorLangId == modest"
}
],
"languages": [
{
......@@ -285,12 +315,12 @@
{
"id": "analysisResults",
"name": "Analysis Results",
"visibility": "visible"
"visibility": "visible"
},
{
"id": "analysisResultsCompView",
"name": "Analysis Results Comparison View",
"visibility": "visible"
"visibility": "visible"
}
]
},
......@@ -343,4 +373,4 @@
"vscode-codicons": "0.0.15",
"vscode-languageclient": "^7.0.0"
}
}
}
\ No newline at end of file
......@@ -57,12 +57,23 @@ export namespace ModestCommands {
});
export let resetDotPosition = vscode.commands.registerCommand('modest.resetDotPosition', async () => {
// Can only trigger when dotView is open, so we can just send a message.
LiveDotView.currentWebView?.postMessage({
type: 'reset'
});
});
export let dotZoomIn = vscode.commands.registerCommand('modest.dotZoomIn', async () => {
LiveDotView.currentWebView?.postMessage({
type: 'zoomIn'
});
});
export let dotZoomOut = vscode.commands.registerCommand('modest.dotZoomOut', async () => {
LiveDotView.currentWebView?.postMessage({
type: 'zoomOut'
});
});
class LiveDotView {
public static currentWebView: vscode.Webview | undefined;
......
......@@ -136,6 +136,8 @@ export function activate(context: ExtensionContext) {
context.subscriptions.push(ModestCommands.simCommand);
context.subscriptions.push(ModestCommands.viewDot);
context.subscriptions.push(ModestCommands.viewDotSameWindow);
context.subscriptions.push(ModestCommands.dotZoomIn);
context.subscriptions.push(ModestCommands.dotZoomOut);
context.subscriptions.push(ModestCommands.resetDotPosition);
extensionUri = context.extensionUri;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment