Commit graph

142 commits

Author SHA1 Message Date
Simon Hausmann
3652f58a3f Change item indices from usize to u32
So that the compiler and run-time can never disagree on the
number of bytes the item index can use.
2023-09-12 08:53:58 +02:00
Olivier Goffart
cf19749943
Make a pass to remove the Expression::Return instruction
So it doesn't appear in the LLR and the C++ codegen can be simplified.
In particular, this removes the need to throw/catch exception to handle return
across generated lambdas
2023-09-06 14:10:26 +02:00
Olivier Goffart
d23ba885ca
C++: add WindowAdaptor::update_window_properties 2023-08-25 13:58:55 +02:00
Olivier Goffart
725a259e3a
C++: move the window related stuff in its own header (#3339)
slint.h starts to be quite big, and lots of it is because of Window, so
move Window to its own header
2023-08-24 15:51:50 +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
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
116648ffcf C++ Platform: remove the experimental namespace 2023-07-27 13:22:22 +02:00
Tobias Hunger
d47d52bf52 ItemVTable::init(...): Take an ItemRc so that the itan can know where in the Item Tree it is located 2023-07-27 12:04:16 +02:00
Olivier Goffart
3054ecfb71
C++ platform API: move the dispatch_* function on the Window like in rust 2023-07-26 16:03:05 +02:00
Olivier Goffart
3a2359f107 C++ Pointer dispatch API 2023-07-25 14:03:40 +02:00
Florian Blasius
8ce2620aaa
Added cpp ReverseModel (#3132) 2023-07-24 11:32:45 +02:00
Simon Hausmann
917cecff85 Add support for embedding bitmap fonts in C++ 2023-07-20 16:20:51 +02:00
Olivier Goffart
7cffad2c3f C++: add a STD feature enabled by default 2023-07-18 12:44:20 +02:00
Simon Hausmann
59d869cb84 Fix missing invocation of init() on Items with C++
In Rust, register_component in the run-time library is called unconditionally and
invokes init(). The window adapter is an optional
parameter.

In C++, we'd call register_component only if we had a window adapter, which meant
that we're missing init calls().

Amends cd9994306e
2023-07-14 13:09:45 +02:00
Simon Hausmann
d8fe052cde Fix bad red markup in C++ slint::Model docs
Revert da95051 and fix the link in the substitution instead.

Fixes #2992
2023-07-10 10:13:42 +02:00
Aurindam Jana
5a4a7fee63
Update royalty free license to 1.1 (#2994) 2023-07-10 10:12:11 +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
Simon Hausmann
83ccd07a88
C++: Add slint::Window::scale_factor() getter (#3004)
Fixes #3003
2023-06-28 13:24:40 +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
Olivier Goffart
12e6b34e2d Translations: support for plurals 2023-06-07 10:34:34 +02:00
Olivier Goffart
723a4477d6 C++: prospective fix for warning in CI on windows 2023-06-06 14:23:02 +02:00
Olivier Goffart
cf746ddf8d WIP: formatting implementation of translate in rust and C++ 2023-06-05 16:34:59 +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
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
289883ccc0 Replace access to raw WindowAdapterRcOpaque with friend declarations 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
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
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
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
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
8d686637f4
Experimental platform API from C++ 2022-12-12 12:54:31 +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
Simon Hausmann
907b58161c Add support for invoking an init callback on component and element construction
This enables imperative code to be run. To be used sparingly :-)
2022-11-17 10:12:08 +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
Simon Hausmann
fa8959c7bc doc: Fix rendering of generated docs for restart()
The `--` was converted into a HTML entity, which was escaped again and shown raw.
2022-11-02 09:48:02 +01:00
Florian Blasius
a4313c3e32
API changes for SortModel and FilterModel (rust and cpp) (#1768)
* Rust SortModel: Rename parameter `S` to `F`
* Rust SortModel: Rename parameter `apply_sorting` to `reset`
* Rust FilterModel: Rename parameter `apply_filter` to `reset`
* C++ SortModel: Rename parameter `sort_fn` to `comp`
* C++ SortModel: Add pub reset function
* C++ FilterModel: Rename parameter `apply_filter` to `reset`
2022-10-26 11:16:12 +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
Florian Blasius
129ee0acae
Florian/sort todo (#1721)
Implement `set_row_data` for `SortModel` and `FilterModel` (rust and cpp). Add sort and filter example to the todo example.
2022-10-11 18:58:00 +02:00