Commit graph

962 commits

Author SHA1 Message Date
Simon Hausmann
a44da14857 doc: There are no experimental renders anymore
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-18 14:27:25 +01:00
Simon Hausmann
cc12315ed5 doc: Remove the experimental label from the LinuxKMS backend
It's been around for a while :-)
2025-12-18 09:22:43 +01:00
Olivier Goffart
fab522cd4b core: Move style_text module outside of API
... just re-export the `StyledText` type from public API

That way we can access StyledText internals from the renderer
2025-12-11 17:48:59 +01:00
David Faure
2c4028b3d2 Rename for consistency repeater_indexes => repeater_indices 2025-12-11 09:55:56 +01:00
Joshua Goins
f015cbe3ee C++: Expose raw window handle API
We had the raw_window_handle_06 feature and functions in Rust, but there
wasn't an easy way to do the same in C++. This is especially useful for
embedding windows (such as browsers, 3D views, etc.) or just wanting to
access the platform's handles for other reasons.

ChangeLog: It's now possible to access platform native window handles
from C++, like a HWND.
2025-12-10 10:34:55 +01:00
David Faure
b71878f36b Introduce Type::ArrayOfU16 for grid layout organized data
No point in stuffing u16 into f32 just to reuse an existing type.

OTOH ArrayOfU16 can be reused for other things than grid layout
organized data, so give it a more generic name than
GridLayoutOrganizedData (we should do the same for LayoutCache, at
least if we ever reuse the type for an additional purpose)
2025-12-10 09:47:23 +01:00
David Faure
45dfe28aa9 3 clippy fixes 2025-12-09 17:54:02 +01:00
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
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
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
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
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
Olivier Goffart
59de54a1e4 Translations: allow to opt out of default context
Fixes #9955
2025-11-26 11:11:07 +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
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
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
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
Tasuku Suzuki
f24ad34a03
Add support for CSS conic-gradient 'from <angle>' syntax (#9830)
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
* Add support for CSS conic-gradient 'from <angle>' syntax

Implement rotation support for conic gradients by adding the 'from <angle>'
syntax, which rotates the entire gradient by the specified angle.

- Add `from_angle` field to ConicGradient expression
- Parse 'from <angle>' syntax in compiler (defaults to 0deg when omitted)
- Normalize angles to 0-1 range (0.0 = 0°, 1.0 = 360°)
- Add `ConicGradientBrush::rotated_stops()` method that:
  * Applies rotation by adding from_angle to each stop position
  * Adds boundary stops at 0.0 and 1.0 with interpolated colors
  * Handles stops outside [0, 1] range for boundary interpolation
- Update all renderers (Skia, FemtoVG, Qt, Software) to use rotated_stops()

The rotation is applied at render time by the rotated_stops() method,
which ensures all renderers consistently handle the gradient rotation.

* Add screenshot to rotated conic gradient docs example

Wraps the rotated conic gradient example in CodeSnippetMD to automatically
generate and display a visual screenshot of the gradient rotation effect.
This makes it easier for users to understand how the 'from' parameter rotates
the gradient.

* Make ConicGradientBrush fields private

The from_angle and stops fields don't need to be pub since:
- Rust code in the same module can access them without pub
- C++ FFI access works through cbindgen-generated struct (C++ struct members are public by default)

* Optimize ConicGradientBrush::rotated_stops to avoid allocations

- Changed return type from Vec to SharedVector
- When from_angle is zero, returns a clone of internal SharedVector
  (only increments reference count instead of allocating new Vec)
- Removed break from duplicate position separation loop to handle
  all duplicate pairs, not just the first one
- Updated documentation to match actual implementation

* Remove automatic sorting in ConicGradientBrush::new() to match CSS spec

- CSS conic-gradient does not automatically sort color stops
- Stops are processed in the order specified by the user
- Changed boundary stop interpolation logic to use max_by/min_by
  instead of relying on sorted order
- This allows CSS-style hard transitions when stops are out of order

* Move conic gradient rotation processing to construction time

Major changes:
- ConicGradientBrush::new() now applies rotation and boundary stop
  processing immediately, instead of deferring to rotated_stops()
- Removed rotated_stops() method - backends now use stops() directly
- Changed to LinearGradientBrush pattern: store angle in first dummy stop
- Added angle() method to retrieve the stored angle
- Maintained #[repr(transparent)] by removing from_angle field
- All backends updated: rotated_stops() -> stops()
  - Qt backend
  - Skia renderer
  - femtovg renderer
  - Software renderer

C++ API changes:
- Added FFI function slint_conic_gradient_new() for C++ to call Rust's new()
- Updated make_conic_gradient() to call FFI function instead of manually
  constructing SharedVector
- Ensures C++-created gradients get full rotation processing

Benefits:
- Eliminates per-frame rotation calculations
- Reduces memory usage (no from_angle field)
- Consistent with LinearGradientBrush design
- C++ and Rust APIs now produce identical results

* Change ConicGradientBrush::new() from_angle parameter to use degrees

- Changed from_angle parameter from normalized form (0.0-1.0) to degrees
- Matches LinearGradientBrush API convention (angle in degrees)
- Updated internal conversion: from_angle / 360.0 for normalization
- Stores angle as-is in degrees in the first dummy stop
- FFI function slint_conic_gradient_new() passes degrees directly

Example usage:
  ConicGradientBrush::new(90.0, stops)  // 90 degrees
  LinearGradientBrush::new(90.0, stops) // 90 degrees (consistent)

* Fix ConicGradient color transformation methods to preserve angle

Changed brighter(), darker(), transparentize(), and with_alpha() methods
to clone and modify the gradient in-place instead of calling new().

- Clones the existing gradient (preserves angle and rotation)
- Modifies only color stops (skips first stop which contains angle)
- Avoids re-running expensive rotation processing
- Maintains the original angle information

Before: ConicGradientBrush::new(0.0, ...) // Lost angle information
After:  Clone + modify colors in-place     // Preserves angle

* Use premultiplied alpha interpolation for conic gradient colors

- Changed interpolate_color() to use premultiplied RGBA interpolation
- Updated signature to match Color::mix convention (&Color, factor)
- Added documentation explaining why we can't use Color::mix() here
  (Sass algorithm vs CSS gradient color interpolation)
- Reference: https://www.w3.org/TR/css-images-4/#color-interpolation

This ensures correct visual interpolation of semi-transparent colors
in gradient boundaries, following CSS gradient specification.

* Run rustfmt on conic gradient code

* Fix ConicGradientBrush edge cases and add comprehensive tests

- Handle stops that are all below 0.0 or all above 1.0
- Add default transparent gradient when no valid stops remain
- Add 7 unit tests covering basic functionality and edge cases

* Apply clippy suggestion: use retain() instead of filter().collect()

* Fix radial-gradient parsing to allow empty gradients

Allow @radial-gradient(circle) without color stops, fixing syntax test
regression from commit 820ae2b04.

The previous logic required a comma after 'circle', but it should only
error if there's something that is NOT a comma.

* Fix conic-gradient syntax test error markers

Update error markers to match actual compiler error positions.
The 'from 2' case produces two errors:
- One at the @conic-gradient expression level
- One at the literal '2' position

Auto-updated using SLINT_SYNTAX_TEST_UPDATE=1.

* Refactor ConicGradientBrush epsilon adjustment and update tests

- Move epsilon adjustment for first stop into rotation block
  (only needed when rotation is applied)
- Update property_view test to reflect boundary stops added by
  ConicGradientBrush::new()

* Update conic-gradient screenshot reference image

Update the reference screenshot to match the current rendering output.
The small pixel differences (1% different pixels, max color diff 3.46)
are due to minor rounding differences in the conic gradient implementation.

* Fix ConicGradientBrush C++ FFI to avoid C-linkage return type error

Refactored ConicGradientBrush construction to match LinearGradientBrush
pattern, fixing macOS Clang error about returning C++ types from extern "C"
functions.

Changes:
- Rust: Split ConicGradientBrush::new into simple construction + separate
  normalize_stops() and apply_rotation() methods
- Rust: Added FFI functions slint_conic_gradient_normalize_stops() and
  slint_conic_gradient_apply_rotation() that take pointers (no return value)
- C++: Construct SharedVector directly in make_conic_gradient(), then call
  Rust functions via pointer (matching LinearGradientBrush pattern)
- Optimized both methods to only copy when changes are needed

This resolves the macOS Clang error:
"'slint_conic_gradient_new' has C-linkage specified, but returns incomplete
type 'ConicGradientBrush' which could be incompatible with C"

The new approach maintains ABI compatibility while keeping complex gradient
processing logic in Rust.

* Fix C++ header generation to avoid GradientStop redefinition error

Resolves the macOS CI compilation error where GradientStop and
ConicGradientBrush were being defined in multiple headers
(slint_color_internal.h, slint_image_internal.h, and slint_brush_internal.h).

Changes:
- cbindgen.rs: Add ConicGradientBrush and FFI functions to slint_brush_internal.h include list
- cbindgen.rs: Add GradientStop, ConicGradientBrush, and FFI functions to exclude list for other headers
- slint_color.h: Add forward declaration for ConicGradientBrush
- slint_color.h: Add friend declaration for ConicGradientBrush to allow access to Color::inner

Root cause: After adding extern "C" functions in graphics/brush.rs,
cbindgen automatically detects and tries to include them in all headers
that use graphics/brush.rs as a source. The exclude list + filter logic
ensures these types only appear in slint_brush_internal.h.

This fixes the C++ compilation errors:
- "redefinition of 'GradientStop'"
- "ConicGradientBrush does not name a type"
- "Color::inner is private within this context"

* Prepare ConicGradientBrush FFI for Rust 2024 edition

Update FFI functions to use the new `#[unsafe(no_mangle)]` attribute
syntax and safe function signatures in preparation for Rust 2024 edition.

- Add `#![allow(unsafe_code)]` to graphics module for `#[unsafe(no_mangle)]`
- Add `#[cfg(feature = "ffi")]` to conditionally compile FFI functions
- Change from raw pointers to safe references (&mut)
- Remove manual null checks and unsafe blocks
2025-11-13 16:05:16 +01:00
mccakit
ab398c4038 Update slint_models.h 2025-11-13 06:58:22 +01:00
Ashley
e7ec065a90
Change color type to use f32 values internally (#9820)
* Change Color type to be f32 internally but no other changes

* Add missing clamp

* Add round function as we're not on MSRV 1.90+

* Prepare for being able to switch between u8s and f32s

* [autofix.ci] apply automated fixes

* Fix Display impl

* Add feature flag for 8-bit color values. Name to be bikeshed

* Fix brighter-darker test

* Update test screenshot

* Remove unused Float trait import

* Add cfg thing for not(cbindgen)

* Change Channel to float in cbindgen

* Change the cpp color type for uint8_t for now

* Opt cpp into 8-bit-color

* Switch feature around

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2025-11-13 04:21:14 +13: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
0700b833f0 C++ live preview: fix getting model in C++ from a defined array in slint
This fixes the printerdemo when using live-preview feature as the
main.cpp tries to load the printing queue from the existing model
2025-11-05 08:32:19 +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
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
Olivier Goffart
f07f9fcd70 C++: Fix crash when accessing C++ parent
C++ part of #3464
2025-10-28 20:25:24 +01:00
Burhan Khanzada
33ab76918f
Add Touch events in WindowEvent (#9858)
for #4352
2025-10-28 10:11:27 +01:00
Olivier Goffart
ad293efa4b Two ways binding to struct fields with C++ 2025-10-24 17:33:13 +02:00
ogoffart
cad0a8ea83 Bump version number to 1.15.0 2025-10-24 14:28:17 +00:00
Andreas Monitzer
eae027e936
Safe Area
Changelog: Added four new properties to the Window element for exposing the safe area to Slint and implement it for iOS.
Changelog: Adjust Android implementation of the window safe area to match the iOS implementation. This is a breaking change!

Fixes #9755
2025-10-24 12:24:45 +02:00
ogoffart
db7e383e33 Bump version number to 1.14.1 2025-10-22 13:17:31 +00:00
Ashley
4a2c334ef3
Very basic Rich Text Support (#9733)
* Add is_markdown property

* Add builtins.slint line

* Add parse_markdown function

* Formatting

* Add strikethrough

* Assume that end tags always match and don't contain any additional info

* Layout rich text

* Formatting

* Handle code blocks, hackily do indentation and list points

* Remove dbg!

* Apply a few suggestions

* Write unit tests

* Do a 3rd layer of bullet point indentation

* Test nested lists

* Add markdown text component

* Add a paragraph_from_text function

* Remove MarkdownText if SLINT_ENABLE_EXPERIMENTAL_FEATURES is not set

* Mark as experimental

* [autofix.ci] apply automated fixes

* Add cfg flag to test

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2025-10-16 09:26:43 +02:00
Simon Hausmann
b6d781fab0 esp-idf: add comment about purpose of linker script 2025-10-08 20:39:38 +02:00
Simon Hausmann
39b86d9482 esp-idf: Fix build with newer Rust toolchains
As per https://github.com/esp-rs/rust/issues/266, the inclusion of a linker script is required when using esp-println.
2025-10-08 20:39:38 +02:00
Simon Hausmann
9a4924fbbb wgpu: Added support for wgpu 27 with Skia
cc #9605
2025-10-06 19:10:31 +02:00
Simon Hausmann
c246d5c636
Rust: Bump MSRV to 1.88 (#9640)
As required by the upcoming WGPU 27 update
2025-10-06 16:02:25 +02:00
Ashley
241964d567
Change the Rotate item to a Transform that supports scaling (#9387)
* Add scale method to backends

* Rename Rotate to Transform

* Add scaling to Transform

* Fix tests

* Insert Transform if any of scale-x, scale-y or rotation-angle are set

* Add scaling to child_transform and handle events as a result

* Cargo fmt

* Femtovg clipping

* Fix femotovg clipping

* Add newline to actual_render.scale

* Cargo fmt tools/lsp changes

* Modify docs

* Change type to a float instead of percent and fix defaults

* Add note about software renderer

* Add basic event scaling test
2025-09-15 21:14:33 +12:00
ogoffart
f2aa4899db Bump version number to 1.14.0 2025-09-11 14:01:14 +00:00
ogoffart
09e397f3ba Bump version number to 1.13.1 2025-09-08 09:43:17 +00:00