Commit graph

2815 commits

Author SHA1 Message Date
Olivier Goffart
5c69db596a
Split the software renderer in its own crate: i-slint-renderer-software (#10229)
The goal is to be able to enable feature conditionally with `i-slint-renderer-software/?...`

NOTE: this change the implementation of
`SceneBuilder::platform_text_fill_brush/platform_text_stroke_brush`
It was warning about `non_exhaustive_omitted_patterns`.
And it changed it to always return the brush color so gradient gets
converted to plain color instead of None.
This is the behavior with the non-parley renderer
2025-12-09 14:17:05 +01:00
autofix-ci[bot]
590c9b7864 [autofix.ci] apply automated fixes
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-12-09 12:11:04 +01:00
David Faure
29e289fbdf Move the workspace to rust edition 2024
Motivation: the git pre-commit hook is confused by the mix of 2021 and
2024 in the same workspace...

The only problem this raises is the std::env::set_var("LANGUAGE", lang) in
demos/printerdemo/rust/lib.rs, pre-existing but now explicitly marked as unsafe
because it actually is. Added a TODO there.
2025-12-09 12:11:04 +01:00
Olivier Goffart
c63733f61d
C++: Fix warnings after edition 2024 move that were not catched by CI
(About unsafe in unsafe functions)
This also replace some gratuitous `NonNull::new_unchecked` with the safe
`NonNull::new`.
2025-12-09 11:51:31 +01:00
autofix-ci[bot]
52459ffb4e [autofix.ci] apply automated fixes 2025-12-09 09:33:17 +01:00
David Faure
2faf91f04c api/cpp: switch to edition 2024 2025-12-09 09:33:17 +01:00
dependabot[bot]
78ef8e224c
build(deps): bump the npm-patch-updates group with 13 updates (#10225) 2025-12-08 09:21:19 +02:00
Simon Hausmann
ffee1e01fb
C++: Enable support for the Slint software renderer by default (#10217)
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 is in line with Rust.
2025-12-05 22:27:54 +01:00
David Faure
41be30ee6a Port from vec![] to Vec::new()
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
vec![] expands to Vec::new(), but expanding macros takes a bit of
time and takes memory in rust-analyzer. Also, the code was using a mix
of vec![] and Vec::new(), so this is more consistent.
2025-12-05 16:53:45 +01:00
Joshua Goins
d5a515d944 C++: Fix NativeWindowHandle Win32 API being available on Linux
This seems just be a typo, I think it's supposed check if _WIN32 *or*
_WIN64 is defined. Before compilation for Linux could easily pass
through because it doesn't have _WIN64 defined.

Shouldn't have any adverse affects since this was never going to work on
Linux in the first place.
2025-12-05 16:52:28 +01:00
Olivier Goffart
80750b37ab Update Corrosion 2025-12-05 14:37:51 +01:00
Olivier Goffart
4b9017e513 translations: set the translation dirty when setting the translator 2025-12-05 09:56:13 +01:00
Olivier Goffart
3b0252dfbc Remove undeeded file for re-use complience
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-12-04 21:58:09 +01:00
Olivier Goffart
84759dc02b Fix html-like comments to be on two lines 2025-12-04 21:58:09 +01:00
Olivier Goffart
88697c68bb Remove license header from .md/.mdx files
They should be in the lines, but the problem is that this causes issues
in the .mdx files.

License header doesn't really make sense for .md files anyway
2025-12-04 21:58:09 +01:00
Simon Hausmann
b76bd8e6e7 C++: Fix build against Yocto SDKs
When using `. environment-setup-*` against a Yocto SDK, we end up with PKG_CONFIG_PATH set to the target sysroot and the pkg-config binary coming out of Yocto SDK and always locating packages in the target.

That means the build of slint-compiler fails as it needs font-config from the host system, when enabling support for embedding glyphs.

In this scenario, enable the compiler/fontique to dlopen fontconfig instead.
2025-12-02 16:02:21 +01:00
Ashley
710f0c1968
Styled Text: add a macro and functions for parsing markdown (#10060)
* Add markdown macro and parse/escape functions

* Markdown stuff

* Implement escape markdown, handle trailing literal sections

* add StyledText Type and Value

* Implement more things

* [autofix.ci] apply automated fixes

* Rename MarkdownText to StyledText

* Add comments and solve warnings

* Apply automated fixes

* Fill out styled text type

* Change rendertext trait to use enum

* Add allow missing docs to stuff

* Fix testing backend thing

* Move test

* Don't use std:: for certain types

* Fix api/node

* [autofix.ci] apply automated fixes

* Rename to StyledTextItem

* Ignore styledtext in cpp for now

* Remove whitespace change

* Add tests, cpp generator changes

* Add markdown interpolation tests

* Add more tests, some fixes

* Implement some StyledText things

* Fix sharedparley imports

* Manually implement StyledText cpp type

* [autofix.ci] apply automated fixes

* Fix escape and parse markdown functions

* [autofix.ci] apply automated fixes

* Add ignore pyi, documentation for cpp styled text

* Apply some suggestions

* [autofix.ci] apply automated fixes

* Add cpp functions for styled text

* [autofix.ci] apply automated fixes

* Add documentation

* Fix api exports

* class -> struct

* Gate exports behind shared-parley

* [autofix.ci] apply automated fixes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2025-12-01 22:58:56 +13:00
Simon Hausmann
d903afecef Python: Fix tests in the CI having difficulties connecting to Xvfb
Instead of connecting to the X server, let's run the Python tests with the testing backend, like we do for test-driver-rust, test-driver-cpp, etc.

When building the Python package, pass --features backend-testing to Cargo, to forward to enabling the backend-testing feature in i-slint-backend-selector. That consequently enables SLINT_BACKEND=testing.
2025-11-30 10:02:36 +01:00
Olivier Goffart
59307db44b Fix warning about redundant explicit link target
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
Since the 2024 edition, Future is in the prelude
2025-11-27 17:07:35 +01:00
Olivier Goffart
b3470206ff Reformat after edition change 2025-11-27 17:07:35 +01:00
burhankhanzada
ef9d5d5c0c docs: Update language mod docs line. 2025-11-26 15:38:03 +01:00
burhankhanzada
3ab76828fc docs: Clarify language module as containing built-in Slint types and add slint_doc attribute. 2025-11-26 15:38:03 +01:00
burhankhanzada
f9dfde1171 refactor: move ColorScheme to the new slint::language module 2025-11-26 15:38:03 +01:00
Simon Hausmann
16a96399b5 Python: Unpin ty type checker version
Match the name of the argument to please the type checker.
2025-11-26 11:30:10 +01:00
Olivier Goffart
59de54a1e4 Translations: allow to opt out of default context
Fixes #9955
2025-11-26 11:11:07 +01:00
YuxuanYan
7bad0c4828
Error message for using a python callback decorator on an async callback not being declared (#10152)
* Error message for using a python callback decorator on an async callback not being declared
2025-11-25 08:43:02 +01:00
Simon Hausmann
dbe2c59ce9 Python: Fix support for underscores in async callback decorators
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
Fixes #10024
2025-11-22 14:03:42 +01:00
Joshua Goins
571e5497bb Fix C++ examples for SharedPixelBuffer
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
Someone has been writing too much Rust! You can't put :: before a
template argument, and there were some leftovers of this in the
C++ documentation.
2025-11-21 23:39:46 +01:00
Ashley
e86119c1d9
Add StyledText type (#10122)
* Add StyledText type

* Move to styled-text.rs

* Apply suggestions

* Don't gate around experimental-rich-text feature

* Gate pulldown_cmark behind std

* [autofix.ci] apply automated fixes

* Make thiserror optional

* Make htmlparser optional

* Gate color-parsing feature

* [autofix.ci] apply automated fixes

* Change flags

* Change to pub(crate)

* [autofix.ci] apply automated fixes

* Better docs

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2025-11-22 03:06:50 +13:00
David Faure
804ca74c24 Move reordering of dialog buttons to the organize step
This repairs the feature of reordering buttons, which was
temporarily left out in the previous commit.
2025-11-21 14:45:55 +01:00
David Faure
8ae28adb6b GridLayout: introduce an Organize step to compute row/col
This allows to store the result into a different cache property
than the one that comes out of solve_grid_layout, which fixes
a binding loop when the text of a widget depends on its row or col
value.
2025-11-21 14:45:55 +01:00
David Faure
bf9031eeaa Lay out grids at runtime rather than at compile time
This includes support for row and col properties to be expressions
rather than just constants.
2025-11-21 14:45:55 +01:00
Simon Hausmann
feecce73ad Python: Speed up testing
Build editable builds as cargo debug builds, not release. This is faster
(because we don't need LTO) and in theory gives additional coverage to
debug asserts.
2025-11-21 09:48:42 +01:00
Olivier Goffart
75058cb230
Compiler: Remove Struct::rust_attributes and make it an error if @rust-attr(...) doesn't lex (#10118)
The `rust_attributes` in langtype::Struct is a bit wierd as it is only
used for rust code generation, yet is stored in every Struct.
Instead, read the `node` while doing code generation like we do in C++.

The previous code was ignoring the error lexing the code in the
attribute, and now we add a compile_error!
2025-11-20 22:41:51 +01:00
Simon Hausmann
f2dc010dbf Python: Speed up testing
Separate steps and remove nox, so that

1. We first set up the env and build slint **once**
2. We run the fast lint/ty/etc. checks
3. We run the python tests directly
2025-11-20 20:51:54 +01:00
Simon Hausmann
831e067f98 Python: Use ty instead of mypy
It has gotten pretty good and it's much faster than mypy.
2025-11-20 20:51:54 +01:00
Simon Hausmann
16ceb115a1
slint-compiler: Add support for generating Python stubs (#10123)
The generated file offers the following two pieces of functionality:

- Convenient front-end to slint.load_file() by loading the .slint file
  (replaces use of auto-loader)
- More importantly: Type information for exported properties, callbacks,
  functions, and globals

On loading, the previously generated API is compared to what's in the
.slint file and if the .slint file was changed in an incompatible way,
an exception is thrown.

A Python test driver is added which performs three steps with each test
case:

1. Generate python stubs and checks that they can be loaded with the
python interpreter and that `uv ty check` passes.
2. Extract expected python API out of pyi sections and compares them.
3. Appends any python code from python sections and runs them (this is
combined with step 1)

Fixes #4136
2025-11-20 17:17:01 +01:00
Nigel Breslaw
a119b714a5
Migrarte final api/node tests to Vitest (#10114) 2025-11-19 18:18:23 +02:00
Olivier Goffart
70e102e2eb Keep in sinc slint and slint-interpreter re-export
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-19 12:04:11 +01:00
Olivier Goffart
7eafcaffaa Polish slint::register_font_from_memory
- Make `FontHandle` opaque.
 - Avoid memory allocations
 - Reword documentation
 - Avoid indirection to i_slint_core (prevent documentation to be
   repeated)

ammends for https://github.com/slint-ui/slint/pull/9762
2025-11-19 12:04:11 +01:00
Nigel Breslaw
428aae87f6
Migrate api and compiler node/api tests (#10111) 2025-11-19 10:20:40 +02:00
Nigel Breslaw
7e690eb1fc
Migrate more api/node tests to Vitest (#10110)
Some checks are pending
autofix.ci / lint_typecheck (push) Waiting to run
autofix.ci / ci (push) Blocked by required conditions
autofix.ci / format_fix (push) Waiting to run
These are the simplest tests to convert. As of this PR 12 out of 58 tests have been migrated.
2025-11-18 21:58:06 +02:00
Simon Hausmann
c3b020eed8 compiler: Move Struct's node field into the name enum
That guarantees the symmetry that if a struct is user defined, we're guaranteed to have a syntax node.
2025-11-18 20:35:05 +01:00
Simon Hausmann
d2f294cf3d compiler: Remove unnecessary StructName::User checks
The node check covers this already.
2025-11-18 20:35:05 +01:00
Simon Hausmann
5cd505b9ac compiler: Change Struct::name to be an enum instead of a string
For the future Python generate, we need to know if a struct type is a
public Slint type, private perhaps, or custom. Instead of continuing
with string operations, an enum gives clarity what's what, and this also
emits removing some string matching to identify specific types.
2025-11-18 20:35:05 +01:00
Nigel Breslaw
942b737577
Introduce Vitest for api/node tests (#10107)
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
Currently Ava is used to unit test the api/node project.
Vitest is already used elsewhere in the monorepo, integrates well with 
Vite, is fast and automatically handles tests written in Typescript. 
Replacing Ava would simplify how Typescript tests are performed.

This PR introduces Vitest to the project, sets it up to match Ava 
(isolated process for each test) and ports just the window.spec.mts 
file.

Later PR's will port the rest.
2025-11-18 17:41:34 +02:00
Tasuku Suzuki
224a06af57
Gallery Example: Add i18n and dynamic font loading for WASM (#9762)
- Bundle translations for WASM/Android only (not for native builds)
- Load Noto Sans CJK fonts dynamically from GitHub at runtime
- Implement register_font_from_memory() with Result<FontHandle, RegisterFontError>
- Make API automatically available with std feature (no explicit feature flag needed)
- Export load_font_from_bytes() for WASM font loading from JavaScript
- Change from wasm_bindgen(start) to explicit main() call for better control

Fonts are loaded before app initialization to ensure proper CJK text
rendering across all major browsers without bundling font files.

Native builds load translations from lang/ directory at runtime.
WASM/Android builds bundle translations at compile time and detect
browser/system language automatically.

API is now available when std feature is enabled, since we always
have fontique with std. No need for experimental-register-font feature.
2025-11-17 14:00:39 +01:00
Simon Hausmann
f2579db32b C++: Update to Corrosion 0.6 beta to fix mingw-llvm builds
Replaces #10052
2025-11-17 09:14:47 +01:00
Joshua Goins
2d7d657a30 C++: Denote limitation compiling multiple .slint files in one namespace
Some checks are pending
autofix.ci / ci (push) Blocked by required conditions
autofix.ci / format_fix (push) Waiting to run
autofix.ci / lint_typecheck (push) Waiting to run
Coming from the QML world  it was normal to just throw a bunch of QML
files into a single CMake target without any thinking. But with Slint, I
encounter into strange symbol conflict issues and thinking this was a
bug in our compiler.

In reality this was actually an acceptable limitation (see #2909) which
is fine... but this wasn't isn't mentioned anywhere in the CMake
documentation - so I never knew about this or the solution. I added a
new cautionary warning to let future developers know that in case of
symbol conflicts, they need to separate files into their own namespaces.
2025-11-14 20:52:32 +01:00
Joshua Goins
4324c187e9 C++: Fix build generation failing when compiling multiple .slint files
If you try to pass multiple files into slint_target_sources, some
generators may complain with a strange error like this:

ninja: error: build.ninja:226: multiple rules generate slint_generated_dialog_1.cpp

The reason for this was how the macro worked (and CMake scoping rules.)
While putting together the list of .cpp files to generate - which is 1
by default but is user-configurable - we append a list called cpp_num.
However we don't *reset* this list variable, so in each foreach
iteration we kept appending a new .cpp file and thus telling CMake we
were generating "slint_generated_dialog_1.cpp" twice, in addition to
whatever other file you had. We don't hit this issue with the other
variables like translation_domain_prop because they're set on every
iteration.

The fix for this is simple though, we can just set the variable to
empty.
2025-11-14 20:50:34 +01:00