Commit graph

1368 commits

Author SHA1 Message Date
Olivier Goffart
4a56531dab swr: Fix panic when drawing clipped text
In some case, when the clip is, eg on a 0.25 of a pixel, but the offset is 0.75,
(such that the begining of the glyph starts at 0.5) difference in
rounding in different computation can result in a width which is one
pixel bigger than the source image.
I couldn't reproduce this in a testcase, but this can be reproduced
while resizing or scrolling through a TextEdit

I think this fixes #2957

The panic fixed by this commit looks like this:
```
thread 'main' panicked at 'index out of bounds: the len is 131 but the index is 131', /home/olivier/slint/internal/core/software_renderer/draw_functions.rs:81:19
stack backtrace:
   3: i_slint_core::software_renderer::draw_functions::draw_texture_line
             at ./internal/core/software_renderer/draw_functions.rs:81:19
   4: <i_slint_core::software_renderer::RenderToBuffer<T> as i_slint_core::software_renderer::ProcessScene>::process_shared_image_buffer
             at ./internal/core/software_renderer.rs:1023:13
   5: i_slint_core::software_renderer::SceneBuilder<T>::draw_text_paragraph::{{closure}}
             at ./internal/core/software_renderer.rs:1404:37
   6: i_slint_core::textlayout::TextParagraphLayout<Font>::layout_lines::{{closure}}
             at ./internal/core/textlayout.rs:219:17
```
2023-07-07 13:12:33 +02:00
Olivier Goffart
c0ac2acbef Avoid panicking when asked to render an empty window 2023-07-07 13:12:33 +02:00
Olivier Goffart
4296ca2afe Software renderer: Fix another panic when the coordinate are NaN 2023-07-07 13:12:33 +02:00
Olivier Goffart
6eef589043 Fix panic in the software renderer with clipped text and scale factor
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
2023-07-07 13:12:33 +02:00
Olivier Goffart
db0dd19447 Sotfware renderer: Fix panic when pressing the End key
(The runtime create a point which is in f32::MAX away, so we need to
keep it within the bounds of i16)

Fixes #3058
2023-07-06 16:34:26 +02:00
Olivier Goffart
eb257774e8
Add modifiers to PointerEvent
* Add modifiers to PointerEvent

Closes #2686
2023-07-06 09:54:43 +02:00
Olivier Goffart
aa8ef4e302 C++: add a "std" feature to the slint-cpp crate
And make it no_std otherwise

