Commit graph

1368 commits

Author SHA1 Message Date
Simon Hausmann
d48e7192d8 Provide a more idiomatic API for accessible_descendents
With just the Qt accessibility support, this is not impactful.
But with accesskit it'll be useful to avoid the intermediate vector of ItemRcs
and map directly to a different data structure.

Otherwise, this is a trade-off between the stack allocation of the recursion and
instead allocating the stack of pending itemrs
on the heap.
2023-06-13 11:20:30 +02:00
Olivier Goffart
5f84cd5a90 Change the return type of WindowAdapterSealed::position to be an Option 2023-06-12 19:25:33 +02:00
Olivier Goffart
facb471d9b Update a comment 2023-06-12 19:25:33 +02:00
Simon Hausmann
01b00d26eb Rust: Allocate the window adapter lazily
This will be needed for embedding - to avoid creating two window
adapters - and it will be needed for the API to allow creating a
component from an existing window.
2023-06-10 11:41:04 +02:00
Tobias Hunger
9c50da9bde
janitor: Fix a few typos 2023-06-08 18:12:52 +02:00
Simon Hausmann
c813e80b48 Fix rendering of links in data structures where docs are shared between C++ and Rust
- in SetRenderingNotifierError using a rustdoc link breaks the C++ docs. Using a qualified backtick'ed slint::Window works perfect with both.
- In TimerMode, the same track unfortunately doesn't work with a function,
  but we can use [`Foo::bar()`] to make the link work with rustdoc and myst-parser.
  The look isn't perfect in C++, the square brackets are visible.
