Commit graph

1068 commits

Author SHA1 Message Date
Simon Hausmann
1e3f05c983 Python: Expose Slint structs
Structs declared and exported in Slint are now available in the module namespace
with a constructor.

Fixes #5708
2024-08-13 12:04:04 +02:00
Olivier Goffart
51481b101c
Make conversion from float to int property truncate
- Make sure that in Rust and C++ we also truncate if the properties are
inlined
 - Change the interpreter to truncate

This is a redo of commit f5d003d but truncate instead of round

fixes #5689
2024-08-10 14:51:05 +02:00
Danut Enachioiu
8e51563609
Fix broken Android build caused by missing font field (#5821) 2024-08-10 13:37:22 +02:00
Olivier Goffart
819e549278 Rust generated code: handle the case if the parent is destroyed in a binding
This can happen if somehow the parent get destroyed while a binding is
running. This is issue #3464

This is enough to fix #5698
2024-08-09 15:05:15 +02:00
ogoffart
bbf7edc5a3 Bump version number to 1.7.2 2024-08-09 09:52:17 +00:00
Tobias Hunger
8c8719e79d live-preview: Simplify code setting properties
Now that the properties are only used in the live preview,
we can simplify the code a bit.

This gets rid of some sanity checks in the code path as well,
which in turn should fix #5696.

Fixes: #5696
2024-08-09 10:44:44 +02:00
Olivier Goffart
4622025969 Use less precision when comparing vaue in slint language
In rust, use f32 instead of f64 for arithmetic comparison.
In the interpreter, use approx_eq

The test is failling in nightly because of precision change in `log`.
By using f32, it actually should work

Also Revert "Disable builds with nightly Rust temporarily"
This reverts commit 4afc3a2e84.

Fixes #5722
2024-08-08 14:30:25 +02:00
W Etheredge
80ae11cd80 Use associated constants on number types 2024-08-01 07:53:48 +02:00
FloVanGH
9b7397f9ac
Fixed text input on 24hour time picker (#5723) 2024-07-31 07:00:37 +00:00
Simon Hausmann
8a7db55bb6
Route debug() calls in Slint consistently through Platform's debug_log() (#5718) 2024-07-29 16:31:09 +02:00
Simon Hausmann
6d7cc521fc Replace compiler dependency on css-color-parser crate
The crate uses an old version of lazy_static that doesn't seem to reliably compiler with newer versions of Rust.

This is a partial fix for #5702 as all the compiler needs is the named color table.
2024-07-29 13:13:53 +02:00
Simon Hausmann
9a34789070 Revert "Fix conversion to from float to int"
This reverts commit f5d003d1e2.

We decided to postpone this change until a later release, in maybe a
different shape.
2024-07-25 15:25:00 +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
Olivier Goffart
f5d003d1e2 Fix conversion to from float to int
Round the value.

The previous behavior is that

 - For the interpreter, we were rounding (same as new behavior)
 - for Rust and C++ we were truncating, unless the properties were
   inlinined and then we were keeping it as float
2024-07-23 17:32:57 +02:00
Olivier Goffart
f36fed2252 Combobox: Fix ComboBox having a too big popup when it has less than 6 items
Fix #5646

Qt is a bit more involved since it always put scrollbar if there is a ScrollArea and we can't
easily know the size to which make the popup. That's why it needs two popups
2024-07-23 14:18:16 +02:00
ogoffart
aa25e3cd44 Bump version number to 1.7.1 2024-07-23 12:05:34 +00:00
Olivier Goffart
a957b7fd98 Rust: Ignore dead code warning for unused enums
Strangely I wasn't able to reproduce the problem in a test, and we already have tests
that have enums which are not fully used.

Fix #5661
2024-07-23 13:33:51 +02:00
Olivier Goffart
5acc7dd42a Live-preview: Prospective fix for panic when moving a component
We were trying to convert a node to a wrong kind of node.
Then of course it didn't have the expected children

In debug mode you'd have
```
assertion `left == right` failed
  left: SubElement
 right: Component
```
from the debug_assert! in `$Node::from`

I changed the call to `.into` to a call to `$Node::new` that return an
option.

Also made the debug_assert into an assert and added track_caller so such
problem are easier to debug in the future. (Retrospectively, we probably
shouldn't have derived From for $Node)

Fix #5642

The change contains no tests because the is_recursive_inclusion function
is currently not tested and would need some effort to create a test
2024-07-20 01:17:53 +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
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