Commit graph

1174 commits

Author SHA1 Message Date
Olivier Goffart
e92dd7797d Rename some occurences 2022-02-02 12:26:55 +01:00
Simon Hausmann
7d297da2fc Rename the sixtyfps C++ namespaces 2022-02-02 12:11:27 +01:00
Simon Hausmann
5226feab01 Rename C++ pre-processor macros 2022-02-02 12:11:27 +01:00
Simon Hausmann
c846633708 Rename C ffi functions 2022-02-02 11:12:34 +01:00
Olivier Goffart
692171bf0c Change the 60 blocks to slint blocs in documentation comments 2022-02-02 10:51:42 +01:00
Simon Hausmann
ef822cc1e8 Clean up target_sources macro
Finish the renaming inside
2022-02-02 10:39:38 +01:00
Olivier Goffart
03534039d6 Replace more .60 by .slint
Mainly an automated change with
    git grep -O"sed -i 's/\.60/.slint/g'" -w "\.60"

and some manual checks
2022-02-02 10:12:31 +01:00
Olivier Goffart
d706d63ce1 Replace references to the .60 files that are now renamed with .slint 2022-02-02 10:12:31 +01:00
Olivier Goffart
0c0a783095 Rename all our .60 files to .slint 2022-02-02 10:05:45 +01:00
Simon Hausmann
b1a70f9e58 Rename the SixtyFPS CMake interface 2022-02-02 09:58:26 +01:00
Simon Hausmann
c333b4de2b Rename the sixtyfps-cpp crate 2022-02-02 09:27:11 +01:00
Simon Hausmann
017da5b3b4 Rename the sixtyfps-compiler crate 2022-02-02 09:07:16 +01:00
Simon Hausmann
809fbfc7a6 Rename sixtyfps-node
This doesn't touch the documentation, just the package/API side
2022-02-01 22:17:35 +01:00
Olivier Goffart
0308f86cd4 Rename sixtyfps_widgets.60 to std-widgets.slint 2022-02-01 18:58:54 +01:00
Simon Hausmann
2f73a27635 Rename the sixtyfps-interpreter crate 2022-02-01 18:11:25 +01:00
Simon Hausmann
cab22f8355 Rename the sixtyfps-compilerlib crate 2022-02-01 18:08:18 +01:00
Simon Hausmann
9494068201 Rename the sixtyfps-rendering-backend-selector crate 2022-02-01 18:06:49 +01:00
Simon Hausmann
2e04b3c8b3 Rename the sixtyfps-rendering-backend-gl crate 2022-02-01 18:04:38 +01:00
Simon Hausmann
19eb3e671d Rename sixtyfps-rendering-backend-qt 2022-02-01 18:04:32 +01:00
Simon Hausmann
ad0c020aa4 Rename the sixtyfps-corelib crate 2022-02-01 18:04:30 +01:00
Olivier Goffart
f9c3e7a8de C++ interpreter: first crash when invoking native callback
This was a regression following the move to the edition 2021.
The CallbackUserData was not capture in the lamda, its member were moved.
So the destructor was called right after it was set.
We must make sure we capture the whole CallbackUserData, so put the callback
inside of it. This also reduce a bit of code duplication at the same time.

Test the callback invokation with statefull lambda
2022-01-31 22:25:24 +01:00
Tobias Hunger
842f75e653 [reorg]: Move api/sixtyfps-rs/sixtyfps-* into api/rs 2022-01-31 18:24:33 +01:00
Olivier Goffart
38d7ac42eb Add compatibility feature to our public crates
We want to be able to put existing functionality behind a feature flag while keeping
the semver compatibility.
This is only possible if that new feature flag is enabled by default, but this is not
working if the users have done `default-features = false` in their Cargo.toml.
So we add new `compat-x-y-z` feature that is mandatory to have and which is
enforced with a `compile_error!`

Now, users that whishes to not have the default features must enable it explicitly.
Say we want only x11 but not qt and wayland, the user will do
```toml
sixtyfps = { version = "0.2", default-features = false, features = ["x11", "compat-0-2-0"] }
```

Now, imagine that in the version 0.2.3, we put the SVG support behind a feature flag.
we will do this in out Cargo.toml:

```toml
[features]
default = ["compat-0-2-0", "x11", "wayland"]
compat-0-2-0 = ["compat-0-2-3", "svg"]
compat-0-2-3 = []

svg = [...]
...
```

