We ended rendering glyphs with empty or even negative size, causing
panics down the line.
I added a way in the screenshot tester to change the scale factor
CC: #2957
Note: the addition of MinimalSoftwareWindow::set_size is there because
it would be a breaking change for user who called set_size on the
MinimalSoftwareWindow while also using the WindowAdapter trait.
This was the case of a test.
The same problem theorically exist with set_position and position, but
is unlikely to be a problem because i don't think people would use the
position with a MinimalSoftwareWindow
The renderer() is now public as well. That's because I want to make sure
that the scealed trait don't have non-provided method
With Qt and eglfs it may happen that when creating a popup, Qt delivers
a paint event via show() before we've had a chance to set the component
on the slint::Window. In that case unwrapping the component in
draw_contents() panics.
This fix is covered by reproducing the same scenario using public
MinimalSoftwareWindow API.
Fixes#2799
Co-authored-by: Olivier Goffart <olivier.goffart@slint-ui.com>
* add screenshot test for text input
* Update tests/screenshots/cases/software/basic/text_input.slint
Co-authored-by: Simon Hausmann <simon.hausmann@slint-ui.com>
* swr: fix clipping of text cursor
---------
Co-authored-by: Simon Hausmann <simon.hausmann@slint-ui.com>
Make text_input_byte_offset_for_position and text_input_cursor_rect_for_byte_offset
low-level in the API, where the implementation becomes easier. Two
helper functions in TextInput in turn collect the necessary parameters
and thus also reduce the amount of duplicated code.
This also decouples the renderer further from the window.
So that we don't need to query the geometry multiple time, and this pave
the way to not have the geometry in the items
Part of #1932
As a drive by, fix the clipping of the Path element which incorrectly
offseted the clip by (x,y).
Similar fixes happen in the Clip element in some renderer, but that
didn't have effect because x and y are always 0 for the Clip element
This would cause some of the image to be drawn outside of the clip
region, which may even lead to panics
(Fix changing pages in the energy-monitor demo)
Having a const generic for that didn't turn to be a good API.
Also made the C++ side more difficult
(Also renamed buffer_stride to pixel_stride)
Closes#2135
Two bugs:
- There was an extra `* 4` that caused panic when the Text was clipped
- There was a bug in glyph handling when the text is being split in
several runs
The current implementation of the software renderer doesn't drawn the
background under the border, so if the border is translusent, we don't
see the background color.
This patch blend the color of the border with the coler of the
background.
Software renderer part of #1988 (minus clipping)
Instead of the ClippedImage. Because we use the colorize property more
often than the source property, and these are soon going to be even more
expensive
Remove platform glyph abstraction, just use non-zero u16 as glyph index
like everyone else. As a bonus, this reduces the memory consumption of
the glyph buffers per glyph from a size of a pointer to the size of the
u16.
The default impl of unregister_component in WindowAdapterSealed would call free_graphics_resources
on the rendere. Any re-implementation would have to do the same,
which the winit backend forwarded through
the winit backend specific internal renderer interface.
Instead, the original call site for unregister_component now calls
free_graphics_resources and unregister_component (for accessibility tree dirty notification).
Replace register_root_component in the WindowAdapterSealed altogether with
a default font size getter on the renderer.
This is overall simpler and allows removing the doc-hidden getter in the software renderer.
* janitor: Fix clippy error drop_copy
Clippy says cache_entry is Copy, so calling drop on it is useless since
it will drop a copied value.
* janitor: Fix clippy error
... about cloning a double ref.
Co-authored-by: Olivier Goffart <olivier@woboq.com>