Commit graph

63 commits

Author SHA1 Message Date
Tobias Hunger
e6b24bceec [reorg]: Set up and populate the internal directory
Move "internal" crates into the `internal` directory. This first batch
includes most of sixtyfps_runtime but leaves the rendering backends
alone for now.

pre-commit applied some cleanups to the moved files:
 - Consistent newline at end of file policy
 - trimming trailing whitespace
 - Formatting Cargo.toml files.
2022-01-31 16:00:50 +01:00
James Blacklock
7ad1ba209d Add support for array index expressions
This is a squash of the changes in
https://github.com/sixtyfpsui/sixtyfps/pull/605
2022-01-14 13:38:25 +01:00
Simon Hausmann
9e61d4168b Fix build of Paths with path elements with rust/llr
A `Path` with `MoveTo`/`LineTo`/etc. sub-elements now maps to an Expression::PathData of type
Type::PathData.

The llr lowering creates an Array of Type::PathElement, which is casted to PathData.

This only covers the element case. The compiled path events are still todo.
2022-01-12 16:22:35 +01:00
Olivier Goffart
50ff8304b0 WIP: start generating rust code from the LLR
WIP does not compile yet
most of the code is actually still commented out and needs to be ported
2022-01-12 16:22:35 +01:00
Olivier Goffart
6dae67e374 Add some comments 2022-01-07 17:14:07 +01:00
Tobias Hunger
bfca0e3573 Mass update copyright messages to be more REUSE compliant 2021-12-22 10:06:12 +01:00
Olivier Goffart
bc8d556799 Compiler: keep const-ness information of native property in the NativeClass 2021-12-04 22:00:12 +01:00
James Blacklock
cc4105e274 no need for InferredGenericType! 2021-10-18 10:21:06 +02:00
James Blacklock
ab665ba7b6 enable scripts to access the length of arrays 2021-10-18 10:21:06 +02:00
Olivier Goffart
3cf9089293 Refactor: Builtin can now have default binding on properties that are inherited from a NativeClass
And make the Window have a NativeClass parent, so it can be re-used for the Dialog
2021-09-29 16:25:44 +02:00
Olivier Goffart
0b2fd617f0 Derive simple enum from Copy 2021-08-13 11:58:22 +02:00
Olivier Goffart
c25538c982 Normalize identifiers to - instead of _
As a result
 - The error messages will now show the error with `-` instead of `_`
 - The LSP will auto-complete with -
 - The interpreter's list of properties will list the property with '-'
   (but we made the change so that set_property, get_property, and so on
   work also if passed a '-')
2021-08-10 22:21:01 +02:00
Olivier Goffart
b6137ecbc4 Error when trying to use internal builtin items 2021-08-09 17:43:22 +02:00
Tobias Hunger
ec7b7f751b Janitor: Fix clippy::or_fun_call 2021-07-30 09:27:48 +02:00
Olivier Goffart
be37a9f69a Allow angle and duration in the public API snce we document it 2021-07-26 17:36:02 +02:00
Tobias Hunger
e5bdeaa804 Janitor: Remove unnecessary & 2021-07-07 08:42:28 +02:00
Olivier Goffart
13bd828b96 Update license date 2021-07-02 15:55:54 +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
Olivier Goffart
52e85933ed Fix unit tests
Code was moved, so the test need to be adapted to that
2021-06-18 15:46:45 +02:00
Olivier Goffart
0b6bd7b219 Fix accessing elided property
Fixes #177
2021-06-18 15:08:30 +02:00
Olivier Goffart
2438f27200 Keep the old long names property as deprecated 2021-06-14 10:28:30 +02:00
Olivier Goffart
522e78915f Fix the tests 2021-06-07 20:40:36 +02:00
Olivier Goffart
3ddc3c6ce5 Don't re-use Type::Void for inferred type
Make it explicit that it is inferred, and differentiate callback and property
2021-06-07 20:40:36 +02:00
Olivier Goffart
6a4cd0087f Apply suggestions from code review
Co-authored-by: Simon Hausmann <simon.hausmann@sixtyfps.io>
2021-06-07 10:48:09 +02:00
Olivier Goffart
715d38903f Allow to omit the type of aliases 2021-06-07 10:48:09 +02:00
Olivier Goffart
54be5f3a84 Some ground work to make more binding analysis
- Mark builtin properties that are modified by the native code as output
 - Record wether the property is set by code in the .60
 - Add a field that will tell us if a property binding is constant
2021-05-20 13:40:51 +02:00
Olivier Goffart
21a80f4562 WIP: Layout refactoring
Instead of using a solve_layout function in the component, use property to hold
a layout cache.

