Commit graph

871 commits

Author SHA1 Message Date
Olivier Goffart
b634b1fa7f corrosion: update to beta2 2023-06-01 09:34:19 +02:00
Olivier Goffart
1036c0d082 c++: remove IMPORTED_NO_SONAME as corrosion sets it now 2023-06-01 09:34:19 +02:00
Olivier Goffart
9a103b9c37 Test beta version of corrosion 2023-06-01 09:34:19 +02:00
Florian Blasius
b4472b9118
Added switch widget (#2798)
* Add material Switch

* Add fluent switch

* Add native Switch and cleanup

* Rebase fix

* Update internal/compiler/widgets/fluent-base/std-widgets-impl.slint

Co-authored-by: Simon Hausmann <simon.hausmann@slint-ui.com>

* Code review

* Update docs/language/src/builtins/widgets.md

Co-authored-by: Simon Hausmann <simon.hausmann@slint-ui.com>

* Update docs/language/src/builtins/widgets.md

Co-authored-by: Simon Hausmann <simon.hausmann@slint-ui.com>

* Code review

* Update docs/language/src/builtins/widgets.md

Co-authored-by: Simon Hausmann <simon.hausmann@slint-ui.com>

* Update examples/gallery/ui/pages/controls_page.slint

Co-authored-by: Simon Hausmann <simon.hausmann@slint-ui.com>

* Code review tweak on gallery layout

* Code review tweak on gallery layout

---------

Co-authored-by: Simon Hausmann <simon.hausmann@slint-ui.com>
2023-05-31 14:57:23 +02:00
Simon Hausmann
590b011d0b Fix build with new cbindgen
Unfortunately the latest cbindgen release added private field to a
public struct, breaking our build. Work around this until
https://github.com/mozilla/cbindgen/issues/841 is fixed.
2023-05-31 13:35:03 +02:00
Florian Blasius
9e267bcc94
Add ProgressIndicator widgets (#2792)
* Add material ProgressIndicator and documentation

* Add fluent ProgressIndicator

* Add native ProgressIndicator

* Update docs/language/src/builtins/widgets.md

Co-authored-by: Simon Hausmann <simon.hausmann@slint-ui.com>

* Update docs/language/src/builtins/widgets.md

Co-authored-by: Simon Hausmann <simon.hausmann@slint-ui.com>

* Update docs/language/src/builtins/widgets.md

Co-authored-by: Simon Hausmann <simon.hausmann@slint-ui.com>

* Update docs/language/src/builtins/widgets.md

Co-authored-by: Simon Hausmann <simon.hausmann@slint-ui.com>

* Code review

* Update internal/compiler/widgets/fluent-base/std-widgets-base.slint

Co-authored-by: Simon Hausmann <simon.hausmann@slint-ui.com>

* Update changelog

---------

Co-authored-by: Simon Hausmann <simon.hausmann@slint-ui.com>
2023-05-31 09:57:12 +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
dd04e044d0 Fix build of C++ OpenGL underlay example
Test for the right feature flag and fix the compatibility feature names.
2023-05-23 17:26:45 +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
3db5b97790 Fix the Qt native platform example
Fix regression introduced with commit d0cdc462c7:
The window surface must exists before querying for the window handles.
2023-05-17 14:59:16 +02:00
Simon Hausmann
d9bc7a08f9 Fix crash when using experimental C++ SkiaRenderer API
Don't box the Result<Renderer, Error>, but box just the renderer.
Otherwhise the cast to the renderer pointer is nonsense.
2023-05-17 14:33:39 +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
db07384e9f Remove stray outdated comment 2023-05-11 10:42:09 +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
481288d489 Initial support for rendering with Skia and Vulkan
Closes #1546
2023-05-09 08:58:35 +02:00
Olivier Goffart
f9e5559eeb C++ test with an example of using the Windows API directly to create a slint platform 2023-05-05 19:53:37 +02:00
Olivier Goffart
76356c181b Tests: look at _all_ markdown files for slint snippets
We were missing some which had errors

Fixes #2689
(Although the error for 2689 was in C++ and would not have been
discovered by the test, better to have it parsed anyway)
2023-05-05 08:50:37 +02:00
Olivier Goffart
65e879e55f
Document how anonymous objects are mapped to native code
As discussed in https://github.com/slint-ui/slint/discussions/2650
2023-04-28 09:30:23 +02:00
ogoffart
dfd5fc38b3 Bump version number to 1.0.3 2023-04-26 14:04:08 +00:00
ogoffart
53cce5bf44 Bump version number to 1.0.2 2023-04-26 11:33:16 +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
Olivier Goffart
4076df928d Fix panic when getting the line, column of diagnostic with invalid span
Introduced in cbc0c790a3
2023-04-19 12:35:17 +02:00
ogoffart
bd63218412 Bump version number to 1.0.1 2023-04-18 14:56:40 +00:00
Simon Hausmann
7e08231650 C++: Enable /bigobj by default when building with MSVC
Large C++ files generated from .slint files can cause link problems with MSVC.
When that happens, MSVC itself suggests /bigobj as remedy.

It's not apparent that there's a downside to using this option, apart from
backwaords binary compatibility - which is not a concern for us.

The discussion at https://developercommunity.visualstudio.com/t/Enable-bigobj-by-default/1031214 suggests that perhaps this
will become the default one day.

To simplify our examples and avoid users running into this, let's enable it by default.
2023-04-14 13:13:03 +02:00
Simon Hausmann
db29d01892 C++ docs: Fix red warning in generated HTML for file and namespace listings
The Furo theme by default generates a "on this page" contents list in
the right column. The breathe output for C++ namespace and file pages
also includes a ::contents:: RST directive, to summarize the available
headings. The duplication of these two is warned about by furo with a
big fat red warning.

Solve this by not making breathe generate the contents directive
anymore. According to

    https://exhale.readthedocs.io/en/latest/reference/configs.html?highlight=contentsspecifier#exhale.configs.kindsWithContentsDirectives

it's by default used for files and namespace, so make it empty in our
config.

Fixes #2505
2023-04-14 11:46:53 +02:00
Simon Hausmann
4d502a9f96 Add a C++ version of the Virtual Keyboard example 2023-04-14 11:39:02 +02:00
Simon Hausmann
004dce6c0b
Fix memory corruption when loading encoded embedded images in C++ (#2542)
The ImageCacheKey enum has a gap when not targeting wasm:

```
pub enum ImageCacheKey {
    /// This variant indicates that no image cache key can be created for the image.
    /// For example this is the case for programmatically created images.
    Invalid,
    /// The image is identified by its path on the file system.
    Path(SharedString),
    /// The image is identified by a URL.
    #[cfg(target_arch = "wasm32")]
    URL(SharedString),
    /// The image is identified by the static address of its encoded data.
    EmbeddedData(usize),
}
```

In the C++ generated header, that cfg was not mapped, and thus the URL
variant was always there, while in a regular slint-cpp build it's not.
Consequently tag value 2 in Rust was used to represent the EmbeddedData
variant, while in the C++ generated code that become variant 3 and 2 was
interpreted as a URL. So the receiving code in C++ tried to interpret
the cache key as URL variant, while Rust created it as EmbeddedData.

Co-authored-by: Olivier Goffart <olivier.goffart@slint-ui.com>
2023-04-12 16:43:37 +02:00
Olivier Goffart
a57c7eb6bc Added TextInputInterface.text-input-focused 2023-04-12 14:49:08 +02:00
Simon Hausmann
a5bea16596
Add Ninja to the list of required tools (#2498)
We have plenty of command lines that explicitly use `-GNinja`, so let's
make Ninja a tool that is required. That's easier than changing all the
command lines to have two variants (use XX or YY if you have Ninja
installed), and we know that the dependency handling works best with
Ninja.

Fixes #2495

Co-authored-by: Olivier Goffart <olivier.goffart@slint-ui.com>
2023-04-11 16:35:28 +02:00
Olivier Goffart
fd3f974d7e Don't use old syntax in docs 2023-04-06 17:06:46 +02:00
Simon Hausmann
08c0f1b34e Clean up hack to detect if we're doing a top-level build
... by introducing an explicit variable.

cc #2075
2023-04-04 09:06:38 +02:00
Simon Hausmann
13a5d3c5cd Fix builds of applications using Slint via FetchContent (part 2)
Amend 8406e1050d by fixing the condition
to apply the install_name when the cache variable used to detect package
builds is defined, not _not_ defined.

cc #2075
2023-04-03 17:36:34 +02:00
Simon Hausmann
8406e1050d Fix builds of applications using Slint via FetchContent
Set install_name to include rpath as per commit
916b927f4f only when doing top-level
builds that are meant to be installed via "make install".

cc #2075
2023-04-03 17:01:47 +02:00
Simon Hausmann
916b927f4f macOS: Fix installed libslint_cpp.dylib containing references to the build directory
Thanks to @jschwe, there's a way to instruct corrosion to supply link
flags that set the install name and work around cargo/rustc behavior.

In exchange, now that we're using rpath, to be able to continue to run
the tests and examples against a build tree, we need to set
CMAKE_BUILD_RPATH.

Fixes #2075
2023-04-03 15:59:01 +02:00
Tobias Hunger
64022bf0bd docs: Document release tags for use in cmake 2023-04-01 23:21:31 +02:00
Olivier Goffart
45c19d6154
C++ docs: fix the dir that should be passed to CMAKE_PREFIX_PATH 2023-03-31 11:25:42 +02:00
Simon Hausmann
714a91e928 cmake: Add the SLINT_FEATURE_RENDERER_WINIT_SOFTWARE option to enable the software renderer 2023-03-31 08:58:04 +02:00
Olivier Goffart
cdaf2abb47
C++: sort the member of a struct in the same order as in the .slint file 2023-03-29 19:11:33 +02:00