That way, the svg feature will be enabled by default for all the users who used previous version
of SixtyFPS, and people that want to disable "svg" can just change from compat-0-2-0 to
compat-0-2-3 in their Cargo.toml
2022-01-31 17:30:24 +01:00
Simon Hausmann
8ec315c941 Remove a doxygen #ifdef
Remove the duplicated definition of the IntSize struct and instead
generate it via cbindgen into the public API.
2022-01-31 17:19:47 +01:00
Olivier Goffart
bdd0b4cc6b document-features: Don't add the Feature flags in the title 2022-01-31 16:38:11 +01:00
Olivier Goffart
6371192bec Add a macro to generate the features documentation from comments in Cargo.toml 2022-01-31 16:38:11 +01:00
Tobias Hunger
a3b86690ff [reorg]: Move the rendering backends into internal 2022-01-31 16:00:50 +01:00
Tobias Hunger
e6b24bceec [reorg]: Set up and populate the internal directory
Move "internal" crates into the `internal` directory. This first batch
includes most of sixtyfps_runtime but leaves the rendering backends
alone for now.

pre-commit applied some cleanups to the moved files:
 - Consistent newline at end of file policy
 - trimming trailing whitespace
 - Formatting Cargo.toml files.
2022-01-31 16:00:50 +01:00
Olivier Goffart
929166f06c Change what is accepted by ModelRc::new and ModelRc::from
- ModelRc::new constructs a ModelRc from a impl Model
 - ModelRc::form constructs a ModelRc from a `Rc<dyn Model>` or `Rc<impl Model>`
2022-01-31 14:44:35 +01:00
Simon Hausmann
648dc34f73 Fix wasm-interpreter build 2022-01-31 14:29:09 +01:00
Simon Hausmann
3eb3ff474c Move sixtyfps::ComponentHandle and sixtyfps::Weak into corelib::api
This allows re-use of these types from node and the interpreter without
depending on the public Rust API crate, which is a heavy dependency.
2022-01-31 14:29:09 +01:00
Simon Hausmann
3aa7588e5a internal cleanup: move the public Rust Window API
Move it from corelib:🪟:api to corelib::api, where we're going to collect more types in the future
that are meant to be re-exported as public API in the sixtyfps-rs and the interpreter crate.
2022-01-31 14:29:09 +01:00
Simon Hausmann
fb64e308b3 Align Rust interpreter instance handling API with the main Rust API crate
Implement `sixtyfps::ComponentHandle` for `ComponentInstance`, instead of providing a copy of the API.

This also removes `WeakComponentInstance` and enables the use of `sixtyfps::Weak` for weak handles. This has the advantage that `sixtyfps:Weak`'s `upgrade_in_event_loop` becomes available with the interpreter, and the
weak handle is Send.
2022-01-31 14:29:09 +01:00
Simon Hausmann
56dca59564 Mark some enums that end up in the public Rust API as non_exhaustive
This allows adding new variants in minor releases without breaking
source compatibility.

cc #431
2022-01-31 12:37:36 +01:00
Tobias Hunger
d59282b3a6 Update api/sixtyfps-rs/migration.md
Co-authored-by: Olivier Goffart <olivier@woboq.com>
2022-01-30 01:26:35 +01:00
Tobias Hunger
018c1a6666 Rename ModelHandle to SharedModel
This patch is mostly a rename now, but also contains a few small
cleanups.

SharedModel implements the Model trait itself and gracefully falls back
to an empty model is no Model was provided. This allows for some small
simplifications.

Also make sure to use the same comparision for SharedModels everywhere.
This fixes the last remaining clippy errors we had.
2022-01-30 01:26:35 +01:00
Matej Zajo Kralik
e2676a5b00 Docs: Fix typo 2022-01-29 12:47:43 +01:00
Olivier Goffart
e28586ede0 Test (and fix) using [] on a temporary array
The C++ code did not compile because it couldn't deduce the template parameter
properly. Since the lambda became a bit big to be placed in one small string,
I moved it into a real function in the header

Example of error:   (sorry for the long lines :-))

