Commit graph

1488 commits

Author SHA1 Message Date
Olivier Goffart
c21064485e Compiler: Fix invalid code gen with return statements
Some checks are pending
CI / node_test (macos-14) (push) Blocked by required conditions
CI / node_test (ubuntu-22.04) (push) Blocked by required conditions
CI / node_test (windows-2022) (push) Blocked by required conditions
CI / python_test (macos-14) (push) Blocked by required conditions
CI / python_test (ubuntu-22.04) (push) Blocked by required conditions
CI / python_test (windows-2022) (push) Blocked by required conditions
CI / cpp_test_driver (macos-13) (push) Blocked by required conditions
CI / cpp_test_driver (ubuntu-22.04) (push) Blocked by required conditions
CI / cpp_test_driver (windows-2022) (push) Blocked by required conditions
CI / cpp_cmake (macos-14, 1.82) (push) Blocked by required conditions
CI / cpp_cmake (ubuntu-22.04, stable) (push) Blocked by required conditions
CI / cpp_cmake (windows-2022, nightly) (push) Blocked by required conditions
CI / cpp_package_test (push) Blocked by required conditions
CI / vsce_build_test (push) Blocked by required conditions
CI / mcu (pico-st7789, thumbv6m-none-eabi) (push) Blocked by required conditions
CI / mcu (pico2-st7789, thumbv8m.main-none-eabihf) (push) Blocked by required conditions
CI / mcu (stm32h735g, thumbv7em-none-eabihf) (push) Blocked by required conditions
CI / mcu-embassy (push) Blocked by required conditions
CI / ffi_32bit_build (push) Blocked by required conditions
CI / docs (push) Blocked by required conditions
CI / wasm (push) Blocked by required conditions
CI / wasm_demo (push) Blocked by required conditions
CI / tree-sitter (push) Blocked by required conditions
CI / build_and_test (ubuntu-22.04, nightly) (push) Blocked by required conditions
CI / updater_test (0.3.0) (push) Blocked by required conditions
CI / fmt_test (push) Blocked by required conditions
CI / esp-idf-quick (push) Blocked by required conditions
CI / android (push) Blocked by required conditions
CI / miri (push) Blocked by required conditions
CI / test-figma-inspector (push) Blocked by required conditions
Fixes #8723
2025-06-18 12:58:59 +02:00
Olivier Goffart
20061392cd
C++: Fix compilation of PopupWindow::show in changed callback
Some checks are pending
CI / ffi_32bit_build (push) Blocked by required conditions
CI / mcu (pico-st7789, thumbv6m-none-eabi) (push) Blocked by required conditions
CI / mcu (pico2-st7789, thumbv8m.main-none-eabihf) (push) Blocked by required conditions
CI / mcu (stm32h735g, thumbv7em-none-eabihf) (push) Blocked by required conditions
CI / android (push) Blocked by required conditions
CI / miri (push) Blocked by required conditions
CI / esp-idf-quick (push) Blocked by required conditions
CI / python_test (macos-14) (push) Blocked by required conditions
CI / node_test (windows-2022) (push) Blocked by required conditions
CI / files-changed (push) Waiting to run
CI / build_and_test (--exclude bevy-example, ubuntu-22.04, 1.82) (push) Blocked by required conditions
CI / build_and_test (--exclude ffmpeg --exclude gstreamer-player, --exclude bevy-example, windows-2022, 1.82) (push) Blocked by required conditions
CI / build_and_test (--exclude ffmpeg --exclude gstreamer-player, macos-14, stable) (push) Blocked by required conditions
CI / build_and_test (--exclude ffmpeg --exclude gstreamer-player, windows-2022, beta) (push) Blocked by required conditions
CI / build_and_test (--exclude ffmpeg --exclude gstreamer-player, windows-2022, stable) (push) Blocked by required conditions
CI / build_and_test (ubuntu-22.04, nightly) (push) Blocked by required conditions
CI / node_test (macos-14) (push) Blocked by required conditions
CI / node_test (ubuntu-22.04) (push) Blocked by required conditions
CI / python_test (ubuntu-22.04) (push) Blocked by required conditions
CI / python_test (windows-2022) (push) Blocked by required conditions
CI / cpp_test_driver (macos-13) (push) Blocked by required conditions
CI / cpp_test_driver (ubuntu-22.04) (push) Blocked by required conditions
CI / mcu-embassy (push) Blocked by required conditions
CI / cpp_test_driver (windows-2022) (push) Blocked by required conditions
CI / cpp_cmake (macos-14, 1.82) (push) Blocked by required conditions
CI / cpp_cmake (ubuntu-22.04, stable) (push) Blocked by required conditions
CI / cpp_cmake (windows-2022, nightly) (push) Blocked by required conditions
CI / cpp_package_test (push) Blocked by required conditions
CI / vsce_build_test (push) Blocked by required conditions
CI / test-figma-inspector (push) Blocked by required conditions
The window is dependent of an lambda `auto` parameter, so the `template` keyword is required in order to call show_popup

