slint/examples/printerdemo/rust/index.html
Olivier Goffart 0359071b1e
Winit initial size adjustments and wasm size fixes
Following the winit 0.29 merge, a few adjustments are in order:

 - Make slint::Window.set_size() before show keep the size
 - on wasm, attempt to keep the size of the canvas from CSS
 - on wasm, one must set the width and height explicitly on the canvas
   otherwise there is wierd scaling
 - on wasm, we can't set None as maximum or minimum size otherwise winit
   panics
 - It seems that the hack we had to keep the size in range is no longer
   necessary
 - The hack in the slide puzzle can be removed. (but unfortunately it
   doesn't follow resizes

Unfortunatelly we always call set_inner_size to avoid infinite loop when
the css properties are not specificed, so this will override layouts

Also we don't default anymore to the preferred size

* Update internal/backends/winit/winitwindowadapter.rs
2023-10-24 15:28:18 +02:00

64 lines
1.8 KiB
HTML

<!DOCTYPE html>
<!-- Copyright © SixtyFPS GmbH <info@slint.dev> -->
<!-- SPDX-License-Identifier: MIT -->
<html>
<!--
This is a static html file used to display the wasm build.
In order to generate the build
- uncomment the #wasm# lines in Cargo.toml
- Run `wasm-pack build --release --target web` in this directory.
-->
<head>
<meta charset="UTF-8">
<title>Slint Printer Demo (Web Assembly version)</title>
<link rel="stylesheet" href="https://slint.dev/css/demos-v1.css">
<style>
@media screen and (max-width: 992px) and (orientation: landscape) {
.hide-in-mobile-landscape {
display: none;
}
* {
margin: 0;
padding: 0;
overflow: hidden;
}
canvas {
width: 100vw !important;
height: 100vh !important;
}
}
</style>
</head>
<body>
<h1 class="hide-in-mobile-landscape">Printer Demo</h1>
<p class="hide-in-mobile-landscape">This is the <a href="https://slint.dev">Slint</a> Printer Demo compiled to
WebAssembly. It simulates the
touch user interface of
the advanced "Print Machine 2000", without actually printing anything.</p>
<div id="spinner" style="position: relative;">
<div class="spinner">Loading...</div>
</div>
<canvas id="canvas" unselectable="on"></canvas>
<p class="hide-in-mobile-landscape links">
<a href="https://github.com/slint-ui/slint/blob/master/examples/printerdemo/ui/printerdemo.slint">
View Source Code on GitHub</a> -
<a href="https://slint.dev/editor?load_demo=examples/printerdemo/ui/printerdemo.slint">
Open in SlintPad
</a>
</p>
<script type="module">
import init from './pkg/printerdemo.js';
init().finally(() => {
document.getElementById("spinner").remove();
});
</script>
</body>
</html>