Commit graph

474 commits

Author SHA1 Message Date
Olivier Goffart
a57c7eb6bc Added TextInputInterface.text-input-focused 2023-04-12 14:49:08 +02:00
Olivier Goffart
6d0d6911f4 Fix visitation of init code
This patch merges the changes from #2344 and #2491 and do some cleanup

In particular, this visit the init code expression when visiting the
root element expression

Closes #2344
Closes #2491
Fixes #2487
2023-04-11 21:30:01 +02:00
Olivier Goffart
208d89c1de LSP: Don't auto-complete reserved properties or sub-elements for globals 2023-04-05 20:05:09 +02:00
Simon Hausmann
d87af7e917 Fix panic when binding Path's commands property to a model entry's field
Fixes #2466
2023-04-03 15:25:13 +02:00
Olivier Goffart
faeaef9143 Qt TabWidget: clip the tabbar to fix the breeze style 2023-03-30 19:16:43 +02:00
Olivier Goffart
c93b5b1be8 typeloader: make sure the vector of wakers don't grow too much
Poll can be called many times with the same waker
2023-03-30 10:48:38 +02:00
Olivier Goffart
bca5f136de typeloader: don't think we recurse if we're loading twice the same file at the same time
It can just be that we need to await for it.
And we need to maintain another stack for the case where we indeed
recurse
2023-03-30 10:48:38 +02:00
Olivier Goffart
ba407694ac Load files in parallel
Should speedup the loading of big project in the online code editor
2023-03-30 10:48:38 +02:00
Olivier Goffart
3404792114 Refactoring: Make the TypeLoader function take a RefCell
So they can operate without mutably borrowing across await
2023-03-30 10:48:38 +02:00
Olivier Goffart
cdaf2abb47
C++: sort the member of a struct in the same order as in the .slint file 2023-03-29 19:11:33 +02:00
Tobias Hunger
de0dc20e5b
slintpad: Move into tools/slintpad (#2435)
* Add "slintpad" to cspell white list for all languages
* Mention online_editor to slintpad rename in CHANGELOG
* Move tools/online_editor into tools/slintpad
* Update github actions accordingly

Co-authored-by: Olivier Goffart <olivier@woboq.com>
2023-03-29 16:32:30 +02:00
Olivier Goffart
538dddf953 Update fontdb since resvg depends on the newer one 2023-03-28 15:55:27 +02:00
Olivier Goffart
977b1cc23a Update resvg dependency
Don't import all the dependent crate, use the re-export

And use a workspace dependency
2023-03-28 15:55:27 +02:00
Olivier Goffart
7652097582 Better error message when trying to use private property in native code
If one declare a `property <int> foo;` in Slint, it will be private by
default, and the getter/setter won't be generated, and it may be
confusing as to why

With this change, it still generate private getter and setter so this
gives a better hint to the developer what the problem is.

Replaces #2170
2023-03-27 17:49:07 +02:00
Olivier Goffart
a5bdd07fbb Compiler: public output properties can still be constant 2023-03-27 14:20:16 +02:00
Simon Hausmann
7cd090dd6d Tweak AboutSlint
- Don't publicly inherit from Rectangle - let's keep that as an
  implementation detail
- Provide a minimum height for the image, to avoid that it becomes
  invisible (for example in `export component Example { VerticalLayout { AboutSlint { } } }`
2023-03-27 12:40:53 +02:00
Olivier Goffart
3267d68541 Turn warning about non-existing image into error
This is only an error if we embedd recources.
(When using absolute path it is not an error/warning)
2023-03-27 11:14:25 +02:00
Olivier Goffart
cdcb1e55bc Turn warnings about invalid SLINT_DEFAULT_FONT into errors 2023-03-27 11:14:25 +02:00
Simon Hausmann
8ffb5131c7
Introduce error handling in the FemtoVG and Skia renderers (#2402)
Avoid unwrap() and expect() and instead propagate errors all the way
down to run_event_loop(), show(), and hide() in the Slint AIP.
2023-03-24 14:18:11 +01:00
Olivier Goffart
1089d29ebb Make Empty not fill the parent by default
Unless `preferred-*:100%` is set

Part of #2284
2023-03-24 11:15:05 +01:00
Olivier Goffart
b180661ff6 const propagation: simplyfy struct access
so that `{ min: 10px, max: 20px }.min`  get optimized
2023-03-24 11:15:05 +01:00
Olivier Goffart
8cefde7c3a Remove space before => in quote_spanned
That's the style encouraged by the documentation
2023-03-24 11:14:48 +01:00
Olivier Goffart
20973bdb7b Report warnings from the slint! macro 2023-03-24 11:14:48 +01:00
Simon Hausmann
00471449b4 Fix compilation of Rust generated code when the generated code uses a return statement inside a block
We cast the result of the body of functions or binding expressions to
the target type via `as _`. When the code contains a return expression,
that works fine, because `return`'s type is the never type, which can be
coerced to a value of any type. However when the return statement is
inside a sub-block, the type becomes `()`, for which the `as _` cast
fails.

Work around this by attempting to detect the situation (return produces
Type::Invalid) and omit the trailing cast.
2023-03-22 18:07:34 +01:00
Olivier Goffart
47ac396bc0 compiler: turn a warning into an error
cc #2024
2023-03-20 19:13:10 +01:00
Olivier Goffart
4cf44ea69d Mark StandardListViewItem and TableColumn as #[non_exhaustive]
Closes #2330
2023-03-18 09:04:48 +01:00
Tobias Hunger
3d87b3ab93 clippy: Allow redundant_clone in generated rust code
This disabled about 70 clippy warnings like this one:

```
warning: redundant clone
     --> target\debug\build\energy-monitor-7b0492feb1633656\out\desktop_window.rs:44279:37
      |
44279 |                      (if (((r#state . clone ()) . r#previous_state as f64) == (1f64 as f64)) {
      |                                     ^^^^^^^^^^^ help: remove this
      |
note: cloned value is neither consumed nor mutated
     --> target\debug\build\energy-monitor-7b0492feb1633656\out\desktop_window.rs:44279:28
      |
44279 |                      (if (((r#state . clone ()) . r#previous_state as f64) == (1f64 as f64)) {
      |                            ^^^^^^^^^^^^^^^^^^^^
      = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_clone
```
2023-03-09 12:12:03 +01:00
Tobias Hunger
d1aaba8117 clippy: redundant clone fix in generated rust code
This fixes about half the `redundant clone` issues that clippy reports
in our generated rust code.
2023-03-09 12:12:03 +01:00
Tobias Hunger
0b03a0646a clippy: Allow cmp_owned in generated rust code 2023-03-09 12:12:03 +01:00
Tobias Hunger
7c19cde055 clippy: Allow eq_op in generated rust code
I get the following clippy errors in the energy monitor:

error: equal expressions as operands to `-`
     --> C:\src\slint\target\debug\build\energy-monitor-7b0492feb1633656\out\desktop_window.rs:47254:94
      |
47254 | ...   (slint :: private_unstable_api :: re_exports :: LogicalLength :: new (((((0f64 as f64) - (0f64 as f64)) as f64) * (((1f64 as f64) *...
      |                                                                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      |
      = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#eq_op

error: equal expressions as operands to `==`
     --> C:\src\slint\target\debug\build\energy-monitor-7b0492feb1633656\out\desktop_window.rs:45382:18
      |
45382 |                  (((0f64 as f64) == (0f64 as f64))) as bool }
      |                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      |
      = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#eq_op

I am not surprised that the generated code sometimes produces code like
this (even though the other demos do not!), so I went ahead and silenced
these errors.
2023-03-09 12:12:03 +01:00
Tobias Hunger
3ac01c3f07 clippy: Fix clippy warnings 2023-03-09 09:35:29 +01:00
Florian Blasius
1237707b7a
scroll-view: add min width/height vor scorll bar (#2353) 2023-03-09 09:08:48 +01:00
Olivier Goffart
488fb14846 Fluent style: Adjust disabled scrollbar background color
So that the TextEdit looks alright when disabled

Fixes #2281
2023-03-07 11:48:21 +01:00
Simon Hausmann
f4c30ce46e Fix panic when accessing a global from init that's not used otherwise
Make sure to visit the named references in the init code, when
collecting globals.

Fixes #2312
2023-03-03 15:23:57 +01:00
Olivier Goffart
a89c5db8db Fix crash when a state condition is detected as constant
States are never constant because the generated state binding depend on
the time as it register the time it was set for the pottential animation

Also adjust the assert so it assert correctly which the right message

Fixes: #2274
2023-02-24 16:43:48 +01:00
Tobias Hunger
f7de5d4602
docs: Go over builtin_elements.md (#2280)
Co-authored-by: Simon Hausmann <hausmann@gmail.com>
2023-02-24 11:03:56 +01:00
Simon Hausmann
19d914f548 Fix SLINT_EMBED_RESOURCES environment variable
The logic was inverted: Setting to true should embed everything, while
false should be the same as if it's not set: Only embed built-in
resources (as always).
2023-02-23 21:10:43 +01:00
Olivier Goffart
889b953304 C++: Don't make the global_* member public
This requires adding more friends to the component root

Fixes: #2169
2023-02-17 17:54:03 +01:00
Olivier Goffart
81cb89d374 C++: fix including the generated file in several translation units 2023-02-17 16:42:40 +01:00
Florian Blasius
1b04601750
std-list-view: bring selected into view (#2246)
* std-list-view: bring selected into view

* Update internal/compiler/widgets/fluent-base/std-widgets-base.slint

Co-authored-by: Simon Hausmann <simon.hausmann@slint-ui.com>

* code review

---------

Co-authored-by: Simon Hausmann <simon.hausmann@slint-ui.com>
2023-02-17 13:50:09 +01:00
Olivier Goffart
361526fb33 Update resvg dependency 2023-02-16 09:03:22 +01:00
Olivier Goffart
8934bf3bf5 Layouting: When propagating constraint to parent, use the explicit constraints...
in addition to the implicit constraints

Finishes #783
2023-02-15 17:07:33 +01:00
Olivier Goffart
03e9edee64 Fix compiler panic when an component's base is not inlined
An element with children must be fully inlined or the children array
can't be easily computed.
But the code wouldn't work if the base of a component was not inlined
2023-02-15 09:20:12 +01:00
Olivier Goffart
41157b9984 Fix visible property on the root of a component
Just like opacity and other properties, it needs to prevent inlining.

And also add the same warning as for opacity if it is used on the root
(the Window)
2023-02-14 13:28:54 +01:00
Olivier Goffart
4f00f268a5 Make the old syntax a warning 2023-02-14 12:38:39 +01:00
Olivier Goffart
ca7b2e0bb8 Harmonize style properties 2023-02-10 16:49:25 +01:00
Olivier Goffart
70f8c45d26 Add a test that styles are in sync
Closes #2051
2023-02-10 16:49:25 +01:00
Olivier Goffart
55ed3bc1f5 Compiler: use the new syntax for builtins.slint 2023-02-10 16:22:52 +01:00
Simon Hausmann
e09943ead5
Improve error message when trying to create a two-way binding to model data
Closes #2186
2023-02-10 13:13:15 +01:00
Olivier Goffart
6889dfa5f5 Rust: Make new(), run() and show() report errors from the backend
Fixes #2198
2023-02-10 05:00:03 +01:00