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
Since winit can't handle resize from the CSS or JS, work it around in
the demo by calling set_size on the slint window.
Also fix slint_size panicking not working on wasm as the map_state was
mutably borrowed by the set_size, and this may recurse into other
functions (eg, draw) causing a panic. So don't keep the state borrowed
when calling winit.
Another fix is fixing the initialization size of the window item when
the initial size is set with set_size
Fixes#547
This patch is mostly a rename now, but also contains a few small
cleanups.
SharedModel implements the Model trait itself and gracefully falls back
to an empty model is no Model was provided. This allows for some small
simplifications.
Also make sure to use the same comparision for SharedModels everywhere.
This fixes the last remaining clippy errors we had.
Change Model::row_data to return an Option<T> (rust) or std::optional<T> (c++)
Co-authored-by: Olivier Goffart <olivier@woboq.com>
Co-authored-by: Simon Hausmann <hausmann@gmail.com>
Remove the `application` infix from `register_application_font`, to
reduce the changes that it might be interpreted to be a function that
also changes the default font in all text elements.
Don't require the caller to Box the closure. With the assumption that
the majority of callers *want* the closure to be boxed (i.e. it's not
already boxed), the API becomes easier to use.
For regular builds this is done by adding Rust API that allows
registering a font, and for the web the font is installed into the
browser using JavaScript API.
This is an initial approach to just add this ability. It might make
sense to introduce a syntax in the `.60` file to allow for the
registration of fonts and letting the compiler generate code that
performs this embedding and registration automatically.