Commit graph

477 commits

Author SHA1 Message Date
Simon Hausmann
834a29f25e Share the font cache across compiler invocations in the screenshots explicitly
... instead of implicitly through thread-local storage.
2024-08-13 16:08:24 +02:00
Simon Hausmann
f55cbc5549 Speed up screenshot test driver build
The test's build.rs invokes the compiler repeatedly with a configuration that enables font embedding. Instead of loading the same font with fontdue repeatedly (slow), store the loaded fonts in a hash table for re-use.

This should not have any impact on single file compilations, but it helps with the screenshot driver test dramatically, bringing down the time of

       touch tests/screenshots/build.rs
       cargo build -p test-driver-screenshots

    on my xps13 linux from 1m26s to 15s.
2024-08-13 16:08:24 +02:00
Danut Enachioiu
8e51563609
Fix broken Android build caused by missing font field (#5821) 2024-08-10 13:37:22 +02:00
Simon Hausmann
dafa559a55 Fix unguarded unwrap when attempting to embed the same default font multiple times in the software renderer glyph embedding pass
Fixes #5684
2024-07-25 15:10:38 +02:00
Simon Hausmann
f4ac8eb859 Fix embedding of default bitmap font
Commit 3764312561 accidentally chained filter_map so that the list of default (fallback) fonts was empty. That resulted in
a simple hello world (with no custom fonts) embedding no font at all and causing a run-time error.
2024-07-17 10:37:33 +02:00
Simon Hausmann
5f0d0937f0 Simplify popup coordinate handling
Instead of replacing the existing x/y properties with "invisible" ones, let's just keep those that we have and merely zero out the geometry x/y.

This has the bonus that access to x/y within the PopupWindow will provide the right value, i.e.

    popup := PopupWindow {
        x: 42px;
        Text { text: popup.text / 1px; }
    }

will show "42" instead of zero.

Since x/y are now merely referenced via the NamedReferences in PopupWindow, this patch also fixes the property materialization pass to use
visit_all_named_references(component) to also visit the x/y named refs,
instead of visit_all_named_references_in_element() that skips them.
2024-07-10 13:43:41 +02:00
Simon Hausmann
419042f476 Add support for using own properties in PopupWindow's x and y properties
This allows positioning popup windows in a way that takes their width/height into account.
2024-07-10 13:43:41 +02:00
Olivier Goffart
5dfa8d56dc API review of the slint interpreter Compiler api
Closes #5466
2024-07-05 17:20:08 +02:00
Olivier Goffart
35a6e7bde5 Split Text item into SimpleText and ComplexText
SimpleText has all the most common properties and is half the size
2024-07-05 12:51:25 +02:00
Olivier Goffart
c6be6e3e85 Don't mark as read for the purpose of analysis property only read from native code
We don't want to keep a smaller bative class to be used only because of
that
2024-07-05 12:51:25 +02:00
Olivier Goffart
5ef7127354 Allow inlining components that inherit from layout
There is no longer a reason to prevent it.
2024-07-04 14:18:42 +02:00
Olivier Goffart
e190d2b2ae compiler: don't generate a binding to center element that covers the whole parent 2024-07-04 13:34:25 +02:00
Olivier Goffart
8117e9b29c Don't force inlining if there is a @children
We should only force inlining if there is children. The presence of a
`@children` or not shouldn't matter
2024-07-03 18:16:12 +02:00
Olivier Goffart
40cabb842c Fix insersion into a child @children when it shouldn't
If a component doesn't have a @children, but inherit from a builtin
element, we shouldn't take the @children from the children
2024-07-03 18:16:12 +02:00
Olivier Goffart
708ab9f7c2
viewer: use the new Compiler API and add a --component command line arg 2024-07-03 16:49:22 +02:00
Olivier Goffart
a0dd978f8a Deprecate exporting the last import if there is no other exported component 2024-07-03 13:34:08 +02:00
Olivier Goffart
f93729ffe2 Port LSP to slint_interpreter::Compiler
Add a feature to only generate a specified component.
2024-07-03 11:51:23 +02:00
Simon Hausmann
7896e645b2 Permit rotation properties on Text elements without children
This works with Skia, Qt, and FemtoVG.

cc #1481
2024-07-03 09:08:23 +02:00
Olivier Goffart
c144dc71b0 Fix change callback on an alias 2024-06-28 10:45:45 +02:00
Olivier Goffart
59942df91f Add some tests and fixes for change handler
Make sure that when inlining, the callback in the sub component
is executed before the root

Fix a warning in the generated C++ code
2024-06-28 10:45:45 +02:00
Olivier Goffart
6a9e0b0189 Fix wasm slintpad not loading images
Regressions since 2fd8744cfc that disabled
the pass that maps the URL with the resource_url_mapper.
Even if we don't embed the ressource, we must still go through them to
map them
2024-06-26 15:28:30 +02:00
Olivier Goffart
42a2c6a569
Only generate code for the exported Window
Have a warning when a component is exported from the main file and
doesn't inherit Window.
Unless it's the last component, for compatibility with Slint 1.6

Also don't warn in the interpreter
2024-06-25 15:13:06 +02:00
Olivier Goffart
539abfc550 Revert "Add a warning if a PopupWindow is in a layout"
This reverts commit 66652cdc1d.

The warning in the gallery are hard to fix because the component inherit
from a layout and there is nowhere to place the popups
2024-06-24 16:38:37 +02:00
Tobias Hunger
1c8b3733f7 janitor: Fix clippy "manual char comparison can be written more succinctly" 2024-06-24 14:59:47 +02:00
Tobias Hunger
9a253dc571 janitor: Fix clippy "match for destructuring a single pattern" 2024-06-24 14:59:47 +02:00
Tobias Hunger
f8e4072d0c janitor: Fix clippy "unneeded return" 2024-06-24 14:59:47 +02:00
Tobias Hunger
cd3b60c889 janitor: Fix clippy "creates a reference which is immediately dereferenced" 2024-06-24 14:59:47 +02:00
Tobias Hunger
f78ea5e7cf janitor: Fix clippy "field assignment outside of initializer
... for an instance created with Default::default()"
2024-06-24 14:59:47 +02:00
Olivier Goffart
3764312561
Generate multiple components in Rust and C++ (#5449)
When lowering to the LLR, generate one PulbicComponent for each exported
component in the main file

Closes #784
2024-06-24 10:03:19 +02:00
Olivier Goffart
c89ea56abb Update a bunch of dependencies
Bigger change is cause by resvg/usvg which now takes the font database
in a Arc, so we must store it in a Arc ourself to cheaply lend it to usvg
2024-06-23 16:47:13 +02:00
Olivier Goffart
408637a677 Remove the is_root_component within the component
There will be serveral roots, so this makes no sense.
2024-06-21 11:58:09 +02:00
Olivier Goffart
8933f3308c Remove the error when using @children on the root component
This complicates multi-component handling
2024-06-21 11:58:09 +02:00
Olivier Goffart
a4c0cc9f09 Move the used_types from the (root) Component in the Document
Preparation for multi-components

Note that this had to rename one instance of TextStyle because it
conflicts with the struct of the same name used in the FontSettings
in the style. This wasn't a problem before because it shares some
property in common, and the the order of processing of component has
changed leading to the other one being generated.
(But that is a wider bug in the compiler outside of the scope of this
refactoring)
2024-06-20 12:03:38 +02:00
Olivier Goffart
2fd8744cfc compiler: Move embedded_file_resources from the root Component to the Document 2024-06-20 12:03:38 +02:00
Olivier Goffart
60e7d54e67 Compiler better test coverage in case of error and fix panics
The compile_syntax_node was used by the syntax_test in case of error
to still cover the coverage, but commit e3908cfce6
made this function a noop when there is an error already.

The LSP does try to build an object tree even though there are error in
order to have the most information even in that case, so we must ensure
that it doesn't panic left and right.

This commit also fix some of these panics.
2024-06-11 19:22:59 +02:00
Olivier Goffart
b3de1e848e Fix inlining of PopupWindow
ammend previous commit to fix building the examples

When inlining things inside a Popup, we must process the popups first.
But in order to inline the popup inside another component, we must
process the popups last.
This makes the code a bit more complicated
2024-06-10 22:18:06 +02:00
Olivier Goffart
42704eee65 Fix @children in a PopupWindow
Fixes #5375
2024-06-10 22:18:06 +02:00
Simon Hausmann
1a8ce3c659 Add support for optimized rectangles in ElementHandle
Keep merging elements, but remember the boundaries in the debug info, separated by a slash.

Also fixed tests that rely on accessible-label being set only once. For example

```
Button { text: "foo"; }
```

will certainly have "foo" as accessible-label on `Button`, but its internal `Text` element has
an implicit "accessible-label" set to the same
value.

So don't rely on that for now but search by id instead.
2024-06-05 01:29:58 -07:00
Simon Hausmann
73b5136f98 WIP: Search by qualified element id 2024-06-05 01:29:58 -07:00
Simon Hausmann
5bfa6044b5 Don't optimized away rectangles that have dedicated accessibility roles 2024-06-05 01:29:58 -07:00
Olivier Goffart
66652cdc1d Add a warning if a PopupWindow is in a layout
This is not intuitive since the position of the PopupWindow will not be
handled by the Layout
2024-06-04 13:31:36 +02:00
Olivier Goffart
78f265f811 Don't remove the Row item if it has a PopupMenu
Otherwise the access to the PopupMenu parent will fail to compute the
x,y position of the popup as the popup's reference the Row as its
parent.

Fixes #5259
2024-06-04 13:31:36 +02:00
Aurindam Jana
3523e86359
Simplify commercial license (#3063)
Base the commercial license on the Royalty-free license adding clauses pertaining to the fees.
2024-05-31 14:06:17 +02:00
Aurindam Jana
9a3aa265d5
Update Royalty-free license (#5257)
Add clarification that Application may not expose Slint APIs.
2024-05-31 10:53:19 +02:00
Olivier Goffart
8221e2e4b2 Fix stack overflow in purity check
Fix #5220
2024-05-29 06:42:37 +02:00
Olivier Goffart
3f32550859 Fix property access from inlined init code
The `fixup_init_expression` was not called for every instructions when it was inlined,
causing invalid code in further passes

Fixes #5260
2024-05-28 16:24:38 +02:00
Florian Blasius
310b01a2e2
ComboBox reset current on model changed (#5217)
---------

Co-authored-by: Simon Hausmann <simon.hausmann@slint.dev>
2024-05-15 14:28:57 +02:00
Tobias Hunger
2e3b00e38e janitor: Fix some clippy warnings pre-release
Nothing that should be controversial, but the
`internal/compiler/builtin_macros.rs` could point to a thinko in the original
commit.
2024-05-06 16:47:14 +02:00
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
cadcd4caf4 Change callback: rust code generation 2024-05-02 22:25:53 +02:00