Commit graph

2036 commits

Author SHA1 Message Date
Simon Hausmann
2d9eff53f4 Node.js: Simplify ArrayModel handling in tests
Add a convenience pop() function (we already have push...) and re-use the model
instead of fetching it.
Previously we fetched it because it was converted to
a new array every time.
2024-02-26 15:02:41 +01:00
Simon Hausmann
02ae80b071 Node.js: Fix failing nodejs tests due that do writebacks
Add missing set_row_data implementation
2024-02-26 15:02:41 +01:00
Simon Hausmann
a211a104a1 Node.js: Implement Iterable<T> for Model<T>
This makes it much easier to extra data from Models, such as using them
in for loops. This is the equivalent of Model::iter() in Rust.
2024-02-26 15:02:41 +01:00
Simon Hausmann
841cb25565 Node.js: Always map Slint arrays to Model<T> in JavaScript
This gives a consistent interface - there's no more need to check the result of a property read on whether it's an array or a model.
2024-02-26 15:02:41 +01:00
Simon Hausmann
fa8e847f7c Fix bi-directional mapping of Model<T> from Node.js to Rust
A Model<T> stores a reference to a External<Rc<ModelNotify>>.
Every time such a Model<T> needs to be exposed to Slint/Rust, we create
a TypedRustModel that wraps the Rc<ModelNotify>, a strong reference to
the JS object, and the Type field for the expected data type (the
interpreter expects). The Model trait is implemented on TypedRustModel,
which means it is allocated every time the conversion is needed, but the
underlying Rc<ModelNotify> is shared and thus the (forwarded) ModelNotify.

When converting back to JavaScript, we downcast_ref to the
TypedRustModel and fetch the original JavaScript object - if available.
2024-02-26 15:02:41 +01:00
Florian Blasius
c952b028fd Use this pointer for RustModel model reference 2024-02-26 15:02:41 +01:00
Florian Blasius
e54dd09604 Start with node RustModel 2024-02-26 15:02:41 +01:00
Olivier Goffart
8bc4c4e053 vtable: increase version number to account for breaking change in vtable::Dyn 2024-02-26 14:45:47 +01:00
Simon Hausmann
d4a6c5774e Add support for writing tests that run with all styles
Tests under tests/cases/for_each_style are run with all styles at least
in the Rust driver.

Amends 6bb9905191 to include a test that
using edited works.
2024-02-23 16:12:45 +01:00
Simon Hausmann
93efd74e24 Add support for mapping image properties
This exposes a slint.Image class, which has a load_from_path class
method as well as size/width/height properties.

