Commit graph

263 commits

Author SHA1 Message Date
Olivier Goffart
9fa59d38cd Generate the enum documentation based of the common/enums.rs
So that makes it harder to forget to update the docs

Note that the new builtin_enums.md does not contain a `### Values`
section header anymore. Also some enum where documented with the full
enum value (such as `TextHorizontalAlignment.left`) while now this
is omitted

The CI should fail if one forget to run `cargo xtask enumdocs` after
adding an enum or changing the docs
2022-05-13 13:15:51 +02:00
ogoffart
3709ded44d Bump version number to 0.2.5 2022-05-09 16:16:00 +00:00
ogoffart
c160ec2aef Bump version number to 0.2.4 2022-05-09 13:49:25 +00:00
Olivier Goffart
2aaefa8e0d C++: Setting a value to a property having a binding should always clear the binding
... even if the old value holds the same value as the new value

This fixes test_cpp_bindings_two_way_priority_default

Also add a C++ unit test that tests the Property type specificaly
2022-05-09 09:30:01 +02:00
Olivier Goffart
51146eccd1 Update corrosion 2022-05-09 09:23:23 +02:00
Olivier Goffart
bc0f878799 Update corrosion 2022-05-05 08:54:32 +02:00
ogoffart
6395cdfc09 Bump version number to 0.2.3 2022-05-04 12:32:58 +00:00
Olivier Goffart
59cc65c774 Janitor: upgrade cbindgen 2022-04-26 11:55:34 +02:00
Tobias Hunger
416aa42d90 Component: Replace parent_item to parent_node
Remove the `parent_item` function. After the recent changes that did not
return an item anymore and since the item tree is exposed, this function
was only used to find the repeater a component was created by.

So replace the old function with a new one that only returns the parent
node in the parent component.

This saves a few lines of generated code that is not used anymore.

Co-authored-by: Simon Hausmann <hausmann@gmail.com>
2022-04-20 14:29:18 +02:00
Olivier Goffart
af3db79472 Janitor: Update cbindgen 2022-04-19 15:32:42 +02:00
Olivier Goffart
8117e7f03d C++: make Model::track_row_data_changes const 2022-04-19 15:12:15 +02:00
Olivier Goffart
2f67564ea9 C++: add a Model::row_data_tracked function 2022-04-19 15:12:15 +02:00
Olivier Goffart
452bc2a696 Update MSRV to rust 1.59 in the CI and documentation
This is only required for dependencies of slint-build and xtask.
So this is not enforced yet and will still work with 1.56 with
for C++ or when not using slint-build.
2022-04-14 19:18:05 +02:00
Olivier Goffart
e85e69fda0
Declare .slint enum in one place in i-slint-common
This avoid repeating the enums both in the compiler and in
the runtime library, and register them in a bunch of other places.

So it should be easier to add enums and enum values

Since cbindgen doesn't see through the macro, generate the enum
manually
2022-04-14 19:17:48 +02:00
Olivier Goffart
f5030cff06
Add a reset function to the model notifier 2022-04-14 14:06:34 +02:00
Simon Hausmann
9a8c5fed9f Remove the ugly style
It's ugly ;-)

The combo box for the style is commented out for now, so that we can
easily re-add it in the future once we add a new style.
2022-04-13 10:35:42 +02:00
Olivier Goffart
54a6cb22ee Allow .darker and .brighter on Brush 2022-04-12 13:01:53 +02:00
Olivier Goffart
1b91158b46 corelib: allow to use i32 for coordinate instead of f32 2022-04-11 17:46:50 +02:00
Olivier Goffart
40c98d6d05 Update cbindgen and enable MouseCursor::move
cbindgen 0.21 was released which contains https://github.com/eqrion/cbindgen/pull/724
which allow to use raw identifier in enums shared with C++.
So now we can have `MouseCursor.move` in slint  despite it being a rust keyword

Note that the strum macro also have trouble with the raw identifier, so we
take that in account in the conversion functions in the interpreter
2022-04-05 06:39:50 +02:00
Olivier Goffart
d940a0b35d Fix NativeSlider::changed in C++
FloatArgs is not properly exposed to C++
2022-04-04 17:33:54 +02:00
Simon Hausmann
4c88b2b19b Start a page with examples and recipes
This is the beginning of a page to collect common things users need to
do, in a format that they can copy & paste into their application code.

