Commit graph

143 commits

Author SHA1 Message Date
Simon Hausmann
1441719f61
Fix cross-compilation of C++ interpreter API to 32-bit architecture (#3810)
cbindgen doesn't reliably tranfser the 64-bit/32-bit #ifdefs around ValueOpaque.
Instead, move Value onto the heap by using a Box.

Fixes #3653
2023-10-31 17:33:49 +01:00
Olivier Goffart
12cd8e71f1 WIP: some polish over the winit update to 0.29 2023-10-23 14:22:48 +02:00
Olivier Goffart
b88a3caacd swrenderer: Put the rotation feature behind a freature gate
We're not ready to make the API public as we want to have the API as
part of the Window rather than part of the renderer
2023-10-09 18:07:23 +02:00
Olivier Goffart
852b4d906d Rename ComponentVTable to ItemTreeVTable
and their related name.
Also move the component module in the item_Tree module
register_component -> register_item_tree
ComponentItemTree -> ItemTreeNodeArray

For #3323

Rationale from that issue:

Right now, we use the term `component` in the Slint language and in the compiler to be a a tree of elements that can be used as an element in a .slint file.

The term is also currently used in the runtime as a tree of runtime Items that are allocated together. (declared in ComponentVTable)

But there are no 1 to 1 mapping between a `component` in the slint language, and a runtime Component.
(for example, the items behind a `if` or `for` or `PopupMenu` are in a different runtime component. And `component` declared in Slint are often inlined)

So we should rename the internal runtime `Component` to  `ItemTree`

The currently public `slint::ComponentHandle` wraps the "root" of the ItemTree, but that's ok because it is generated from a .slint `component`,  so it doesn't change name
2023-10-09 11:01:56 +02:00
Olivier Goffart
4c0a435196 Implement TouchArea::scroll-event
Closes #1280
2023-10-07 07:59:53 +02:00
Olivier Goffart
8f16b519a2 use #repr(uX) instead of repr(C) for fieldless enums
Otherwise the ABI may differ between the C++ and the Rust
2023-08-31 10:22:03 +02:00
Olivier Goffart
c47e6cd029 C++: Api changes in the WindowAdapter
- s/physical_size/size/ (consistant with the slint::Window API)
 - remove const of virtual function  (they don't need to be const and
   make implementation potentially easier)
 - Move the WindowProperties in it
2023-08-30 14:59:41 +02:00
Ian McFarlane
1de7b1512c
Expose clipboard_text accessors to C++ (#3265) 2023-08-28 12:26:40 +02:00
Olivier Goffart
d23ba885ca
C++: add WindowAdaptor::update_window_properties 2023-08-25 13:58:55 +02:00
Olivier Goffart
7904493e1c C++: dispatch close request and activation change 2023-08-24 17:27:04 +02:00
Olivier Goffart
146ed520e8
C++: rename SLINT_FEATURE_STD in SLINT_FEATURE_FREESTANDING with the opposite meaning 2023-08-21 16:52:30 +02:00
darknight
37488f015d Refactoring: define macro rules to group builtin structs
apply new macro for struct declaration, type register,
doc generation, cpp header generation, struct-value conversion.
2023-08-03 11:01:18 +02:00
Simon Hausmann
0c9199b17f
Add support for flipping borrowed OpenGL textures vertically (#3205)
Closes #2986

Co-authored-by: Olivier Goffart <olivier.goffart@slint-ui.com>
2023-08-02 13:11:13 +02:00
Olivier Goffart
ad389aa4eb linuxkms: Implement keyboard input and clamp mouse
Unfortunately, this is currently not mapped to the right keyboard layout

Also keep the mouse clamped in the visible area.
And make it start in the middle of the screen.
2023-07-31 17:27:53 +02:00
Olivier Goffart
0a8f9c585a
C++: expose special key codes constants 2023-07-31 15:11:57 +02:00
Olivier Goffart
ecf3937518
C++: use a macro to define the EnabledFeatures struct
So that there shouldn't be more copy-paste mistakes
2023-07-28 12:18:12 +02:00
Olivier Goffart
fd7fc5ab9b C++, remove the experimental flag
The platform namespace is now always enabled.
2023-07-28 10:36:08 +02:00
Olivier Goffart
3a807e46c1
Renderer feature refactor 2023-07-27 19:11:24 +02:00
Olivier Goffart
3a2359f107 C++ Pointer dispatch API 2023-07-25 14:03:40 +02:00
Olivier Goffart
3a420d5769 C++ platform: return the updated region from the render function 2023-07-24 09:44:36 +02:00
Simon Hausmann
917cecff85 Add support for embedding bitmap fonts in C++ 2023-07-20 16:20:51 +02:00
Olivier Goffart
70978f88d2 C++: fix constructing zero-size slice with nullptr
We construct zero size slize from std::array in the generated code, and
std::array<T, 0> may have a nullptr as data.  But Slice use a NonNull
internally.
2023-07-20 15:34:36 +02:00
Olivier Goffart
7cffad2c3f C++: add a STD feature enabled by default 2023-07-18 12:44:20 +02:00
Olivier Goffart
a1bf77383f
C++: Add a mechanism to #define features that are enabled (#3103) 2023-07-18 11:49:00 +02:00
Simon Hausmann
7961bd68e5 Fix inclusion of some C++ interpreter data structures C++ docs
Make sure to generate the public interpreter header file for the docs
xtask unconditionally.
2023-07-17 15:52:42 +02:00
Simon Hausmann
64f1504ab9 Fix rendering of QStyle animations
Allocate a widget per NativeXXX. This way QStyleAnimation objects
created by Qt aren't shared among style options.

Fixes #2045
Fixes #2987
2023-07-14 13:09:45 +02:00
Aurindam Jana
5a4a7fee63
Update royalty free license to 1.1 (#2994) 2023-07-10 10:12:11 +02:00
Olivier Goffart
2023ebc9a9 C++: Fix build with or without the interpeter feature 2023-07-05 09:54:03 +02:00
Olivier Goffart
5a7a052533 C++: Don't generate the interpreter header if the feature is disabled 2023-07-04 18:19:47 +02:00
Olivier Goffart
331e5713c2 C++: Use a static_assert to detect Slint version mismatch
cc #2909 , #223

New message:
```
/home/olivier/slint/build2/examples/gallery/gallery.h:6:73: error: static assertion failed: This file was generated with Slint compiler version 1.1.1, but the Slint library used is 1.1.0. The version numbers must match exactly.
    6 | static_assert(1 == SLINT_VERSION_MAJOR && 1 == SLINT_VERSION_MINOR && 1 == SLINT_VERSION_PATCH, "This file was generated with Slint compiler version 1.1.1, but the Slint library used is " SLINT_VERSION_STRING ". The version numbers must match exactly.");
/home/olivier/slint/build2/examples/gallery/gallery.h:6:73: note: the comparison reduces to ‘(1 == 0)’
```

Previous message:
```
/home/olivier/slint/build2/examples/printerdemo/cpp/printerdemo.h:12218:161: error: conversion from ‘VersionCheckHelper<[...],[...],0>’ to non-scalar type ‘VersionCheckHelper<[...],[...],1>’ requested
12218 | [[maybe_unused]] constexpr slint::private_api::VersionCheckHelper<1, 1, 1> THE_SAME_VERSION_MUST_BE_USED_FOR_THE_COMPILER_AND_THE_RUNTIME = slint::private_api::VersionCheckHelper<SLINT_VERSION_MAJOR, SLINT_VERSION_MINOR, SLINT_VERSION_PATCH>();
      |                                                                                                                                                                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/olivier/slint/build2/examples/printerdemo/cpp/printerdemo.h:12218:161: error: could not convert ‘slint::private_api::VersionCheckHelper<1, 1, 0>()’ from ‘VersionCheckHelper<[...],[...],0>’ to ‘VersionCheckHelper<[...],[...],1>’
12218 | [[maybe_unused]] constexpr slint::private_api::VersionCheckHelper<1, 1, 1> THE_SAME_VERSION_MUST_BE_USED_FOR_THE_COMPILER_AND_THE_RUNTIME = slint::private_api::VersionCheckHelper<SLINT_VERSION_MAJOR, SLINT_VERSION_MINOR, SLINT_VERSION_PATCH>();
      |                                                                                                                                                                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |                                                                                                                                                                 |
      |                                                                                                                                                                 VersionCheckHelper<[...],[...],0>
```
2023-06-28 14:16:52 +02:00
Olivier Goffart
1b9e245b4e Remove the NativeSwitch
It is identical to the NativeCheckBox  (Qt don't have a switch widget)
2023-06-23 11:02:46 +02:00
Simon Hausmann
ab0e38c76d
Merge absolute-x and absolute-y "virtual" properties into absolute-position (#2942)
The type of thep property is `Point`, which existed before. It was
mapped to `slint::private_unstable_api::re_exports::Point` (euclid) and
is now mapped to slint::LogicalPosition (also in C++).
2023-06-21 08:17:57 +02:00
Olivier Goffart
11dea135f7 Domain: slint-ui.com -> slint.dev 2023-06-16 10:55:08 +02:00
Aurindam Jana
039e54a5de
Add royalty free license to files except examples and docs (#2888) 2023-06-15 11:20:50 +02:00
Simon Hausmann
0f54b9599b Add support for manually closing PopupWindows
This patch adds a `close()` function that can be called to close a popup
window, and a `close-to-click` boolean that can be set to false to
disable the default behavior.
2023-06-02 18:07:49 +02:00
Olivier Goffart
5599bd44e0 Remove Color::opaque
It is not a right name and i don't think it is a so common operation
2023-06-02 17:02:08 +02:00
Olivier Goffart
4845241ebf Rename translucent to transparentize and mixed to mix 2023-06-02 17:02:08 +02:00
Arthur Araruna
64ad1ce357 Add some color and brush manipulation funcs (#2565)
The added functions enable mixing colors and manipulating the opacity
of colors and brushes.

They enable the behavior of some of the available functions from SASS and are
added for future use for adding the Adwaita style (future PR).
2023-06-02 17:02:08 +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
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
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
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
ae20ec59c8 Rename PointerEventButton::None to PointerEventButton::Other
And mark the enum non_exhaustive

closes #1903
2023-01-26 13:36:54 +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
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
Olivier Goffart
8d686637f4
Experimental platform API from C++ 2022-12-12 12:54:31 +01:00