Commit graph

216 commits

Author SHA1 Message Date
Olivier Goffart
5d4c390b0f
Compiler: Error when assigning to compile time properties
Some property need to be known at compile time. We already had checks
that the binding is a compile time constant, but there was no check to
prevent, say

    self.row = 42;

which wouldn't work or could even cause panic or miscompilation of
generated code

Closes #4037
2023-12-12 21:51:56 +01:00
Tobias Hunger
2ad8774a61 Add clamp function to slint language 2023-11-22 12:27:54 +01:00
Olivier Goffart
678afb3ba0 Throw an error when returning no value when one is expected.
Previously we were likely to get error in the compiled code anyway.
(although the interpreter worked fine)

Fixes #3962
2023-11-20 13:50:57 +01:00
Olivier Goffart
ac8fd60091 Fix regression with empty array
Regression noticed in this line:
3f97d98bff/ui/tabs/downloads.slint (L77)

The following used to work:

```slint
import { Button, VerticalBox } from "std-widgets.slint";
export component Demo {
    in property <[int]> mods;
    VerticalBox {
        alignment: start;
        for xxx in true ? mods : [] : HorizontalLayout { alignment: center; Button { text: "OK!"; } }
    }
}
```

But we fixed array conversion and this caused a regression with empty
array
2023-11-01 11:30:59 +01:00
Olivier Goffart
85ca10d32e Disallow access to internal globals (NativeStyleMetrics and SlintInternal)
It only stay accessible in our builtin styles

Fixes #3793
2023-10-28 16:07:38 +02:00
Olivier Goffart
ae4debafe2 Compiler: Don't panic when a Row is repeated in a GridLayout
Fixes #3729
2023-10-23 19:43:46 +02:00
Olivier Goffart
166f19aeff
Fix compiler panic when trying to resolve aliases in invalid import
Fixes #3674
2023-10-16 16:37:49 +02:00
Tobias Hunger
b12575a4c4 janitor: Go over our spell checking setup
* Extend the cspell word list
* Remove those extensions from individual source files
* white-list licenses and such as we should not meddle with those
* Fix spelling
2023-10-16 09:01:51 +02:00
Olivier Goffart
8f001ac490 Add support for protected functions
Protected function can only be called from the direct base

Issue #3636
2023-10-11 10:50:50 +02:00
Olivier Goffart
661080676a Compiler: fix conversion of array of array of structs
When finding the common types for array of array, we must recurse in the
inner type