There's a lot more that could be done though.
2022-04-04 10:01:26 +02:00
Simon Hausmann
ed5b76e7fc Improve syntax highlighting in the language reference
Highlight all Slint code and don't do the preview on snippets where it
doesn't make sense.

Some snippets, such as the bare statement or expression snippets, are
now highlighted, but they are continued to be excluded from the doctest.
2022-04-04 09:58:09 +02:00
Simon Hausmann
9582168d94 Fix broken links to C++ types in C++ Type mapping documentation
The links to slint::Color (and other types) was coded to their direct
.html file name, so for example classslint_1_1_color.html.
Unfortunately in the CI the class name became classslint_1_1color.html
and therefore the links on our website were broken.

Now my-st parser has a way of resolving links in markdown to references,
basically {cpp:class}`slint::Color`. Unfortunately that link resolution
is not working when used inside markdown tables.

Therefore this patch converts the entire table to restructured text,
where we can use native references to hopefully always generate the
correct links, regardless of the doxygen/breathe/exhale version.
2022-03-31 21:48:27 +02:00
Tobias Hunger
e5aadd7c26 C++: Make component_at() return a ComponentWeak 2022-03-28 14:13:36 +02:00
Tobias Hunger
ee68716d07 Component: Add information to stich together ItemTrees
Add accessors to the information necessary to stitch together the
Component-wide ItemTrees (which include DynamicNodes) into one logical
tree of Items.
2022-03-28 14:13:36 +02:00
Simon Hausmann
df2d6442d4 Make it possible to disable the slint compiler from the CMake build
This isn't always needed, for example when using only the interpreter API,
and its dependency to native libraries on Linux (namely fontconfig) makes it difficult to cross-compile with
CMake.

While cargo is invoked correctly for the native binary build, the library search paths
coming from CMake will be target specific, not host specific.

So for now this provides a way of disabling the compiler.
2022-03-22 12:59:52 +01:00
Simon Hausmann
535e134223 Add a Layer element that's created when using a layer boolean property
For now no backend implements this optimization hint.
2022-03-21 20:22:43 +01:00
Simon Hausmann
9b62b08ed6 Fix CMake setting DT_NEEDED to the absolute soname of libslint_cpp in apps
As per rust-lang/cargo#5045, cargo does not set soname on created
cdylibs. We use corrosion to import our .so into CMake, which ends up
passing the absolute path to the .so to the link line of the
application. Due to the lack of DT_SONAME, this means that DT_NEEDED of
the application contains the full path to libslint_cpp.so. This is
sub-optimal for example for building Yocto SDKs, the build paths should
not end up in the created binaries.

The library should be located using the linker's search paths and the
.so name. For convenience, the application can use rpath to extend those
search paths (and usually CMake already does that), but there is no need
to code the absolute path to the library.

Set the IMPORTED_NO_SONAME CMake variable to work around this.

This can be verified with the steps as in #1066.

Fixes #1066
2022-03-18 16:58:53 +01:00
Tobias Hunger
86a6add32c janitor: Fix typos and make cspell happy 2022-03-18 10:15:44 +01:00
Tobias Hunger
526166090e cmake: Do not break when slint is build with empty CMAKE_BUILD_TYPE
Do not break building against slint using CMake from C++ when no
CMAKE_BUILD_TYPE was set when building Slint.

This just makes sure the build type is properly quoted, which makes sure
we keep a (empty) string token where CMake expects one.

Fixes: #1065
2022-03-17 18:18:20 +01:00
Olivier Goffart
ca5151de11 C++: implement Window::on_close_requested 2022-03-17 14:49:12 +01:00
Tobias Hunger
bdc3778cec Rename init/free item functions back 2022-03-14 09:43:50 +01:00
Tobias Hunger
095537e3fd Remove item from ItemTreeNode
... and make ItemTreeNode non-generic this way.