cc #4202
2024-02-23 16:05:07 +01:00
Simon Hausmann
fa2cf8c28a C++ Interpreter: Add support for setting the translation domain
This maps straight to the Rust API.
2024-02-22 16:58:38 +01:00
Olivier Goffart
9f0c3c94a9 C++: minimize/maximize/fullscreen API on Window 2024-02-22 13:17:50 +01:00
Ralph Minderhoud
9cb1a4a4e0
Add API for minimize/maximize on Window component (#4581)
Closes #4400
2024-02-22 10:40:36 +01:00
Olivier Goffart
7b2ff89f1c Fix nightly warnings
eg:
```
warning: the item `Box` is imported redundantly
```
2024-02-21 10:52:04 +01:00
ogoffart
a0eed4e58e Bump version number to 1.5.0 2024-02-20 17:33:11 +00:00
Olivier Goffart
ddebd64064
Android: make slint::android public
Add a `backend-android-activity-05` feature that enables the
`slint::android` module
2024-02-20 15:00:11 +01:00
Tobias Hunger
a8f912900b janitor: Fix warnings in nightly about redandant use 2024-02-19 17:05:21 +01:00
Florian Blasius
f03aedf14c
node: ComponentDefinition::create returns now a result instead of an optional (#4622) 2024-02-15 14:20:52 +01:00
Olivier Goffart
97067c3d65 Add 9slice information at runtime 2024-02-13 14:46:27 +01:00
Simon Hausmann
1055f22ac4 Node.js: Avoid unnecessary cloning of Type
There's no need to consume the Type in the value conversion.
2024-02-07 19:15:31 +01:00
Simon Hausmann
2d6edfbd6c Node.js: Fix MapModel rowData() calling map function even if the source model returned undefined
Also fix the function signature, which was wrong.
2024-02-07 19:15:02 +01:00
Olivier Goffart
9b094251b8 C++: only enable the qt backend by default on Linux 2024-02-07 15:20:03 +01:00
Olivier Goffart
af8075d1b2 Only enable the Qt backend by default on Linux
The trick is that the backend selector build by default with the
i-slint-backend-qt, but the "enable" feature is only enabled if the
qt-backend feature is enabled explicitly, or on linux from the slint
or slint-interpreter crate
2024-02-07 15:20:03 +01:00
Simon Hausmann
fd48321e99
Permit the use of Image, Brush, and related data types in slint_interpreter from Rust without depending on i_slint_core (#4552)
Re-export them just like in the slint crate.
2024-02-06 21:34:30 +01:00
J-P Nurmi
cc5d2b24e5 Add BasicBorderRectangle to avoid unnecessary xxx-border-radius bindings 2024-02-06 18:01:35 +01:00
Olivier Goffart
09a5c724bf ListView: Fix redraw when model changes
Amend 48180919da
That commit added the dependency, but did not reset the dirty flag, so
it only worked once.

Fixes: #4538
2024-02-05 15:02:44 +01:00
Olivier Goffart
5e12f0876f C++: fix the FilterModel's row_removed
Same fix as in the rust equivalent from previous commit
2024-02-05 12:04:30 +01:00
Olivier Goffart
9200480b53 Fix a few links to the docs that changed with the new structure 2024-02-03 09:38:49 +01:00
Simon Hausmann
b4cddbbe18 Python: Add support for converting structs
They map to Python dicts.

cc #4202
2024-02-02 22:15:52 +01:00
Yuya Nishihara
004749157f Fix rust codegen to skip over backslash-escaped character
If the generated code contains "\"" and format!("{}", ..), the latter would be
corrupted because the code formatter rewrites "{}" as if it were a code block.
2024-02-02 08:35:03 +01:00
ogoffart
fec2b961db Bump version number to 1.4.1 2024-02-01 09:12:42 +00:00
Simon Hausmann
5d3ad7b252 Python: Fix venv setup
A subtly missing letter :)
2024-01-31 17:04:06 +01:00
Simon Hausmann
45f182e666
C++: Permit passing a value to VectorModel::set_vector by value (#4491)
The previous signature would not allow that, but we should allow it for consistency with the constructor.
2024-01-31 16:09:06 +01:00
Simon Hausmann
988e4fcd09 Bump more version numbers in Rust docs 2024-01-31 09:12:27 +01:00
Simon Hausmann
a90a75266d Bump version number in mcu docs 2024-01-31 09:11:01 +01:00
Florian Blasius
39106acbdc
Added runEventLoopUntilQuit for node (#4444)
Co-authored-by: Simon Hausmann <simon.hausmann@slint.dev>
2024-01-30 05:46:46 +00:00
Olivier Goffart
fa24283cd4 Add a few funciton to make SlintContext usefull
Make it possible to spawn future and run event loop with a SlintContext
handle
2024-01-29 15:34:48 +01:00
Simon Hausmann
108975ad6c Add deno to the Slint-node cover docs
- We could import from `npm:...` directly, but by using an import map, the import is centrally controlled and all subsequent snippets for Node.js can also be used with Deno
- Use .mjs for the node snippet as we use ES module syntax

Unfortunately our own examples can't be equipped with a deno.json yet as
deno does not support yet imports of node modules from a local path.
2024-01-26 18:55:38 +01:00
Olivier Goffart
83adb467c0 Only depends on i-slint-backend-linuxkms on linux, even if the feature is enabled
This allows to simplify the npm build as well
2024-01-26 13:46:11 +01:00
Simon Hausmann
c10f0c7f13 Node.js: Refine features for binary npm packages
Use the same features as for the the lsp.
2024-01-26 11:23:07 +01:00
Olivier Goffart
1e19e0a754 Rust codegen: fix compile if slint names matches internal names
Fixes #4419
2024-01-24 22:47:58 +01:00
Olivier Goffart
573d4a3b50 Remove the test function for sending double_click
They are not commonly used so no need to use semi-public api for that
and it's really easy to similate with ust two clicks anyway

The previous test function were added before there was public way to
send events
2024-01-24 10:20:06 +01:00
Simon Hausmann
9f440c2699 Node.js: Document global singletons 2024-01-23 17:51:01 +01:00
Olivier Goffart
f5bba87db0
Docs: explain how to use tokio futures
Discussed in https://github.com/slint-ui/slint/discussions/4377
2024-01-23 17:43:36 +01:00
Olivier Goffart
5a43f3b8af Janitor: dependency updates 2024-01-22 12:36:32 +01:00
Simon Hausmann
8e0af0bf63 C++: Add convenience functions to clear and replace the VectorModel's vector
This was requested by a customer recently and it seems rather straight-forward to implement and offer. `clear()` mirrors `std::vector::clear()` and `set_vector` mirrors the `set_vec` we have in Rust.
2024-01-19 16:58:20 +01:00
Simon Hausmann
d44717a11d doc: Add a section for targeting MCUs in the C++ documentation
Fixes #4180
2024-01-19 11:42:30 +01:00
Simon Hausmann
7a295d1b75 Bump Corrosion
Fixes #2508
2024-01-17 18:08:59 +01:00
Simon Hausmann
dd0805c8fc Node.js: Add binaries for macOS and Windows
These are built with the default features of the interpreter crate, as
unfortunately napi-rs doesn't allow us to select features on the command
line yet. The next version (3.0) will add that, then we can keep the
binaries in sync.

So meanwhile, these are basically winit/femtovg/software enabled
binaries.

cc #1991
2024-01-17 11:48:54 +01:00
Simon Hausmann
787a8d6bfb Node.js: Include napi generated module loader in npm package
That might help with build-on-demand.mjs trying to load it :)
2024-01-16 09:28:21 +01:00