Commit graph

1041 commits

Author SHA1 Message Date
Tobias Hunger
41896332b3 compiler: Fix bug in snapshotting
Do not `take` an ElementRc to move it into the `Component`'s `root_element`.

@ogoffart spotted this! Thanks!
2024-07-08 16:34:17 +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
7c93c7438b Rename resize-border => resize-border-width 2024-07-05 12:50:16 +02:00
Olivier Goffart
b5100a872d Fix appliying property from a builtin global
(eg: NativeStyleMetrics)

We would consider the property constant and inline them as their default
value

Fix regression from 6687995c36
2024-07-04 15:50:44 +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
14593a55e1 llr: Don't generate unused globals
Global for which none of the properties are used can be omitted in the
generated code.
2024-07-04 10:24:54 +02:00
Olivier Goffart
6687995c36 llr: ensure const property without bindings are recognize as such by expression inlining
This allow to optimize away many property like the materialized x and y
properties.
2024-07-04 10:24:54 +02:00
Olivier Goffart
c41b3bde83 llr: pretty-printer: print the geometry expression 2024-07-04 10:24:54 +02:00
Olivier Goffart
821aefc20c expression-inliner: adjust the cost for a condition
Take the max of the two branch instead of the sum of it
2024-07-04 10:24:54 +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
Simon Hausmann
0f158e10dd testing api: Avoid bogus warnings about missing debug info
A `Rectangle { clip: true; }` will generate an intermediate `Clip` rectangle, which
certainly has no debug info.

The check whether debug info is present or not should not be done on a per-element
level but it can be done on the level of the compilation unit.
2024-07-03 18:01:24 +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
875d20f1ac Add test for deprecated import
Should have been part of a0dd978f8a
2024-07-03 16:44:31 +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
66370b6bda
Add export { ... } from "....slint"; syntax. (#5533) 2024-07-03 12:50:40 +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
a63618fcfe Fix error messages with invalid change callback 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
c19dbc0cfc Rust: Rename the slint_generated module to its old name
Some project on github were reaching into that module so it cannot be
renamed
2024-06-26 13:39:58 +02:00
Arnold Loubriat
ce2db77e88
Add the accessible-placeholder-text property (#5464) 2024-06-26 12:59:22 +02:00
Olivier Goffart
bd18d8dc0a Fix compiler crash when const propagating a property of component-factory with its default value
We couldn't represent an empty component factory in the exrpession tree,
so add Expression::EmptyComponentFactory for that
2024-06-25 20:25:01 +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
0639b9a61b janitor: Fix clippy "bound is already specified as the supertrait" 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
acb7da11d2 fix missing warning of missing export
... for last component when globals are exported
2024-06-21 11:57:49 +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
11e7b12a81 compiler: perform remove return pass before const propagation
Otherwise we end up inlining "returns" in the wrong property

Fixes #5430
2024-06-19 12:51:47 +02:00
Olivier Goffart
b5aea0ed64
Spinner: simplify the arc path (#5420)
Since we use the stroke and stroke with, then a single arc is enough
instead of two connected by lines
2024-06-18 15:52:17 +02:00
Daniel Stuart
9f63d157d1 Add character wrapping for Qt Backend
This adds a new wrapping mode called `char-wrap`, which allows for wrapping at any character.
Currently, it only supports the Qt backend, with the other backends falling back to `word-wrap` when this option is selected.
2024-06-17 23:52:04 -07:00
Olivier Goffart
62e0fdd5bd Rust: Attempt to fix the stack overflow when constructing the item array
Workaround from https://github.com/rust-lang/rust/issues/53827
2024-06-17 10:16:53 +02:00
Olivier Goffart
d0ed0438ce
LLR: peliminary support for multiple public components
There currently still can only be one because the passes expect that,
but now the LLR and generator should be ready to accept multiple public
component later
2024-06-15 14:44:11 +02:00
Tobias Hunger
f55ef8fa08 compiler: Add current document into snapshot
It went missing before as it gets added to the `TypeLoader` that gets
snapshot only after the function we snapshot in...
2024-06-14 16:59:39 +02:00
Olivier Goffart
d0cdebfee6 C++: move globals in a different struct
So that subcomponent don't depend on the root component name
which will hallow to have several root components
2024-06-14 16:26:53 +02:00