Commit graph

1537 commits

Author SHA1 Message Date
Olivier Goffart
6a32a8b37a Don't error on empty documents 2021-07-29 17:40:20 +02:00
Olivier Goffart
b0b3912c27 Add support for the visible property 2021-07-29 15:02:25 +02:00
Olivier Goffart
bd52f4d444 Allow the clip property to be a dynamic property 2021-07-29 15:02:25 +02:00
Olivier Goffart
09c36ae965 Test for commit e0fad7fbdf 2021-07-29 13:25:47 +02:00
Simon Hausmann
2b5badcae2 Fix cargo fmt 2021-07-28 17:08:27 +02:00
Simon Hausmann
fd26dd4944 Fix expected error messages
Amends a3652e6823
2021-07-28 17:08:27 +02:00
Simon Hausmann
be05b54fa1 Tweak error message for conditionals/for in grid
Will adapt the tests in the next commit

Co-authored-by: Olivier Goffart <ogoffart@sixtyfps.io>
2021-07-28 17:08:27 +02:00
Simon Hausmann
e8727e98c5 Produce an error message when using if or for in grid layouts
An early error is better than a build error at compile time of generated code.
2021-07-28 17:08:27 +02:00
Simon Hausmann
14c6819791 Add support for icons in the Button widget
The icon in the gallery example was generated via https://emoji.aranja.com
2021-07-27 19:37:06 +02:00
Olivier Goffart
e0fad7fbdf Proper .60 compilation error when changing a property linked with a two way binding in a state
Instead of generating wrong code or panic
2021-07-27 10:18:24 +02:00
Olivier Goffart
f544e67fa1 Fix panic or invalid code caused by invalid expression in the tree
When there is an animaiton but no expression, the binding is
left with an invalid expression.
State was keeping that invalid expression as part of sub expression
this is a regression since commit ba32777cab
2021-07-27 09:10:33 +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
Olivier Goffart
7f611d21e3 Fix Angles conversion 2021-07-26 17:36:02 +02:00
Olivier Goffart
74bc9521b9 Fix the scope while resolving a model expression
The `self` was always referring to the `root` instead of the enclosing
element.
2021-07-26 11:08:46 +02:00
Olivier Goffart
ac751c1052 Re-arrenge a match
looks prettier this way
2021-07-23 17:11:54 +02:00
Olivier Goffart
ae210e79ec Properly handle self assignment on non-float types 2021-07-23 16:33:50 +02:00
Olivier Goffart
807377ed40 fix warnings 2021-07-23 15:40:11 +02:00
Olivier Goffart
01f11695a7 Properly merge the animation when inlining and removing aliases
Fix #193
Fix #345
2021-07-23 15:25:53 +02:00
Olivier Goffart
ba32777cab Refactoring: move the animation in the PropertyBinding struct
Since they always belong together.

This will help for issue #193
2021-07-23 15:25:53 +02:00
Tobias Hunger
2cdc5848a2 Janitor: Replace float comparison dance with approx_eq from euclid
Sixtyfps uses euclid already, so let's use euclid for float comparisons
as well.

I changed the code to decide whether a number is a positive integer to
make do without a comparison along the way.
2021-07-23 13:48:52 +02:00
Tobias Hunger
9539a53480 Janitor: Fix clippy::redundant_clone 2021-07-23 13:48:52 +02:00
Tobias Hunger
d64291245e Janitor: Fix clippy::len_zero 2021-07-23 13:48:52 +02:00
Tobias Hunger
3e0534afea Janitor: Fix clippy::needless_lifetimes 2021-07-23 13:48:52 +02:00
Tobias Hunger
9e224f579c Janitor: Fix clippy::comparison_to_empty 2021-07-23 13:48:52 +02:00
Simon Hausmann
4f13238ff5 Fix preview on rectangles with opacity or drop shadow
Instead of producing an error, produce just a warning that the effect won't
be visible on root elements.
2021-07-23 11:41:28 +02:00
Olivier Goffart
2447de3d1b We should only set the height of the element in a repeater for the children of ListView 2021-07-22 18:18:58 +02:00
Olivier Goffart
6aa6dec9b4 Small simplification on the usages of ListView
Now that the height computation is done properly
2021-07-22 17:29:53 +02:00
Olivier Goffart
ff8f7930d2 ListView: fix default height of items 2021-07-22 17:13:36 +02:00
Olivier Goffart
8743ff87ed Consider that elements in a listview are part of a layout 2021-07-22 14:38:58 +02:00
Olivier Goffart
19ad14b6f2 C++: Fix assigning a @linear-gradient to a color property 2021-07-22 14:38:58 +02:00
Olivier Goffart
c2433d0f0b Fix panic when parsing linear-gradient with a trailing coma 2021-07-22 14:38:58 +02:00
Olivier Goffart
f7923bfb77 Fix an error ending by a period
Reword the error because we might not even have an identifier
2021-07-22 14:38:58 +02:00
Simon Hausmann
d6eb45b4f8 Regression: Fix missing window background
After commit 492af0f67c the native class
name of "Window" changed to "WindowItem", so the string based check here
didn't match anymore. For consistency this match now uses the element
name instead, like in other places in the compiler.
2021-07-22 13:02:04 +02:00
Simon Hausmann
3146fb7764 internal cleanup: Remove the sixtyfps::testing::HasWindow trait
and replace it with the internal, re-exported WindowHandleAccess
one.

