Commit graph

95 commits

Author SHA1 Message Date
Simon Hausmann
58768bf70a Add default bindings for width/height for Image and Text to their implicit size 2021-01-15 17:58:32 +01:00
Olivier Goffart
0d2d48be4f Rename "signal" to "callback" 2020-12-18 09:51:01 +01:00
Olivier Goffart
7f78bea8b5 Fix a bunch of cargo clippy warnings in the compiler 2020-12-07 12:54:38 +01:00
Olivier Goffart
a37a287a17 Limit the conversion from percentage to lenght for the width and height property 2020-12-04 11:20:09 +01:00
Olivier Goffart
276e11a101 More work on signals with return value 2020-12-01 18:47:49 +01:00
Olivier Goffart
852eeb1c11 WIP popup 2020-11-30 15:20:51 +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
7967a074fb Fix accessing struct declared in a different file 2020-11-17 12:02:21 +01:00
Olivier Goffart
dd4435fe5d Add round/ceil/floor 2020-11-16 12:52:01 +01:00
Olivier Goffart
b45a14bd7a modulo 2020-11-13 16:07:18 +01:00
Olivier Goffart
d499e86640 Implement cubic-bezier 2020-11-13 13:36:32 +01:00
Olivier Goffart
11e55dd8d2 String -> Float conversions 2020-11-03 15:19:58 +01:00
Olivier Goffart
e5302e0b7b Remove unused Type::EnumerationValue
Values are not their own types
2020-11-03 12:34:17 +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
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
86e3c8740e Fix conversion to void
anything can convert to void
2020-10-19 19:43:13 +02:00
Olivier Goffart
1de39e5769 String concatenation 2020-10-19 18:37:15 +02:00
Simon Hausmann
855672a2e4 Minor code cleanup
We don't need to explicitly return if the cast we want to do is done
afterwards anyway :)
2020-10-19 12:41: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
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
071ab9fda1 Prepare for use of percentages as widths in layouts
Delay the conversion of percentage to the float to code generation type
by inserting the multiplication into the syntax tree. That way we will
be able to detect plain uses of percetages and interpret them
differently.
2020-10-16 15:38:35 +02:00
Simon Hausmann
a695d551da Small typo fix 2020-10-16 14:59:58 +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
Olivier Goffart
519de0f860 Allow convertion of object type even if a property is missing 2020-10-14 13:53:44 +02:00
Simon Hausmann
4c96dc85df Minor cleanup in builtin function handling
We don't need to duplicate the SetFocusItem signature.
2020-10-08 10:26:29 +02:00
Olivier Goffart
c7e5b39973 Layout the items in the ListView 2020-10-02 18:07:39 +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
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
2050f08f1e Ability to make change to the model property 2020-09-30 15:04:32 +02:00
Olivier Goffart
2d01b92c84 Ability to change part of objects from the .60 syntax 2020-09-30 11:33:36 +02:00
Olivier Goffart
4981c3ca75 Some check for the two way bindings 2020-09-23 14:06:08 +02:00
Olivier Goffart
bfe2bf2478 Ability to read properties of a struct 2020-09-17 13:53:00 +02:00
Olivier Goffart
8134fe5088 Support for named type as property 2020-09-17 13:14:01 +02:00
Olivier Goffart
a6504ee61b Start implementing some code that passes argument to functions and signals 2020-09-08 14:37:44 +02:00
Olivier Goffart
e10ed650ee Lookup of signal argument within a signal handler 2020-09-08 12:12:01 +02:00
Olivier Goffart
9f026c820d Parse declaration of signal with arguments 2020-09-07 17:41:24 +02:00
Olivier Goffart
9fbb40d91b Start working on a debug statement 2020-09-03 19:10:07 +02:00
Olivier Goffart
b2b5645195 Allow property of type object, and conversion between objects 2020-09-03 08:39:23 +02:00
Olivier Goffart
2bb7616b80 Show in the error message how to perform conversion between units 2020-08-31 10:30:16 +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
Simon Hausmann
fcc819e395 Add support for enums to the compiler
This replaces the duplicated text alignment enums
2020-08-07 13:15:43 +02:00
Simon Hausmann
aecf6a8878 Center text in buttons in the demo and gallery
This adds horizontal_alignment/vertical_alignment properties, along with
width/height to Text.

This still uses a hard-coded enumeration in the compiler, which is meant
to go away in favor of general enum support.
2020-08-07 10:02:52 +02:00
Simon Hausmann
41671e3efb Represent the window scale factor conversions in the IR
That means less code in the generators and easier to extend in the
future with more built-in functions.
2020-08-04 12:49:37 +02:00
Olivier Goffart
feec73674f Start implementing easing curve 2020-07-29 15:19:41 +02:00
Olivier Goffart
f02512f467 Allow to get the span of a binding 2020-07-28 18:02:23 +02:00
Simon Hausmann
88fb491837 Add support for mapping elements to different native classes
The Rectangle element has properties for a border outline. If those are
used, then the generated code should use BorderRectangle. But if they are
not used, then we can fall back to just generating a Rectangle.
2020-07-24 17:48:19 +02:00
Olivier Goffart
f87a3e2c13 Assignment operator 2020-07-24 11:43:23 +02:00
Olivier Goffart
232848de9e Make sure that there is only one error reported when assigning to invalid
This also start parsing assignment ('=') as a self assignement
but the code generation is not yet implmented
2020-07-24 11:33:00 +02:00