Commit graph

477 commits

Author SHA1 Message Date
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
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
Tobias Hunger
ce8b42b3a1 live-preview: Get better basic values for the property editor 2025-06-02 13:28:25 +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
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
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
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
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
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
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
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
Olivier Goffart
9058456fbf
live-preview: don't replace the native menu bar with the previewed one
Always use the non-native one for the previewed component
2025-04-17 17:12:23 +02:00
Joshua Goins
d1f2fef430
Menu: Add enabled property (#8145)
By default it's enabled, of course. This property is not only added to
MenuItem, but Menu as well - since they can be nested. It's also
possible to select a disabled item, but it's hard to modify that since
it's logic is written in Slint. You should be prevented from activating
it with a tap or key press at least.

See #7791
2025-04-15 08:08:11 +02:00
Tobias Hunger
7a1bc6f6d7 live-preview: Add gradient support to the property editor
Parse the gradient data from source code and pass it on to the
UI side to do its magic.

SQUASH ME
2025-04-11 13:34:18 +02:00
Tobias Hunger
9942afd183 SQUASH: Rework the element id to be a hash based on filename
and position iof the LBrace token.
2025-04-09 13:52:29 +02:00
Tobias Hunger
aaeb4a0df5 compiler: Add a DebugHook expression
You can not create this expression manually, but there
is a pass in the compiler that adds it to all set
properties in a compilation run.

All it does is basically associate an id with an expression,
so that we can then in a later step have the interpreter do
something with that information. Apart from that, it tries to
be as transparent as possible.

The LLR lowering removes that expression again, just so we can
be sure it does not end up in the generated live code.
2025-04-09 13:52:29 +02:00
Olivier Goffart
ca0c75bfe1 Menu: don't remove the title properties
Let further pass materialize them, and most likely remove them anyway.
That way, they can be properly set and read from the rest of the .slint
code.

Fixes #8080
2025-04-08 13:30:01 +02:00
Olivier Goffart
e5289af154 Introduce MenuSeparator
Fixes #7790
2025-04-02 11:50:45 +02:00
Olivier Goffart
fa650ed5ec Allow to have builtin item function to return a value
This does some refactoring to allow builtin item functions to return a
value:
 - builtin member functions are no longer BuiltinFunction, but they are
   just normal NamedReference
 - Move special case for them in the LLR/eval
2025-03-31 14:06:24 +02:00
Olivier Goffart
92e5cef55f
Deprecate alias to global callback and error out when setting such callback
Also properly error out when the number of arguments to a callback alias
is not correct

Fixes #7806
2025-03-24 15:17:20 +01:00
Olivier Goffart
286bdc9ce5
Interpreter: Fix panic when animating a % property
Should register the Type::Percent as animated

Also avoid duplicating the binding for both min and max, and just make
one use the other.

Fixes #7761
2025-03-24 14:54:08 +01:00
Olivier Goffart
4015288080 Compiler: fix const propagation in condition
We should simplify the false branch even if the true branch can't be
inlined

Fixes #7827
2025-03-21 18:00:34 +01:00
Olivier Goffart
70c7fd1b49 Fix @children next to Timer or PopupWindow
Fixes #7887
2025-03-21 15:58:55 +01:00
Olivier Goffart
51523e981f Compiler: Fix when one branch of a void condition is not void
Fix panic or warning in the generated code

Fixes #7864
2025-03-21 14:37:10 +01:00
Olivier Goffart
d63168d51b Fix change handler with callback
Don't merge a property with a global property if it has a change handler
as we can't mobe the change handler in the global
Fixes #7784

If two property are merged that each have a change handler, we must
merge the change handler. (Note that the order in which they are being
called is not deterministic)
Fixes #7747
2025-03-20 21:34:52 +01:00
Olivier Goffart
bcd8c5d7be Fix compiler warning with nightly rust
```
error: unused `ControlFlow` that must be used
   --> internal/compiler/passes/infer_aliases_types.rs:185:5
    |
185 |     recurse(&root, element, &mut scope);
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
```
2025-03-19 13:00:42 +01:00
Olivier Goffart
a3ab90d4fc compiler: Fix infinite recursion trying to inline function argument
We can't use `body.visit_recursive_mut` because it will recurse on the
newly replaced argument. Implement recursion manually instead.
2025-03-06 23:24:08 +01:00
Olivier Goffart
11accc190a Fix panic when inlining into clip during the second phase of inlining
During the second phase, anything that involve @children should already
have been processed, so there shouldn't be anything left to inline.
But the children insertion point may be pointing to the wrong location
if some items were moved around (eg because of the `clip`).
So work it around by not accessing the children array at that indax that
might be out of range.

Fixes #7724
2025-02-24 19:15:39 +01:00
Olivier Goffart
1a2aff8b57
Revert "compiler: inline components that are used only once" (#7697)
This reverts commit bf716ff8c5.
(And also revert the test part of 259756c0fd)

This exposed the bug #7693 and more issues mentined in
https://github.com/slint-ui/slint/issues/7693#issuecomment-2675077008

Fixes #7693
CC #7680
2025-02-21 19:11:11 +01:00
Olivier Goffart
39191e5acd
Menu API changes
`ContextMenu` -> `ContextMenuArea`

`ContextMenu` must have a `Menu` child.
`MenuItem` can no longer be put dirrectly in `MenuBar` and can no longer
have children
`Menu` is used now for sub menus
2025-02-21 16:03:47 +01:00
Alex Badics
337282373f compiler: add more complicated const propagation unit test 2025-02-21 11:16:00 +01:00
Alex Badics
7128097b94 compiler: add handling for < and > in const propagation 2025-02-21 11:16:00 +01:00
Alex Badics
848e54a9ac compiler: fix func constness propagation 2025-02-21 11:16:00 +01:00
Alex Badics
61df727c48 compiler: fix materialize_fake_properties change 2025-02-21 11:16:00 +01:00
Alex Badics
68dd67244b compiler: emit optimized fake properties for Images 2025-02-21 11:16:00 +01:00
Alex Badics
bf716ff8c5 compiler: inline components that are used only once 2025-02-21 11:16:00 +01:00
Alex Badics
259756c0fd compiler: don't inline repeater components
They don't need to be inlined, and a lot of the times inlining them incur
a significant overhead (e.g. in case of conditional complex components)
2025-02-21 11:16:00 +01:00
Alex Badics
65bcca1082 compiler: inline functions if possible 2025-02-21 11:16:00 +01:00
Alex Badics
38ddb4d2b7 compiler: improve return elimination 2025-02-21 11:16:00 +01:00
Alex Badics
c2e9fa9f66 compiler: enhance const propagation 2025-02-21 11:16:00 +01:00
Simon Hausmann
368ec3459b
Improve default accessibility of TextInput elements
Apply similar logic as to LineEdit and TextEdit, so that when folks build their own text input widgets, they're accessible by default. Also fixed the docs while at it to mention default applications.

Amends #7669
2025-02-20 13:44:16 +01:00
Olivier Goffart
1e814c9bdc
Stabilize the sdf-fonts feature
Enable the SDF feature by default in our compiler binaries

(Still disabled by default for other users because it takes up compile
time for something they probably don't need)
2025-02-19 21:24:53 +01:00
Arnold Loubriat
90c337f1d1
Add AccessibleRole::Image and use it in the AboutSlint widget (#7593)
* Add `AccessibleRole::Image`

* Improve accessibility of the `AboutSlint` widget

* Filter out some images from the accessibility tree
2025-02-18 09:43:53 +01:00