Strictly speaking, this is a breaking change. In practice the
returned type of this trait was in `sixtyfps::re_exports`, so any
public use is questionable :)
2021-07-21 20:33:02 +02:00
Simon Hausmann
eaddbe664e internal cleanup: Rename ComponentWindow to WindowRc
That's all it is nowadays, it's a wrapper around Rc<Window>. It's not an
alias because we need to also "wrap" it to C++ via cbindgen, but that's
about it.
2021-07-21 20:33:02 +02:00
Tobias Hunger
aeebbb1d96 Janitor: Fix remaining clippy::option_map_unit_fn 2021-07-21 19:44:57 +02:00
Simon Hausmann
ef184f7f1a internal cleanup: Remove the rest of the ComponentWindow API
Now it just remains a wrapper around the Rc, and it can soon be moved to
the API crate hopefully.
2021-07-21 17:41:12 +02:00
Simon Hausmann
77ea5b7a15 API cleanup: hide the rest of the ComponentWindow "internals" 2021-07-21 17:41:12 +02:00
Simon Hausmann
4c1d9dc03e internal cleanup: Remove the poup functions from ComponentWindow
Use WindowHandleAccess instead. Also the clone()
isn't needed anymore since the function take a self reference instead of an Rc<Self> by value.
2021-07-21 17:41:12 +02:00
Simon Hausmann
e005058285 internal cleanup: remove free_graphics_resource from the public ComponentWindow API
Use the WindowHandleAccess backdoor instead.
2021-07-21 17:41:12 +02:00
Simon Hausmann
492af0f67c Rename the implementation of the Window item to WindowItem
If we were to add `sixtyfps:🪟:Window` to the re_exports, then
this clashes. We might rename the former, but this is a cleaner naming
in any case.

Relates to #333
2021-07-20 17:50:17 +02:00
Olivier Goffart
1360f1e26e Added icon property to the Window element 2021-07-20 16:34:19 +02:00
Olivier Goffart
f5de7e00a0 Make sure error messages don't end with '.'
As suggested in https://github.com/sixtyfpsui/sixtyfps/pull/275#issuecomment-881240725
2021-07-16 12:39:50 +02:00
Olivier Goffart
e633ee825d Fix error with struct that are only referenced by callbacks
We would have a compilation error in rust or C++ because the
collect_struct visitor would not visit these type and not produce
them correctly
2021-07-15 14:06:49 +02:00
Simon Hausmann
3aa959700c Revert "Attempt to fix a stack overflow in debug"
This reverts commit 51836a9457.

This is not needed anymore since PR #322
2021-07-15 12:20:01 +02:00
Simon Hausmann
42110263f6 Simplify field offset access workaround
As suggested by Olivier, we don't need the temporary variable. A ref followed
by immediate deref works just as well.
2021-07-15 12:19:20 +02:00
Simon Hausmann
aaf162d504 rust codegen: clarify comment about stack usage by referencing github issue 2021-07-15 12:19:20 +02:00
Simon Hausmann
30dbcdcaad rust generator: simplify field access code
There's no need for a separate access_self_field_offset function when
we can use format_ident directly.
2021-07-15 12:19:20 +02:00
Simon Hausmann
f7248a4863 Fix stack overflow with Rust generated code in debug builds on Windows
On Windows the default stack size is less than on Linux/macOS and
therefore an issues surfaces that is however operating system agnostic:

Due to inlining we generate quite big inner components with many fields.
Their field offsets are accumulated in the separate FIELD_OFFSETS
struct. The access pattern typically looks like this:

    Self::FIELD_OFFSETS.some_field.apply_pin(...)

This is destructed into at least two smaller operations, fetching
some_field and then calling apply_pin with that field as self parameter.

In Rust debug builds the first operation, unfortunately, ends up making
a full copy of Self::FIELD_OFFSETS into a temporary variable on the
stack. Unfortunately also that stack space isn't reused, so every access
results in a new stack allocation to hold all of the FIELD_OFFSETS
structure (~5kb in the printer demo).

With so many accesses to that in the generated code, we run out of stack
space already in the new() function, in item_tree() as well as in the
Drop impl that also accesses all field offsets.

This patch applies the following workaround that does the trick. The
above expression is replaced with

    {
        let field = &Self::FIELD_OFFSETS.some_field;
        *field
    }.apply_pin(...)

Fixes #133
2021-07-15 12:19:20 +02:00
Tobias Hunger
ca53abdbc7 Janitor: calls to push immediately after creation
This is clippy::vec_init_then_push.
2021-07-15 07:55:06 +02:00