Commit graph

1514 commits

Author SHA1 Message Date
Olivier Goffart
3bc758bc3f Janitor: deps update 2024-09-11 17:19:36 +02:00
Olivier Goffart
7d446c98a0
Fix generated setter and getter of public property alias in globals
We need to skip the generation of the local property so it directly
forward to the alias in the public property

Fixes #5855
ChangeLog: Fixed generated getter and setter of alias properties in globals
2024-09-11 08:35:38 +02:00
Olivier Goffart
0c8a9fcefb Fix compiler panic when accessing path.commands in expressions
Fixes #5564
2024-09-10 13:36:09 +02:00
Olivier Goffart
ea3072d696 Path: fix panic when accessing properties on sub commands
We need to keep the ElementRc around with its properties so that
accessing them doesn't panic later
2024-09-10 11:44:13 +02:00
Olivier Goffart
5663ddd9cc
SwipeGestureRecognizer (#6005) 2024-09-09 14:40:55 +02:00
Olivier Goffart
0feb674612
unmark changed callback as experimental
Closes #112
2024-09-09 14:40:16 +02:00
Nigel Breslaw
482308f5da
Add Math.atan2 to the inbuilt math function
Math.atan2(y, x) -> angle
2024-08-30 09:55:10 +02:00
Olivier Goffart
1d3e9120d8 Avid reporting further error when an element is misspelled
eg, don't report an error for each callback or animation or changed
event that the the property doesn't exist or such.

Also reword the message when an element doesn't exist. Use "element"
rather than "type" as it is more accurate.
2024-08-29 13:10:35 +02:00
Enyium
5a796e6dc0
Change debug() separator from , to . (#5997)
This is also how JavaScript's `console.log()` behaves.

Fixes #5991.
2024-08-29 12:02:13 +02:00
Tobias Hunger
bacae03919 compiler: More wrappers around rowan methods
... in SyntaxNode and SyntaxToken.

And do a small code cleanup enabled by this.
2024-08-28 18:02:47 +02:00
Olivier Goffart
bf1b014840 Timer: fix timer when two timers have the same id
We need to give unique name to optimized item as well, otherwise the
properties ends up the same.

Also fix the optimized element and timer when inlining

Fixes #5977
Fixes #5976
2024-08-28 16:21:34 +02:00
FloVanGH
5b8f68f43b
visual clamp slider (#5967) 2024-08-28 10:41:24 +00:00
FloVanGH
039f33eaae
Added scrolled callback to ListView and ScrollView (#5964) 2024-08-27 10:18:43 +00:00
Olivier Goffart
f57cd6735b janitor: better panic message when accessing wrong NamedReference 2024-08-27 12:01:54 +02:00
FloVanGH
c9f005b40a
Fixed TimePickerPopup does not open minute view by click on selected hour (#5959) 2024-08-27 09:56:55 +00:00
FloVanGH
7a0c3dcc50
Do not trigger current-item-changed on StandardListView if current-item is set on the same value (#5958) 2024-08-27 07:22:18 +00:00
Tobias Hunger
d28b13cbe5 lsp: Remove explicit rowan dependency from LSP
... by implementing more helpers on `parser::SyntaxNode` and
`parser::SyntaxToken`.
2024-08-26 14:51:47 +02:00
Tobias Hunger
90e55bd29f compiler: Fix a couple of clippy issues
Nothing major, nothing controversial, just killing time
while waiting on CI.
2024-08-26 08:45:52 +02:00
Olivier Goffart
47028bce27 Fixed inlining updating property use count 2024-08-23 17:17:15 +02:00
Olivier Goffart
5f77808d1c Optimization: improve expression inlining
If a property is only used once, we can inline it with a bigger
threshold.
But this require to first compute the use, and then do the inlining
while adjusting the usages
2024-08-23 17:17:15 +02:00
Olivier Goffart
4de03fba5b Use f32 for float-to-string conversion
Because f64 has too much precision, so limit to f32 so that we don't
have extra precision we don't need and would be wrong as all our float
as in f32

(Also avoid double allocation in rust generated code)
2024-08-23 16:09:53 +02:00
Tobias Hunger
45c24803f2 compiler: Remove version info from SourceFile again
... and fix the fallout of that change.
2024-08-21 16:55:13 +02:00
Olivier Goffart
85063dc4dc Fix rust generated code with struct of percent value
We wouldn't detect percent as a unit product in
43c7f57b0f/internal/compiler/generator/rust.rs (L2418-L2422)

Percent is not strictly of percent unit because that unit doesn't
combine with other unit (as per the comment in `default_unit`)
But since it converts to number, it is then an unitless value. (scalar)

Fixes #5887
2024-08-21 14:48:22 +02:00
Olivier Goffart
e0ca9dfd76 Fixes rust generated code when taking expression of void callback
code like so:
```slint
callback foo();
if true : Button {
   clicked => {
      true ? foo() : foo();
   }
}
```

the code like foo() use the `option.map()`  to get to the parent, but then it
needs to still be wrapped in a `{...}` to convert that to a `()` expression

Fixes #5883
2024-08-21 11:52:15 +02:00
Olivier Goffart
12820c809f compiler: enable use of internal features when the experimental flag is set
This allow to preview/edit the widgets with the lsp's preview when the
experimental mode is enabled
2024-08-20 18:02:39 +02:00
Olivier Goffart
686f5e43e2 Widget style: simplify -light/-dark handling
Instead of having all style duplicated and re-using a base, we just hack
into the funciton that queries the dark/light theme based on the style
suffix known at compile time.

This removes one of the problem that happens when trying to work on the
widget style with the extension, as it relies on include path hacks
2024-08-20 16:55:15 +02:00
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