The Item is now only in the extra ItemArray struct and we are free to
expose the ItemTree further.
2022-03-14 09:43:50 +01:00
Tobias Hunger
5d3f296af9 API: Change WindowRc::free_graphics_resources and init_items on C++
Use the ItemArray in both cases.
2022-03-14 09:43:50 +01:00
Tobias Hunger
1fd14272cf Use item_array in C++ 2022-03-14 09:43:50 +01:00
Simon Hausmann
b34f733716 Point C++ users to the new release/0.2 branch
That way version upgrades to new patch release become easier.
2022-03-10 11:08:58 +01:00
ogoffart
7b50791db4 Bump version number to 0.2.2 2022-03-10 08:48:33 +00:00
Olivier Goffart
3b2b1c92a4 Update version number in docs and readmes
```
sed --follow-symlinks -i 's/^\(slint.*\) = ".*"/\1 = "0.2.1"/' **/*.rs **/*.md
sed --follow-symlinks -i 's/GIT_TAG v.*$/GIT_TAG v0.2.1/' **/*.md
```
2022-03-10 08:46:16 +01:00
Tobias Hunger
ebe3a3c37c cpp: Fix cmake property mapping
Fix the mapping between a projects CMAKE_BUILD_TYPE and the build type
of the imported Slint library.

Fixes #1027
2022-03-09 19:53:06 +01:00
Olivier Goffart
15781411de C++ interpreter: Cast the pointer, not the reference
May result in warnings otherwise

```
slint_interpreter.h:426:79: error: dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing]
  426 |                 &inner, &reinterpret_cast<slint::SharedVector<ValueOpaque> &>(array))) {
      |                                                                               ^~~~~
```
2022-03-09 13:11:05 +01:00
Simon Hausmann
583c7a1b80 Fix C++ build
With ImageInner::StaticTextures (the variant) and StaticTextures (the
struct), we need to disambiguate for the generated enum contructor
functions. This is done by prefixing the enum variant with their name.
2022-03-03 14:39:11 +01:00
Jared Moulton
fdbc8056b3 Add an option to draw *'s instead of characters for password fields 2022-03-02 15:47:32 +01:00
Simon Hausmann
39a2290221
Build the backends without rtti unless needed (#1001)
* Build the backends without rtti unless needed

Only the interpreter needs the rtti generated code.

 * Since `SlintElement` emits `#[cfg(feature = "rtti")]` tokens, each
 crate using `SlintElement` needs to have an `rtti` feature.
 * The selector gets backend specific rtti selection features, in order
   for the interpreter to enable them.
* Enable rtti when building the C++ project with the interpreter enabled
2022-03-01 18:37:07 +01:00
n-raine
beda5aca07 Add dark style detection support for GL backend
With the help of dark-light crate this is now exposed as dark-style
boolean property in NativeStyleMetrics.

Co-authored-by: Olivier Goffart <olivier@slint-ui.com>
Co-authored-by: Simon Hausmann <simon.hausmann@slint-ui.com>
2022-03-01 16:41:20 +01:00
Olivier Goffart
0dc188f328 Support for referring to other globals from globals
- We need to make sure that the initialization of global is in the right order.
 - In C++ and rust, we need to add accessor to the global component
 - There can be `PropertyReference::Global` in binding of globals
 - The interpreter globals need to hold references to the global they may depend on

Fixes #175
2022-02-28 10:14:34 +01:00
Olivier Goffart
350f0d0d6a
C++ interpreter API: add a Value::Value(int) constructor (#974) 2022-02-21 14:00:51 +01:00
Olivier Goffart
ea2e91ece9 Upgrade Catch2
I get a compilation error otherwise

```
_deps/catch2-src/single_include/catch2/catch.hpp:10830:58: error: call to non-‘constexpr’ function ‘long int sysconf(int)’
10830 |     static constexpr std::size_t sigStackSize = 32768 >= MINSIGSTKSZ ? 32768 : MINSIGSTKSZ;
      |                                                          ^~~~~~~~~~~

```
2022-02-21 13:30:01 +01:00
ogoffart
ecd0fb7ecd Bump version number to 0.2.1 2022-02-10 16:25:28 +01:00
Olivier Goffart
e429968a15 Update version number in the docs 2022-02-09 17:08:19 +01:00
Olivier Goffart
567b54501a Upate the links to the templates repository
Also update a few more links and reference to slint in the readme
I know this means that we will have invalid links and instructions until the release,
but the instructions are already broken anyway
2022-02-09 15:49:18 +01:00