Commit graph

871 commits

Author SHA1 Message Date
Olivier Goffart
4c8f7a4103 C++: generate a .zip for the package
For #8665

(untested)
2025-06-11 08:10:51 +02:00
Olivier Goffart
2930d90bf0 Update C++ MSRV
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
2025-06-10 12:15:30 +02:00
Avery Townsend
8c4ccabf7d
Expose FocusReason to .slint as an argument in focus-event-changed and add focus-gained and focus-lost callbacks (#8569)
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
2025-06-04 09:51:26 +02:00
Olivier Goffart
5030431caa C++: make sure we do not crash if a Model::row_data returns nullopt
Rust had a test for it, but C++ not yet

Reported on https://chat.slint.dev/public/pl/pcqefc3fbff3xfuio3uhp58ate
2025-05-30 15:47:13 +02:00
Olivier Goffart
dc915b1af3 C++: add asserts that we are in the main thread
Some checks are pending
CI / build_and_test (--exclude ffmpeg --exclude gstreamer-player, windows-2022, beta) (push) Blocked by required conditions
CI / build_and_test (--exclude ffmpeg --exclude gstreamer-player, windows-2022, stable) (push) Blocked by required conditions
CI / build_and_test (ubuntu-22.04, nightly) (push) Blocked by required conditions
CI / node_test (macos-14) (push) Blocked by required conditions
CI / node_test (ubuntu-22.04) (push) Blocked by required conditions
CI / node_test (windows-2022) (push) Blocked by required conditions
CI / python_test (macos-14) (push) Blocked by required conditions
CI / python_test (ubuntu-22.04) (push) Blocked by required conditions
CI / cpp_test_driver (macos-13) (push) Blocked by required conditions
CI / cpp_test_driver (ubuntu-22.04) (push) Blocked by required conditions
CI / cpp_test_driver (windows-2022) (push) Blocked by required conditions
CI / cpp_cmake (macos-14, 1.82) (push) Blocked by required conditions
CI / cpp_cmake (windows-2022, nightly) (push) Blocked by required conditions
CI / cpp_cmake (ubuntu-22.04, stable) (push) Blocked by required conditions
CI / cpp_package_test (push) Blocked by required conditions
CI / vsce_build_test (push) Blocked by required conditions
CI / mcu (pico2-st7789, thumbv8m.main-none-eabihf) (push) Blocked by required conditions
CI / mcu (stm32h735g, thumbv7em-none-eabihf) (push) Blocked by required conditions
CI / mcu-embassy (push) Blocked by required conditions
CI / ffi_32bit_build (push) Blocked by required conditions
CI / docs (push) Blocked by required conditions
CI / wasm (push) Blocked by required conditions
CI / wasm_demo (push) Blocked by required conditions
CI / tree-sitter (push) Blocked by required conditions
CI / updater_test (0.3.0) (push) Blocked by required conditions
CI / fmt_test (push) Blocked by required conditions
CI / esp-idf-quick (push) Blocked by required conditions
CI / android (push) Blocked by required conditions
CI / miri (push) Blocked by required conditions
CI / test-figma-inspector (push) Blocked by required conditions
- In the timer functions
 - in the generated getter/setters and callback invocation
2025-05-28 11:29:48 +02:00
Avery Townsend
c41d4a4df3
Add FocusEventReason to FocusEvent and add a select all on keyboard focus for TextInput (#8523)
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
2025-05-27 07:56:13 +02:00
Olivier Goffart
2f2116686f C++: forward declare explicitly to make the code more robust
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
2025-05-26 18:32:09 +02:00
Olivier Goffart
23962b3e25
Upgrade cbindgen and use unsafe(no_mangle) attributes (#8539)
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
2025-05-26 11:21:33 +02:00
Olivier Goffart
08aa021166 C++: expose the DrawRectangleArgs and DrawTextureArgs
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++)
2025-05-23 17:10:26 +02:00
omahs
74232eae8d
Fix typos (#8421) 2025-05-12 13:03:59 +02:00
Tobias Hunger
d0b58760d3 chore: A few clippy fixes
Nothing systeamatic, just a bunch of fixes I stumbled over
during unrelated work.

No behavior change is intended in here...
2025-05-09 13:25:38 +02:00
Olivier Goffart
3a9ae8af0e Remove CompositionMode enum
It was used in the previous TargetPixelBuffer interface, but this is no
longer the case
2025-05-07 15:49:58 +02:00
Olivier Goffart
e42c4b18c2
swrenderer: interface for hw rendering of rectangle with border or gradients (#8384) 2025-05-06 15:53:53 +02:00
Simon Hausmann
f983cf0b19 Add Platform.os as well as a rudimentary test 2025-05-06 13:06:27 +02:00
ogoffart
e0099ea500 Bump version number to 1.12.0 2025-04-30 13:27:50 +00:00
Olivier Goffart
c8138ff1db
swrenderer: rewrite TargetPixelBuffer::draw_texture interface
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
2025-04-29 23:26:02 +02:00
Simon Hausmann
302926edfa
Skia: Improve multi-window rendering resource consumption (#8304)
Share Vulkan instance as well as Metal device and command queue across windows.
2025-04-29 18:58:09 +02:00
Simon Hausmann
da5e7d5b22 WGPU: Add support for using WGPU textures in Slint
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>
2025-04-29 17:46:57 +02:00
Simon Hausmann
a50b8f8793
FemtoVG: Add support for WGPU based rendering (#8268)
Enable via the `renderer-femtovg-wgpu` feature flag.

cc #171
2025-04-25 14:37:32 +02:00
Olivier Goffart
7d3cf6a451 Janitor: Bump corrosion version 2025-04-25 08:47:45 +02:00
Simon Hausmann
6595aee73c
Replace use of Rc<winit:🪟:Window> with Arc (#8257)
In preparation for wgpu usage, where the wgpu API requires the window
handle to be send, i.e. Arc<dyn HasWindowHandle>.
2025-04-24 13:28:51 +02:00
Simon Hausmann
eb825f2e95 Support default-font-* properties in Live-Preview
... 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
2025-04-24 09:18:45 +02:00
Olivier Goffart
cd8ab8ce53
Fix array index access at negative index
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
2025-04-22 11:28:09 +02:00
Simon Hausmann
c4386ce22c Fix esp32-p4 build
jtag is not supported with esp-println
2025-04-16 09:47:01 +02:00
Olivier Goffart
9b1d4e740c Document better the argument of the select_bundled_translation 2025-04-16 06:03:31 +02:00
Simon Hausmann
5cd1c157f1 Fix C++ crate build
The newer version of esp-println requires choosing the output channel.
2025-04-15 11:32:27 +02:00
Juraj Michálek
fafde05338 initial migration to esp-hal-1.0.0 2025-04-15 11:32:27 +02:00
Olivier Goffart
78a3757b7f
Remormat all the toml file again to fix npm upload
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
2025-04-09 15:06:00 +02:00
Olivier Goffart
12a2493269
C++: add notify_ prefix to the Model functions and add docs
* 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)
2025-04-03 07:59:15 +02:00
Olivier Goffart
4145eafe14 C++: Fix segfault when calling Model::row_changed() after Model::reset()
Fixes #8021
2025-04-02 12:41:57 +02:00
Tobias Hunger
cd6f2e2cf2 ci: Format toml files
... 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:-)
2025-04-02 11:03:41 +02:00
Olivier Goffart
bf3c47f1fa C++: add code sample form model adapters
Fixes #4967
2025-03-31 16:13:45 +02:00
Olivier Goffart
aca30901be C++: put the parent in a weak pointer
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
2025-03-28 17:24:14 +01:00
Olivier Goffart
a80f14e7d8 Fix re-instentiating if elements when the condition is dirty
Fixes #3953
2025-03-27 15:37:07 +01:00
Olivier Goffart
54a3506f4d C++: move model code to its own file
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
2025-03-25 10:37:20 +01:00
Tobias Hunger
e5ecb9cf6c infra: Test out mise
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 :-)
2025-03-20 16:33:00 +01:00
ogoffart
178cf21c2e Bump version number to 1.11.0 2025-03-18 09:48:22 +00:00
Simon Hausmann
154d877d9f CMake: Add support for overriding the translation domain via a target property
This is useful in environments such as esp-idf, where the component name is something awkward like __esp_idf_main or so.
2025-03-14 14:46:29 +01:00
scristall-bennu
be59032ecb
Use find_package to search for Corrosion (#7797)
First try to search for corrosion before fetching it
2025-03-05 19:19:47 +01:00
Olivier Goffart
d40a8b6d23 esp-idf: Be smarter about RGB888 and RGB565
This changes the default if the user has selected
`CONFIG_BSP_LCD_COLOR_FORMAT_RGB888` in their sdkconfig,
(which will result in build error if the buffer were passed as
Rgb565Pixel, or in garbage of the screen if the screen was configured
programatically to use rgb565 without calling `bsp_display_new` which is
unlikely if they set CONFIG_BSP_LCD_COLOR_FORMAT_RGB888)
2025-03-05 12:18:12 +01:00
Olivier Goffart
5ab791416b Implement Property::set_constant in C++ 2025-03-03 00:50:09 +01:00
Olivier Goffart
9571889861 esp-idf: assert that malloc succeeds when allocating line buffer
This allocates quite a lot of memory and is likely to fail.
Make it easier to debug
2025-02-28 07:59:22 +01:00
autofix-ci[bot]
eae4f21e24 [autofix.ci] apply automated fixes 2025-02-26 14:39:51 +01:00
Simon Hausmann
28da9bd996 C++: Clean up boolean accessible property getters
Share the code to convert the string to a boolean.
2025-02-26 14:39:51 +01:00
Olivier Goffart
da9fbebf18
esp-idf line by line renderer: use two line buffer
esp_lcd_panel_draw_bitmap is async so we should render in a different
buffer.
2025-02-25 21:37:36 +01:00
Simon Hausmann
beebffe829 C++ cleanup: Move the experimental render() overloads after the stable functions 2025-02-25 17:23:11 +01:00
Simon Hausmann
4d8f99e35d c++: Mark experimental target pixel buffer as experimental in the docs 2025-02-25 17:23:11 +01:00
Olivier Goffart
278e140147 Fix typo 2025-02-25 09:18:46 +01:00
Olivier Goffart
7390df1b47
ContextMenuArea: Intercept long press on Android 2025-02-24 18:27:25 +01:00
Simon Hausmann
f114ff28dd Rename TargetPixelBuffer::Pixel to ::TargetPixel 2025-02-24 17:02:10 +01:00