Commit graph

651 commits

Author SHA1 Message Date
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
Simon Hausmann
acb6eddeaf Expose the focused property on TextInput correctly
As per #55 introduce a has_focus property on the TextInput.
2020-09-25 11:22:32 +02:00
Simon Hausmann
e5dfb3a4c0 Implement basic focus handling
Similar to the mouse_grabber, we use a VisitChildrenResult field to
track the focus item within a component. Unlike the mouse grabber
however, it is set/cleared using dedicated focus events.

The key event now routes the key event directly to the focus item.

The focus can be requested via set_focus_item on a window, which the
TextItem does.
2020-09-25 10:43:47 +02:00
Olivier Goffart
0cb827a901 Two ways binding with optimized public property in the interpreter 2020-09-25 09:50:03 +02:00
Olivier Goffart
8361ef4019 Start code egeneration for the two ways binding
This is only meant to include the cases in which the property are optimized.
Does not work yet for the dynamic component
2020-09-24 14:37:16 +02:00
Simon Hausmann
0e2c845ff7 Add a test for multi-byte text input
Also fix an incorrect unwrap() at the same time.
2020-09-23 18:55:17 +02:00
Simon Hausmann
7ca66d62b9 Fix crash in TextInput when deleting a left-directed selection
When selecting to the left, the anchor remains to the right of the cursor.
When deleting such a selection, we fetch the cursor and anchor using a helper
method, which ensures that the anchor is to the left of the cursor.
Finally when setting the cursor then to the anchor, we need to also
set the anchor, since both were swapped.

This also add an automated test for this scenario.
2020-09-23 17:33:09 +02:00
Olivier Goffart
315fd7a881 Start doing a ScrollArea element
Unfortunately something is wrong with the Qt style, it looks like the Qt style
does not respect the rect given for the sub components

Also Input is not handled yet.
2020-09-22 20:05:41 +02:00
Olivier Goffart
8561106a15 Fix $children when there are two levels of insertion 2020-09-22 17:39:51 +02:00
Olivier Goffart
2ee861365c Flickable: expose the viewport property as viewport_*
The code generator forward that the the viewport
2020-09-22 13:52:27 +02:00
Simon Hausmann
93a08c5207 Add a LineEdit widget to the ugly and native style 2020-09-18 18:54:37 +02:00