Fixes: #3574
2023-10-02 19:00:21 +02:00
Guiguiprim
05cdf88871
Add spacing-horizontal and spacing-vertical to layout (#3532) 2023-09-28 13:49:28 +02:00
Olivier Goffart
a310fdc912 Fix panic when parsing invalid gradiant
Fixes #3241
2023-08-09 21:20:54 +02:00
Tobias Hunger
eb84994e7a Add lower_component_container pass
Do some diagnostics in that pass.
2023-07-27 12:04:16 +02:00
Olivier Goffart
5dea1f1d29 compiler: Fix loading relative path to the workdir
This should in principle not be allowed, it should be relative to the
file itself.
Make it a warning, and at least, don't duplicate the globals

Fixes #2719
2023-07-24 18:21:53 +02:00
Olivier Goffart
37f11e566b Better error when using ';' instead of ',' when declaring struct 2023-07-24 12:31:41 +02:00
Olivier Goffart
57e9b5b796 Don't panic when an unresolved alias has a binding
Fixes #3085

When there are both a binding and a two way binding, we must keep the
two way binding in our bindings map. Otherwise type inference will not
work
2023-07-14 14:13:48 +02:00
Olivier Goffart
c990660500 Run the import pass even when building the object tree fails.
This improve the code coverage of syntax_text, so some adjustment had to
be made.
This may add more error in the main file, but this make it the same
behavior as for imported files and lsp who were already running these
passes all the time
2023-07-14 14:13:48 +02:00
Aurindam Jana
5a4a7fee63
Update royalty free license to 1.1 (#2994) 2023-07-10 10:12:11 +02:00
Simon Hausmann
016d776b7d Simplify implementation of absolute-position
Since we materialize only one point property, we don't need to cache the
parent position in a separate property, but we can just store that in
the binding.
2023-06-21 10:02:04 +02:00
Simon Hausmann
ab0e38c76d
Merge absolute-x and absolute-y "virtual" properties into absolute-position (#2942)
The type of thep property is `Point`, which existed before. It was
mapped to `slint::private_unstable_api::re_exports::Point` (euclid) and
is now mapped to slint::LogicalPosition (also in C++).
2023-06-21 08:17:57 +02:00
Olivier Goffart
fdec5960bd Support for @rust-attr on enums 2023-06-19 22:40:49 +02:00
Olivier Goffart
300cb06ac8 Make sure we don't load internal files 2023-06-16 22:03:45 +02:00
Olivier Goffart
11dea135f7 Domain: slint-ui.com -> slint.dev 2023-06-16 10:55:08 +02:00
Tobias Hunger
04d1229685 Fix licnese information using xtask 2023-06-16 09:14:20 +02:00
Aurindam Jana
039e54a5de
Add royalty free license to files except examples and docs (#2888) 2023-06-15 11:20:50 +02:00
Olivier Goffart
af604a29b4 Ensure there are no duplicated enum values 2023-06-12 13:02:14 +02:00
Olivier Goffart
e97a2e8229 Translations: support context 2023-06-06 14:48:48 +02:00
Simon Hausmann
1bf05eae7c
Add support for absolute-x and absolute-y properties on any element (#2823)
Fixes #1691
2023-06-06 14:37:53 +02:00
Olivier Goffart
9b3ccd3dc3 Check validity of the format string at compile time 2023-06-05 16:34:59 +02:00
Olivier Goffart
dcd8450dfa WIP: start working on translations: @tr()
This commit just do the parsing of the @tr macro.
2023-06-05 16:34:59 +02:00
Simon Hausmann
0f54b9599b Add support for manually closing PopupWindows
This patch adds a `close()` function that can be called to close a popup
window, and a `close-to-click` boolean that can be set to false to
disable the default behavior.
2023-06-02 18:07:49 +02:00
Olivier Goffart
6441968a43 Janitor: Remove trailing spaces in most files 2023-05-04 08:14:28 +02:00
Olivier Goffart
6111b17a7c Proper error when wrong type used in an unary operation
Fixes #2669
2023-05-02 17:41:36 +02:00
Olivier Goffart
d881a4fb66 Syntax tests: move some tests to another folder
tidy a bit the basic directory
2023-05-02 13:06:50 +02:00
Tobias Hunger
bbdd6aeab7 compiler: Ignore leading whitespace when parsing
... and update all out test cases accordingly.
2023-04-26 17:22:13 +02:00
Olivier Goffart
ae1fb4c7cf Handle complex forward-focus loops 2023-04-24 18:03:33 +02:00
Olivier Goffart
7e7b9176a7 Don't infinite loop when forwarding focus to self 2023-04-24 18:03:33 +02:00
Olivier Goffart
a1ea00553f Compiler: hint when an id has the same name as a property or enum value 2023-04-18 16:16:31 +02:00
Olivier Goffart
875a7ea179 Parser: Nicer error when extra top-level semicolon
Recover from extra semicolon
2023-04-17 15:13:20 +02:00
Olivier Goffart
ee9f730a6d Parser: Don't parse everything as a component
The old parser always try first to find `Foo :=` from the old syntax so it
would error saying it expect an identifier or `:=`
But if we don't find a component, don't try to parse it as a component too early
This way we get better error and better auto-completions
2023-04-17 07:58:18 +02:00
Olivier Goffart
40922874fa parser: don't parse error on empty import statement
Report the error later when loading the import.
That way, we get a more complete AST for auto-completion
2023-04-17 07:58:18 +02:00
Olivier Goffart
82ae83ce8c Parser: don't have the whitespace as part of an expression
That way the error for an expression is at a better location, and
this also prevent the formater that removes space in expressions to
remove the spaces before the expression that shouldn't be removed
2023-04-14 17:46:19 +02:00
Simon Hausmann
d87af7e917 Fix panic when binding Path's commands property to a model entry's field
Fixes #2466
2023-04-03 15:25:13 +02:00
Olivier Goffart
3267d68541 Turn warning about non-existing image into error
This is only an error if we embedd recources.
(When using absolute path it is not an error/warning)
2023-03-27 11:14:25 +02:00
Olivier Goffart
1089d29ebb Make Empty not fill the parent by default
Unless `preferred-*:100%` is set

Part of #2284
2023-03-24 11:15:05 +01:00
Olivier Goffart
47ac396bc0 compiler: turn a warning into an error
cc #2024
2023-03-20 19:13:10 +01:00
Olivier Goffart
41157b9984 Fix visible property on the root of a component
Just like opacity and other properties, it needs to prevent inlining.

And also add the same warning as for opacity if it is used on the root
(the Window)
2023-02-14 13:28:54 +01:00
Olivier Goffart
4f00f268a5 Make the old syntax a warning 2023-02-14 12:38:39 +01:00
Simon Hausmann
e09943ead5
Improve error message when trying to create a two-way binding to model data
Closes #2186
2023-02-10 13:13:15 +01:00
Olivier Goffart
9c20369653 Fluent style: cleanup unwanted properties
Don't make our widgets inherit element that we didn't want to expose in the API

The other styles will be synchronized with later
2023-02-03 20:29:26 +01:00