Commit graph

4255 commits

Author SHA1 Message Date
Simon Hausmann
ea0d0be032 slint-compiler: Fix fallback family handling for glyph embedding on Linux
Some checks are pending
autofix.ci / ci (push) Blocked by required conditions
autofix.ci / lint_typecheck (push) Waiting to run
autofix.ci / format_fix (push) Waiting to run
For macOS and Windows we've had hard-coded fallbacks, but none for Linux
after the fontconfig removal. So go through the same fallback families
as when using fontique regularly, and add emoji as parley tries that
within.

This fixes picking up glyphs such as "←→↵⌫".
2025-11-11 18:49:59 +01:00
Olivier Goffart
6b3ea3d7cc Fix font familly of component that inherit from PopupWindow with the material style
Some checks are pending
autofix.ci / format_fix (push) Waiting to run
autofix.ci / lint_typecheck (push) Waiting to run
autofix.ci / ci (push) Blocked by required conditions
Fixes #9866

The material style defines a `StyleMetrics.default-font-family` which is
meant to be applied to `Window` element if not set by the user.
But it was mistakely sometimes applied to PopupWindow

Consider this code:
```slint
component MyPopup inherits PopupWindow {
    Text { text: "Hello"; }
}

export component MainWindow inherits Window {
    my_popup := MyPopup { }
}
```

First, we would process MyPopup: `apply_default_property_from_style`
wouldn't do anything, but the `lower_popups` pass would replace its
root with a Window builtin.
Second, we would process MainWindow: `apply_default_property_from_style`
would see that my_popup is using the Window as a builtin and would apply
default window properties from style, which it shouldn't.