This commit only implement the GridLayout and only the interpreter part
2021-05-11 14:59:57 +02:00
Simon Hausmann
c6a4841cd4 Simplify item vtable retrieval in C++
Use a macro instead of a template function to make the getter vs. global
symbol choice.
2021-05-11 07:55:51 +02:00
Simon Hausmann
28701d2f90 Fix item vtable usage on Windows
The item tree is intended to be initialized with pointers to the item
vtables, which are implemented using data relocation records that
resolve to the symbols exported by the sixtyfps_cpp shared library.

On windows, according to

    https://docs.microsoft.com/en-us/cpp/c-language/rules-and-limitations-for-dllimport-dllexport?view=msvc-160

such data relocations are not supported, so this patch implements the
fallback through getter functions.
2021-05-10 22:54:06 +02:00
Simon Hausmann
4198513832 Add a dummy indirection in C++ for the item vtable access
This will allow for a compile-time decision in the future whether
to use the vtable symbol or getter function.
2021-05-10 22:54:06 +02:00
Olivier Goffart
e163794549 Fix panic when a non-element type is used as an element 2021-05-07 15:36:10 +02:00
Olivier Goffart
f620351cbf Go to definition of structs
Also add the struct in the outline
2021-04-24 15:06:58 +02:00
Olivier Goffart
847f3b26e4 Hide internal type in auto-completions 2021-04-23 15:06:37 +02:00
Olivier Goffart
14772a9b58 Handle reduction of logical lenght when the units are more complex 2021-04-21 17:15:19 +02:00
Olivier Goffart
91ed04a72c Make length (still the default for all property) be the logical length
And a new `physical_length` is now the physical_length unit

Note: this does not change the runtime part yet
2021-04-21 17:15:19 +02:00
Olivier Goffart
7ae850d564 Rename Type::Length -> Type::PhysicalLength 2021-04-21 17:15:19 +02:00
Simon Hausmann
9a06a29314 Implement dynamic image-fit and aspect ratio behavior for Image elements
This is part of #168 where `image-fit` has dynamic defaults and missing
width or height property bindings are installed with an aspect ratio
preserving behavior.
2021-04-09 15:17:52 +02:00
Olivier Goffart
81ebb2177e LSP: completion of properties 2021-04-07 23:55:46 +02:00
Olivier Goffart
3db3400951 Rename the Object type to Struct in the compiler 2021-03-16 12:38:53 +01:00
Olivier Goffart
c840b046ae Rename the "resource" type to "image" 2021-03-10 17:24:31 +01:00
Simon Hausmann
2f3c280ebe Fix cargo fmt --check
Not sure what happened but I guess the new release made it stricter
2021-02-18 13:45:42 +01:00
Olivier Goffart
0174db3679 Delay the percentage size conversion to after the layouting phase
So we can see inthe layouting phase if the size was in percent
2021-02-11 15:08:24 +01:00
Simon Hausmann
50d9211e0a Fix failing default_color.60 test
Allow converting a brush to a color. In the case of a gradient, the color of the first stop is returned.

For the C++ generator this requires adding the extra case of explicitly
calling the `Brush(const Color &)` constructor, despite it being implicit,
in order to generate the correct code when we have IR that casts twice:

```
   Expression::Cast {
       from: Expression::Cast {
           from: Expression::Cast {
               from: Expression::NumberLiteral(...),
               to: Type::Color,
           }
           to: Type::Brush,
       },
       to: Type::Color,
   }
```
2021-02-04 13:44:10 +01:00
Olivier Goffart
b75e135459 Support complex product of units
Fixes #68
2021-02-04 12:56:14 +01:00
Simon Hausmann
7982325da4 Change Rectangle::background's type to be a brush
This also introduces the brush type in the compiler and generators. At the
moment only conversion from Color is implemented.
2021-02-03 12:49:44 +01:00
Simon Hausmann
1f091cb1c0 Rename Rectangle.color to Rectangle.background
Add support for built-in property aliases and rename `color` to
`background` - in preparation for it also changing to type brush.

Right now the alias is silent, a deprecation and overall change
will come in a subsequent change.
2021-02-02 17:01:12 +01:00
Olivier Goffart
ad1e18764a Make angle its own type 2021-02-01 14:49:25 +01:00
Simon Hausmann
326d235ff5 Fix calling focus() on components
Fixes #153
2021-02-01 13:05:08 +01:00
Olivier Goffart
97917c43db Fix selecting the minimal class when no properties are used
Otherwise `Rectangle{}`  would be a BorderRectangle
2021-01-28 18:52:39 +01:00
Simon Hausmann
f7ea2a9dce Forward focus() calls on items that have initial-focus defined
This also makes the focus() method available as a member function on any
item, but the resolve_element_reference_in_set_focus_calls() pass will
check if the elements are valid.

The check for `has-focus` to determine a focusable item was replaced
with an annotation on the built-in elements, so that `has-focus` can
later be implemented as a built-in function through the run-time,
without the need for a boolean property.
2021-01-20 14:31:01 +01:00