Commit graph

477 commits

Author SHA1 Message Date
Olivier Goffart
dddfcf572d Fix const detection with two ways binding
The const detection for two way binding was not detecting change if one
of the property was set to a const value in a component using it.

This would cause the compiler to generate call set_content on one of the
property in a two way bindings, and later, the "const sentinel" be
present in the dependency list, causing crash.

To avoid segfault for similar bug in the future, added added an assert!
in the property system to detect that.

Fixes #2185
2023-02-07 10:27:37 +01:00
Olivier Goffart
7290049a17 Fix panic parsing invalid linear grandient
If the last position expression is invalid due to an unrelated error,
the code that tries to do the interpolation was panicking with the
message "The last should never be invalid". (Because it assumed that
invalid meant that it was not set, and we added a 100% for that last
one if it wasn't set. But if it is set and invalid, this would error.)
2023-01-27 13:56:48 +01:00
Olivier Goffart
7c55b9f925 Only apply the constraint to the parent with the new syntax
Also attempt to document it
2023-01-24 19:18:59 +01:00
Olivier Goffart
ee672d65f5 Fix panic when the binding loop is caused by accessing the same component twice
The component properties might be accessed through different paths so we
may still reach a case where we have to borrow something that is already
borrowed
2023-01-24 18:01:30 +01:00
Olivier Goffart
bc1afb6f8f Fix TabWidget::current-index bindings
The property set by the user was not kept because the binding went the
wrong way.

Also remove the undocumented (and equaly not working)
TabWidget::current-focused property from the public API.
The current-focused property is initialized by the tab.
2023-01-24 11:34:35 +01:00
Simon Hausmann
24dcef5fed
First stage of cleaning up the export handling of the slint root component (#2095)
We implicitly export the last component of a .slint file to the generator.
Issue a warning when that happens and suggest to export it explicitly.
2023-01-23 15:19:49 +01:00
Simon Hausmann
629c7ed80e Remove undocumented and dysfunctional PathLayout
This type is poorly implemented and not documented. Let's remove it for now.
It shall remain available in the git history in the event of a resurrection.
2023-01-21 13:10:19 +01:00
Olivier Goffart
4a086d7ed2 Always generate the native struct for exported struct
Fixes #594
2023-01-19 15:42:32 +01:00
Olivier Goffart
95e07ff4fe Fix two way binding to global getting the wrong value
We should not move the expression from a component to a global because
there is a two way binding

Fixes #2064
2023-01-18 14:07:32 +01:00
Olivier Goffart
279f399adf Don't forget elements with box-shadow error
There may still be reference to them. We may panic in later passes.

Fixes syntax/basic/box_shadow.slint test
2023-01-17 16:29:13 +01:00
Olivier Goffart
b55ec6894a Layouting: forward the implicit constraint from the children to the parent
Closes #783
2023-01-17 16:29:13 +01:00
Olivier Goffart
5fbf68a647 Compiler: use the empty type more often instead of the Rectangle
We have that type now, so it should be used when we don't really need a
rectangle
2023-01-10 22:23:53 +01:00
Simon Hausmann
c04bc00d34 Add initial support for rendering text in the screenshot test driver
This uses the approach discussed in Mattermost: The compiler understands
a SLINT_DEFAULT_FONT environment variable that can point to a path,
which overrides the fallback font that would otherwise come from the
system (and differ between test systems).
2023-01-09 14:12:33 +01:00
Olivier Goffart
dace899cc5 Pure function: make it a warning in legacy context instead of an error 2022-12-22 00:26:27 -08:00
Olivier Goffart
8fc7c2dafc Error when mixing purity in callback aliases
Also adjust the way we report error while infering to avoid double
reporting errors
2022-12-22 00:26:27 -08:00
Olivier Goffart
1cbd61145e WIP: pure qualifier for callback and functions 2022-12-22 00:26:27 -08:00
Olivier Goffart
8a09043e63 Properly remember the location of builtin member function call
So we can report an error if they are called in a pure context
2022-12-22 00:26:27 -08:00
Olivier Goffart
3dc560be06 Make source-clip-width/height defaults to the size of the image
And use that to compute the ratio

Whilte technically a breaking change, i don't think anyone rely on the
previous behavior.

Fixes #664
2022-12-20 08:42:47 -08:00
Olivier Goffart
69df22e2fb Update resvg dependencies 2022-12-18 08:49:19 -08:00
Olivier Goffart
57d2e99723 Fix panic when a PopupWindow is a children of an optimized element 2022-12-15 07:01:58 -08:00
Simon Hausmann
b38fe7c5f0 Clean up internal Exports struct
- Use deref instead of `.0` tuple access (looks neater)
- Provide a convenience find() function that also makes use of the sorting
2022-12-09 11:05:08 +01:00
Olivier Goffart
ed07cd825d Make functions private by default unless annotated with 'public' 2022-12-06 14:56:25 +01:00
Olivier Goffart
dfdbc942f6 Split Expression::CallbackReference and Expresison::FunctionReference 2022-12-06 14:56:25 +01:00
Olivier Goffart
4672e54f5e Compiler: make calling functions work 2022-12-06 14:56:25 +01:00
Olivier Goffart
fdf5d4c0dd Fix in/out/private property on global
This is technicly a breking change. But this is also a bug and it was only
allowed since 0.3.2, so it is probably fine.

The problem is that any property access to a global was considered as being
local.
Now, change that so that property access to a global object is no longer
local, and other components can't access private property anymore
2022-12-06 10:29:44 +01:00
Simon Hausmann
755cd66398 Revert "Prospective build fix for arm cross build" and "With Rust 1.64 we can use core:ffi types instead of depending on libc"
This reverts commit 000d95670b and commit
d764796e0c to fix arm cross build and
x86-64 linux.

Let's use the core::ffi types when fontconfig-sys switches to it.
2022-12-06 09:16:03 +01:00
Simon Hausmann
d764796e0c With Rust 1.64 we can use core:ffi types instead of depending on libc 2022-12-05 10:33:50 +01:00
Olivier Goffart
20bc567b6d Don't match builtin type purely on it's base type name
Make sure this is the actual builtin type we are looking at and not a
re-defined component

Doesn't work for ListView unfortunately because ListView is not a
builtin type

CC #861
2022-12-01 12:56:59 +01:00
Olivier Goffart
eee2a3d012 Fix two ways binding between globals
The previous code did not remove two ways binding that were between two
globals. Now we do the remove_aliases pass over the whole document at
once which allos to simplify aliases between globals.
2022-11-28 14:39:47 +01:00
Simon Hausmann
f2c5184bf2 Fix embedding of images referenced in globals
When doing builds that require image embedding (such as for WASM), it's crucial
to also visit the globals (after they've been collected) to catch all image references.
2022-11-24 15:04:25 +01:00
Simon Hausmann
d8a1f2cf01 Introduce a rem unit in the type system
This allows specifying font sizes relative to the Window's
default-font-size, similar to CSS rem.
2022-11-24 11:33:38 +01:00
Simon Hausmann
bddbd43fac Apply the default-font-family from the Style's StyleMetrics if available
This allows the style to provide a default font family.
2022-11-22 20:20:53 +01:00
Olivier Goffart
51933b99bb New syntax for transitions, within the state 2022-11-22 15:16:54 +01:00
Simon Hausmann
907b58161c Add support for invoking an init callback on component and element construction
This enables imperative code to be run. To be used sparingly :-)
2022-11-17 10:12:08 +01:00
Olivier Goffart
443a5f7657 Center element by default in their parent with the new syntax 2022-11-15 17:33:27 +01:00
Olivier Goffart
0318b52a4c remove alias pass: make sure to keep priority correctly
Fixes the bug that caused the TextEdit in the gallery to sometimes be
empty.

Generated default value without any priority means it should not be
taken against a real binding if set
2022-11-15 13:19:20 +01:00
Olivier Goffart
d2fdd161e9 Make sure that the Clip element created for a visible binding has an empty size
The `inject_element_as_repeated_element` will create width and height
binding that we should not have.

Fixes #1846
2022-11-14 12:46:46 +01:00
Olivier Goffart
6ab6ae63d4 input output property: fix semantic with two ways bindings 2022-11-11 13:02:53 +01:00
Olivier Goffart
5b44cc54d9 Don't generate a native setter for out property 2022-11-09 18:48:19 +01:00
Olivier Goffart
4556291e1a Compiler: move the image and font embedding behind a software-renderer flag
Limit the dependency tree of things like the interpreter or the C++ compiler that
doesn't support it anyway.
It is still enabled inconditionally in slint-build though
2022-11-09 12:56:44 +01:00
Olivier Goffart
ca616857b1 Workaround compiler bug with Rust 1.64 and aarch64 2022-11-07 12:50:09 +01:00
Olivier Goffart
be7bc66e6d Add a changelog and fix flacky change_sub_property_indirection test
The test was only failing in some cases with node because of the
inlining in the interpreter, and it depended in which order the property
were processed (they were in a hash)

A test property was added to also test the interpreter
2022-11-04 15:32:20 +01:00
Olivier Goffart
f4bd77461d Remove the check_aliases pass
The behavior has now changed, so no need for the warning

cc #1394
2022-11-04 15:32:20 +01:00
Olivier Goffart
425b477874 Always keep the binding of the right in a two way binding
When having a binding such as
```
  foo <=> bar
```
The default value will always be the value of `bar` regardless what's
the value of foo.

This change of behavior is the only one that makes sense bacause if we
are having repeater or if, this will be a problem. eg:
```
property <xxx> bar;
if (some_cndition) : SomeElement {
   foo <=> bar;
}
```
Then we can't possibly take the default value of foo for the value of
bar since it depends on the condition. (and it is even worse in case of
repeater)

This is a change of behevior, this is why the tests have changed. The
cse of tests/cases/bindings/* were already covered by a warning since
0.3.0 so that should be fine. But the warning did not trigger for
builtin property such as `visible`  (eg, input/visible_mouse test)

Also some internal two way bindings had to be reversed.

cc: #1394
2022-11-04 15:32:20 +01:00
Simon Hausmann
39121994ca Always set Window.default-font-size
Permit the style metrics to provide a `default-font-size` and bind that
to the `Window` if set. If not provided, then the backend can set a
`default-font-size`. By ensuring that the value is non-zero at run-time,
we can later introduce a rem unit that can act as factor relative to
this non-zero font size.
2022-11-03 17:15:44 +01:00
Olivier Goffart
2ceafc6392 New syntax: Make it an error to set the value of a builtin output property
With the old syntax, this becomes a warning
2022-11-01 12:51:45 +01:00
Simon Hausmann
65e4e7bf15 Bump resvg/usvg/tiny-skia dependencies 2022-11-01 10:44:33 +01:00
Olivier Goffart
f055afd2de New syntax: allow to create component without base 2022-10-26 18:09:57 +02:00
Olivier Goffart
28ae8f7bc4 Refactoring: split ElementType away from the types used as property type
These are two different concept, and it is confusing to keep them in the
same enum

We want to support component without any base element, and Void is
already used for global component, so do this refactoring before
2022-10-26 14:50:44 +02:00
Florian Blasius
c58c704f16
Change type of Window background from color to brush (#1755) 2022-10-21 16:17:22 +02:00