This is a first step towards getting C++ on MCU (#2136)
2023-07-05 21:48:01 +02:00
Olivier Goffart
9afadf50be Get rid of the "use_modules" workaround
This doesn't seem to be needed anymore with newer rust version.
As long as one symbol from the crate is used, all exported function
from the crate are available.

The reason why some symbols in some module were gone was a bug in rust
that has been fixed, it seems
2023-07-05 13:41:06 +02:00
Tobias Hunger
66cf903d70 janitor: Fix some typos in properties.rs 2023-07-04 20:04:28 +02:00
Olivier Goffart
5e5c0c4fb7 Fix timer corruption if a Timer ids Drop'ed in the event handler of another Timer
Fixes #3019
2023-07-04 10:54:33 +02:00
Olivier Goffart
530e6783ab
Fix crash when evaluating two_way_link too early
two_way_link shouldn't force the evaluation of the property
2023-06-30 17:06:29 +02:00
Guilhem Vallat
023d5a041d remove clippy::wrong_self_convention warnings 2023-06-30 12:28:13 +02:00
Guilhem Vallat
555e191ab4 remove clippy::needless_borrow warnings 2023-06-30 12:28:13 +02:00
Guilhem Vallat
a8f5ce3cc8 remove clippy::collapsible_else_if warnings 2023-06-30 12:28:13 +02:00
Guilhem Vallat
d27e0a4852 micro-optim ItemRc::component() returns a ref instead of cloning 2023-06-29 12:38:54 +02:00
Olivier Goffart
7a88dba2e7 Add clear-selection() to all our input fields 2023-06-28 17:07:55 +02:00
Tobias Hunger
4ab19f3011 Incorporate feedback from code review 2023-06-28 14:22:30 +02:00
Tobias Hunger
e81a3d40f0 Get rid of more clippy warnings
* Configure clippy to not report about type complexity until *much*
  later
* Configure clippy to only complain about more than 10 function
  arguments
* Properly format safety sections
* Allow unnecessary main functions in doctests in the slint API crate
* AccessKit: Move big block of code before if condition
2023-06-28 14:22:30 +02:00
Tobias Hunger
e02c360000 Clippy polish 2023-06-28 14:22:30 +02:00
Olivier Goffart
a0dd643d83
TextEdit: Discard the preedit when focus change or other text is enter (#3000)
Otherwise we end up with outdated pre-edit data if we change focus while
editing.

Note: Qt doas actually send a "commit" event when the focus change
(but of course that does not happen when changing the focus within
slint)
But firefox does discard the preedit when loosing the focus.

CC #1925
2023-06-28 12:01:41 +02:00
Olivier Goffart
e4bf8ca9d4 Add an assert in the software renderer if the buffer is too small
So it panics early instead of panicking deep in the renderer when trying
to draw outside of the buffer

Fixes #2027
Replaces #2973
cc: #2957
2023-06-27 14:34:13 +02:00
ogoffart
c8c9496722 Bump version number to 1.1.1 2023-06-26 12:50:02 +00:00
Olivier Goffart
9b59036816 Add licenses symlinks 2023-06-26 13:12:29 +02:00
Simon Hausmann
d1daa8dbe4 doc: Document coordinate system expectations for borrowed textures 2023-06-26 12:49:22 +02:00
Olivier Goffart
8cf57badbf swrenderer: basic text selection 2023-06-22 23:20:49 +02:00
Simon Hausmann
aa41277df1 Improve safety notes on the slint::Image texture import functions
Elaborate how to call this function safely, and copy the same description to the C++ docs.
2023-06-22 22:31:51 +02:00
Simon Hausmann
279c143d31 Clarify request_redraw() docs in the WindowAdapter 2023-06-22 22:31:51 +02:00
Olivier Goffart
da83857a60 Remove embedded_graphics dependency from i-slint-core
This feature was never used.
2023-06-22 14:12:01 +02:00
Tobias Hunger
501024aa02 Fix: Handle AltGr on Windows
AltGr on windos sends a left control pressed followed by AltGr pressed
on both winit and Qt. On AltGr release it sends left control released
followed by AltGr released.

So unset left control on windows once AltGr is pressed to avoid treating
special characters entered via AltGr key combos to be treated as control
sequences -- leading to the input being ignored!

Also treat `Alt-Ctlr-X` as `AltGr-X` on windows.

Fixes: #2933
2023-06-21 21:03:50 +02:00
Olivier Goffart
31fc7cdd08 Janitor: Some dependencies update 2023-06-21 17:24:57 +02:00
Olivier Goffart
613992d0dc LSP: fix errors or panic when exiting
Two problem:
 1. we were calling quit_event_loop from another thread, which didn't
    work with winit
 2. we need to ignore error from the lsp-server when shutdown as it may
    result in https://github.com/slint-ui/slint-cpp-template/issues/15

Closes https://github.com/slint-ui/slint-cpp-template/issues/15
2023-06-21 16:34:16 +02:00
Simon Hausmann
c81a3f7b64 Remove yeslogic-fontconfig dependency
We need only 9 different functions from fontconfig and one data
structure.  We can do that interaction with libloading by hand and avoid
causing issues like servo/font-kit#212
2023-06-21 12:13:18 +02:00
Simon Hausmann
ab0e38c76d
Merge absolute-x and absolute-y "virtual" properties into absolute-position (#2942)
The type of thep property is `Point`, which existed before. It was
mapped to `slint::private_unstable_api::re_exports::Point` (euclid) and
is now mapped to slint::LogicalPosition (also in C++).
2023-06-21 08:17:57 +02:00
Olivier Goffart
08e20c8586 Don't emit clicked when the pointer did not press the area
eg: releasing the pointer over a button that wasn't pressed shouldn't
click it

Fixes #2918
2023-06-20 16:06:12 +02:00
Olivier Goffart
bf8bbeda40 Take self by value in JoinHandle::abort 2023-06-20 11:36:36 +02:00
Simon Hausmann
a13ad77820 Fix rendering of spawn_local example in the docs
Remove leading triple-slash (and added trailing closing fence, although it also works without).
2023-06-20 08:24:59 +02:00
Simon Hausmann
a84aa70cd0 Fix rendering of scale SVGs
Commit c8f1f4354b accidentally inverted
the target size computation logic when porting away from FitTo, scaling
to the tree width instead of scaling the tree width to the image element
width but preserving aspect ratio.

Fixes rendering of AboutSlint in gallery.
2023-06-19 22:39:39 +02:00
Simon Hausmann
653b63a35e Port to resvg 0.34 2023-06-18 08:58:09 +02:00
Simon Hausmann
c8f1f4354b Port to resvg 0.33 2023-06-18 08:58:09 +02:00
Olivier Goffart
11dea135f7 Domain: slint-ui.com -> slint.dev 2023-06-16 10:55:08 +02:00
Tobias Hunger
04d1229685 Fix licnese information using xtask 2023-06-16 09:14:20 +02:00
Olivier Goffart
99ab5e78d4 Implement a way to run future on the slint event loop
Closes #747
2023-06-16 08:35:19 +02:00
ogoffart
641cab0e75 Bump version number to 1.1.0 2023-06-15 16:01:28 +00:00
Aurindam Jana
039e54a5de
Add royalty free license to files except examples and docs (#2888) 2023-06-15 11:20:50 +02:00
Olivier Goffart
4dd10f4a78 Make WindowAdaptor::request_redraw public 2023-06-13 20:29:52 +02:00
Olivier Goffart
ff6653c77e Hide the renderer() function from the public API 2023-06-13 17:44:04 +02:00
Olivier Goffart
0e31f097a4 Un-seal the WindowAdapter trait 2023-06-13 17:44:04 +02:00
Olivier Goffart
23b910725f Rename WindowAdapterSealed to WindowAdapterInternal 2023-06-13 17:44:04 +02:00
Olivier Goffart
f4dba7bcfd Seal the Renderer trait
Because we need to make the Render trait public so one can re-implement
the WindowAdapter trait
2023-06-13 17:44:04 +02:00
Olivier Goffart
6341769cbd WindowAdaptor: move a few function to the public trait
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
2023-06-13 17:44:04 +02:00