In fact, `apply_default_property_from_style` should only apply default
for elements that are directly using the builtin, not a component that
inherits from that builtin, as these property should have been already
set.
2025-11-11 17:17:54 +01:00
Simon Hausmann
ce4283e802 winit: Fix explicit renderer-femtovg-wgpu selection
When no graphics API is requested by the app, permit the selection to continue.
2025-11-11 16:50:58 +01:00
Simon Hausmann
e7313dd239 Skia: Update to the latest version of the Rust bindings
Some checks are pending
autofix.ci / format_fix (push) Waiting to run
autofix.ci / lint_typecheck (push) Waiting to run
autofix.ci / ci (push) Blocked by required conditions
For details, see https://github.com/rust-skia/rust-skia/releases/tag/0.90.0
2025-11-11 09:22:17 +01:00
Olivier Goffart
14ff32942c Fix unsoundess in ChangeTracker
Make sure to annotate the function with `'static` or it is possible that
the handler runs closure that reference dead objects
2025-11-10 17:51:23 +01:00
Ashley
dfbcbdaed2
Richtext: color handling (#9996)
* Use htmlparser

* Parse color values

* Cargo fmt

* Use imported Color

* Actually handle colors via overrides

* Check that the tags match

* Use color parsing feature

* Make htmlparser optional

* Error handling

* [autofix.ci] apply automated fixes

* debug_log!

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2025-11-11 01:05:44 +13:00
Ashley
5c6f07da64
Move named color & color literal parsing to slint common (#9981)
* Move color_parsing to common

* [autofix.ci] apply automated fixes

* Fixes

* Change how feature flags work

* Use std feature for common in compiler

* Add color-parsing feature instead

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2025-11-10 08:39:28 +00:00
David Faure
dcacddcae5
Fix typos in comments while reading the code (#10005)
Some checks are pending
autofix.ci / format_fix (push) Waiting to run
autofix.ci / lint_typecheck (push) Waiting to run
autofix.ci / ci (push) Blocked by required conditions
2025-11-10 08:12:07 +00:00
David Faure
5ad1d99a1c
Fix slint_debug_property build: missing '!' and debug_name var needed (#10004)
* must be format!() instead of format()

* line 1192 uses a debug_name local variable, which got removed

Amends commit e11015e7b3
("Two way binding with struct for the interpreter")
2025-11-10 08:11:37 +00:00
Olivier Goffart
289b595447
properties: a bit more type safety in the BindingCallable trait (#9997) 2025-11-07 16:34:46 +00:00
Simon Hausmann
e97361204c
Parley: cleanups (#9995)
* parley: Move the code for creating the ranged builders into a separate struct

This makes it easier to see what's needed for create the builders and reduces the lines of code for the layout function.

* parley: Move the parley::Layout building into LayoutWithoutLineBreaksBuilder

That way we can make sure that the text applied to the ranged_builder and the final layout is the same.

* parley: Separate creation of parley layouts from applying the line breaks and positioning

In the future, once fully separated, we can cache the layout without the line breaks.

* parley: Simplify LayoutWithoutLineBreaksBuilder::build

We only need the contexts within, so remove the argument.

* parley: Move pixel size computation into LayoutWithoutLineBreaksBuilder constructor

That's the only place where we need to compute it.

* parley: Reduce fields in LayoutOptions

Remove font_request and stroke, as that's only needed in LayoutWithoutLineBreaksBuilder, which is now passed into layout().

This is, again, in preparation of further separating the creation of the layouts (mainly shaping) and the line breaking and positioning.

* parley: Separate text layout steps further

With this PR, text layout is now split into three phrases:

1. Set up parley
2. Create paragraphs of text with formatting applied - stored in essentially a vec of parley layouts. This step includes shaping.
3. Apply line breaking to the layouts. This step includes glyph positioning.

* parley: Move selection handling into LayoutWithoutLineBreaksBuilder

It's only needed there, and only set from draw_text_input.

* parley: Move text wrap into LayoutWithoutLineBreaksBuilder

* parley: Move LayoutOptions creations right to the call where needed

* parley: In draw_text() initialize variables closes to their use-site

* parley: In draw_text_input() initialize variables closer to their use-site

This is done with the exceptions of opportunities for early returns, as those can then also avoid unnecessary property dependencies.

* parley: In text_size(), improve localty if variable declaration and use-site slightly

* parley: Improve variable locality in link_under_cursor

* parley: Improve variable locality in text_input_cursor_rect_for_byte_offset

* parley: Improve variable locality in text_input_byte_offset_for_position

* parley: Avoid unnecessary pixel_size computation in text_input_cursor_rect_for_byte_offset

* parley: Simplify cursor drawing code
2025-11-07 14:20:09 +00:00
Simon Hausmann
19975846f5 renderer: Remove the str slice from text_size()
Instead, hide access to the string behind a RenderString trait.

The objective in the future is to cache the layout, which means that we need to query the text and other properties only if the cache is dirty.
2025-11-07 12:41:52 +00:00
Simon Hausmann
e6f74960d4 text: Introduce char_size() in the renderer to simplify size computation for text input and text elements
To compute the logical size of a character we need less parameters and
properties than for an entire string.
2025-11-07 12:41:52 +00:00
Simon Hausmann
1b5713f25f parley: Create the font request for link_under_cursor inside the function 2025-11-07 12:41:52 +00:00
Simon Hausmann
fc54b48fdf parley: Create the font request for text_size inside shared parley code 2025-11-07 12:41:52 +00:00
Simon Hausmann
3a6d873c43 parley: Create the font request for draw_text_input inside shared parley code 2025-11-07 12:41:52 +00:00
Simon Hausmann
098af0843e parley: Create the font request for draw_text inside shared parley code 2025-11-07 12:41:52 +00:00
Simon Hausmann
ec6659a79a text: Separate FontRequest creation into a trait of its own
This is in preparation of moving the overall font request creation out
of the text items and renderers, mostly into the shared parley code.
2025-11-07 12:41:52 +00:00
Simon Hausmann
1c93acc701 renderer: Simplify text_input_cursor_rect_for_byte_offset 2025-11-07 12:41:52 +00:00
Simon Hausmann
c7b23077e3 renderer: Simplify text_input_byte_offset_for_position
Instead of letting each caller create the FontRequest in the same way, do it once in sharedparley.
2025-11-07 12:41:52 +00:00
Tasuku Suzuki
0db86509a8 Skia: Skip wgpu surface configuration when size is zero
During window initialization, Slint window properties (width/height)
are set incrementally, which can result in Surface::configure being
called with zero dimensions. This causes wgpu to panic with the error:
"Both Surface width and height must be non-zero."

This fix skips surface configuration when either dimension is zero,
following wgpu's recommendation to "wait to recreate the Surface
until the window has non-zero area."
2025-11-07 04:40:31 +00:00
npwoods
62d29b4879
Implementing font-family property on TextEdit control (#9846)
ChangeLog: Added `font-family` property on `TextEdit`
2025-11-06 11:24:39 +01:00
Arnold Loubriat
82dd83d29f
Implement increment, decrement and set-value accessibility actions on Slider (#9975)
Changelog: Implemented increment, decrement and set-value accessibility actions on Slider (#9975)
2025-11-06 11:13:35 +01:00
Andreas
7f21826607
Add support for FB Renderer Format DrmFourcc(BA24) in LinuxKMS
Some checks are pending
autofix.ci / format_fix (push) Waiting to run
autofix.ci / lint_typecheck (push) Waiting to run
autofix.ci / ci (push) Blocked by required conditions
As suggested in #9862 this PR adds support for FB Renderer Format DrmFourcc(BA24) in LinuxKMS.

Changelog: Added support for FB Renderer Format DrmFourcc(BA24) in LinuxKMS
Closes #9862
2025-11-05 19:50:32 +01:00
Simon Hausmann
2fa4db23de renderer: Remove the scale factor argument from the text functions
Instead of each caller obtaining the scale factor, the renderer can do that, too. This also eliminates the dependency to the scale factor where it's not needed, such as for the font metrics.
2025-11-05 16:28:35 +01:00
Katherine Whitlock
beb75c0465
Add path drawing to software renderer (#9894)
ChangeLog: Add path drawing to software renderer

CC #4178 

Note: this feature is not yet possible to enable as there is no public feature flag for it.
2025-11-05 15:19:30 +01:00
Olivier Goffart
184102a2dc Rust: Fix two way binding to different structs
Some checks are pending
autofix.ci / format_fix (push) Waiting to run
autofix.ci / lint_typecheck (push) Waiting to run
autofix.ci / ci (push) Blocked by required conditions
This line was added by mistake in a previous commit.

But the feature can't work for C++ and the interpreter for now because
they can't re-use the same binding.
It would also break for eust if there was another layer of two way
binding.
That's because `impl BindingCallable for TwoWayBindingWithMap` doesn't
(and can't) implement intercept_set_binding
2025-11-05 10:55:02 +01:00
Arnold Loubriat
6348dc4b19
Add the accessible-id property (#9940)
Changelog: Added the `accessible-id` property
2025-11-05 10:54:11 +01:00
Olivier Goffart
a8ef4a05e6
Saner codegen for debugging enum
The previous code would create many many lambda and if conditions which
would cause nesting to be way too high for big enums.

Also improve the C++ codegen for condition to use the ternary operator
when possible

Fixes #9954
2025-11-04 16:13:37 +01:00
Ashley
8a43b39f55
rich text: add an open-url function (#9936)
* Add an open-url function

* Add cpp implementation

* Add workspace dep

* Add core::open_url function

* Remove pub use webbrowser

* Put open_url behind a flag

* [autofix.ci] apply automated fixes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2025-11-05 04:10:19 +13:00
Anton Helwart
4ea3eab8f5 fix scrollbar jumping bug for qt style 2025-11-04 15:43:50 +01:00
Anton Helwart
27621da9f7 In ScrollView use a single property to save reference values on mousepress.
This change was suggested in PR 9696
2025-11-04 15:43:50 +01:00
Olivier Goffart
ad4eec2924 Native live preview: Forward the translation domain to fix translations
Some checks are pending
autofix.ci / format_fix (push) Waiting to run
autofix.ci / lint_typecheck (push) Waiting to run
autofix.ci / ci (push) Blocked by required conditions
CC #9942
2025-11-04 14:06:03 +01:00
Olivier Goffart
dbf9b2bb44 More optimization when the scale factor is constant
When compiled with a const scale factor, we don't want to register too
many dependencies to the scale factor.
2025-11-04 14:05:50 +01:00
Olivier Goffart
a235369efe C++: Remove unsafe keyword when it is not needed
No extra safety constraints that is not expressed in the type system
(eg, if they don't take any raw pointers)

Fix UB in slint_interpreter_value_to_array (The vector was already constructed in C++)
2025-11-04 14:05:30 +01:00
Nigel Breslaw
a31e944959
Download skia prebuilt binary for macos builds (#9943)
The comment says '...enabled here just so that we can make use of the 
pre-built Skia libraries.' however 'macos' wasn't an included target. 
Speeds up uncharted or initial runs.
2025-11-04 14:26:17 +02:00
npwoods
4124c9f102
Changing win32_set_window_redraw() to only be functional when the window is visible (#9937)
According to Stack Overflow (https://stackoverflow.com/questions/9248553/wm-setredraw-and-losing-z-order-focus) the default handling of `WM_SETREDRAW` has some weird behaviors for windows that are not visible.  This seems to be the case for Slint windows that are freshly created.

This should fix https://github.com/slint-ui/slint/issues/9921
2025-11-04 09:05:56 +01:00
Ashley
75ae80574a
MarkdownText: link color handling (#9905)
Some checks are pending
autofix.ci / format_fix (push) Waiting to run
autofix.ci / lint_typecheck (push) Waiting to run
autofix.ci / ci (push) Blocked by required conditions
* MarkdownText: link color handling

* Set color in link_under_cursor fn
2025-11-04 01:50:16 +13:00
Lance
bbd5d8554b
Add stroke-line-join for Path (#9912)
* Add `stroke-line-join` for `Path`
* Add `LineJoin` enum
* Add `stroke-line-join` property for `Path`
* Set line_join in Skia and FemtoVG renders
* Set pen_join_style in Qt backend
* Add example test case
* Docs: Add `stroke-line-join` property for `Path`
2025-11-03 10:25:04 +01:00
MAlba124
0bdb99d2c4
android: provide correct java path to check_javac_version (#9908) 2025-11-03 10:04:20 +01:00
Arnold Loubriat
2949410041 Add AccessibleRole.radio-button
Some checks are pending
autofix.ci / format_fix (push) Waiting to run
autofix.ci / lint_typecheck (push) Waiting to run
autofix.ci / ci (push) Blocked by required conditions
2025-11-03 10:24:30 +08:00
Arnold Loubriat
f4fc53b1fa Set toolkit name and version on AccessKit tree 2025-11-03 09:48:30 +08:00
Ashley
2bd5dc1356
Add a handle_links function to shared-parley (#9875)
Some checks failed
autofix.ci / format_fix (push) Has been cancelled
autofix.ci / lint_typecheck (push) Has been cancelled
autofix.ci / ci (push) Has been cancelled
* Add a handle_links function

* Handle input event

* Add cfg flags

* [autofix.ci] apply automated fixes

* Add click_link callback

* [autofix.ci] apply automated fixes

* Use binary search in handle_links

* Rename click_link to link_clicked

* Rename handle_link to link_under_cursor

* Handle is_touch

* Revert "Use binary search in handle_links"

This reverts commit b0216cc4f7.

* Use paragraph_by_y

* Rename from link_clicked to link-clicked

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2025-11-01 04:12:55 +13:00
Simon Hausmann
3ba646bead parley: Avoid unnecessary entry in font fallback list when the user didn't specify a font-family
Instead of always creating an array with fallbacks + 1 that's padded with SystemUi, create two arrays depending on the existence of a user-specified family.
2025-10-31 16:39:05 +08:00
Simon Hausmann
62f94eb1cf compiler: Fix font family fallback handling when embedding glyphs and the specified default font family could not be found in the system
Share the fallback to SansSerif/SystemUi across all the fontique/parley fallbacks and (most importantly for this fix) in embed_glyphs.rs set families on the query always as a list that ends up with the fallbacks, instead of just the family that could not be found.

Fixes #9879
2025-10-31 16:39:05 +08:00
Olivier Goffart
e97a1a53d8 compiler: refactor the function repeater_special_property 2025-10-31 09:13:04 +01:00
Olivier Goffart
71ff218b05 llr: Do not return a Result if one can't fail 2025-10-31 09:13:04 +01:00
Simon Hausmann
339a2e0e48 LinuxKMS: Report touch events as touch events to Slint
Some checks failed
CI / cpp_cmake (macos-14, 1.88) (push) Has been cancelled
CI / cpp_cmake (ubuntu-22.04, stable) (push) Has been cancelled
CI / cpp_cmake (windows-2022, nightly) (push) Has been cancelled
CI / mcu (stm32h735g, thumbv7em-none-eabihf) (push) Has been cancelled
CI / test-figma-inspector (push) Has been cancelled
CI / node_test (macos-14) (push) Has been cancelled
CI / node_test (ubuntu-22.04) (push) Has been cancelled
CI / node_test (windows-2022) (push) Has been cancelled
CI / python_test (macos-14) (push) Has been cancelled
CI / python_test (ubuntu-22.04) (push) Has been cancelled
CI / python_test (windows-2022) (push) Has been cancelled
CI / cpp_test_driver (macos-14) (push) Has been cancelled
CI / cpp_test_driver (ubuntu-22.04) (push) Has been cancelled
CI / cpp_test_driver (windows-2022) (push) Has been cancelled
CI / cpp_package_test (push) Has been cancelled
CI / vsce_build_test (push) Has been cancelled
CI / mcu (pico-st7789, thumbv6m-none-eabi) (push) Has been cancelled
CI / mcu (pico2-st7789, thumbv8m.main-none-eabihf) (push) Has been cancelled
CI / mcu-embassy (push) Has been cancelled
CI / ffi_32bit_build (push) Has been cancelled
CI / docs (push) Has been cancelled
CI / slintpad (push) Has been cancelled
CI / wasm_demo (push) Has been cancelled
CI / tree-sitter (push) Has been cancelled
CI / updater_test (0.3.0) (push) Has been cancelled
CI / fmt_test (push) Has been cancelled
CI / esp-idf-quick (push) Has been cancelled
CI / android (push) Has been cancelled
CI / miri (push) Has been cancelled
CI / material-components (push) Has been cancelled
cc #4352
2025-10-30 18:51:03 +08:00
Olivier Goffart
e34064e905 properties: fix setting properties via two way binding to struct fields
... when there are two level of indirection, as it is the case with the
interpreter as it tries to create mapping to Value as one first level of
indirection
2025-10-30 10:07:48 +01:00
Olivier Goffart
ad24046663 Some Fix in preparation to the edition 2024
I've just tried to compile some crate with the edition and fix the error
that can be done in a compatible way
2025-10-29 23:08:05 +01:00