Commit graph

87 commits

Author SHA1 Message Date
Olivier Goffart
3b7c2d0c5e compiler: Add layout information the the Element 2023-10-24 15:49:12 +02:00
Olivier Goffart
975abf3c42 Don't steal the x and y properties for dummy parents
Parents surch as Opacity, Clip, and co, used to steal the x and y
property of their children, making the property not what they ought to
be.

Now that we refactored recently the code so that geometry need not to be
always linked to a property of the same name, we can dissociate the x
and y property of these generated elements and their content so that the
actual "x" property of the former elementstay some value, despite its
relative item property is now 0.

Had to change a bit of code that was still assuming a literal "height"
or "width" or "y" or "x" property that no longer worked when the
geometry is dissociated from its property

Fix #1072
2023-10-21 07:30:46 +02:00
Tobias Hunger
d72dbb1386 compiler: Fix font loading
Get the full path before deciding what to do.
2023-10-12 19:15:53 +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
Guilhem Vallat
aada8bb485 include geometries in Element debug print 2023-09-13 16:08:37 +02:00
Olivier Goffart
e0fd9a6105 WIP: Add item_geometry to the ComponentVTable
(unused yet)
2023-09-13 16:08:37 +02:00
Simon Hausmann
3652f58a3f Change item indices from usize to u32
So that the compiler and run-time can never disagree on the
number of bytes the item index can use.
2023-09-12 08:53:58 +02:00
Tobias Hunger
5db78b6dd2 Implement LLR code lowering for ComponentContainer 2023-07-27 12:04:16 +02:00
Tobias Hunger
689238a3af Lower ComponentContainer into two objects
... so that we have one that controls the embedding operation and one
that we can turn into a dynamic tree node where the actual embedding
happens.

Mark the placeholder Element as `is_component_placeholder` and make sure to not
optimize out that object in a later pass.

Adapt Element creation to account for the new
`is_component_placeholder`.
2023-07-27 12:04:16 +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
Olivier Goffart
0c71a94867 Remove dbg! 2023-07-03 10:10:54 +02:00
Olivier Goffart
03bed94072 Fix default geometry of items with inject_element_as_repeated_element
Fixes #3027
2023-06-30 17:35:29 +02:00
Tobias Hunger
e02c360000 Clippy polish 2023-06-28 14:22:30 +02:00
Olivier Goffart
fdec5960bd Support for @rust-attr on enums 2023-06-19 22:40:49 +02:00
Olivier Goffart
11dea135f7 Domain: slint-ui.com -> slint.dev 2023-06-16 10:55:08 +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
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