Commit graph

651 commits

Author SHA1 Message Date
Simon Hausmann
e0f3e6b782 Fix the C++ printer demo with disabled inline
For the following reduced test-case the order in how the dynamic nodes
in the item tree were generated (and dyn indices assigned) differed from
the way the visit_dynamic_children slots were generated:

```
Blah := Rectangle {
    for x in 1: Text {
        text: "Should be on the right";
    }
}

MainWindow := Window {
    width: 772px;
    height: 504px;
    Text {
        if (false): TouchArea {
        }
    }
    Blah {
        x: 200px;
    }
}
```

The item tree node was constructed using build_item_tree, which
basically assigned dyn index 0 to the "repater" for the touch area
and "1" to the one for the repeater inside the sub-component.

Afterwards we traversed the element tree - without descending into the
sub-components - to generate the fields and the dispatch in in the
dynamic visitor. Here a subtle order would result in a mismatch of
indices:

recurse_elem_level_order would end up visiting Text, Blah and then
Text's children, assigning the first dynamic index to Blah.

This is now fixed by merging the two iterations into one.
2021-11-04 11:03:44 +01:00
Olivier Goffart
f316c38d54 Do the apply_default_properties_from_style before the lower_states pass
because we don't want the lowered state property to look like we set a property on it.

Also do the ensure_window before because it need to be done before to be assigned
the default color
2021-11-04 10:08:30 +01:00
Olivier Goffart
ab88e3553e Fix the item tree building for components whose base is a component
We should only visit element that are native item with the visit_item function
2021-11-03 14:59:27 +01:00
Olivier Goffart
19e9186a31 Add a way to run the C++ tests with valgrind 2021-11-03 10:35:12 +01:00
Simon Hausmann
7c8874e803 Fix nodejs test
There's in invoke_ prefix for callbacks :)
2021-11-03 10:23:00 +01:00
Simon Hausmann
da169b0e3c Fix calling focus() in sub-components when inlining is disabled
focus() is implemented by calling set_focus() on the window with the absolute item
index as a parameter. The
generate_item_indices pass generates local item indicies,
which need to made absolute.

Sadly there exists a gap in the item tree between the root element of a sub-component
and its children. Therefore each sub-component gets two members passed to the constructor,
the tree_index and tree_index_of_first_child.
The former is to be used when the local index is zero (indicates the root).
The latter is used as base for any children.
2021-11-03 09:45:35 +01:00
Olivier Goffart
ab772828e9 Don't try to keep the used_component while doing the inline pass
Because some Component might be inlined, and some other not.
Instead, just call the collect_subcomponents pass.
2021-11-01 13:47:09 +01:00
Olivier Goffart
8622dcb910 Do the default_geometry pass without inlining 2021-10-28 15:52:29 +02:00
Olivier Goffart
67dd409f87 Move a few more passes before inlining 2021-10-28 15:52:29 +02:00
Olivier Goffart
7b41f8a4bc Do the popup window pass before inlining 2021-10-28 15:52:29 +02:00
Olivier Goffart
6e5596cdfc Make the repeater pass work on the non-inlined object tree 2021-10-28 15:52:29 +02:00
ogoffart
b25ae6fbcd Bump version number to 0.1.5 2021-10-26 07:36:54 +00:00
Simon Hausmann
8596cca549 Fix model length tracking in the interpreter
Added the missing tracking call and fix the test to cover this properly.
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
63bf1af093 Add support for tracking the length of a model in Rust
This is done by exposing the ModelNotify to the caller via the new
ModelTracker trait, which has a function that allows "hooking" into the
dirty tracking of the size.

By extension, this also works in JavaScript.

cc #98
2021-10-20 15:25:28 +02:00
Simon Hausmann
dec6c6ca51 Work around crash in Qt mac style when drawing scrollbars with invalid size
Fixes #595
2021-10-19 12:36:26 +02:00
James Blacklock
b409ee8cbe add license header to test case 2021-10-18 10:21:06 +02:00
James Blacklock
36f4b32506 use shared pointer in cpp test 2021-10-18 10:21:06 +02:00
James Blacklock
1f0a5a6d7c fix formatting & cpp test case 2021-10-18 10:21:06 +02:00
James Blacklock
642e4b539a (hopefully) fix cpp generation 2021-10-18 10:21:06 +02:00
James Blacklock
25f14ab58c add test case 2021-10-18 10:21:06 +02:00
Olivier Goffart
4436b422e5 Fix LineEdit.has-focus witht he native style
The property had the wrong name.

