Commit graph

374 commits

Author SHA1 Message Date
Simon Hausmann
c428601370
Add support for select-all(), cut(), copy() and paste() functions on text input elements (#2804)
In the compiler this is still very primitive, but an attempt to start a
generic interface. The basic assumption is that all item functions will
eventually need access to the window adapter and itemrc. Support for
additional arguments is still missing.

Also missing is support for the function access via rtti in the
interpreter, hence the hardcoding at the moment.
2023-06-01 16:04:53 +02:00
Simon Hausmann
e7320607a3 Remove BorrowedOpenGLTexture from the public API again and just provide a factory function in slint::Image 2023-06-01 15:56:55 +02:00
Simon Hausmann
084ff70079 C++: Improve reliability of comparison operator of slint::Image
Call into the Rust implementation, so that we have to maintain only one
implementation.
2023-06-01 15:56:55 +02:00
Simon Hausmann
f51ca82f10 Add C++ API and example for borrowing OpenGL textures 2023-06-01 15:56:55 +02:00
Simon Hausmann
599d86e4e1 Simplify Skia renderer API
Remove the size argument from render().
2023-05-26 10:46:59 +02:00
Simon Hausmann
dd61890e23 Fix rendering of the Qt platform example with high-dpi
- Provide a C++ platform event for the scale factor change and send it
- Report the correct logical and physical sizes to Slint
2023-05-25 05:29:52 +02:00
Simon Hausmann
ef4074b041 Further simplify renderer storage in C++ platform API
Using an std::optional is even simpler and avoids a malloc.
2023-05-21 14:40:43 +02:00
Simon Hausmann
b47936d4cd Make AbstractRenderer functions private in the sub-class 2023-05-21 14:40:43 +02:00
Simon Hausmann
289883ccc0 Replace access to raw WindowAdapterRcOpaque with friend declarations 2023-05-21 14:40:43 +02:00
Simon Hausmann
baba30370a Simplify C++ WindowAdapter <> Renderer interface further
Instead of the WindowAdapter being a template for a concept, let's just
use an abstract base class for the renderer. Since we provide the
renderers, this simplifies two things:

- Ownership becomes clear to the user by creating the renderer instance
in a field of theirs.
- All template use goes away on the user side.
2023-05-21 14:40:43 +02:00
Simon Hausmann
fe4a434ce4 Remove the WindowAdapter from the renderer constructor
This allows disentangling the native window creation from the renderer
creation, which is rather ugly and complicated on the C++ side.
2023-05-21 14:40:43 +02:00
Olivier Goffart
dd5ef9993f
Platform: Add a Resized event and use that to convey the changes in size (#2759) 2023-05-21 12:12:30 +02:00
Simon Hausmann
b27163954a Fix build of experimental C++ platform API on Linux 2023-05-17 12:41:37 +02:00
Olivier Goffart
422bcc3a4a C++: optimize SharedVector's iterator constructor
Don't detach for every element.

Closes #2737
2023-05-17 09:23:17 +02:00
Simon Hausmann
185334d5e7 Fix doc comment 2023-05-11 10:42:09 +02:00
Simon Hausmann
3340c31249 Clean up C++ experimental native window handle API
- Use explicit constructor functions
- Box the implementation
2023-05-11 10:42:09 +02:00
Simon Hausmann
0475b91daf skia: Simplify renderer API
Remove the generic window handle owner part of the API. Instead assume
that the caller provides safety for the given window handles, like we do
for FemtoVG and like softbuffer does it in its public API.
2023-05-11 10:42:09 +02:00
Simon Hausmann
d0cdc462c7 Simplify Skia Renderer
Allocate the renderer's surface type in the constructor.

This also changes the C++ API to match this, which complicates some code
a little bit.
2023-05-11 10:42:09 +02:00
Simon Hausmann
77645d9908 C++: Warn when the return value of slint::Image::load_from_path is not used
Somebody recently accidentally wrote this code:

```cpp
slint::Image image;
image.load_from_path(...);
```

and that should have produced a warning.
2023-05-10 11:46:00 +02:00
Simon Hausmann
c6c6564537 Fix C++ formatting 2023-04-24 18:02:55 +02:00
Simon Hausmann
0ba6ef1c24 Fix build against macOS deployment target 10.10
- std::optional<T>::value() is not available, use operator * instead
- alignment allocation is also only available in 10.14 or newer
2023-04-24 18:02:55 +02:00
Simon Hausmann
4d502a9f96 Add a C++ version of the Virtual Keyboard example 2023-04-14 11:39:02 +02:00
Olivier Goffart
a57c7eb6bc Added TextInputInterface.text-input-focused 2023-04-12 14:49:08 +02:00
Olivier Goffart
fd3f974d7e Don't use old syntax in docs 2023-04-06 17:06:46 +02:00
Simon Hausmann
e3800fd3c3
Fix incorrectly rendered C++ docs code fence 2023-03-24 20:39:27 +01:00
Tobias Hunger
da95051db1
docs: Fix dead links between docs
... and add in text that went missing in the Globals section of the rust
docs.
2023-03-23 11:22:51 +01:00
Olivier Goffart
c82bb1515e C++ image: add some docs
Note: Don't use cbindgen to generate `operator==` for public types.
Because it doesn't have docs and the documentation show warnings
otherwise
2023-03-20 17:22:56 +01:00
Olivier Goffart
ef7fb6422a C++ Image API: introduce the SharedPixelBuffer 2023-03-20 17:22:56 +01:00
Olivier Goffart
be47c8464c C++: implement creation of image from raw data
Issue #616
2023-03-20 17:22:56 +01:00
Tobias Hunger
9af756bf3f
cpp: Do not produce warnings when using the UIntModel 2023-03-06 17:03:20 +01:00
Simon Hausmann
aba5797eaa C++ docs: Elaborate a little on the argument to Window::set_rendering_notifier 2023-02-17 11:12:54 +01:00
Olivier Goffart
a19efc30db
Replace the MAX_BUFFER_AGE const generic with a runtime enum
Having a const generic for that didn't turn to be a good API.
Also made the C++ side more difficult

(Also renamed buffer_stride to pixel_stride)

Closes #2135
2023-02-08 14:44:01 +01:00
Olivier Goffart
eaa9db4911 C++: use size_t everywhere as index in our models
cc #2024
2023-02-07 15:25:44 +01:00
Olivier Goffart
63cc68ea0c C++: Use concepts for the invokables 2023-01-26 11:35:16 +01:00
Olivier Goffart
a3ec320bfb Remove some deprecated stuff
CC #2024
2023-01-26 11:19:21 +01:00
Simon Hausmann
629c7ed80e Remove undocumented and dysfunctional PathLayout
This type is poorly implemented and not documented. Let's remove it for now.
It shall remain available in the git history in the event of a resurrection.
2023-01-21 13:10:19 +01:00
Florian Blasius
ac5eaf495f
move cpp StandardListViewItem from private to public namespace (#2062)
* move cpp StandardListViewItem to public namespace
* Fix missing C++ docs for StandardListViewItem

The struct is originally defined in Rust in model.rs and cbindgen creates the
compatible C++ declaration. For doxygen
to see it, it needs to be emitted into slint_generated_public.h.

* Improve the StandardListViewItem docs a little bit
* move cpp StandardListViewItem to public namespace

Co-authored-by: Simon Hausmann <simon.hausmann@slint-ui.com>
2023-01-16 09:06:36 +01:00
Simon Hausmann
96c80a2dd1
Fix crash when using an int model in a repeater with a negative value (#2063)
Make sure that we return an unsigned for row_count() in C++ and Rust by ensuring an unsigned int model at creation time.

For the interpreter this "worked" by chance as casting a negative floating
number to usize automatically caps at zero, and all values are stored as f64. For safety this patch
applies the same fix though, to be on the safe side.
2023-01-14 21:20:14 +01:00
Florian Blasius
f2aab576f4
Add StandardTableView widget (#2032)
* Text only StandardTableView with column and rows
* Text editing of cells
* Sort by column ascending and descending
* Variants of the TableView for native, fluent and material
2023-01-12 19:41:12 +01:00
Simon Hausmann
ad0aaa4759 Fix crash when using repeaters in C++ on 32-bit architectures
The abort in the repeated item traversal is represented as 64-bit unsigned value with all bits set, not just 32-bits.

Fixes #2039
2023-01-09 13:00:25 +01:00
Olivier Goffart
629a64ba89 C++ interpreter: do the renaming invoke_callback -> invoke 2023-01-02 23:55:47 +01:00
Simon Hausmann
8145d10b5b janitor: adaptor -> adapter 2022-12-13 08:35:20 +01:00
Simon Hausmann
6a87a07e12 Add support for showing the renderer on macOS with AppKit 2022-12-12 17:02:11 +01:00
Olivier Goffart
fe0e881418 C++ wrapper for the Skia backend 2022-12-12 17:02:11 +01:00
Olivier Goffart
10d1595f3a Janitor: cleanup C++ AbstractWindowAdapter
- virtual destructor can be = default
 - rules of 3 for AbstractWindowAdapter
 - Since WindowAdapter inherit AbstractWindowAdapter, it is already no-copy
2022-12-12 15:00:55 +01:00
Simon Hausmann
2d72781f9f Fix warning about missing virtual destructor 2022-12-12 14:40:07 +01:00
Olivier Goffart
f1fb4e16bb C++ platform API: remove the template parameter in Platform 2022-12-12 14:04:33 +01:00
Olivier Goffart
8d686637f4
Experimental platform API from C++ 2022-12-12 12:54:31 +01:00
Olivier Goffart
ccf3e8e9e9 C++: Generate image texture data for software renderer 2022-12-09 09:25:48 +01:00
Simon Hausmann
1162ebbb79
Reduce the amount of re-creation of cells in repeaters when the model changes (#1954)
Re-use the cells but mark them as dirty, instead of re-creating them every time.
In the included test-case that provides behavior that's
more intuitive.
2022-12-06 18:43:55 +01:00