Commit graph

216 commits

Author SHA1 Message Date
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
Simon Hausmann
9180704d70 Warn about components that are neither used nor exported 2023-01-26 15:52:40 +01:00
Simon Hausmann
448b216bd8 Second stage of cleaning up the export handling of the slint root component
Commit 24dcef5fed added a warning for the
implicit export of last component. For 1.0, this commit makes it so that
the root component is determined by the last export in the file.
2023-01-26 15:52:40 +01:00
Olivier Goffart
5bb84c1d69 Remove deprecated Keys enum in slint language 2023-01-26 15:35:18 +01:00
Olivier Goffart
a0fb8bc771 Remove support of old SIXTYFPS_ env variable, and sixtyfps_widgets.60 2023-01-26 13:36:38 +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
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
8d7b8df922 Fix conversions of array literal containing struct with array literal
Fixes #2023
2023-01-02 23:53:22 +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
Simon Hausmann
554d153e35 Limit re-exporting of types
- Only allow one module re-export per file
- Warn when a re-exported type clashes with a locally exported type, and prioritize the local type.
2022-12-09 11:05:08 +01:00
Simon Hausmann
03fe599890 Add support for re-exporting modules
Use `export * from "somewhere.slint"` to avoid having to repeat all the
types of an existing module in order to re-export all of the types.
2022-12-09 11:05:08 +01:00
Olivier Goffart
3c5aeb5897 Test for binding loops involving functions 2022-12-06 14:56:25 +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
851a910e41 Parser: Parse functions 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
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
d468bbec05 ListView: Warn when we have other elements than just a for
This is not supported right now, the other elements will not be part of
the layout, and two `for` will be in the same listview, creating bad
situation with the scrollbar.

This is a warning since it would be a breaking change to make it an
error.

For example, we used a FocusScope in the StandardListView implementation so
I had to go trough one level of indirection

CC: #860
2022-11-30 11:17:22 +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
Olivier Goffart
395532cebd Forbid former transitions declaration with the new syntax 2022-11-22 15:16:54 +01:00
Simon Hausmann
59d3a69688
Fix support for multiple import statements from the same path (#1868)
Importing multiple types from the same file with multiple import statements would produce an error.
2022-11-21 15:37:38 +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
Simon Hausmann
7be00f6d60 Improve error message when a property declaration clashes with a callback
(also continue, don't allow the declaration to proceed)
2022-11-16 09:46:40 +01:00
Simon Hausmann
e6bd9dc8c4 Improve error message when a callback clashes with a property
(also continue, don't declare the the callback anyway)
2022-11-16 09:46:40 +01:00
Simon Hausmann
9bb9ac3c39 Disallow callback overrides as well 2022-11-16 08:56:30 +01:00
Simon Hausmann
27db2bdcc6 Disallow duplicated callback declarations
A duplicated callback would silently overwrite the previous declaration,
which is counter-intuitive.
2022-11-16 08:56:30 +01:00
Florian Blasius
61c39b5fa1 Add support for dispatching key events through the public platform API
This change adds `KeyPress` and `KeyRelease` variants to the
`WindowEvent` enum, along with the new `slint::Key` enum, that allows
encoding keys.
2022-11-15 10:34:17 +01:00
Olivier Goffart
6ab6ae63d4 input output property: fix semantic with two ways bindings 2022-11-11 13:02:53 +01:00
Olivier Goffart
dd4c701307 Rename input and output property to in, out and in-out 2022-11-08 15:25: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
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
Olivier Goffart
5613fc4416 Rename inout property to input output
`inout` and `input` are too similar, so use a longer form for `inout`

CC https://github.com/slint-ui/slint/issues/191#issuecomment-1296176978
2022-10-31 14:57:52 +01:00
Olivier Goffart
53090ab489 Forbid usage of @children in repeated or conditional element
It leads to compiler panic, or errors in the generated code.
2022-10-31 14:13:42 +01:00
Olivier Goffart
84ae4d2928 New syntax: Only allow children if the component has @children
For compatibility reason, this is also allowed when inheriting
2022-10-28 17:45:37 +02:00
Simon Hausmann
ab1341878f
Make SlintInternal.dark-color-scheme a property instead of a function (#1790)
That's a more idiomatic API - the compiler can map the lookup straight
to a function call.
2022-10-28 14:20:20 +02: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
Olivier Goffart
0ba8f58076 New syntax: New lookup rules for unqualified identifier
Instead of looking up any property in `self` and `root`, only resolve
the properties in scope declared in the current component.
2022-10-20 16:40:29 +02:00
Olivier Goffart
b24a2d6a57 new syntax: comments from review 2022-10-20 08:02:26 +02:00
Olivier Goffart
fd23745c02 Test for the input output properties 2022-10-20 08:02:26 +02:00
Olivier Goffart
c1f4f4e96b Start working on input/output properties 2022-10-20 08:02:26 +02:00
Olivier Goffart
0d07d34c69 Fix panic when the forward-focus expression is invalid
Caused a crash of the LSP when having invalid element in the
forward-focus property
2022-10-18 10:13:55 +02:00
Olivier Goffart
d18ed9f799 Fix panic when doing binding analysis of properties in repeater in layout
Given an element in a layout, we must visit the properties in the
repeated component, not the dummy repeated element.
2022-10-18 10:11:40 +02:00
Olivier Goffart
6d12b276a9
Polish of the rotation feature
- Add a check that this only Applies to Image element without children
 - Default the origin to the center of the Image
 - Add docs and test

cc: #1481
2022-08-30 12:10:42 +02:00
Olivier Goffart
46854c7291 Workaround for issue #1461
Some binding can't be express with the current data structures because
they reference propertis within inner elements within a component.

The fix is a bit involved and the best is to have an error istead of a
panic, for now.
2022-08-17 07:49:05 +02:00
Olivier Goffart
57d61475b3 Detect loop on the property itself
This is the most basic loop and we wouldn't show a signal.

Turn out the comment was wrong and we do not seem to emit the error
twice for two ways binding to itself

Fixes #1407
2022-07-22 13:29:18 +02:00