Skip to content

Commit

Permalink
Merge pull request spcl#46 from spcl/event_bubbling
Browse files Browse the repository at this point in the history
Allow click event bubbling to regain window focus for renderer clicks
  • Loading branch information
tbennun committed Aug 6, 2021
2 parents df3133c + 0a32049 commit c573aa8
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 21 deletions.
2 changes: 1 addition & 1 deletion dist/main.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/main.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/sdfv.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/sdfv.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@spcl/sdfv",
"version": "1.0.4",
"version": "1.0.5",
"description": "A standalone viewer for SDFGs",
"homepage": "https://github.com/spcl/dace-webclient",
"keywords": [
Expand Down
26 changes: 14 additions & 12 deletions src/renderer/renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,13 @@ export class SDFGRenderer {
this.overlay_manager = null;
}

this.in_vscode = false;
try {
vscode;
if (vscode)
this.in_vscode = true;
} catch (ex) { }

// Draw debug aids.
this.debug_draw = debug_draw;

Expand Down Expand Up @@ -269,13 +276,6 @@ export class SDFGRenderer {
this.toolbar.style = 'position:absolute; top:10px; left: 10px;';
let d;

let in_vscode = false;
try {
vscode;
if (vscode)
in_vscode = true;
} catch (ex) { }

// Menu bar
try {
ContextMenu;
Expand All @@ -298,7 +298,7 @@ export class SDFGRenderer {
}
cmenu.addCheckableOption("Inclusive ranges", that.inclusive_ranges, (x, checked) => { that.inclusive_ranges = checked; });
cmenu.addCheckableOption("Adaptive content hiding", that.ctx.lod, (x, checked) => { that.ctx.lod = checked; });
if (!in_vscode)
if (!this.in_vscode)
cmenu.addOption(
'Overlays',
() => {
Expand All @@ -323,7 +323,7 @@ export class SDFGRenderer {
MemoryVolumeOverlay
);
that.draw_async();
if (in_vscode)
if (this.in_vscode)
refresh_analysis_pane();
}
);
Expand Down Expand Up @@ -479,7 +479,7 @@ export class SDFGRenderer {
document.addEventListener('keyup', (e) => this.on_key_event(e));

// Exit previewing mode
if (in_vscode) {
if (this.in_vscode) {
let exit_preview_btn = document.createElement('button');
exit_preview_btn.id = 'exit-preview-button';
exit_preview_btn.className = 'button hidden';
Expand Down Expand Up @@ -706,8 +706,10 @@ export class SDFGRenderer {
let cancelled = this.on_mouse_event(x, comp_x, comp_y, evtype);
if (cancelled)
return;
x.stopPropagation();
x.preventDefault();
if (!this.in_vscode) {
x.stopPropagation();
x.preventDefault();
}
});
}
}
Expand Down
11 changes: 7 additions & 4 deletions src/sdfv_ui_handlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import { sdfg_property_to_string } from "./utils/sdfg/display";
import { traverse_sdfg_scopes } from "./utils/sdfg/traversal";
import { htmlSanitize } from "./utils/sanitization";
import { globals } from "./sdfv";

export const SDFVUIHandlers = {
on_init_menu,
Expand Down Expand Up @@ -44,8 +45,9 @@ function on_fill_info(elem) {
attr[0] == "position")
continue;
html += "<b>" + attr[0] + "</b>:&nbsp;&nbsp;";
html += sdfg_property_to_string(attr[1], renderer.view_settings()) +
"</p>";
html += sdfg_property_to_string(
attr[1], globals.daceRenderer.view_settings()
) + "</p>";
}

// If access node, add array information too
Expand All @@ -57,8 +59,9 @@ function on_fill_info(elem) {
attr[0].startsWith("_meta_"))
continue;
html += "<b>" + attr[0] + "</b>:&nbsp;&nbsp;";
html += sdfg_property_to_string(attr[1], renderer.view_settings()) +
"</p>";
html += sdfg_property_to_string(
attr[1], globals.daceRenderer.view_settings()
) + "</p>";
}
}

Expand Down

0 comments on commit c573aa8

Please sign in to comment.