Fixes #8710
2025-06-16 23:25:24 +02:00
ogoffart
92f9f0e85d Bump version number to 1.12.1 2025-06-16 13:32:39 +00:00
Simon Hausmann
06a19e59ad
slint: Change Platform.os to return a new enum OperatingSystemType (#8679)
* slint: Change Platform.os to return a new enum OperatingSystemType

cc #8631
2025-06-12 14:25:16 +02:00
Olivier Goffart
c0cac46009 Add --generate-link-to-definition in the docs of all our published crate
This is a nice nightly rustdoc feature and we should make use of it
2025-06-06 21:47:36 +02:00
Olivier Goffart
7b4d2fd3d3 Renames after the API review
CC #8631
2025-06-06 12:31:50 +02:00
Simon Hausmann
114a7853b2 CI: Fix remaining lifetime annotation warnings
Amends de81fa1dba
2025-06-06 11:47:14 +02:00
Simon Hausmann
de81fa1dba CI: Fix build with nightly and -D warnings
Add life-time annotations as recommended by the compiler to clarify
the flow of life times of arguments to the output.
2025-06-06 11:38:50 +02:00
Tobias Hunger
93f72b8c99 core: Fix the component container
Some checks are pending
CI / build_and_test (ubuntu-22.04, nightly) (push) Blocked by required conditions
CI / node_test (macos-14) (push) Blocked by required conditions
CI / node_test (ubuntu-22.04) (push) Blocked by required conditions
CI / node_test (windows-2022) (push) Blocked by required conditions
CI / python_test (macos-14) (push) Blocked by required conditions
CI / python_test (ubuntu-22.04) (push) Blocked by required conditions
CI / python_test (windows-2022) (push) Blocked by required conditions
CI / cpp_test_driver (macos-13) (push) Blocked by required conditions
CI / cpp_test_driver (ubuntu-22.04) (push) Blocked by required conditions
CI / cpp_test_driver (windows-2022) (push) Blocked by required conditions
CI / cpp_cmake (macos-14, 1.82) (push) Blocked by required conditions
CI / cpp_cmake (ubuntu-22.04, stable) (push) Blocked by required conditions
CI / cpp_cmake (windows-2022, nightly) (push) Blocked by required conditions
CI / cpp_package_test (push) Blocked by required conditions
CI / vsce_build_test (push) Blocked by required conditions
CI / mcu (pico-st7789, thumbv6m-none-eabi) (push) Blocked by required conditions
CI / mcu (pico2-st7789, thumbv8m.main-none-eabihf) (push) Blocked by required conditions
CI / mcu (stm32h735g, thumbv7em-none-eabihf) (push) Blocked by required conditions
CI / mcu-embassy (push) Blocked by required conditions
CI / ffi_32bit_build (push) Blocked by required conditions
CI / docs (push) Blocked by required conditions
CI / wasm (push) Blocked by required conditions
CI / wasm_demo (push) Blocked by required conditions
CI / tree-sitter (push) Blocked by required conditions
CI / updater_test (0.3.0) (push) Blocked by required conditions
CI / fmt_test (push) Blocked by required conditions
CI / esp-idf-quick (push) Blocked by required conditions
CI / android (push) Blocked by required conditions
CI / miri (push) Blocked by required conditions
CI / test-figma-inspector (push) Blocked by required conditions
This fixes the contents of the `n`-th repeater inside the
`ComponentContainer` to also show up in the `n`-th repeater *after*
the `ComponentContainer`.

The ComponentContainer is lowered to a Comonent Container and a
dynamic tree node. The tree node is managed manually and I messed
up the repeater indices since there were no entries in the repeater
array for the embedded components. That mad things hard to keep
consistent as components get merged.

This chnages that: It lowers a Component Container to Something like this:

```slint
    ComponentContainer {
        if false: Emtpy {}
    }
```

This way the standard mechanismns make sure we have something to put into
the repeater list and that unscrews the indices, saving a bit of code along
the way.

The inserted repeated node is still marked as `is_component_placeholder`, so
that we can wire it up as needed.
2025-06-05 13:48:16 +02:00
Avery Townsend
8c4ccabf7d
Expose FocusReason to .slint as an argument in focus-event-changed and add focus-gained and focus-lost callbacks (#8569)
This exposes FocusReason to .slint, and adds it as an argument to focus-event-changed callback on FocusScope to close #8387. It also adds two new callbacks, focus-gained and focus-lost, which are identical to focus-event-changed but are only invoked on focus gain or loss respectively.

In addition to this, it removes the FocusEventReason::AccessKit variant, replacing it with the mouse variant to hopefully make AccessKit more compatible with any Slint code that will use FocusEventReason.

Finally, I added two tests based on focus_change_event.slint, one for testing the FocusEventReason argument and another for testing the new callbacks.

close #8387

ChangeLog: Added `focus-gained` and `focus-lost` callback to FocusScope.  Pass an `FocusReason` enum to the FocusScope callbacks
2025-06-04 09:51:26 +02:00
Olivier Goffart
db18f4e2e5 Change the new error that detects binding loop through the window into a warning
In 80de96488a (#3397) we introduced a new
error if we detect a binding loop from the Window geomerty to its layout.
But it looks like this causes a lot of error in existing project, so
make it a warning instead.

It will continue to be an error in the live preview as this will cause a
panic otherwise.

This commit also change the text of the error to include the actual
binding loop. I hope this makes it easier for users to see the loop and
help to fix it.
2025-06-02 19:01:47 +02:00
Olivier Goffart
505d22594d Path: use the Display instead of the Debug error for path
Still not perfect but a bit better than before
2025-06-02 18:19:44 +02:00
Olivier Goffart
12393e21bd
syntax_tests: allow to update tests, and don't use a regexp (#8589)
* syntax_tests: allow to "bless" tests, and don't use a regexp

A regexp was used at the beginning because I thought we would want to
allow error to contains things that were not predictable or that would
often change. But this is not the case¹. It is better to actually test
for the full error message

¹ well actually it was the case for path, but there is another substitution to 
 `📂` for the manifest directory

* syntax_tests: Bless the tests

* syntax_tests: Manual adjust after bless

Because there used to be comments on the same line of the message which
bless don't support

* Fix error message with path on windows

 - The debug implementation of path make double slash, that's not what
   we want to show the user
 - normalize paths to use `/` so the test passes
2025-06-02 16:47:33 +02:00
Tobias Hunger
ce8b42b3a1 live-preview: Get better basic values for the property editor 2025-06-02 13:28:25 +02:00
Olivier Goffart
dc915b1af3 C++: add asserts that we are in the main thread
Some checks are pending
CI / build_and_test (--exclude ffmpeg --exclude gstreamer-player, windows-2022, beta) (push) Blocked by required conditions
CI / build_and_test (--exclude ffmpeg --exclude gstreamer-player, windows-2022, stable) (push) Blocked by required conditions
CI / build_and_test (ubuntu-22.04, nightly) (push) Blocked by required conditions
CI / node_test (macos-14) (push) Blocked by required conditions
CI / node_test (ubuntu-22.04) (push) Blocked by required conditions
CI / node_test (windows-2022) (push) Blocked by required conditions
CI / python_test (macos-14) (push) Blocked by required conditions
CI / python_test (ubuntu-22.04) (push) Blocked by required conditions
CI / cpp_test_driver (macos-13) (push) Blocked by required conditions
CI / cpp_test_driver (ubuntu-22.04) (push) Blocked by required conditions
CI / cpp_test_driver (windows-2022) (push) Blocked by required conditions
CI / cpp_cmake (macos-14, 1.82) (push) Blocked by required conditions
CI / cpp_cmake (windows-2022, nightly) (push) Blocked by required conditions
CI / cpp_cmake (ubuntu-22.04, stable) (push) Blocked by required conditions
CI / cpp_package_test (push) Blocked by required conditions
CI / vsce_build_test (push) Blocked by required conditions
CI / mcu (pico2-st7789, thumbv8m.main-none-eabihf) (push) Blocked by required conditions
CI / mcu (stm32h735g, thumbv7em-none-eabihf) (push) Blocked by required conditions
CI / mcu-embassy (push) Blocked by required conditions
CI / ffi_32bit_build (push) Blocked by required conditions
CI / docs (push) Blocked by required conditions
CI / wasm (push) Blocked by required conditions
CI / wasm_demo (push) Blocked by required conditions
CI / tree-sitter (push) Blocked by required conditions
CI / updater_test (0.3.0) (push) Blocked by required conditions
CI / fmt_test (push) Blocked by required conditions
CI / esp-idf-quick (push) Blocked by required conditions
CI / android (push) Blocked by required conditions
CI / miri (push) Blocked by required conditions
CI / test-figma-inspector (push) Blocked by required conditions
- In the timer functions
 - in the generated getter/setters and callback invocation
2025-05-28 11:29:48 +02:00
Tobias Hunger
25c1085b50 compiler: Add a struct to hold a ChildrenInsertionPoint
I expect I will need to add something here to handle
indices on children and then a tuple might get unwieldy.
2025-05-27 10:49:26 +02:00
Avery Townsend
c41d4a4df3
Add FocusEventReason to FocusEvent and add a select all on keyboard focus for TextInput (#8523)
Closes #5992

Adds the enum FocusEventReason and makes it an argument for FocusEvent. This reason could eventually be exposed in Slint to solve #8387.

Using the focus reason tracking, I also added a select all on keyboard focus for TextInputs (except on macOS), which should close #5992.

ChangeLog: TextInput selects its content when focused with the keyboard on Windows and Linux
2025-05-27 07:56:13 +02:00
Avery Townsend
f7fa27b9b4
added mouse-drag property to ScrollView (#8512)
Closes #2260
2025-05-26 22:22:57 +02:00
Olivier Goffart
2f2116686f C++: forward declare explicitly to make the code more robust
We currently forward declare classes as we use them in functions.
But this breaks if classes with the same name were declared in the
parent namespace. As shown with this example

```C++
// Uncomment that line to make the code break
//struct SharedGlobals;

namespace ns {
    // Is that a forward declaration in `ns`?
    // Depends if it was declared before in the parent namespace
    void foo(struct SharedGlobals *x) {}

    // Actualy define ns::SharedGlobal
    struct SharedGlobals { int x; };

    int xyz() {
        SharedGlobals globals;
        foo(&globals);
    }
}
```

So make sure we forward-declare the classes properly to be more robust
and be able to include generated file with namespace after a file
without namespace

CC #2909
2025-05-26 18:32:09 +02:00
Olivier Goffart
c3021ff955 compiler: Fix materialize of absolute-position in timer callback
Noticed that while working on bug #8541
2025-05-26 15:44:11 +02:00
Olivier Goffart
f504064921 binding analytics: properly visit timer properties and callback
Fixes #8541
2025-05-26 15:44:11 +02:00
Tasuku Suzuki
83db461f63
Transition: Introduce in-out to allow writing symmetry animation (#8509) 2025-05-26 09:17:22 +02:00
Olivier Goffart
18c3ae53d2 Compiler: Fix generated invalid expressions in remove_return pass
... when the two branch of a if/else return, and one of the branch has
also non-terminator return in sub conditions

Fixes #8485
2025-05-23 12:28:57 +02:00
Tobias Hunger
447ee5de44 live-preview: Handle colors/brushes using palette names
Find color names/values defined in palettes in property bindings.

Make sure to not report those as code.

Do a lot more complex evaluation of color values "behind" the palette name
to get a useful value out for the palete name. This will e.g. follow the
true branch of conditions, handle Structs, struct field access and references to
globals when looking for the color value.
2025-05-21 16:28:03 +02:00
Tobias Hunger
63f7533dc9 compiler: Fix identifier normalization function
`__1` is a valid identifier, which we normalized to
`--1`, which is invalid.

This changes the nromalization function to leave a `_` in the first position.
2025-05-21 12:21:20 +02:00
Olivier Goffart
80de96488a Detect binding loops that applies to the Window itself
The Window geometry depends on its constraints, so its constraints
cannot depends on its geometry

This fixes Infinitely growing layout, and other panics

Fixes #3989
Fixes #2902
Fixes #8065
2025-05-21 10:33:02 +02:00
Olivier Goffart
fece71ebf0
Menus: make it possible to have items with different height
Can be usefull for separator
(Required for #8339)
2025-05-19 14:58:31 +02:00
Olivier Goffart
a33c598ea8 compiler: Fix compilation if SLINT_DEFAULT_STYLE.txt gets deleted
Fixes https://github.com/slint-ui/slint/issues/8445
2025-05-19 13:25:34 +02:00
omahs
74232eae8d
Fix typos (#8421) 2025-05-12 13:03:59 +02:00
Simon Hausmann
bd0a486da8 Clean up cfgs for Apple operating systems
Replace ios specific cfgs with "apple but not macOS", dubbed
ios_and_friends, so that we also cover iPadOS, etc.. What those have in
common is that they don't have user-resizable windows. (We might want to
add visionOs in the future)

Also, simplify a few macos or ios cfgs with just target_vendor =
"apple", for what applies to all the operating systems.
2025-05-09 20:54:47 +02:00
Olivier Goffart
e8012c70d0
Fix MenuBar on android
The ContextMenuArea on android intercepts clicks to trigger on long clicks
and this prevent the MenuBar's TouchArea to work properly

Fixes #8353
2025-05-09 08:58:12 +02:00
Olivier Goffart
31867fad61
compiler: Reject comparison on unsupported types
The compiler was accepting the comparison of types such as color, or
struct, and then later we'd get rust compilation error or interpreter
panic.

Example seen in the crash reporter:
`internal/interpreter/eval.rs:257:35`
```
unsupported Value::Brush(SolidColor(Color { red: 0, green: 0, blue: 0, alpha: 0 })) ≤ Value::Brush(SolidColor(Color { red: 255, green: 0, blue: 0, alpha: 255 }))
```

Note that some code hapenned to compile with rust or C++.
For example, comparison of bool, or anonymous struct (represented as
tuples), or color represeted as int)
So technically this is a breaking change.
But this should be fine as this was not working in the interpreter and
this is a bug fix.

ChangeLog: Slint compilation error for comparison of types that can't be
compared with less or greater operator.
2025-05-07 11:39:27 +02:00
Olivier Goffart
9289940371 Prospective panic fix in the rust generated code
From the v1.11.0 crash reporter:
There is a panic in
`target/x86_64-unknown-linux-gnu/release/build/slint-lsp-8494405be069a534/out/main.rs:115729:64`
```
called `Result::unwrap()` on an `Err` value: Other("Could not initialize any renderer for LinuxKMS <REDACTED: user-file-path> from Skia renderer: Error opening device <REDACTED: user-file-path>: No such file or directory (os error 2)\\nError from FemtoVG renderer: Error reading DRM resource handles: Permission denied (os error 13)\\nError from Software renderer: Error opening device <REDACTED: user-file-path>: No such file or directory (os error 2)\\nNo renderers configured.")
```

That line in the generated file is in
```
115728   │          fn window_adapter_impl (& self) -> sp :: Rc < dyn sp :: WindowAdapter > {
115729   │              sp :: Rc :: clone (self . window_adapter_ref () . unwrap ()) }
```

Relevant backtrace:
```
6	"core::result::unwrap_failed"
7	"slint_lsp::preview::ui::slint_generatedPreviewUi::PreviewUi::new"
8	"slint_lsp::preview::ui::create_ui"
```

So the theory is that user_init need the window for some reason.
(eg, could be needing the scale factor to conver sizes or some other
things that needs the window)
So make sure we do the test before calling user_init
2025-05-07 09:04:02 +02:00
Simon Hausmann
ac1233491d cupertino: Fix missing title in GroupBox widget
Regression from commit c931cc28ae, which removed the two-way binding.
2025-05-06 17:26:10 +02:00
Simon Hausmann
f983cf0b19 Add Platform.os as well as a rudimentary test 2025-05-06 13:06:27 +02:00
Simon Hausmann
904bc56e62 Introduce Platform.style-name
This replaces the previously hidden `StyleMetrics.style-name` that was only accessible for internal use.
2025-05-06 13:06:27 +02:00
Olivier Goffart
86978e9fc1
Rust generated: fix constant non-inlined global
We must take care that all access to property that we consider constant
in global are accessed after the global has been initialized.

So initialize the global before the properties.

Fixes #8375 , #8337
2025-05-05 18:55:19 +02:00
Montel Laurent
4cd6f92013
Hide action when widget is disabled
ChangeLog: TextEdit/LineEdit : disable context menu action when the widget is disabled or read-only
ChangeLog: Added ContextMenuArea::enabled
2025-05-02 13:20:46 +02:00
FloVanGH
c931cc28ae
ChangeLog: std-widgets: added content-padding to GroupBox (#8314)
* [autofix.ci] apply automated fixes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2025-05-02 07:11:52 +00:00
ogoffart
e0099ea500 Bump version number to 1.12.0 2025-04-30 13:27:50 +00:00
Bryce Happel Walton
769f85584d
Fix ScrollView scrollbar actions not triggering scrolled callback
Fixes #8170
2025-04-28 10:56:30 +02:00
Olivier Goffart
ff2e2e6731
Compiler: Fix changed callback on private global properties
The code would fail to compile because the property would not be seen as
used and would be removed, but not the change callback.

Fixes #8269

Also fix a segfault in the added test because it will initialize the
change callback (and therefore query the properties) because the
SharedGlobal structure is fully initialized.
So we must only initialize the change callback on global after the
SharedGlobal is fully initialized
2025-04-25 16:10:12 +02:00
Bryce Happel Walton
dedc5d31e2
Added Exp and Ln functions to Slint (#8226)
ChangeLog: Added Math.exp and Math.ln
2025-04-25 14:30:38 +02:00
Simon Hausmann
eb825f2e95 Support default-font-* properties in Live-Preview
... by changing the resolution for the `WindowItem` to traverse the
item tree from the current item, instead of going to the window.

This doesn't quite fix #4298 because `rem` resolution is still missing.
That requires the built-in default font size function to be fixed as
well, which is non-trivial.

cc #4298
2025-04-24 09:18:45 +02:00
Olivier Goffart
cc46811d95 Fix layout property set in when deriving components
The layout pass needs to see when going over the layout, that these
properties are set. So inline the element that sets these properties if
they are not set in the base.

Fixes #8091
2025-04-23 09:23:07 +02:00
Olivier Goffart
cedfefb1a2 Menubar: fix native menus
The condition was reversed

Fixes #8246
2025-04-23 07:29:14 +02:00
Olivier Goffart
cd8ab8ce53
Fix array index access at negative index
Conversion from negative float to unsigned is saturating to 0 in rust
and undefined behavior in C++, we should therefore handle the case
properly

Fixes #8222
2025-04-22 11:28:09 +02:00
U. Bruhin
a5ec77ac99
Allow trailing comma in import statements (#8223)
Adding support for (optional) trailing commas like this:

    import {
        Foo,
        Bar,
    } from "foobar.slint";

This way it's more convenient to keep component imports sorted and
leads to smaller diffs when adding more components to the end of the
import statement.

ChangeLog: Allow trailing comma in import statements

Closes #4922
2025-04-21 17:24:18 +02:00
Olivier Goffart
b77368f1b6
diagnostic: try to detect use of range expression and recommand to use number
Several users have been asking if it is possible to use range
expression.
Detect this and have a meaningful error message
2025-04-19 22:47:45 +02:00
Simon Hausmann
8761eaadeb
Move Palette.style-name to internal protected StyleMetrics.style-name (#8200)
This is only exposed when internal types are exposed (such as in the lsp).

The plan is to make this public under a new name/global after the release.

Co-authored-by: Olivier Goffart <olivier.goffart@slint.dev>
2025-04-19 10:20:52 +02:00