Commit graph

216 commits

Author SHA1 Message Date
Tobias Hunger
e3c4209b1f
Change Model::row_data to return an Option<T> (#873)
Change Model::row_data to return an Option<T> (rust) or std::optional<T> (c++)

Co-authored-by: Olivier Goffart <olivier@woboq.com>
Co-authored-by: Simon Hausmann <hausmann@gmail.com>
2022-01-26 13:55:38 +01:00
Olivier Goffart
319704d3fb C++: use default operator==
Since we now use C++20, we can simplify our code a bit
2022-01-24 17:16:55 +01:00
Olivier Goffart
973c5960b7 C++ interpreter: Use std::span instead of the internal Slice in the public API 2022-01-24 13:04:12 +01:00
Olivier Goffart
f9f90e1b4e C++: Do not expose private types in the sixtyfps namespace 2022-01-19 11:19:47 +01:00
Olivier Goffart
99adc25a81 llr-cpp: Fix for within layout 2022-01-19 10:02:23 +01:00
Olivier Goffart
d62b788829 C++: Do wrapper to the layout function
That returns and take their argument in a C++-like way instead of by pointer.
2022-01-19 10:02:23 +01:00
Simon Hausmann
6e3fcd1b08 Add row data tracking to C++ sixtyfps::Model
This works the same way as in the Rust model notify.
2022-01-14 13:38:25 +01:00
Simon Hausmann
43830ccd78 Add insert to C++ VecModel 2022-01-14 13:38:25 +01:00
Tobias Hunger
79e2456ead Allow for bigger indices in VisitChildrenResult
The indexes stored in `VisitChildrenResult` are unsigned. We have 64
bits to store two values and we need to have one special value as a flag.

So accept any index `< u32::MAX` instead of `< i32::MAX`, which should
allow for more data to be visited;-)
2022-01-08 20:55:22 +01:00
Simon Hausmann
dc387553ba Centralize the C++ sixtyfps version macros in the generated public header file 2022-01-05 16:32:55 +01:00
Simon Hausmann
174fd2659f Remove some duplication in the documentation of API that's shared between Rust and C++
This change makes the start of sharing the docs for the `TimerMode` enum
between Rust and C++. The reference to Timer::start in there works as
both doxygen and rustdoc find the right reference, but this needs
careful editing in the future and double-checking!

Another "caveat" is that the docs for the TimerMode enum say that the
enum is defined in the file "sixtyfps_generated_public.h", which is
correct as-is but not as pretty as "sixtyfps.h". I tried various ways
with \file and \includedoc, but couldn't get it working differently.

To implement this, the cppdocs steps now also runs cbindgen and cbindgen
generates a new sixtyfps_generated_public.h file that contains types we
do want to have in the public sixtyfps namespace.
2022-01-05 16:32:55 +01:00
Simon Hausmann
083ae5692b Fix the Rust/C++ Timer API to be more convenient to use
Allow calling restart() on a repeated timer if it has been previously stopped.
2022-01-05 13:26:28 +01:00
Simon Hausmann
f557a27556 Complete the C++ Timer API
With this patch it matches the Rust API, with start(), restart(), running() and
a default constructor.
2022-01-05 12:10:29 +01:00
Tobias Hunger
bfca0e3573 Mass update copyright messages to be more REUSE compliant 2021-12-22 10:06:12 +01:00
Simon Hausmann
774be9ba76 Improve timer docs
Use the term interval instead of duration to emphasize that it's not a single shot.

(The single-shot docs still use duration)
2021-12-12 09:29:16 +01:00
Olivier Goffart
53775465dc
C++: add version macro
Fixes #705
2021-12-06 15:36:16 +01:00
Olivier Goffart
e4bd6bbfb8 Native style: respond to the StyleChange event
So that color scheme is updated when switching to the dark style, for example

