Pros: the composition shows up as selected
Cons: te cursor is shown at the begining of the preselection, and
clicking on the field commit the selection at the wrong place
The test system may run tests in threads using the fluent style and the
testing backend. But because the Qt backend is compiled in, the
NativeStyleMetrics is going to be Qt's and it will potentially be
constructed several times in parallel from different thread, causing
warnings and crashes within Qt.
So don't initialize the StyleMetrics, it is only used for the dark style
anyway
SVGs are rendered using HTML image elements, that are converted to textures.
The size of the texture defaults to the SVGs viewbox, which may be small - despite
it being possible to render the SVG at a higher resolution with great quality.
Similar to the native code path, this patch also uses the target image size
and propagates it to the DOM HTML image element to instruct the browser to
render the SVG at a higher resolution.
Co-authored-by: Olivier Goffart <olivier.goffart@slint-ui.com>
This avoids accidental use of logical pixels, esp. for SVG, elimiates
one call to `to_untyped()` as well as an untyped scale factor in the
femtovg renderer.
The suggestions popup from the input method was off by the y-coordinate. This was due to
text_input_cursor_rect_for_byte_offset returning the y position of the line only.
However QTextLine::y() is relative to QTextLayout::position().y(),
which needs to be added to take any vertical alignment into account.
This comes with the same caveats as the winit one: The composition is
not committed when clicking with the mouse or generally aborting the
composition.
Known caveats:
- winit doesn't forward mouse events to the IME, so clicking
with the mouse while composing results in funny effects such
as the pre-edit text following the cursor.
- With FemtoVG there's no text decoration support, thus no underlining
of the preedit area.
This allows setting the RUST_FONTCONFIG_DLOPEN environment variable
to dlopen fontconfig at runtime rather than linking it at build
time. This is helpful for cross compiling to Linux, particularly
because fontconfig has lots of C dependencies. Building a vendored
copy of fontconfig does not work as expected:
https://github.com/slint-ui/slint/issues/88
Suppose we render an SVG at 100px x 100px with a screen scale factor of 2.
Consequently we should be rendering the SVG at 200phx x 200phx, not 100x100.
Do this by applying the scale factor, just like it is done in the femtovg renderer.
At end of text, take the right edge of the glyph cluster; otherwise the left edge
of what's to the right of the cursor.
For empty text inputs, just return the height of the text to be.
cc #1480
A resize of the HTML canvas element would trigger our own resize
handler, which tried to do a special dance to trigger a redraw.
As it turns out, this breaks with current winit as the event loop target
is gone, so calling with_window_target() panics.
See also commit 8b728df021
Instead, this patch reverts to the simpler method of calling
invoke_from_event_loop, has workarounds for how to properly wake up the
event loop and return poll. In there we can just call request_redraw()
on the winit window directly to trigger a draw.
* Add `RequestedSize` and `RequestedPosition` enum to enable asking for
logical or physical size/position.
* Rename `Window::size()` to `Window::physical_size()`
* Make `Window::set_size(...)` take an `Into<RequestedSize>`
* Rename `Window::position()` to `Window::physical_position()`
* Make `Window::set_position(...)` take an `Into<RequestedPosition>`
* Change `WindowAdapter` and related classes to be able to handle
requests being made in the either physical or logical units.
Implement this for C++, Rust and node.
We need to assign the width beofre computing the preferred height
otherwise zero or very small value can be assumed and it will case the
text engine return a huge preferred height.
Testcase:
```
export App := Window {
VerticalLayout {
padding: -10px;
Text {
text: "Lots of text with\nnewlines etc.\n lorem ipsum dolor sit amet";
wrap: word-wrap;
}
}
}
```
In particular, this fixes the gallery window size being too high when
using the skia renderer, because when given a zero width, skia return
a big size for the height, (contrary to the Qt backend that consider 0
as infinite, or the femtovg backend that will stop rendering once a line
can't fit)
Replaces #1621
This puts the basics in place for text input. There are a few missing pieces (and probably more not yet discovered):
* Selections are not rendered yet.
* The cursor is not show at end of text.
* Cursor up and down doesn't work correctly in preserving the x position.
cc #1480
The old workaround doesn't work anymore (commit
575665994a removed the
redraw_all_windows() but that was correct as well). Instead we take an
approach that is hopefully more idiomatic to winit:
The winit documention suggests two methods: For continuously repainting
windows, we can just draw in MainEventsCleared. Otherwise call
request_redraw() and wait for Event::RedrawRequested(id).
In practice sometimes a call to request_redraw() from within the input
event processing results right away in a Event::RedrawRequested
(observed on Windows). Sometimes a request_redraw() results in waking up
with NewEvents() but no Event::RedrawRequested, and then in the next
iteration a new request_redraw() is included (observed on Windows).
We will continue to issue request_redraw() but for any windows that
haven't received Event::RedrawRequested() we will just draw. This still
allows the windowing system to compress / combine paint events.
If during draw() request_redraw() is called, we assume that the
application wants to redraw ASAP and we fall back to Poll. This was
previously the workaround in corelib that's now only in the winit code.
Fixes#1574
Since event_loop.rs is not shared anymore between the winit backend and
the "mcu" backend, we can reduce the WinitWindow trait to the features
that are needed for the event loop code to store it as trait object.