Commit graph

182 commits

Author SHA1 Message Date
Olivier Goffart
f8f02a13eb Refactor the helper to visit all named reference to take a component
If we want to add more expression or named reference in the component,
we then can just update that function
2020-11-25 17:15:27 +01:00
Olivier Goffart
0ad0c181e3 Take a component in the function that visit all elements 2020-11-25 15:16:39 +01:00
Simon Hausmann
fa95064363 Fix resource embedding across component boundaries
When referencing an image a repeated element and were targeting a
configuration that requires resource embedding, then that image would
not embedded.

This was due to the fact that we didn't recurse into sub-components in
the resource collection phase and the generators made a per-component
embedding decision. The field responsible for that was also not
propagated to sub-components.

This patch addresses these two bugs by cleaning up the entire mechanism:

The compiler first generates the new ResourceReference::AbsolutePath for
all img!"foo.png" expressions. If the compiler is configured to embed
resources, then the embed_resources pass will traverse all
sub-components and expressions in them to change them to
ResourceReference::EmbeddedData with a unique integer id. Simultaenously
all the resources to be embedded get also collected in the root
component, so that the build script as well as the generator can take
care of dependency handling and actual resource embedding.
2020-11-23 13:47:16 +01:00
Olivier Goffart
df318d9104 Fix states in the root of other components 2020-11-20 17:14:04 +01:00
Simon Hausmann
89e0b57627 Rework and simplify the focus handling
Instead of determining the focus item through item tree traversal and
pointer comparison and storing the intermediate indices in the
components in the tree, remember the focus item by a pair of
VWeak<ComponentVTable, Dyn> and item_index: usize.

This speeds up determining the focus item as well as delivering events,
which can now be done directly after retrieving an ItemRef with
get_item_ref.

This also fixes the duplicate line edit focus in the 7gui cells
test case.
2020-11-20 15:33:15 +01:00
Olivier Goffart
091a0834d3 Transitions in rust (C++ and interpreter not implemented yet) 2020-11-20 10:30:17 +01:00
Olivier Goffart
88ceeeb3e6 Error when a transition reffers to a state that does not exist 2020-11-20 09:39:06 +01:00
Olivier Goffart
4d4c73925c Some refactoring to prepare for transitions on properties 2020-11-20 09:39:06 +01:00
Olivier Goffart
f131c2d081 When only importing a component, treat that component as the root component 2020-11-18 10:43:39 +01:00
Olivier Goffart
dec29e6d98 Allow to export structs 2020-11-17 12:22:10 +01:00
Olivier Goffart
7967a074fb Fix accessing struct declared in a different file 2020-11-17 12:02:21 +01:00
Olivier Goffart
281a744e86 Load the builtin from a fake .60 file 2020-11-04 16:56:35 +01:00
Olivier Goffart
decbe0ade5 Fix panic when exporting invalid types
And also still allow to export builtin component
2020-11-02 17:18:42 +01:00
Olivier Goffart
a82c23fc41 Add ability for the native style to export native Globals 2020-11-02 16:13:04 +01:00
Simon Hausmann
cba020182a Remove unused parameter 2020-10-29 14:03:15 +01:00
Simon Hausmann
e9bb668921 Replace errors with panics in the export processing
The errors here are not subject to regular test coverage because their
occurrence indicates a grave internal error. There should not be valid
input syntax that leads to this code path.
2020-10-29 14:00:52 +01:00
Olivier Goffart
1479bc956e Support for global in the interpreter 2020-10-29 11:01:04 +01:00
Olivier Goffart
5f5e5b7420 Access global properties from rust
C++ and interpreter implementation is still missing so the new stest is failling
2020-10-29 11:01:04 +01:00
Olivier Goffart
97166672c0 Semantic checks for the globals 2020-10-28 07:52:23 +01:00
Olivier Goffart
980aceded6 Parser: put the component name in a DeclaredIdentifier node
that way we will be able to have the global keyword as another identifier there
2020-10-28 07:18:24 +01:00
Olivier Goffart
d3801e26d3 Change the syntax of structures to require the struct keyword 2020-10-27 16:09:05 +01:00
Olivier Goffart
333c96fd79 Change Type::Object to be able to hold a name
Internally, structure will be represented with a Type::Object with a name
instead of a Component with a void base type
2020-10-27 16:09:05 +01:00
Olivier Goffart
27a6ff1227 Move Type and related concepts in a different module
Leaving only the TypeRegister in the typeregister module
2020-10-23 11:17:14 +02:00
Olivier Goffart
76b7f1aef6 Allow dashes in identifier
Currenly, dashes are normalized to '_'.
Dashes are not allowed at the begining of an identifier.
If an identifier with a dash is not found, we also look for identifier
without a dash and if that exist, we hint the user to use spaces.