Fixes #687
2021-11-29 17:18:23 +01:00
Olivier Goffart
d26e95fb95 C++: Fixed sixtyfps::blocking_invoke_from_main_loop when the callable returns void
Fixes #623
2021-11-01 10:51:13 +01:00
Simon Hausmann
096fbab93d Simplify the destructor of generated C++ components
Similar to the parent commit, avoid creating an array of item refs and pass the item tree instead
to a run-time helper function.
2021-11-01 10:19:17 +01:00
Olivier Goffart
567c644a5f Fix PopupWindow position when all elements are not inlined
Pass a reference to the parent item in the show_popup function
so we can compute the exact location at runtime.
2021-10-28 15:52:29 +02:00
Simon Hausmann
d420d5efd7 internal cleanup: Rename Property::set_dirty() to mark_dirty() 2021-10-20 15:25:28 +02:00
Simon Hausmann
7d12fd7b4e Add support for tracking the length of a model in C++
Similar to the parent commit, the model tracks changes to the rows and
marks an internal property dirty. Since we have a base class this is a
little less intrusive.

cc #98
2021-10-20 15:25:28 +02:00
Simon Hausmann
c91a38cdce Add support for embedding data in generated C++ code
This allows compiling with SIXTYFPS_EMBED_RESOURCES=true and
images/fonts are embedded as inline variables.

Generated data is emitted into the header file as

   inline uint8_t sfps_embedded_resources_123[789] = {
       0x1, 0x2, 0x3,
   };
2021-10-05 15:05:50 +02:00
Olivier Goffart
2716e4b4dd TouchArea: add the pointer-event callback
... instead of `pressed-changed`

This allows to see what mouse button was pressed.

Closes #535
2021-10-04 14:39:49 +02:00
Olivier Goffart
fafcbfde2c Fix panic when trying to access layout cache of destroyed items
This can be reproduced by deleting the last item of the printer queue in the
printer demo.
It is a regression showing up because we now emit the MouseExit event after
the mouse grab as released.
The problem is that we upgrade the weak item, and call geometry() on it.
Calling geometry will re-evaluate the layout cache which will re-evaluate
the model which will result in the component being removed and the cache
entry having less item than expected.

It is ok to simply return 0. for these layout location since the item will
disapear anyway.
2021-09-08 14:42:08 +02:00
Olivier Goffart
619ce6c4f7 Struct exposed to .60 as struct need to be layed out in alphabetical order
because that's the order in which the C++ code generator pass the argument
to the agregate initialization
2021-09-05 09:29:00 +02:00
Olivier Goffart
092d5d551f C++: add blocking_invoke_from_event_loop
A blocking version of invoke_from_event_loop
2021-09-01 23:19:13 +02:00
Olivier Goffart
e1be599bc0 Print an warning in stderr when modifying read-only model
... and improve the documentation of Model
2021-08-31 10:36:22 +02:00
Simon Hausmann
8de3075270 C++ docs: rework the entry points
Move the sixtyfps::namespace entry into a dedicated C++ integration overview
page. Also duplicate and specialize the instantiation and model bits, which
differ between the compiled code and the interpreter.

Finally, fix the generated C++ docs to not mention that there's a constructor,
instead we generate a constructor function.
2021-08-27 16:56:36 +02:00
Simon Hausmann
bcb200c547 Add an example for invoke_from_event_loop in C++
This way we can link from it from the blog and it looks maybe as good as in Rust :)
2021-08-18 10:12:34 +02:00
Olivier Goffart
9b869f2dc0 C++ Add a few asserts that the non-thread safe API is not called in a thread 2021-08-12 12:59:50 +02:00
Simon Hausmann
661f23760b Fix build: Add missing non-const arrow/deref operators for VRc/Component 2021-08-03 10:32:04 +02:00
Simon Hausmann
e97ecea480 Fix constness in generated C++ API
run(), show() and hide() should not be const, as well as the window() accessor.
2021-08-03 10:32:04 +02:00
Simon Hausmann
341387c8d0 Provide sixtyfps::Window by reference in the generated C++ API 2021-08-03 10:32:04 +02:00
Simon Hausmann
66891a299c Start a new sixtyfps::Window API for Rust, C++, the interpreters and JS
The generated component now provides access to a Window type
via the window() accessor function.

