Commit graph

143 commits

Author SHA1 Message Date
Olivier Goffart
ccf3e8e9e9 C++: Generate image texture data for software renderer 2022-12-09 09:25:48 +01:00
Simon Hausmann
e9db914fb1
Add is_visible to NodeJS and C++ Window types (#1816)
Amends commit 82278a5742
2022-11-04 16:24:24 +01:00
Olivier Goffart
f055afd2de New syntax: allow to create component without base 2022-10-26 18:09:57 +02:00
Simon Hausmann
c16253d29f Use Property<LogicalLength> instead of Property<Coord>
This removes the special code for the generated property getters and
ensures type safety in the run-time library for property value setting.

In the Rust generated code we continue to do arithmetic on the scalar
values, that means we immediately extract the scalar, do arithmetic and
rely on the compiler to only allow compatible units.

Danger zone alert: In the interpreter Value::Number can now be converted
to LogicalLength as-is.
2022-10-24 12:49:37 +02:00
Olivier Goffart
6ee932883a Rename stark-style to dark-color-scheme
That's the term used by CSS
2022-10-19 15:23:41 +02:00
Olivier Goffart
0ba468c236 Use a builtin function to access the dark-style
instead of a property on NativeStyleMetrics
2022-10-19 15:23:41 +02:00
Simon Hausmann
38a55f87a4 Change internal MouseEvent to use logical points 2022-10-13 17:02:18 +02:00
Simon Hausmann
c11b4305c1 Change Item::geometry() to return a LogicalRect 2022-10-13 17:02:18 +02:00
Tobias Hunger
53a3c72b57
api: Change logical/physical position and size on window (#1620)
* Add `RequestedSize` and `RequestedPosition` enum to enable asking for
  logical or physical size/position.
* Rename `Window::size()` to `Window::physical_size()`
* Make `Window::set_size(...)` take an `Into<RequestedSize>`
* Rename `Window::position()` to `Window::physical_position()`
* Make `Window::set_position(...)` take an `Into<RequestedPosition>`
* Change `WindowAdapter` and related classes to be able to handle
  requests being made in the either physical or logical units.

Implement this for C++, Rust and node.
2022-09-13 08:55:31 +02:00
Tobias Hunger
1e6ffeaa0f API cleanup: Rename PlatformWindow to WindowAdapter 2022-08-29 16:53:47 +02:00
Simon Hausmann
98e1befd0d Port the C++ generator and C++ API to the new window ownership model
One key difference to the Rust way is what `slint::Window` means. In
Rust that holds the `WindowInner` and `slint::Window` is only exposed as
`&slint::Window`. This is possible because the component owns the
`Rc<dyn PlatformWindow>`, which has a function to return the
`&slint::Window`.

In C++ `slint::Window` is also exposed as `slint::Window&` in the
`window()` getter, but there's no way to get a reference to a  C++
wrapper for the Rust `&slint::Window` that the `PlatformWindow` trait
returns. Therefore in C++ `slint::Window` wraps `Rc<dyn
PlatformWindow>`.
2022-08-19 15:07:27 +02:00
Simon Hausmann
af86f36157 Invert slint:🪟:WindowInner and PlatformWindow ownership
Previously: Window is an Rc<WindowInner>, which has an Rc<dyn
PLatformWindow> - and weak references the other way around.

Now: Rc<dyn PlatformWindow> is the root of window ownership. The impl
PlatformWindow has a slint::api::Window, which just holds a WindowInner.

This change is incomplete on a few levels, mainly that neither of the
code generators nor the interpreter is ported.
2022-08-19 15:07:27 +02:00
Olivier Goffart
ac4f3e97ad Change slint enum values to be PascalCase in rust
... while still being kebab-case in .slint

Some enums might become public API and we want to have them as
PascalCase to respect the rust conventions
2022-07-22 12:23:52 +02:00
Olivier Goffart
c28c527e0e Split the properties.rs files in modules 2022-07-21 14:07:15 +02:00
Simon Hausmann
34dc0a80e7 Fix duplicated images when building with embedded images
For embedded images the path is empty but we unconditionally used it to create a TextureCacheKey,
which clashes.

Instead, preserve and store the ImageCacheKey in the ImageInner variants.
2022-07-20 12:57:37 +02:00
Olivier Goffart
65346c699c Attempt to get the "image-in-corelib" feature compile with C++ 2022-07-20 12:57:37 +02:00
Simon Hausmann
67a2f0ce3f WIP: Make image decoding a feature of the core library
This includes the cache of decoded images, the HTMLImage element support
and the SVG rendering adapter.

The objective is that Image holds an ImageInner, which is not a path
anymore that the backend has to process, but instead always either
decoded image data, a pointer to a static texture or an SVG tree that
can be rendered to the desired size.
2022-07-20 12:57:37 +02:00
Simon Hausmann
937c37677e Add API for setting and getting the size of a Window in Rust and C++ 2022-07-08 18:37:01 +02:00
Simon Hausmann
372ad60a8f Add support for position() and set_position() to C++ slint::Window 2022-07-08 18:37:01 +02:00
Olivier Goffart
615c7635ee Qt: use a HashMap for the cache
And not the cache dirrectly within the item, because it is already in use
for the partial rendering
2022-05-31 10:48:24 +02:00
Olivier Goffart
b4ebd88d35 Implements @radial-gradient(circle, ...)
Only the circle is implemented so far.

Part of #263
2022-05-19 14:07:20 +02:00
Olivier Goffart
e85e69fda0
Declare .slint enum in one place in i-slint-common
This avoid repeating the enums both in the compiler and in
the runtime library, and register them in a bunch of other places.

So it should be easier to add enums and enum values

Since cbindgen doesn't see through the macro, generate the enum
manually
2022-04-14 19:17:48 +02:00
Olivier Goffart
1b91158b46 corelib: allow to use i32 for coordinate instead of f32 2022-04-11 17:46:50 +02:00
Olivier Goffart
d940a0b35d Fix NativeSlider::changed in C++
FloatArgs is not properly exposed to C++
2022-04-04 17:33:54 +02:00
Simon Hausmann
535e134223 Add a Layer element that's created when using a layer boolean property
For now no backend implements this optimization hint.
2022-03-21 20:22:43 +01:00
Tobias Hunger
86a6add32c janitor: Fix typos and make cspell happy 2022-03-18 10:15:44 +01:00
Olivier Goffart
ca5151de11 C++: implement Window::on_close_requested 2022-03-17 14:49:12 +01:00
Simon Hausmann
583c7a1b80 Fix C++ build
With ImageInner::StaticTextures (the variant) and StaticTextures (the
struct), we need to disambiguate for the generated enum contructor
functions. This is done by prefixing the enum variant with their name.
2022-03-03 14:39:11 +01:00
Jared Moulton
fdbc8056b3 Add an option to draw *'s instead of characters for password fields 2022-03-02 15:47:32 +01:00
n-raine
beda5aca07 Add dark style detection support for GL backend
With the help of dark-light crate this is now exposed as dark-style
boolean property in NativeStyleMetrics.

Co-authored-by: Olivier Goffart <olivier@slint-ui.com>
Co-authored-by: Simon Hausmann <simon.hausmann@slint-ui.com>
2022-03-01 16:41:20 +01:00
Olivier Goffart
0dc188f328 Support for referring to other globals from globals
- We need to make sure that the initialization of global is in the right order.
 - In C++ and rust, we need to add accessor to the global component
 - There can be `PropertyReference::Global` in binding of globals
 - The interpreter globals need to hold references to the global they may depend on

Fixes #175
2022-02-28 10:14:34 +01:00
Tobias Hunger
4230ac2572
Update copyright information to reflect name change
Also run resue over the codebase and fix complaints from that tool.
2022-02-09 10:27:47 +01:00
Olivier Goffart
753784c331
C++: drops IntSize in favor of Size<T> (#922)
Fixes #909

Since we declare the struct in C++, we don't need to declare it in
rust for cbindgen anymore, as long as we expose the Size2D type from
euclid to the cbindgen_private namespace
2022-02-08 14:12:52 +01:00
Olivier Goffart
91e107150e Merge remote-tracking branch 'origin/wip/rename'
Conflicts:
	examples/opengl_underlay/index.html
	examples/opengl_underlay/main.cpp
2022-02-08 07:29:41 +01:00
Simon Hausmann
0b6beb081b Minor fixup to the C++ rendering notifier API
Add the graphics state enum to the callback, too. When we add support for different backends,
it would be nice if it didn't require an API change.

 It's duplicated from Rust
because it doesn't provide values. The WebLG one doesn't make sense for C++ and
the proc address closure isn't ffi safe.

(It could be manually bridged thought)
2022-02-07 08:50:09 +01:00
Simon Hausmann
125b90a64b Merge remote-tracking branch 'origin/master' into wip/rename
Conflicts:
	api/cpp/cbindgen.rs
	api/cpp/include/slint.h
	examples/CMakeLists.txt
	examples/imagefilter/Cargo.toml
	examples/plotter/main.rs
	internal/backends/mcu/lib.rs
2022-02-04 16:47:20 +01:00
Simon Hausmann
18bba6ede4 Add sixtyfps::Window::request_redraw()
This allows scheduling a redraw of a Window explicitly. Unfortunately it
comes with a winit caveat :(
2022-02-04 15:41:53 +01:00
Simon Hausmann
8959eac3d0 Add rendering callbacks to sixtyfps::Window
This API allows specifying a callback that will be invoked when setting
up graphics (great for compiling shaders), before rendering a frame (but
after the clearning of the surface background), after rendering a frame
(before swapbuffers) and when releasing graphics resources.
2022-02-04 15:41:53 +01:00
Simon Hausmann
fcf59f3793 Rename the C++ header files 2022-02-02 13:07:26 +01:00
Simon Hausmann
7d297da2fc Rename the sixtyfps C++ namespaces 2022-02-02 12:11:27 +01:00
Simon Hausmann
5226feab01 Rename C++ pre-processor macros 2022-02-02 12:11:27 +01:00
Simon Hausmann
c846633708 Rename C ffi functions 2022-02-02 11:12:34 +01:00
Tobias Hunger
842f75e653 [reorg]: Move api/sixtyfps-rs/sixtyfps-* into api/rs 2022-01-31 18:24:33 +01:00
Renamed from api/sixtyfps-cpp/cbindgen.rs (Browse further)