Commit graph

661 commits

Author SHA1 Message Date
Olivier Goffart
20cfb65e53 Bump version 2020-10-22 08:41:45 +02:00
Olivier Goffart
ac6d4007ab Node: Add setHandler features on signals 2020-10-21 12:22:22 +02:00
Olivier Goffart
c50b9d73d3 Document the generated C++ code 2020-10-21 11:29:25 +02:00
Olivier Goffart
eb73f987e0 Update cargo-metadata dependency 2020-10-21 08:58:48 +02:00
Simon Hausmann
f6d8f78e3f Hide the private API of the NodeJS integration
Hide it behind a `private_api` property in the module export.
2020-10-20 16:52:28 +02:00
Simon Hausmann
7905285562 Change the Model API for the NodeJS Integration to use CamelCase 2020-10-20 16:40:49 +02:00
Simon Hausmann
c188851b45 Fix nodejs tests on Windows
npm is in fact `npm.cmd` and Rust's std::process::Command doesn't look
for executables with .cmd extension. This is a common issue but also a deliberate choice
it appears (due to emulating CreateProcess).
2020-10-20 16:30:16 +02:00
Simon Hausmann
279ce560f9 Convert NodeJS API to use & export TypeScript
This will make the types available to API consumers and makes the
documentation clearer.
2020-10-20 15:57:50 +02:00
Olivier Goffart
4fb87f401e Some fixes for the initializations of two way bindings within sub components
There are still more issues
2020-10-20 14:33:06 +02:00
Olivier Goffart
73ccdec73e Fix overwriting value from a component to the other 2020-10-19 20:32:16 +02:00
Olivier Goffart
86e3c8740e Fix conversion to void
anything can convert to void
2020-10-19 19:43:13 +02:00
Olivier Goffart
587b0a9fa8 Test for string concatenation 2020-10-19 19:43:13 +02:00
Simon Hausmann
3b051f2176 Clarify hexadecimal color encoding
We parse hex colors as per CSS, including the #RRGGBBAA variant, as per
https://www.w3.org/TR/css-color-4/#hex-notation . This is now documented
and the JS conversion also generates that instead of #AARRGGBB.
2020-10-19 16:38:58 +02:00
Simon Hausmann
41ad33f443 Fix bug in struct initialization from object literals
When converting from object literal to object literal, we would check
recursively if the individual fields can be converted and then generate
code to convert each field.

For a conversion frmo object literal to a struct, we would a per-field
can_convert check as well, but there would not be any code (Expression)
generated for the conversion, instead it would be a straight cast. That
was fine so far in our tests and example code, because the fields never
required a conversion. With commit
071ab9fda1 the percentage number literals
used in the printer demo however would now require a conversion
(multiplication by 0.01) before the assignment to the float level field.

This patch adds the missing conversion by matching the Object -> Struct
conversion case, generating an intermediate Object type based on the
struct's properties, call maybe_convert recursively and *then* cast the
result to a struct.
2020-10-19 12:17:41 +02:00
Olivier Goffart
14198052ac ArrayModel support in JS 2020-10-17 13:33:22 +02:00
Simon Hausmann
13f845ee4f Add support for property<percent> 2020-10-16 18:56:54 +02:00
Simon Hausmann
cf87ac804b Add support for relative lengths
Typically `some_length_prop: 40%` produces an error, but if there's a
matching property in the parent, then it will be allowed and interpreted
as relative value and creates a dynamically updated binding.
2020-10-16 18:54:04 +02:00
Olivier Goffart
cdc6a34eaf Support for array in JS 2020-10-16 12:58:27 +02:00
Olivier Goffart
3ea524694e Support for color in JS (as string) 2020-10-16 12:58:27 +02:00
Olivier Goffart
67dddd69e7 JS: implement conversion to Type::Object 2020-10-16 12:58:27 +02:00
Olivier Goffart
e4e601de83 Draw the frame properly around the native scrollview 2020-10-16 10:45:17 +02:00
Simon Hausmann
6aa292eac1 Change the names of the logical and physical pixel units
The logical pixels are now just called "px" and the less frequently
used physical pixels have the "phx" suffix.

The existing markup was adapted using the syntax updater and the
following patch:

    +    if node.kind() == SyntaxKind::NumberLiteral {
    +        if node.text().ends_with("lx") {
    +            return write!(
    +                file,
    +                "{}px",
    +                node.text().as_str().split_at(node.text().as_str().len() - 2).0
    +            );
    +        }
    +        if node.text().ends_with("px") {
    +            return write!(
    +                file,
    +                "{}phx",
    +                node.text().as_str().split_at(node.text().as_str().len() - 2).0
    +            );
    +        }
    +    }