This is part of #333
2021-08-03 10:32:04 +02:00
Simon Hausmann
eaddbe664e internal cleanup: Rename ComponentWindow to WindowRc
That's all it is nowadays, it's a wrapper around Rc<Window>. It's not an
alias because we need to also "wrap" it to C++ via cbindgen, but that's
about it.
2021-07-21 20:33:02 +02:00
Olivier Goffart
13bd828b96 Update license date 2021-07-02 15:55:54 +02:00
Simon Hausmann
f8abd57c3b C++ docs: For the model bits, link to the for-in and ListView docs
Using an rst epiloge we can define global references that are even formatted
(using rst substitutions)
2021-07-02 12:32:28 +02:00
Simon Hausmann
69bbef529c C++ docs: Link to the section of the generated code from the namespace intro 2021-07-02 09:56:52 +02:00
Simon Hausmann
4705415642 C++ docs: First draft of a sixtyfps namespace intro 2021-07-02 09:46:48 +02:00
Olivier Goffart
9b99b558ae Spellcheck 2021-07-01 13:54:26 +02:00
Olivier Goffart
fe81590b07 Silence a bunch of MSVC warnings 2021-07-01 13:47:22 +02:00
Simon Hausmann
5d58d34e84 Document run_event_loop() and quit_event_loop()
The C++ versions were there before, but undocumented. The Rust version
for quit() was missing.
2021-06-29 16:12:00 +02:00
Simon Hausmann
3ab287223c Silence exhale error
Doxygen would still generate xml for private_api::ArrayModel and would
try to resolve a reference to iself, which is not possible because we've
excluded the namespace:

```
   stderr: (!) Critical error while generating the file for [/home/vagrant/sixtyfps/target/cppdocs/api/classsixtyfps_1_1Model.rst].Traceback (most recent call last):
      File "/home/vagrant/.local/share/virtualenvs/docs-4wjFCyEr/lib/python3.8/site-packages/exhale/graph.py", line 2591, in generateSingleNodeRST
        gen_file.write("{0}\n".format(node.baseOrDerivedListString(
      File "/home/vagrant/.local/share/virtualenvs/docs-4wjFCyEr/lib/python3.8/site-packages/exhale/graph.py", line 393, in baseOrDerivedListString
        link=nodeByRefid[refid].link_name
    KeyError: 'classsixtyfps_1_1private__api_1_1ArrayModel'
    ```

Making the entire class as \private works around it.

Oddly, this isn't needed for IntModel, perhaps because it's not a template?
2021-06-28 14:18:45 +02:00
Olivier Goffart
ae114cf79d C++: don't re-export private symbol in the public API
Use the cbindgen_private namespace dirrectly from the generated code
2021-06-28 12:03:49 +02:00
Olivier Goffart
daff9e8e65 Move Callback and internal Models to the private_api namespace 2021-06-28 11:23:44 +02:00
Tobias Hunger
13d7f5e7bd Janitor: Fix typos in comments and user-facing strings
Also adapt tests for error messages containing the fixed strings.

No behavior change is intended!
2021-06-28 08:32:25 +02:00
Simon Hausmann
8a8ff6d2e9 Work around doxygen complaining about lack of override function 2021-06-26 09:42:56 +02:00
Simon Hausmann
919cc3065f C++: Fix remaining doxygen warnings in sixtyfps.h 2021-06-25 20:33:03 +02:00
Simon Hausmann
929dd8dbf4 Fix various doxygen warnings
and hide some internal members from doxygen
2021-06-25 20:26:33 +02:00