2023-06-08 10:02:15 +02:00
Olivier Goffart
db6110f3a9 janitor: move the test closer to the code they test 2023-06-07 17:32:56 +02:00
Olivier Goffart
12e6b34e2d Translations: support for plurals 2023-06-07 10:34:34 +02:00
Simon Hausmann
0eab14139e Add convenience implementations of From for ModelRc from slices and arrays
Fixes #2787
2023-06-06 14:38:52 +02:00
Simon Hausmann
1bf05eae7c
Add support for absolute-x and absolute-y properties on any element (#2823)
Fixes #1691
2023-06-06 14:37:53 +02:00
Olivier Goffart
895c97a4df Don't use gettext on windows after all because it's broken, also on wasm
`https://github.com/Koka/gettext-rs/issues/12`
2023-06-05 16:34:59 +02:00
Olivier Goffart
57d41b44b5 Enable runtime translations from rust 2023-06-05 16:34:59 +02:00
Olivier Goffart
bbc50edd29 Make translation work in the viewer 2023-06-05 16:34:59 +02:00
Olivier Goffart
cf746ddf8d WIP: formatting implementation of translate in rust and C++ 2023-06-05 16:34:59 +02:00
Olivier Goffart
a3855f1bcb WIP: add a formatting function that works in the interpreter 2023-06-05 16:34:59 +02:00
Olivier Goffart
bef2e3617d Fix ListView panic when setting a new model
.. that has less items and the ListView is scrolled.

We should not have an offset that is higher than the current count
otherwise we're going to access invalid item in the model

Fix #2780
2023-06-05 15:52:06 +02:00
Simon Hausmann
f9ba8023d4 Fix read-only TextInput reporting input method access
When the TextInput item is read-only, it should not report availability
or any other status to the input method via the window adapter.

This also fixes the order of events when clicking on a TextInput: We
would send the ime position update request before enabling the ime,
because we set the focus _after_ setting the cursor pos.

Fixes #2812
2023-06-05 14:55:22 +02:00
Simon Hausmann
0f54b9599b Add support for manually closing PopupWindows
This patch adds a `close()` function that can be called to close a popup
window, and a `close-to-click` boolean that can be set to false to
disable the default behavior.
2023-06-02 18:07:49 +02:00
Olivier Goffart
f7e61fdd37 Fix transparentize to multiply by 1-factor
Also add `[[nodicard]]` in C++
2023-06-02 17:02:08 +02:00
Olivier Goffart
5599bd44e0 Remove Color::opaque
It is not a right name and i don't think it is a so common operation
2023-06-02 17:02:08 +02:00
Olivier Goffart
cb4ef70d33 Fixup tests and and compilation with no_std
The interpolation now rounds the value, so the test needs to be adjusted
by one unit
2023-06-02 17:02:08 +02:00
Olivier Goffart
4845241ebf Rename translucent to transparentize and mixed to mix 2023-06-02 17:02:08 +02:00
Arthur Araruna
64ad1ce357 Add some color and brush manipulation funcs (#2565)
The added functions enable mixing colors and manipulating the opacity
of colors and brushes.

They enable the behavior of some of the available functions from SASS and are
added for future use for adding the Adwaita style (future PR).
2023-06-02 17:02:08 +02:00
Simon Hausmann
a8fcb5acd6 Fix delayed docs preview not working
After commit 7df902b53c, the winit window
is not created when calling show() anymore but it's now created at
component creation time.  That means the event loop workaround removed
in 459f810bd8 is now needed at
construction time.

Since this is a winit and wasm specific issue, it's now dealt with in
the wasm interpreter implementation, by invoking the creation from the
event loop from there and returning a promise in the API.

This changes the API therefore: create() can only be called after the
event loop is running.
2023-06-01 16:51:12 +02:00
Simon Hausmann
c428601370
Add support for select-all(), cut(), copy() and paste() functions on text input elements (#2804)
In the compiler this is still very primitive, but an attempt to start a
generic interface. The basic assumption is that all item functions will
eventually need access to the window adapter and itemrc. Support for
additional arguments is still missing.

Also missing is support for the function access via rtti in the
interpreter, hence the hardcoding at the moment.
2023-06-01 16:04:53 +02:00
Simon Hausmann
e7320607a3 Remove BorrowedOpenGLTexture from the public API again and just provide a factory function in slint::Image 2023-06-01 15:56:55 +02:00
Simon Hausmann
084ff70079 C++: Improve reliability of comparison operator of slint::Image
Call into the Rust implementation, so that we have to maintain only one
implementation.
2023-06-01 15:56:55 +02:00
Simon Hausmann
eadfec64a3 Add support for importing OpenGL textures into Slint
This is the initial API for Slint to borrow OpenGL textures from the
application for rendering.
2023-06-01 15:56:55 +02:00
Simon Hausmann
e3e9131dc3
Fix panic when attempting to render window contents without a component (#2800)
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>
2023-06-01 12:40:01 +02:00
Simon Hausmann
6b8214c3f9 Add support for italic and bold text in the software renderer's bitmap font path
In the screenshot tests this works by setting SLINT_DEFAULT_FONT to
pointer to a directory, instead of a file. We then load all fonts in
that directory and consider their families the default unless a family
is specified. This way for "Noto Sans" a regular as well as an italic
version is registered in fontdb and returned in the list of font
fallback ids. embed_glyphs in the compiler then embeds those variants
and we find them at run-time.
2023-05-31 18:47:39 +02:00
Simon Hausmann
057493b3a9 Add support for italic text in the software renderer's vector font path
Centralize also fontdb::Query creation and family fallback handling in
sharedfontdb. This way SLINT_DEFAULT_FONT also works for the femtovg
renderer.
2023-05-31 18:47:39 +02:00
Simon Hausmann
3cf1b38a48 Add basic support for italic font face selection to Text and TextInput
This is implemented for FemtoVG, Skia, and Qt.
2023-05-31 18:47:39 +02:00
Simon Hausmann
439b0c09d8
Try to improve the documentation for ModelRc (#2791)
- Mention in the type mapping table as well as in ModelRc that ModelRc is also used for array struct fields.
- Use an itemized list for the different ways of constructing, with the from_slice variant being listed second.

cc #2787
2023-05-31 17:16:06 +02:00
Tobias Hunger
1eb8d2875b
Fix warnings in cargo doc output 2023-05-30 10:08:44 +02:00
Simon Hausmann
ed287c55fe Use shared fontdb in the compiler
This eliminates the copy of the fontconfig handling code.
2023-05-23 08:26:03 +02:00
Simon Hausmann
328cfc76b6 Move sharedfontdb from core to common
This way it is also accessible to the compiler.
2023-05-23 08:26:03 +02:00
Mehrbod Akhlaghpour
cf71ccbb21 Add support for serializing SharedVector and SharedString via serde 2023-05-22 12:42:36 +02:00
Simon Hausmann
fe4a434ce4 Remove the WindowAdapter from the renderer constructor
This allows disentangling the native window creation from the renderer
creation, which is rather ugly and complicated on the C++ side.
2023-05-21 14:40:43 +02:00
Olivier Goffart
dd5ef9993f
Platform: Add a Resized event and use that to convey the changes in size (#2759) 2023-05-21 12:12:30 +02:00
Simon Hausmann
846c48b81d Add public API to allow platforms to report the window scale factor
Add WindowEvent::ScaleFactorChanged and made set_scale_factor on
WindowInner private.

This achieves what #2486 tried to do, but using the clean platform
window event interface.
2023-05-19 17:06:38 +02:00
Simon Hausmann
afd85a9a0b Remove outdated comment
This is handled in fixup_text now.
2023-05-19 10:40:51 +02:00
Simon Hausmann
0c11408dc5 Cleanup in software renderer systemfonts implementation
Make the VectorFont struct lighter by not having a reference to the
fontdb, which is thread-local anyway.
2023-05-19 10:40:51 +02:00
Simon Hausmann
4970742f88 Fix support for text in SVGs
This feature was lost in the move of the image decoding to core.

Fixes #2646
2023-05-19 10:40:51 +02:00
Simon Hausmann
51dc58a70a Use the shared fontdb for the software renderer's systemfonts feature 2023-05-19 10:40:51 +02:00
Simon Hausmann
37a21ee13a Move the shared font database to core 2023-05-19 10:40:51 +02:00
Simon Hausmann
97129eb940 FemtoVG renderer: Separate the font database from the font cache
This is done in preparation for moving the database to core.
2023-05-19 10:40:51 +02:00
Simon Hausmann
aa005e76ec Unify fontdb versioning across all crates 2023-05-19 10:40:51 +02:00
Olivier Goffart
24d37751e8
Properly send exit event when two TouchArea are on top of eachother (#2745)
Fixes #2716

This also fix the elements/flickable test
But change the behavior that when flicking, the has-hover is not set
2023-05-17 19:38:03 +02:00
Olivier Goffart
a68df6eb70
WindowAdaptor: change the 3 ime call into one single ime request enum (#2747) 2023-05-17 17:50:19 +02:00
Florian Blasius
757a744123
Add screenshot test for TextInput (#2746)
* 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>
2023-05-17 15:43:43 +02:00