```
tmp/.tmpE42a4c.cpp: In member function 'void TestCase::init(const TestCase*, sixtyfps::cbindgen_private::ComponentWeak, uintptr_t, uintptr_t)':

/tmp/.tmpE42a4c.cpp:67:238: error: no match for call to '(TestCase::init(const TestCase*, sixtyfps::cbindgen_private::ComponentWeak, uintptr_t, uintptr_t)::<lambda(const std::shared_ptr<sixtyfps::Model<ModelData> >&, const auto:24&)>) (std::shared_ptr<sixtyfps::private_api::ArrayModel<2, sixtyfps::SharedString> >, int)'
   67 |     self->root_window_1_hello_world.set([&]<typename D>(const std::shared_ptr<sixtyfps::Model<D>> &model, const auto &index) -> D { model->track_row_data_changes(index); if (const auto v = model->row_data(index)) return *v; return D(); }(std::make_shared<sixtyfps::private_api::ArrayModel<2,sixtyfps::SharedString>>(sixtyfps::SharedString ( sixtyfps::SharedString(u8"hello") ), sixtyfps::SharedString ( sixtyfps::SharedString(u8"world") )), 1));
      |                                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/tmp/.tmpE42a4c.cpp:67:41: note: candidate: 'template<class D, class auto:24> TestCase::init(const TestCase*, sixtyfps::cbindgen_private::ComponentWeak, uintptr_t, uintptr_t)::<lambda(const std::shared_ptr<sixtyfps::Model<ModelData> >&, const auto:24&)>'
   67 |     self->root_window_1_hello_world.set([&]<typename D>(const std::shared_ptr<sixtyfps::Model<D>> &model, const auto &index) -> D { model->track_row_data_changes(index); if (const auto v = model->row_data(index)) return *v; return D(); }(std::make_shared<sixtyfps::private_api::ArrayModel<2,sixtyfps::SharedString>>(sixtyfps::SharedString ( sixtyfps::SharedString(u8"hello") ), sixtyfps::SharedString ( sixtyfps::SharedString(u8"world") )), 1));
      |                                         ^
/tmp/.tmpE42a4c.cpp:67:41: note:   template argument deduction/substitution failed:
/tmp/.tmpE42a4c.cpp:67:238: note:   mismatched types 'sixtyfps::Model<ModelData>' and 'sixtyfps::private_api::ArrayModel<2, sixtyfps::SharedString>'
   67 |     self->root_window_1_hello_world.set([&]<typename D>(const std::shared_ptr<sixtyfps::Model<D>> &model, const auto &index) -> D { model->track_row_data_changes(index); if (const auto v = model->row_data(index)) return *v; return D(); }(std::make_shared<sixtyfps::private_api::ArrayModel<2,sixtyfps::SharedString>>(sixtyfps::SharedString ( sixtyfps::SharedString(u8"hello") ), sixtyfps::SharedString ( sixtyfps::SharedString(u8"world") )), 1));
      |                                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
```
2022-01-28 20:32:35 +01:00
Olivier Goffart
5ceeecf22b Some changes to the migration docs
Fixes #888
2022-01-28 15:25:49 +01:00
Simon Hausmann
0fe4c18520 Rename CallCallbackError to InvokeCallbackError in sixtyfps::interpreter
cc #431
2022-01-28 13:46:26 +01:00
Simon Hausmann
a79f3c7185 Make sixtyfps::Weak<T>::upgrade_in_event_loop easier to use
... by taking &self instead of self

cc #431
2022-01-28 10:09:15 +01:00
Simon Hausmann
f31f4201c6 Improve sixtyfps::Image::size() API for consistency
Make size() return an unsigned integer size type instead of floats.

cc #431
2022-01-27 22:15:29 +01:00
Simon Hausmann
8d4927bac2 Fix failing nodejs tests
Also run set_property within run_scoped, so that later invocations of `run_with_global_context`
succeed.

Currently this happens because set_property() on a model property will check for
value type compatibility, which ends up querying the model to compare values,
which in turn calls into JsModel and then into JS (and needs run_with_global_context).
2022-01-27 18:37:36 +01:00
Olivier Goffart
653e7d0c5d Some docs regarding the last model changes in the interpreter 2022-01-27 18:37:36 +01:00
Olivier Goffart
02bfdda0e3 Use ModelHandle in Value::Model
As a drive by change, remove the special comparison
for the SharedVectorModel. Two different model that have the
same elements are still not equal
2022-01-27 18:37:36 +01:00
Olivier Goffart
4aceb1f19c Finish the removal of interpreter::Value::Array 2022-01-27 18:37:36 +01:00
Simon Hausmann
de40e002c3 WIP: Remove sixtyfps_interpreter::Value::Array
This is never created
2022-01-27 18:37:36 +01:00
Tobias Hunger
2a42a55728
Migration docs: Remove one level of headlines 2022-01-26 18:45:35 +01:00
Tobias Hunger
6e74a7b330
Model: Remove deprecated APIs
Co-authored-by: Simon Hausmann <hausmann@gmail.com>
2022-01-26 18:41:15 +01:00
Simon Hausmann
b6492b02e8 Fix read-access through C++ interpreter to models declared as arrays
Arrays declared in .60 are mapped to a SharedVectorModel<Value> in order
to permit for write access. They can also be turned intoValue::Array /
SharedVector<Value> very cheaply, when reading from C++.
2022-01-26 16:24:29 +01:00