Commit graph

102 commits

Author SHA1 Message Date
Olivier Goffart
af1aa2991e
Fix component that inherits from PopupWindow
This regressed in commit 12d904a71c
which changed the order of the pass to get the lower_popup pass before
the first inlining pass.
If by chance (which is likely if one have children), the component that
inherits from PopupWindow was inlined in that pass, it would be as
if it was not a component, and it would be removed from its parent.
But since it is no longer inlined, we need to support that case and
delay the removal when processing the component that holds that popup.
2024-05-06 13:20:25 +02:00
Olivier Goffart
c5f857ffc9 Change callback: gate behind experimental flag 2024-05-02 22:25:53 +02:00
Olivier Goffart
2e4d1f2427 WIP: work on changed callback 2024-05-02 22:25:53 +02:00
Olivier Goffart
12d904a71c
Fix compiler panic with init in a component inlined into a repeater
The problem was that the code from #4322 inlined the init code in the
parent Component as at that point, the per-repeater component don't
exist yet.
Fix it by removing the workaround from #4322, but changing the order of
the passes so that the init code are already proccessed before any
inlining. This required to change the order of a bunch of passes.

Fixes #5146

As a drive-by, also add the missing C++ implementation of set_animated_value
for Brush that was discovered by the test. (Code wouldn't compile)
2024-04-29 15:34:12 +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
18eea8602a Fix insertion point of @children
Don't always appends at the end

Fixes #4935
2024-03-26 18:14:14 +01:00
Tobias Hunger
28b96ca6f6 janitor: manual cargo clippy fixes
Semi-random selection of clippy topics that were
uncontroversial before:-).

Leaves about 84 deduplicated issues in the code base
according to clippy from nightly.
2024-03-14 13:42:38 +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
fac0921579 Compiler: keep the layout debugging info next to its node 2024-02-21 11:33:37 +01:00
Olivier Goffart
09dc25f107 Keep all nodes for a given element (even if it is optimized out) 2024-01-25 14:45:22 +01:00
Olivier Goffart
ffaf19812c Refactoring: use Element::to_source_location instead of the node directly 2024-01-25 14:45:22 +01:00
Tobias Hunger
9142336d5c interpreter: Add highlighting feature-gated functions
The preview can not leave it up to the interpreter to handle element selection
and highlighting. So add new functions to the interpreter (behind the
"highlight" feature-gate) to query positions of elements.

This exposes some of the code that is used by the existing highlighting code
and extends it where needed.

Two use-cases need to be covered:

1. Query the positions of a component (given by source file path and offset).
   This is then used to highlight all occurences of a component as the
   cursor position in a source file changes.

2. Query the position of an element (given as `ElementRc`).
   This is used when selecting elements in the UI. We need to work at
   the element level for this, not at the component level.

Also make the `highlight` module public but feature-gated, so that we
can put helper-types there.
2023-12-20 19:28:35 +01:00
Tobias Hunger
2404cce0bc janitor: Fix typos 2023-12-19 17:04:33 +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
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
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