Commit graph

881 commits

Author SHA1 Message Date
Simon Hausmann
42d575262e
Fix SharedString::end() throwing an exception when MSVC iterator debugging is enabled (#4017)
Don't dereference end() of a string_view.

Co-authored-by: Olivier Goffart <olivier.goffart@slint.dev>
2023-11-27 18:11:55 +01:00
Olivier Goffart
b903c60a3a Upgrade corrosion 2023-11-23 09:34:27 +01:00
ogoffart
0a5bf6c37b Bump version number to 1.3.1 2023-11-23 07:47:07 +00:00
Olivier Goffart
e008019243 C++: Fix warning on macOS about unused variable 2023-11-17 10:58:20 +01:00
Olivier Goffart
0efd2fd2a4 janitor: code formating 2023-11-03 15:43:29 +01:00
Olivier Goffart
f043234890 C++: fix (private) properties of type EasingCurve
tests/cases/properties/animation_props_depends.slint in previous commit
added a property<easing> and that didn't work with C++
2023-11-03 15:11:06 +01:00
Ken Carpenter
b20536131f
Add more easing formulas (#3812)
Closes #2655
2023-11-03 09:20:44 +01:00
Olivier Goffart
243b44d424 Fix C++ after refactoring of the KeyEvent 2023-11-02 12:16:40 +01:00
Olivier Goffart
1efd83621d Refactor: Merge KeyInputEvent and KeyEvent
Both structure are bascially the same and only used internally, no need
to have the two.

The only difference was that one had the modifiers and the other one
not. But we can just set the modifier at the point we were converting
between the two.
2023-11-02 12:16:40 +01:00
Aurindam Jana
50a6040c38
Update cpp docs on installing or building slint (#3821) 2023-11-01 19:10:04 +01:00
Olivier Goffart
ac8fd60091 Fix regression with empty array
Regression noticed in this line:
3f97d98bff/ui/tabs/downloads.slint (L77)

The following used to work:

```slint
import { Button, VerticalBox } from "std-widgets.slint";
export component Demo {
    in property <[int]> mods;
    VerticalBox {
        alignment: start;
        for xxx in true ? mods : [] : HorizontalLayout { alignment: center; Button { text: "OK!"; } }
    }
}
```

But we fixed array conversion and this caused a regression with empty
array
2023-11-01 11:30:59 +01:00
Simon Hausmann
1441719f61
Fix cross-compilation of C++ interpreter API to 32-bit architecture (#3810)
cbindgen doesn't reliably tranfser the 64-bit/32-bit #ifdefs around ValueOpaque.
Instead, move Value onto the heap by using a Box.

Fixes #3653
2023-10-31 17:33:49 +01:00
Olivier Goffart
d55803d290 Models: fix writing data doesn't update ListView model data property
This fixes a couple of bug:
 - Bug #3740 happens because `Repeater::model_set_row_data` did not use
   the inner.offset to get the instance (So that's the `val == 106` part
   of the test)
 - But I went ahead and also tested what happenned if you changed the
   model from the "outside" using the `model[i] = `, and that was not
   implemented, hence the move of the code from
   `Repeater::model_set_row_data` to `RepeaterTracker::row_changed`,
   That does need Pin though, so Pin was added everywhere
 - C++ is not affected by bug #3740, because because the C++ listview
   don't do the "allocate only visible" optimization. But the
   "val == 1106" part of the test would fail so this patch also moces
   the update from  `model_set_row_data` to `row_changed`.
   But following that we don't set the state as Dirty in `row_changed`,
   the write_to_model test started filling  because the `row_added`
   function was missing an update of the index on every further items

The change in the interpreter prevent a borrow_mut from causing trouble.
The Value really don't need to be in a RefCell anyway

Fix #3740
2023-10-31 13:41:31 +01:00
Olivier Goffart
0c529cd345 janitor: Some no-brainer deps update 2023-10-27 19:11:38 +02:00
Olivier Goffart
78d273e599 Revert "Reduce the amount of re-creation of cells in repeaters when the model changes (#1954)"
This reverts commit 1162ebbb79.

Because otherwise if we keep the elements, their internal state is kept
and this causes bug #2598

Fixes #2598
2023-10-23 16:52:03 +02:00
Olivier Goffart
12cd8e71f1 WIP: some polish over the winit update to 0.29 2023-10-23 14:22:48 +02:00
Olivier Goffart
5bf2c7192b Fix panic with very large ListView
In `ItemRc::find_sibling` we currently do:
 1. get the range
 2. check that the next index is within the range
 3. call `get_subtree`

The problem is that get_subtree itselg will call 'ensure_updated' which
will do the relayout of the ListView and may get a different range of
element.

So don't query the range before and just have get_subtree to return an
empty ItemWeak if we are out of the actual range.

Couldn't really find a way to make a test since this is called from
the accessibility code which is hard to test as is

For #3700
2023-10-21 14:03:39 +02:00
Olivier Goffart
f4dd08783c janitor: C++: make the code more readable by having the type explicit 2023-10-19 18:09:14 +02:00
Olivier Goffart
172dcfa775 C++: fix crash when accessing empty model from Slint
Fixes #3704
2023-10-19 18:09:14 +02:00
Simon Hausmann
e0d1d4366d doc: In the type mapping, refer to the angle as "angle", not as "value" 2023-10-17 13:26:04 +02:00
Tobias Hunger
b12575a4c4 janitor: Go over our spell checking setup
* Extend the cspell word list
* Remove those extensions from individual source files
* white-list licenses and such as we should not meddle with those
* Fix spelling
2023-10-16 09:01:51 +02:00
Olivier Goffart
347b2d0fbf C++: Don't use optional::value
It is not available when targetting older macOs since it can throw an
exception that needs library support
2023-10-11 07:57:57 +02:00
Simon Hausmann
f5c3908b7e Fix build of Skia renderer in Yocto for armhf
As per commit 69feb7f0f40cc8dc4ca52777cf87a4c879d4b953 in meta-slint and
others, the Skia build is tricky because clang needs to be indirectly
and carefully instructed where gcc headers are located. In the Yocto
recipes, we go through lengths to set CLANGCC/CLANGXX correctly so that
the --target matches the triplet sub-directories in
recipe-sysroot/usr/lib and recipe-sysroot/usr/include/c++/$ver/ .

For aarch64 it's simple, there's usually just aarch64-$distro-linux, but
for example for armv7-$distro-linux-gnueabihf magic has to come
together: The gcc install dir is typically
recipe-sysroot/usr/lib/arm-$distro-linux-gnueabi (note the v7 and hf
absence). That means that's what --target needs to be when invoking
clang. But now the `hf` suffix is gone, which means clang relies on for
example -mfloat-abi=hard to avoid the use of gnu soft-float stubs. All
that's meticulously prepared in the Yocto recipe and placed for easy
consumption in CLANGCC/CLANGCXX environment variables. Therefore, when
those environment variables are set, don't overwrite them in
CORROSION_ENVIRONMENT_VARIABLES.when those environment variables are
set, don't overwrite them in CORROSION_ENVIRONMENT_VARIABLES.
2023-10-10 15:25:42 +02:00
Olivier Goffart
b88a3caacd swrenderer: Put the rotation feature behind a freature gate
We're not ready to make the API public as we want to have the API as
part of the Window rather than part of the renderer
2023-10-09 18:07:23 +02:00
Olivier Goffart
414a9e85e7 Expose swrenderer screen rotation to C++ and esp-idf 2023-10-09 18:07:23 +02:00
Olivier Goffart
091dd0a7b9 Rename dynamic_component to dynamic_item_tree 2023-10-09 11:01:56 +02:00
Olivier Goffart
a5488d6285 Rename RepeatedComponent -> RepeatedItemTree
And some more cleanups
2023-10-09 11:01:56 +02:00
Olivier Goffart
852b4d906d Rename ComponentVTable to ItemTreeVTable
and their related name.
Also move the component module in the item_Tree module
register_component -> register_item_tree
ComponentItemTree -> ItemTreeNodeArray

For #3323

Rationale from that issue:

Right now, we use the term `component` in the Slint language and in the compiler to be a a tree of elements that can be used as an element in a .slint file.

The term is also currently used in the runtime as a tree of runtime Items that are allocated together. (declared in ComponentVTable)

But there are no 1 to 1 mapping between a `component` in the slint language, and a runtime Component.
(for example, the items behind a `if` or `for` or `PopupMenu` are in a different runtime component. And `component` declared in Slint are often inlined)

So we should rename the internal runtime `Component` to  `ItemTree`

The currently public `slint::ComponentHandle` wraps the "root" of the ItemTree, but that's ok because it is generated from a .slint `component`,  so it doesn't change name
2023-10-09 11:01:56 +02:00
Olivier Goffart
4c0a435196 Implement TouchArea::scroll-event
Closes #1280
2023-10-07 07:59:53 +02:00
Olivier Goffart
22284000ec esp-idf: Wait for vsync before swapping frame buffers 2023-10-06 17:19:07 +02:00
Simon Hausmann
231dbd5695 Revert "Revert "Improve file type for SLINT_COMPILER cmake cache variable""
This reverts commit 292f487815.

Olivier had the brilliant idea of preceeding the path with a slash
on the Yocto side, so we can go back to the correct "type".
2023-10-06 14:56:28 +02:00
Simon Hausmann
292f487815 Revert "Improve file type for SLINT_COMPILER cmake cache variable"
This reverts commit 0773e51d92.

By the SLINT_COMPILER being a `FILEPATH`, cmake will convert any
relative path to an absolute path. That's not wanted for the Yocto
build, because there we pass
'$ENV{OECORE_NATIVE_SYSROOT}/usr/bin/slint-compiler', so that
the path is resolved dynamically against the environment variable that
the Yocto SDK sets.

CMake would convert this to an absolute path that points into the build
directory, i.e. it would be /home/blah/foo/\$ENV{...}
2023-10-06 13:05:30 +02:00
Simon Hausmann
a982bdebe2 Fix cmake producing absolute DT_NEEDED paths in applications when linking against installed libslint_cpp on Linux
Commit 9b62b08ed6 fixed
https://github.com/slint-ui/slint/issues/1066 initially, but commit
1036c0d082 erroneously regressed this
again, because while Corrosion sets this property, it is only set on the
locally generated CMake target. We still need to propagate that also
into the installed CMake target, which this patch does.
2023-10-05 16:07:28 +02:00
Simon Hausmann
dbabb33c45 Fix build of dependencies that use pkg-config when building Slint in buildroot
When building with cmake, buildroot sets PKG_CONFIG_SYSROOT_DIR in its
toolchain file, and therefore it's only available at configure time but
not build time, which is when our dependencies need it.
2023-10-05 09:39:04 +02:00
Simon Hausmann
0773e51d92 Improve file type for SLINT_COMPILER cmake cache variable
Use a FILEPATH to reflect that this is a path to a file and then the cmake configurator will
show a file dialog.
2023-10-02 13:15:20 +02:00
Olivier Goffart
d688f37ee8 Change alias to the native style depending on the platform
Fixes #3431
2023-09-29 17:05:10 +02:00
Simon Hausmann
87a548a972 Fix cross-compilation with a Yocto SDK
Since commit 7947f233f1a744f5ce9dfdf44372727d4fefb50b in Corrosion,
cmake will default to ${CMAKE_C_COMPILER} for linking a cdylib,
which means that C must be enabled as a language in the project.

Previously, it tried C, CXX, and Fortran and picked the first one.
2023-09-29 12:03:40 +02:00
Tobias Hunger
85e1c6020b janitor: Use workspace dependnecies for the slint crates
This moves most of the version information we need to update into one
place.

Note that the workplace dependency features are in *addition* to any
feature set when using the workspace dependency. So we have all
workspace dependencies defined with `no-default-features = true`.
2023-09-25 16:34:16 +02:00
Tobias Hunger
d6695c55cb Janitor: Use cargo workspace package data more 2023-09-25 16:34:16 +02:00
Olivier Goffart
36f43d535f fix typo in esp-idf README
Also lists in lists don't render well on components.espressif.com, so
don't use two level of numbers
2023-09-22 09:07:25 +02:00
Olivier Goffart
855cc025b0 esp-idf README: add information about missing stack or RAM 2023-09-19 12:51:35 +02:00
Simon Hausmann
55b2ff280d Troubleshoot Slint for ESP-IDF on Windows 2023-09-19 12:28:00 +02:00
Olivier Goffart
14f7fe4ba2
cmake: add flags to only build the compiler
... and to use an external compiler

For example, this is how one only build the compiler:

```
cmake .. -DSLINT_BUILD_RUNTIME=OFF -DCMAKE_INSTALL_PREFIX=/tmp/slint_compiler
make install
```

And this only build the runtime
```
cmake .. -DSLINT_FEATURE_COMPILER=OFF -DCMAKE_INSTALL_PREFIX=/tmp/install_runtime
make install
```

And then this can be used in a project like so:
```
cmake .. -DCMAKE_PREFIX_PATH=/tmp/install_runtime/ -DSLINT_COMPILER=/tmp/install_compiler/bin/slint-compiler
```
2023-09-15 14:42:52 +02:00
Olivier Goffart
e0fd9a6105 WIP: Add item_geometry to the ComponentVTable
(unused yet)
2023-09-13 16:08:37 +02:00
Olivier Goffart
8f61f1c2a7 Update esp deps 2023-09-13 14:33:44 +02:00
Olivier Goffart
5d37a4a158 Update to corrosion 0.4.3
That include a fix for parsing espressif target so workaround can be
removed
2023-09-13 11:36:46 +02:00
Simon Hausmann
8b478431a7 Help the Skia build to find clang
..even if cmake sets CC/CXX to GCC.
2023-09-13 10:11:39 +02:00
Simon Hausmann
c8b05c2b05 Add documentation about the different renderers, their pros/const, and availability in backends and API 2023-09-12 11:28:17 +02:00
Simon Hausmann
3652f58a3f Change item indices from usize to u32
So that the compiler and run-time can never disagree on the
number of bytes the item index can use.
2023-09-12 08:53:58 +02:00
Simon Hausmann
090665de13 Remove traces of required C++ exception support
After commit cf19749943 this isn't needed anymore.
2023-09-07 11:32:56 +02:00