Also it is not a native-output
2021-10-14 15:34:25 +02:00
Olivier Goffart
acf2ef38a6 Don't put no-frame on the printer demo example
Prefer just put it in a random test instead
2021-10-11 10:30:31 +02:00
Olivier Goffart
3b6e0e5802 Fixes the PointerEvent.kind always being down
Fixes #558
2021-10-08 16:56:35 +02:00
ogoffart
77fcd5221b Bump version number to 0.1.4 2021-10-07 09:36:43 +00:00
Olivier Goffart
cc0d5e17a1 Fix materialized property being wrongly re-initilized when used within the same Element
Because the `bindings` field is taken in order not to keep the Element borrowed.

Fixes original report from #553
2021-10-07 09:23:24 +02:00
Olivier Goffart
72d556113f Visit globals when finding usages of structs
Otherwise some used struct might not be found, and they can cause
compilation failure in the generated C++ or Rust code

Fixes #549
2021-10-06 18:48:06 +02:00
Olivier Goffart
7939d834d4 Fix panic in the interpreter if there are properties that are aliased to struct 2021-10-06 18:33:27 +02:00
ogoffart
8b9717633e Bump version number to 0.1.3 2021-10-05 10:31:45 +00:00
Olivier Goffart
ae3e1b4680 Allow normal Element to be in the Dialog's button row with dialog-button-role 2021-10-05 09:46:20 +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
5c7a8e7842 Fix test 2021-09-30 13:42:56 +02:00
Olivier Goffart
fd435ec270 Fix the default Text color overriding a color specified in a two way binding
We just need to adjust the priority of the default binding to be a high value
(eg, less priority) since the other values must always win.

This fixes the placeholder text color
2021-09-30 12:48:19 +02:00
Olivier Goffart
7db9f3dfa9 Dialog: automatically add clicked callback for the standard button
And make the viewer listen to them and set them to automatically close dialogs
2021-09-30 10:21:13 +02:00
Olivier Goffart
7f05bfa309 Add the Dialog element 2021-09-29 16:25:44 +02:00
Simon Hausmann
324fb48499 Clean up generated C++ include directory handling
Don't generate the headers by default in the source directory, put them
into a sub-directory in OUT_DIR instead and convey that location via
links to the C++ test driver.
2021-09-18 07:32:53 +02:00
Simon Hausmann
4f158618a1 Fix make install in the C++ build running cbindgen
Make install would still trigger the generated_headers_target CMake
custom command - due to the use of add_dependencies - and that would end
up running cbindgen. That in turn breaks "make install" when it's run in
an environment that doesn't have cargo in PATH (for example when using
"sudo make install").

This patch folds the generation of the C++ header files into the build
of the sixtyfps-cpp crate - via build.rs. By default the headers are
placed in api/sixtyfps-cpp/generated_include but the CMake build
redirects that into the build directory.

Note: Due to the way that corrosion works, cargo is still run when
running "make install", but it's path is absolute and there should not
be any reliance on the PATH environment variable.
2021-09-18 07:32:53 +02:00
Simon Hausmann
5742a122ed Fix listview not updating its geometry in Rust when the entire model is changed
The geometry tracker did not track the model property itself, so it did not become dirty.

Fixes #500
2021-09-15 08:49:27 +02:00
Olivier Goffart
e98ecee1d8 rerun cbindgen when api/sixtyfps-cpp/lib.rs changes 2021-09-09 20:19:26 +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
Simon Hausmann
1b1a9ef06a Add a test-case for the ctrl+a shortcut to select all text 2021-09-07 11:33:28 +02:00
Olivier Goffart
d35c92bdc2 Make tests/cases/text/default_color.60 not depend on the style 2021-09-06 21:52:12 +02:00
Simon Hausmann
7da24c40c3 Use the GL backend in the CI for node tests
In the CI we set SIXTYFPS_NO_QT=1 and this change removes the testing
backend from the nodejs tests, in order to fix #419 .
2021-09-06 15:56:59 +02:00
Simon Hausmann
4d3f08d954 Allow global singletons to have default callback handlers
It's already working, we just need to remove the error handling :-)

Fixes #467
2021-09-06 13:56:27 +02:00
Simon Hausmann
2159ad5775 Restore test case
The changes in f8876fe2b2 were unintentional.
2021-09-06 13:09:57 +02:00
Olivier Goffart
4aeb9bcd08 Interpreter: fix comparison of enums
We need to normalize native enum to use dashes
2021-09-06 12:22:24 +02:00
Olivier Goffart
f8876fe2b2 Implement the image-rendering in the Qt backend
cc #465
2021-09-06 10:49:56 +02:00
Ryan Van Gilder
e7245cd0af cargo fmt and remove uneeded HorizontalLayout import 2021-09-06 10:03:51 +02:00
Ryan Van Gilder
4d1d0e73a4 Rename image-scaling to image-rendering to align with CSS 2021-09-06 10:03:51 +02:00
Olivier Goffart
6906475e22 Remove the unicode test
The GCC version on the CI is still too old

Also this fixes the CI not running the C++ driver tests
2021-09-05 09:29:00 +02:00