Commit graph

168 commits

Author SHA1 Message Date
Olivier Goffart
d989aebdaa Exports of enum between files 2023-06-12 13:02:14 +02:00
Olivier Goffart
d540c63d21 LSP: support for enum in the outline and in the goto definition 2023-06-12 13:02:14 +02:00
Olivier Goffart
18ba3c2ae2 Slint enums in Rust and C++ 2023-06-12 13:02:14 +02:00
Olivier Goffart
ac6f473a64 WIP: support for enum in slint
Parser and interpreter part
2023-06-12 13:02:14 +02:00
Amirhossein Akhlaghpour
3a4f3c61d5
Add @rust-attr on scturct (#2785)
Fixes: #2660
2023-06-05 16:29:55 +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
6d0d6911f4 Fix visitation of init code
This patch merges the changes from #2344 and #2491 and do some cleanup

In particular, this visit the init code expression when visiting the
root element expression

Closes #2344
Closes #2491
Fixes #2487
2023-04-11 21:30:01 +02:00
Olivier Goffart
7652097582 Better error message when trying to use private property in native code
If one declare a `property <int> foo;` in Slint, it will be private by
default, and the getter/setter won't be generated, and it may be
confusing as to why

With this change, it still generate private getter and setter so this
gives a better hint to the developer what the problem is.

Replaces #2170
2023-03-27 17:49:07 +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
Tobias Hunger
3ac01c3f07 clippy: Fix clippy warnings 2023-03-09 09:35:29 +01:00
Simon Hausmann
f4c30ce46e Fix panic when accessing a global from init that's not used otherwise
Make sure to visit the named references in the init code, when
collecting globals.

Fixes #2312
2023-03-03 15:23:57 +01:00
Simon Hausmann
047ab1d419 Fix run-time panic when combining forward-focus with text rendering in no_std environments
As outlined in #2199, there may be ways to trigger text layout code
through forward-focus before embedded fonts are registered. To fix this,
this patch replaces the init_code vector, which had the SetFocusItem
code before the font registration, with three explicit vectors for focus
setup code, code from init callbacks, and initial focus, and defines the
order in one central place in the copmiler (iter()).

Fixes #2199
2023-02-08 15:41:35 +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
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
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
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
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
Simon Hausmann
6c01ad858c Clean up setup of exported names and components/types
Replace the intermediate NamedExport and SeenExport structs and the hash
table to find duplicates with a simpler algorithm:

1. Collect all exports into a vector, sorted, with duplicates
2. Eliminate duplicates and issue warnings accordingly and insert the
   result into a second vector.

As a bonus, the resulting vector of exports is now sorted.
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
851a910e41 Parser: Parse functions 2022-12-06 14:56:25 +01:00
Simon Hausmann
7122d22c88 janitor: use the new default attribute for enums 2022-12-05 10:20:39 +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
Olivier Goffart
395532cebd Forbid former transitions declaration with the new syntax 2022-11-22 15:16:54 +01:00
Olivier Goffart
1ad6523960 Error message wording: remove the "TODO" 2022-11-22 15:16:54 +01:00
Olivier Goffart
51933b99bb New syntax for transitions, within the state 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
Olivier Goffart
443a5f7657 Center element by default in their parent with the new syntax 2022-11-15 17:33:27 +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
dd4c701307 Rename input and output property to in, out and in-out 2022-11-08 15:25:20 +01:00
Olivier Goffart
6f3a73abd7 Debugging aid: print the base component for repeater
(These component are not on their own and they are not prprocessed
separately by most passes)
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
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
659cb3a06c LSP: fix property call on invalid base or non-main component
- We should not panic if the base type is invalid
 - We should try to keep bindings in the Element even if the base type
   is invalid
 - Fix querying the element at a position in case it is not in the last
   component of a file
2022-10-21 12:50:42 +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
c1f4f4e96b Start working on input/output properties 2022-10-20 08:02:26 +02:00