Commit graph

259 commits

Author SHA1 Message Date
Simon Hausmann
10e5c228b7 Fix calling clear-focus() on non-focusable elements not producing an error 2024-04-26 11:09:11 +02:00
Simon Hausmann
31767eb6ab Add a clear-focus()function on all elements that have a focus() function
This is the counter-part, which removes focus from the element if it's currently focused. The window - if focused - may still be focused towards the windowing system.
2024-04-26 11:09:11 +02:00
Olivier Goffart
13127dc71c Accessibility: Add support for accessibility-action-* callback (#5073)
Merge branch 'feature/accessibility'

 Conflicts:
	internal/compiler/widgets/cosmic-base/button.slint
	internal/compiler/widgets/cupertino-base/button.slint
	internal/compiler/widgets/fluent-base/button.slint
	internal/compiler/widgets/material-base/button.slint

Also updated license header in actions.slint
2024-04-16 15:02:25 +02:00
Olivier Goffart
0f05089d5e Polish the C++ and Rust HSV API 2024-04-15 18:18:00 +02:00
Olivier Goffart
eb2b7bf178
Widgets: test that widgets have the same accessible-role in all styles (#5065) 2024-04-15 18:15:47 +02:00
Simon Hausmann
ae2e0197f8
Deprecate the use of StyleMetrics for users of the public API (#4947) 2024-04-15 17:07:05 +02:00
Aurindam Jana
0cfeec1a31
Update Slint Community License (#4994)
Updated the version from 1.1 to 1.2 
Renamed the header to "Slint Royalty-free Desktop, Mobile, and Web Applications License"
Added definition of "Mobile Application" and grant of right
Moved "Limitations" to 3rd section and "License Conditions - Attributions" to 2nd section
Added flexibility to choose between showing "MadeWithSlint" as a dialog/splash screen or on a public webpage
Moved the para on copyright notices to section under "Limitations"
2024-04-15 15:18:55 +02:00
Olivier Goffart
ea0227098a Throw an error when a callback aliases itself
Instead of panicking
Fixes #4938
2024-03-26 18:14:31 +01:00
Simon Hausmann
68083243b2
Add an in-out boolean color-scheme property to Palette (#4701)
This allows applications to force dark/light mode, as well as determine
which mode is active.
2024-03-26 15:44:22 +01:00
Olivier Goffart
42a4286048 Fix missing error when calling argb() with too many arguments
This is technically a breaking change if someone was calling it with too
many args by mistake, but i think it's fine to do this as a bugfix
2024-03-22 14:57:07 +01:00
Olivier Goffart
c553eb4398
compiler: Don't panic when using foo.focus(something)
Just ignore the case where focus has more argument that planed as it has
been reported as an error earlier.

Also fix the error message for calling member function with the wrong
number of argument to not include the base in the count.

Fix #4883
2024-03-19 11:06:08 +01:00
Olivier Goffart
255dc59ef4 Rename @image-url(..., 9slice(...)) to @image-url(..., nine-slice(...))
As per API review:
 - In the Rust and C++ API we use `set_nine_slice_edges` because the getter couldn't start with 9
 - in english we spell number less than 10 with letters and this is a name
2024-03-07 17:01:57 +01:00
Tobias Hunger
06b04e71b5 compiler: Return the TypeLoader from compile_syntax_node 2024-02-29 19:35:52 +01:00
Olivier Goffart
11e8070726 Compiler: fix lookup of the model not seeing that the element is being repeated
The problem is that we were taking the whole `repeated` field and as a
result we wouldn't see that the element was being repeated and that we
shouldn't have to lookup id within it

Fix #4683
2024-02-26 12:16:51 +01:00
Olivier Goffart
22d9fc9cf9 @image-url: Semantic analysis of the 9slice 2024-02-13 14:46:27 +01:00
Olivier Goffart
6e2280ece3 Parse 9slice in @image-url 2024-02-13 14:46:27 +01:00
Simon Hausmann
7ce0bd493a Fix panic when using foward-focus with non-element binding
Since commit 6fefe75a1c the handling
of forward-focus bindings happens before the resolve_expressions pass,
which means that we cannot rely on type mismatch
error handling yet.

Fixes #4475
2024-01-30 10:09:07 +01:00
Simon Hausmann
6fefe75a1c Don't require components that use forward-focus to be inlined
Achieve this by generating a `focus()` function for such components
and call it from the outside.

This replaces the previous focus handling with what should be cleaner:

- Any `forward-focus: some-element;` is basically syntactic sugar for
 `public function focus() { some-element.focus(); }`.
- The init code gets simplified to calling focus() on the root, if it's
  available.

Since the `focus()` functions are now generated in the imports pass,
they become visible in the style checker. That means the checker
requires consistent focus handling between the styles.
2024-01-26 12:16:09 +01:00
Olivier Goffart
2564eede9f Compiler: avoid two error message when trying to call a non-existing function 2024-01-24 20:06:48 +01:00
Olivier Goffart
638985612c Test purity of model expression 2024-01-11 15:13:01 +01:00
Olivier Goffart
5aa6b424e3 Janitor: Optimize usage of is_dir/is_file
As suggested in https://github.com/slint-ui/slint/issues/4219

Closes #4219
2023-12-27 10:36:25 +01:00
Olivier Goffart
2ce161ced8 Parser: Hint for the mod function when parsing %
Was reported several times:
 - https://github.com/slint-ui/slint/discussions/4190
 - https://github.com/slint-ui/slint/issues/3980
2023-12-19 17:23:30 +01:00
Olivier Goffart
85526d772e Fix detection of properties when they are only used in two way bindings
Fixes #2166
2023-12-19 11:14:53 +01:00
Tobias Hunger
d785f2d5df compiler: Store an optional version number with the document
A None value means the file on disk is the golden version.

We have an editor, the LSP and the preview that all need to at least
notice when they have newer data then their peers. So IMHO it makes
sense to have an optional document version around.

The language server protocol makes use of a version number already. This
patch moves that code into the compiler so that it is stored with the
actual data getting versioned.
2023-12-18 14:21:50 +01:00
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
Olivier Goffart
44ec841609 Fix lookup relative to the manifest path in .rs file
For the slint! macro, we need to lookup files in the manifest path.
The base_directory function regressed in commit 0ff8e2c.
This was not cought by the test because it had falled back to the `pwd`
with a warning, as we used to load ressources relative to `pwd` as a
fallback.
So also check that there are no warning (meaning updating the rest of
the test so that there isn't any warnings)

Fix #4045
2023-12-02 13:11:59 +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
J-P Nurmi
c5248c005e Allow specifying paths for @library imports 2023-10-20 16:47:00 +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
Tobias Hunger
0ff8e2cdb6 compiler: Rework path handling
Add some code to do platform-independent path processing.

This is necessary aas WASM does e.g. not have any absolute paths and
such and the compiler tended to produce wrong results in that case.

Side-effect: We no longer need to depend on `dunce`
2023-10-10 20:04:47 +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
b55cdb9cf4 Make ComponentContainer a compiler configuration feature
Require `SLINT_EXPERIMENTAL_FEATURES` to be set in the environment to
enable `ComponentContainer` and `component-factory`.
2023-07-27 12:04:16 +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
Tobias Hunger
8345c6cd79 Do automatic clippy fixes 2023-06-28 14:22:30 +02:00
Olivier Goffart
56a58f704b Compiler: load import and other files relative to the CARGO_TARGET_DIR for .rs files 2023-06-26 18:44:34 +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