Skip to content

Commit

Permalink
Slintpad: resize the cansvas after showing the UI
Browse files Browse the repository at this point in the history
Right now, the winit window adaptor will force a px value on the width
and height once the ui is up.
We should then override that again with 100% after the UI is shown
  • Loading branch information
ogoffart authored Jan 3, 2024
1 parent a3e3ccc commit 2ff9399
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
6 changes: 5 additions & 1 deletion editors/vscode/src/wasm_preview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,11 @@ function getPreviewHtml(
}
});
preview_connector.show_ui().then(() => vscode.postMessage({ command: 'preview_ready' }));
preview_connector.show_ui().then(() => {
canvas.style.width = "100%";
canvas.style.height = "100%";
vscode.postMessage({ command: 'preview_ready' });
});
</script>
</head>
Expand Down
8 changes: 3 additions & 5 deletions tools/slintpad/src/preview_widget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,6 @@ export class PreviewWidget extends Widget {
canvas.style.height = "100%";
canvas.style.outline = "none";
canvas.style.touchAction = "none";
canvas.width = canvas.offsetWidth;
canvas.height = canvas.offsetHeight;

canvas.dataset.slintAutoResizeToPreferred = "false";

node.appendChild(canvas);

return node;
Expand All @@ -56,6 +51,9 @@ export class PreviewWidget extends Widget {
// when searching the document.
this.#previewer.show_ui().then(() => {
console.info("UI should be up!");
const canvas = document.getElementById(canvas_id) as HTMLElement;
canvas.style.width = "100%";
canvas.style.height = "100%";
});
});
}
Expand Down

0 comments on commit 2ff9399

Please sign in to comment.