Commit graph

15583 commits

Author SHA1 Message Date
Simon Hausmann
23eace7a43 wgpu: Fix panic when obtaining current surface texture
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
When calling surface.get_current_text() to obtain the next texture to render into, we need to handle errors. Best attempt is to try again after a timeout, and for the other errors (Outdated, Lost, etc.) just try to re-configure the surface and try again as well.

Fixes #9941
2025-11-15 09:54:07 +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
Simon Hausmann
e5a91d0277 winit: Replace as_any() with trait upcasting
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-14 17:49:42 +01:00
Simon Hausmann
e727411002 femtovg: Implement webgl context loss and restore event handling
Handle it gracefully when the browser decides to take away our WebGL context.

Fixes #1088
2025-11-14 17:49:42 +01:00
Olivier Goffart
ba28b73245 Compiler: update to edition 2024 2025-11-14 16:10:46 +01:00
Olivier Goffart
a42fd636d7 Compiler: Reformat with edition 2024 2025-11-14 16:10:46 +01:00
Burhan Khanzada
52ecb84571
CI: Added servo example to main CI workflow (#10067)
* CI: Added servo example to main CI workflow

* CI: Make servo_example job only runs when file chanages in  examples/servo

* CI: Remove permissions
2025-11-14 15:02:21 +01:00
David Faure
ca492faf49 core: fix edition 2024 warnings with slint_debug_property enabled 2025-11-14 14:10:15 +01:00
Burhan Khanzada
a344d50149
servo: Mac and Android CI (#10064)
- Adeed Mac and Android CI
- Ignore exmaples/servo/Cargo.lock license
2025-11-14 13:23:25 +01:00
autofix-ci[bot]
4154f7e1cd [autofix.ci] apply automated fixes
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
2025-11-14 09:58:27 +01:00
Tasuku Suzuki
20e9c29b65 printerdemo_mcu: Make window resizable with minimum dimensions
Replace fixed width/height with min-width/min-height and set preferred dimensions to allow the window to be resized while maintaining a minimum size.
2025-11-14 09:58:27 +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
Simon Hausmann
be0aea7e8a core: Fix edition 2024 warnings 2025-11-13 15:59:32 +01:00
Simon Hausmann
3216d54aaa core: Switch to edition 2024 and just reformat
Warnings fixed in follow-up commit
2025-11-13 15:59:32 +01:00
Simon Hausmann
8cdbbd7bdc common: switch to 2024
No changes needed, just reformatting.
2025-11-13 15:59:32 +01:00
Simon Hausmann
7e2c4f37af const-field-offset: Switch to edition 2024
(no changes necessary)
2025-11-13 15:59:32 +01:00
Simon Hausmann
a6f94862cf vtable: Upgrade to edition 2024 2025-11-13 15:59:32 +01:00
David Faure
c5a4b99c5f
interpreter: improve "bad type" panic by adding property name (#10047) 2025-11-13 15:55:45 +01:00
Olivier Goffart
453d1bf7cf ChangeLog update 2025-11-13 15:48:43 +01:00
Manuel Plavsic
3668eeca86 Zed extension: Readd the check for slint-lsp to use the binary in PATH 2025-11-13 14:55:45 +01:00
Arnold Loubriat
4e466df420
Invert vertical slider direction (#10002)
Changelog: Inverted vertical slider direction 

Closes https://github.com/slint-ui/slint/issues/9932
2025-11-13 14:51:08 +01:00
Olivier Goffart
1e2c4b5060 LLR: split properties and callback arrays
The idea is that then we can map 1-to-1 with internal array in a
llr-based interpreter
2025-11-13 14:37:36 +01:00
autofix-ci[bot]
be41b91c81 [autofix.ci] apply automated fixes 2025-11-13 14:35:56 +01:00
Tobias Hunger
4dd82bd27a live-preview: Fix context menu on SpreadSheet
It should only pop up when explicitly requested by a
(left) mouse click on the row header.
2025-11-13 14:35:56 +01:00
Tobias Hunger
f716fe2e6d live-preview: Do not uselessly import components 2025-11-13 14:35:56 +01:00
Tobias Hunger
7f4a7fbbeb live-preview: Fix handling of struct and values when setting a tables
Before we assumed that there are either values in an array or structs
with more than one field. Fix that. This is basically the inverse of #9889.
2025-11-13 14:35:56 +01:00
Tobias Hunger
9ac541e4d0 live-preview: Improve handling of structs and arrays in "Simulation Data"
Do not treat structs with one value as simple values in the "Simulation Data" tab.

Arrays of structs were considered too complex and forced into
"JSON mode". That is not necessary, so do not do that.

Closes: #9889
2025-11-13 14:35:56 +01:00
Simon Hausmann
6be68fdc3d parley: Apply clipping to text input rendering
We lay out text for text inputs with text_overflow == Clip, so we should also render it like that.

Fixes #10055
2025-11-13 13:03:24 +01:00
Andreas Monitzer
6e08b62f1d
Virtual Keyboard Handling on iOS (#10020)
On iOS/winit, listen to keyboard show/hide/change notifications and scroll Flickables to keep the element in focus visible. (#9857)
2025-11-13 12:41:29 +01:00
Olivier Goffart
3f12bba817
zed: Fix the name of the slint-lsp binary on windows (#10057)
The .zip file don't contain any subdirectories

Fixes #9869
2025-11-13 12:28:02 +01:00
Murmele
c5c482f548
Checkbox: Add documentation and remove not required function (#10007)
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
* Iintialize tristate
* Control the check_box.check_state always using the set_check_state function
Reason: Otherwise the tristate is not handled properly
* Handle tristate directly in checkbox
* fix documentation
2025-11-13 10:24:34 +02:00
Olivier Goffart
e3da256584 LLR: A pass to remove unused properties from the LLR 2025-11-13 08:00:53 +01:00
Olivier Goffart
2edbc970c2 LLR: fix printing of invalid parent reference 2025-11-13 08:00:53 +01:00
Olivier Goffart
b134c08d29 LLR: remove unused parent_context 2025-11-13 08:00:53 +01:00
mccakit
ab398c4038 Update slint_models.h 2025-11-13 06:58:22 +01:00
Tasuku Suzuki
3d53701ffe mcu-board-support: Fix memory.x linker precedence for STM32H735G
Copy board-specific memory.x to OUT_DIR and add it to the linker search path. This ensures the STM32H735G board-specific memory.x takes precedence over any generic memory.x from dependencies like ft5336.

Fixes: #10035
2025-11-13 06:56:05 +01:00
Apollo-Roboto
20108fd74a no need for mut 2025-11-13 06:51:07 +01:00
Apollo-Roboto
e5e265e139 moved imports inside target cfg 2025-11-13 06:51:07 +01:00
Apollo-Roboto
d35e919172 updates with system changes 2025-11-13 06:51:07 +01:00
Apollo-Roboto
0050c4f24d winit muda uses window color scheme 2025-11-13 06:51:07 +01:00
David Faure
5a152c6783 compiler: don't allow the row property in a GridLayout's Row element
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-12 21:58:39 +01:00
David Faure
4595f116f4 testing: Modernize layout testcases
I kept seeing distracting warnings when working with these testcases,
and it's better to have good examples when writing new testcases.

I didn't touch the issue_*.slint regression tests, so those will
still be testing the old syntax.
2025-11-12 18:17:24 +01:00
David Faure
3d50bc2f69 testing: Rename testcases to ease debugging
Rename grid to grid_simple, otherwise
    cargo test -p test-driver-interpreter -- test_interpreter_layout_grid
runs multiple tests, no way to run only that one.

Same for nested_grid.slint given that there's a nested_grid_2.slint
2025-11-12 18:17:24 +01:00
David Faure
892d1d3762 testing: Add interpreter test for dialog button order
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
There was no such test yet, and my upcoming changes refactor how
and when this reordering happens.
2025-11-12 17:08:31 +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
Simon Hausmann
7605850706 ffmpeg: Use newer ffmpeg-next version 2025-11-12 15:49:54 +01:00
Simon Hausmann
a7f8717f53 testing: Permit tests to override the detected operating system
Co-Authored-By: Olivier Goffart <olivier.goffart@slint.dev>
2025-11-12 15:25:00 +01:00
Simon Hausmann
72c3e77524 layout: Use existing API to query operating system
This will get the order right for WASM builds :)

Co-Authored-By: Olivier Goffart <olivier.goffart@slint.dev>
2025-11-12 15:25:00 +01:00
Olivier Goffart
535a5b5dc3 LLR: don't use LocalMemberReference to initialize property binding
Because they could be aliases to global
2025-11-12 12:07:23 +01:00