Issue #52
2020-10-22 18:32:25 +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
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
Simon Hausmann
1b4317a93a Minor cleanup in the layout code in the compiler
Free the term "Layout Constraints" for use later for the actual constraints
of layouts.
2020-10-13 18:00:54 +02:00
Olivier Goffart
8f1c5a96c1 Fix ListView being scrollable when it shouldn't
Relates to #86
2020-10-13 13:45:18 +02:00
Olivier Goffart
3397103dd2 Fix access aliases within a for or a if 2020-10-13 13:45:18 +02:00
Olivier Goffart
3bdd71b36f Start working on the Native ListView
Currently only the interpret part
2020-10-08 15:51:33 +02:00
Olivier Goffart
c7e5b39973 Layout the items in the ListView 2020-10-02 18:07:39 +02:00
Olivier Goffart
f10c2bfd7c More ListView WIP 2020-10-02 18:07:39 +02:00
Olivier Goffart
dec06be70c WIP ListView 2020-10-02 18:07:39 +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
Simon Hausmann
dbdd9126ac Small typo fix 2020-09-28 11:43:45 +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
Olivier Goffart
4981c3ca75 Some check for the two way bindings 2020-09-23 14:06:08 +02:00
Olivier Goffart
8561106a15 Fix $children when there are two levels of insertion 2020-09-22 17:39:51 +02:00
Olivier Goffart
d4e1bfe360 Fix using local exported components
Components need to be processed in source order.
Not exported last as it was before.
2020-09-17 09:09:38 +02:00
Olivier Goffart
1c8150cb35 One should not be able to instantiate structures 2020-09-16 18:38:08 +02:00
Olivier Goffart
e0ed5252a8 Parse type declaration
```
export Foo := {
    property <int> xxx;
}
```
2020-09-16 18:26:13 +02:00
Simon Hausmann
ad77896312 Change the way Text's default color is implemented
Instead of via an item constructor, implement support for default
bindings in the compiler.
2020-09-16 13:41:18 +02:00
Olivier Goffart
637a0e792c Some more progress in signal connection with arguments 2020-09-07 18:49:38 +02:00
Olivier Goffart
9f026c820d Parse declaration of signal with arguments 2020-09-07 17:41:24 +02:00
Olivier Goffart
9d405060e2 Parse object and array type 2020-09-03 07:43:20 +02:00
Olivier Goffart
59dbb610be Materialize fake properties such as layout width/height 2020-09-01 18:49:49 +02:00
Simon Hausmann
7976a4057f Improve handling of nested layouts
We support directly nested layouts, but we did not support indirect
nesting:

    GridLayout {
        Rectangle {
            l2 := GridLayout { ... }
        }
    }

This patch fixes that by detecting this scenario and merging the layout
info of the element (Rectangle) and the layout inside (l2). This makes
it much easier to create re-usable components that use layouts
themselves and allows placing them in layouts.
2020-08-28 15:06:14 +02:00
Simon Hausmann
c1aa4b28c6 Add support for children insertion points for components
Sometimes re-usable components need to act as containers that allow the
user to place other items inside. The component needs to be able to
control the placement of these user-provided elements. That is what the
new

    $children

expression inside elements does.
2020-08-28 15:05:21 +02:00
Olivier Goffart
58cdaeb8dd Update license header to mention that commertial option are available 2020-08-26 13:23:42 +02:00
Simon Hausmann
2823f32692 Apply license headers to all non-binary/non-json sources 2020-08-17 17:55:20 +02:00