Fixes #49
2020-10-16 07:19:40 +02:00
Simon Hausmann
309fa8aef1 Fix build 2020-10-14 15:34:38 +02:00
Olivier Goffart
07829a54d9 Array test 2020-10-14 14:31:56 +02:00
Olivier Goffart
519de0f860 Allow convertion of object type even if a property is missing 2020-10-14 13:53:44 +02:00
Olivier Goffart
3397103dd2 Fix access aliases within a for or a if 2020-10-13 13:45:18 +02:00
Simon Hausmann
853a74043f Add support for moving/selecting to beginning/end of line 2020-10-13 13:20:26 +02:00
Simon Hausmann
2d387d4c3b Fix hang when pressing the right arrow to go back the end of text input
str::is_char_boundary() returns true at text.len() but beyond that it'll return false.
2020-10-13 13:20:26 +02:00
Olivier Goffart
4d4aa81007 Revert the commit than pins aho-corasick version
This reverts commit 0c8a31211e.

aho-corasick 0.7.14
2020-10-13 07:57:02 +02:00
Olivier Goffart
1138c9dbed Normalize the spelling of SixtyFPS 2020-10-13 07:48:55 +02:00
Simon Hausmann
0c8a31211e Work around build failure on macOS
I keep running into https://github.com/BurntSushi/aho-corasick/issues/64
on macOS, so pin aho-corasick to 0.7.4.
2020-10-12 14:46:21 +02:00
Olivier Goffart
cae0503fbb Update outdated dependencies 2020-10-12 10:29:07 +02:00
Olivier Goffart
d8f7139f48 Fix Native StandardListView with C++ 2020-10-08 17:18:22 +02:00
Olivier Goffart
13be880d66 Fix interpreter with empty model 2020-10-08 12:06:58 +02:00
Simon Hausmann
7e0e7b43f0 Add support for calling focus() on TextInput elements
This allows activating text inputs in signal handlers connected for
example to buttons.

This implements parts of #55
2020-10-01 08:52:45 +02:00
Olivier Goffart
f01977ca06 Fix removing from model in C++ 2020-09-30 18:17:15 +02:00
Olivier Goffart
5fbe79006c Add test for writing to model 2020-09-30 18:15:53 +02:00
Simon Hausmann
9ad8968529 Add support for the initial_focus synthetic property
Setting it will translate to a set_focus_item call in the constructor.

This implements parts of #55
2020-09-30 15:11:01 +02:00
Olivier Goffart
2d01b92c84 Ability to change part of objects from the .60 syntax 2020-09-30 11:33:36 +02:00
Simon Hausmann
23ffcec22b Fix formatting 2020-09-29 22:18:19 +02:00
Simon Hausmann
e757284097 Fix build of tests on Windows
Now that the test names may include path separators, make sure to replace
main separator, not just the forward slash.
2020-09-29 22:07:18 +02:00
Simon Hausmann
c16f2f2185 Clean up test cases
Instead of all files collected in a flat directory, restructure them
into categories and thus sub-directories.
2020-09-29 17:00:48 +02:00
Olivier Goffart
f4f4775a19 Refactor the C++ Repeater to do the same as the Rust one 2020-09-29 14:20:43 +02:00
Olivier Goffart
2337eb097b Refatoring of the rust Repeater so we can take track of which items are dirty
So we do not recreate items unless they were removed and re-added
2020-09-29 14:20:43 +02:00
Olivier Goffart
6662e1ff00 Proper Scrollbar on the native style 2020-09-28 18:13:13 +02:00
Olivier Goffart
6dd0d178a0 Rename ScrollArea to ScrollView 2020-09-28 10:52:29 +02:00
Olivier Goffart
3b6679ed4b Two ways binding works also work as three ways binding and more
A side effect is that the order of calling set_binding and link_two_ways is no longer relevant
2020-09-28 10:42:27 +02:00
Olivier Goffart
2d4f3ff50b Two way bindings in the interpreter 2020-09-25 16:21:48 +02:00
Olivier Goffart
abe24e2e9e C++ two way bindings 2020-09-25 15:21:37 +02:00
Olivier Goffart
9d53c45291 Implement two ways binding in rust 2020-09-25 12:57:08 +02:00