Commit graph

1488 commits

Author SHA1 Message Date
Simon Hausmann
9bdade0105 Compile the multiple-includes test with a header-only build of appwindow.slint 2024-08-20 15:53:24 +02:00
Simon Hausmann
8146799e8a Fix build with type aliases and generated .cpp files
These need to remain in the header file
2024-08-20 15:53:24 +02:00
Simon Hausmann
4b2d572732 C++ code generator: Fix header-only build when included multiple times
Make sure to mark whatever variables and functions that are left in the header as inline,
even if we don't generate C++ files.
2024-08-20 15:53:24 +02:00
Simon Hausmann
fddb6e30e3 C++: Place embedded resources into generated .cpp files 2024-08-20 15:53:24 +02:00
Simon Hausmann
c25a03d6f7 C++: Make it possible to split up the C++ code generated for a .slint file
Add a COMPILATION_UNITS argument to slint_target_sources that defines into how many .cpp files to split up a .slint file. The new default is now one.
2024-08-20 15:53:24 +02:00
Olivier Goffart
f7171e1fc1 Fixup children insertion point in the flickable
Last commit uncovered some bug in which the second phase of inlining
tries to inline children in the wrong place

(This usually inlines zero children as it was already done in the first
phase, but we still assert that the location is right)
2024-08-19 16:27:11 +02:00
Olivier Goffart
a69966a296 Fix @children is the root
We were not respting the order (index) at this point.

Fixes #5865
2024-08-19 16:27:11 +02:00
Olivier Goffart
3a59950751 Experimental support for named callback parameters
And use that in the lsp/ui implementation instead of comments.

This is only a parser support for now, the name is otherwise unused.
Hence I rather keep that experimental.
2024-08-19 14:10:01 +02:00
Olivier Goffart
a9f526491a Timer Element
Closes #5724
2024-08-16 16:36:38 +02:00
Olivier Goffart
2643a327e8 Change events: keep unused property with change event 2024-08-16 16:36:38 +02:00
Olivier Goffart
3a12ebf7ab Report an error when accessing a function within a PopupWindow
instead of panicking

Fixes #5852
2024-08-16 10:31:13 +02:00
Olivier Goffart
8a0df2b3a5 Rename NumValueExpression -> NumberWithUnitExpression 2024-08-15 14:52:13 +02:00
Olivier Goffart
9b71cf1a36 Math postfix member functions on numbers
Closes #5328
2024-08-15 14:52:13 +02:00
ogoffart
4dd7d96a28 Bump version number to 1.8.0 2024-08-15 12:44:46 +00:00
Simon Hausmann
641b833c91 Fix TextEdit not invoking edited callbacks
Fixes #5848
2024-08-15 10:10:08 +02:00
Simon Hausmann
fb6775b386 When the slint scale factor is provided at compile time, propagate it also as initial value to the slint::Window created 2024-08-14 11:00:50 +02:00
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
Simon Hausmann
ad6e12dacf Speed up glyph embedding in the compiler
Enable the use of parallel glyph outline extraction in fontdue.

Brings down the time of

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

on my xps13 linux from 3m30s to 1m26s.
2024-08-13 16:08:24 +02:00
Simon Hausmann
28f9d3cc71 Remove unnecessary helper function 2024-08-13 12:04:04 +02:00
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