Commit graph

1050 commits

Author SHA1 Message Date
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
b67fcce4a3 Add a new descendants api as well as deeper element queries to ElementHandle 2024-07-15 11:30:34 +02:00
Florian Blasius
806d12bcb3
Made ComboBox scrollable (#5581) 2024-07-12 15:14:00 +02:00
Tobias Hunger
10ca3de1ed compiler: Add a really simple snapshot test 2024-07-11 19:09:26 +02:00
Olivier Goffart
e67e46ab47 LLR: merge the popup's x and y property access in one expression 2024-07-10 17:54:03 +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
c81ab5cd6d Remove hard-coded sizes from date and time picker popups
Use the layout and position the popup centered relative to its parent.
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
Florian Blasius
6e2013e4ff
API Review: DatePicker and TimePicker (#5582) 2024-07-09 22:16:54 +02:00
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