CMake 4.0 remove some deprecated code < 3.5
Catch2 old version still depend against cmake 3.0 + deprecated method.
Necessary to increase version otherwise when we try to compile
example with cmake 4.0 it will failed to configure it
This ensures that the binary directory path isn't exposed in the
target's `INTERFACE_INCLUDE_DIRECTORIES`.
This prevents CMake errors when we `install` a target with generated
Slint sources in the include directory:
```
[cmake] CMake Error in slint/cpp/CMakeLists.txt:
[cmake] Target "slint-demo-cpp" INTERFACE_INCLUDE_DIRECTORIES property contains
[cmake] path:
[cmake]
[cmake] "/path/to/build/slint/cpp"
[cmake]
[cmake] which is prefixed in the build directory.
```
This adds an icon that is displayed to the left of the title, and is
also shown for Menus are inside of a parent menu.
Closes#7791
ChangeLog: Added icon property to MenuItem and Menu
For the slint-compiler, we use ${CMAKE_SYSTEM_PROCESSOR}, which on Windows is - unfortunately - derived from the PROCESSOR_ARCHITECTURE environment variable, and
thus AMD64 or ARM64. Fix the package suffix on the CI side.
We could try to make the cmake variable to known values and then arm64/x86_64, but I'd rather stick with less exceptions when these names are not really visible in the documentation or our users.
The same applies to the C++ packages, where the CMake/Windows suffix (AMD64/ARM64) works better with FindSlint.cmake's use of the corresponding variable.
Similarly, the tool binaries were called
slint-viewer-windows-aarch64-pc-windows-msvc, but neither the compiler, nor the rest of the triplet is needed, merely the architecture. So rename it to slint-viewer-windows-arm64 and x86_64. Here we don't need cmake and can use the "correct" suffixes.
Python is missing, otherwise this builds windows arm64 binaries for the
tools, C++ packages, slint-compiler, npm binaries, and lsp binaries for
the VS code extension.
Because some crate in our examples are using the edition2024 resolver
with no way to remove them without removing the exmaples from the
workspace, this means that effectively the C++ build which needs to run
the cargo metadata on the workspace, doens't build anymore with the
rust MSRV
ChangeLog: C++: requires Rust 1.85
This exposes FocusReason to .slint, and adds it as an argument to focus-event-changed callback on FocusScope to close#8387. It also adds two new callbacks, focus-gained and focus-lost, which are identical to focus-event-changed but are only invoked on focus gain or loss respectively.
In addition to this, it removes the FocusEventReason::AccessKit variant, replacing it with the mouse variant to hopefully make AccessKit more compatible with any Slint code that will use FocusEventReason.
Finally, I added two tests based on focus_change_event.slint, one for testing the FocusEventReason argument and another for testing the new callbacks.
close#8387
ChangeLog: Added `focus-gained` and `focus-lost` callback to FocusScope. Pass an `FocusReason` enum to the FocusScope callbacks
Closes#5992
Adds the enum FocusEventReason and makes it an argument for FocusEvent. This reason could eventually be exposed in Slint to solve #8387.
Using the focus reason tracking, I also added a select all on keyboard focus for TextInputs (except on macOS), which should close#5992.
ChangeLog: TextInput selects its content when focused with the keyboard on Windows and Linux
We currently forward declare classes as we use them in functions.
But this breaks if classes with the same name were declared in the
parent namespace. As shown with this example
```C++
// Uncomment that line to make the code break
//struct SharedGlobals;
namespace ns {
// Is that a forward declaration in `ns`?
// Depends if it was declared before in the parent namespace
void foo(struct SharedGlobals *x) {}
// Actualy define ns::SharedGlobal
struct SharedGlobals { int x; };
int xyz() {
SharedGlobals globals;
foo(&globals);
}
}
```
So make sure we forward-declare the classes properly to be more robust
and be able to include generated file with namespace after a file
without namespace
CC #2909
To be compatible with the 2024 edition, we need to wrap the
`no_mangle` attribute in `unsafe()`.
The parsing for that in cbindgen was only added in the version 0.28,
but we couldn't upgrade cbindgen before because of a regression in
cbindgen 0.27 that prevented us from upgrading.
Now that cbindgen 0.29 is released with a fix, we can prepare for the
2024 edition
This is still experimental API, but just have a copy of all arguments in
a plain struct that the C++ code can operate on.
(Because previous refactor of the interface had made it hidden from C++)
Instead of using datastructure that are tailored to our line by line
renderer and draw functions, use more generic and future proof data that
are easier to handle by hardware accelerator, and may be easier to
stabilize.
The screenshots from the screenshots test have to be re-done
because the rounding is different
Note: the C++ API DrawTextureArgs is not exposed yet
This adds a `unstable-wgpu-24` feature that exposes WGPU types in the
GraphicsAPI enum, adds `require_wgpu_24()` to the backend selector,
and adds a conversion from `wgpu::Texture` to `slint::Image`.
The `require_wgpu_24()` function in the selector will be extended in the
future (before the next release) to permit specifying additional aspects
of the WGPU configuration.
Co-Authored-By: Olivier Goffart <olivier.goffart@slint.dev>
... by changing the resolution for the `WindowItem` to traverse the
item tree from the current item, instead of going to the window.
This doesn't quite fix#4298 because `rem` resolution is still missing.
That requires the built-in default font size function to be fixed as
well, which is non-trivial.
cc #4298
Conversion from negative float to unsigned is saturating to 0 in rust
and undefined behavior in C++, we should therefore handle the case
properly
Fixes#8222
Commit cd6f2e2 reformated the .toml, but the 80 char width column is
judged too small to be practical
Add a .taplo.toml file
Also do not split feature array
* C++: add `notify_` prefix to the Model functions and add docs
The `notify_*` function are used by the model to notify the view.
As opposed to the function without the prefix, which are used to get
notified when a source model change
Fixes#3888
CC #3945 (for the docs about thread safety)
... using taplo with default settings
I tried this with 4 spaces indentation, but the patch is almost as
big as this one, so I went with default settings instead as that
is just easier:-)
Right now we always `lock().value()` it which is the equivalent of
`upgrade().unwrap()` in rust, this helps because it keeps the parent
alive when we are calling function in it.
Ideally we should also check that it wasn't deleted, but that's another
issue.
Fixes#7880
Most of the slint.h file is used for model code, so before doing some
work on the model i wanted to refactor the code in its own file.
Since the model need access to the ComponentHandle, i also had to move
that in its own file
I found `mise` a tool to help manage development projects.
https://mise.jdx.dev/
It basically can manage ENV vars based on the directory you are in,
manages tools you need (and makes thoser available based on the
directory you are in), and allows to define simple tasks that can
then be shared between developers.
Tools can be found in npm, pipx, aqua, binaries on github, ...
and it tries to verify signatures and all that (if supported by the
repo the data comes from).
I replaces the entire autofix workflow with mise tooling and tasks,
just to give it a try :-)
To reproduce:
```sh
> cargo install mise # to get the tool itself
# Follow the necessary step
# https://mise.jdx.dev/installing-mise.html#shells
# to intergate into your shell
> cd /your/slint/folder
# Mise will now ask whether or not to trust this dir and prints the
# command needed to do so. Run that.
> mise install # Install all the tools defined in .mise/config.toml
# Add a .mise.local.toml with local overrides. Git will ignore this file.
# Or add tasks into .mise/tasks/local ... Git will also ignore those.
> mise run 'ci:autofix:**:all' # To run all the ci:autofix tasks.
```
It is so much fatser to see these checks fail locally than it is to
bother CI with them :-)