Commit graph

1647 commits

Author SHA1 Message Date
Olivier Goffart
07ea17fe71 LLR: Fix the repeater indices 2022-01-12 16:22:35 +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
d1298a9353 collect the globals once more at the end
Fix warning in the rust generated code about unused global.
After constant propagation, some uses of the global disapear, so we should
re-check which globals are really used
2022-01-12 16:22:35 +01:00
Olivier Goffart
a11714fefb LLR: More work
Fix animations and public fields and callbacks
2022-01-12 16:22:35 +01:00
Olivier Goffart
2d31ec2438 LLR: fix lookup into builtin global 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
24b01057d0 Add the orientation in llr::Expression::BoxLayoutCellDataArray 2022-01-12 16:22:35 +01:00
Olivier Goffart
c397c4cae2 Debug: print the LLR 2022-01-12 16:22:35 +01:00
Olivier Goffart
d395e92f3f More work on LLR
generate the actual tree and support a bunch more of expressions
2022-01-12 16:22:35 +01:00
Olivier Goffart
53c3e6a279 WIP: introduce the new llr module (Low Level Representation)
The main thing here is that the Component are in different data structure
depending on whether they are sub-component global component or repeated component

Then the properties at are the right place and there will be no more lookup
in the base. The PropertyReference knows how to access which property via which
element and such.

The idea is that it will be easier to lower from this representation than
what we currently do in each language backend.

This commit is still WIP, it is far from finished
2022-01-12 16:22:35 +01:00
Olivier Goffart
6699067351 TabWidget: focus the tab when clicking on it
The Tab currently doesn't do anything with the focus, but this
serves as a workaround for #798 so that inner widget of a tab can't
keep the focus when they are hidden

cc #798
2022-01-12 14:54:04 +01:00
Tobias Hunger
e6f9718faa Implement delay property on PropertyAnimation
Implement a property `delay` on animations that will wait for the
duration provided before the actual animation is triggered.
2022-01-11 20:58:26 +01:00
Tobias Hunger
4c331f1ac2
janitor: More clippy fixes
None of these should be controversial: It is all similar to quick fixes
I pushed before.
2022-01-09 14:50:58 +01:00
Tobias Hunger
2d2c560220 janitor: Remove unnecessary return statements
Some of these actually seem to make some stylistc sense
2022-01-09 13:46:33 +01:00
Tobias Hunger
ac8f7b4957 janitor: Sprinkle #[must_use] over the codebase 2022-01-09 13:46:33 +01:00
Tobias Hunger
79e2456ead Allow for bigger indices in VisitChildrenResult
The indexes stored in `VisitChildrenResult` are unsigned. We have 64
bits to store two values and we need to have one special value as a flag.

So accept any index `< u32::MAX` instead of `< i32::MAX`, which should
allow for more data to be visited;-)
2022-01-08 20:55:22 +01:00
Olivier Goffart
7d1266e4e4 Allow to animate angles 2022-01-08 14:35:52 +01:00
Be
ab7403e57e allow FnMut as argument for on_callback 2022-01-08 03:09:28 +01:00
Olivier Goffart
6dae67e374 Add some comments 2022-01-07 17:14:07 +01:00
Jared Moulton
c5c139fbc9
Feat: Add math funcs Log10, Log2, Log and Exp (#813)
Implement Math.log and Math.pow
2022-01-07 12:07:58 +01:00
Simon Hausmann
89df782463 Don't panic in the compiler when encountering a Path element with for-in
Instead, produce a diagnostic message.

cc #754
2022-01-06 12:53:46 +01:00
Tobias Hunger
11d46892e4
janitor: Remove some unnecessary lazy evaluation 2022-01-04 18:22:49 +01:00
Tobias Hunger
3e448f75eb
janitor: Remove some unnecessary references
These are immediently dereferenced by the compiler according to clippy.

Remove some now unnecessary muts to make things build again.
2022-01-04 18:22:15 +01:00
Tobias Hunger
767704a88b
janitor: Remove some redundant closures 2022-01-04 18:21:07 +01:00
Tobias Hunger
c89fa46b2c
janitor: Remove some redundent clone() calls 2022-01-04 18:20:24 +01:00
Tobias Hunger
cde907fb41
Merge pull request #796 from hunger/pr/generated_code
janitor: Canonicalize a x.filter(f).next().is_none() sequence
2022-01-04 11:45:48 +01:00
Tobias Hunger
d54e2a642a
Janitor: Change push_str of a one-char str to push 2022-01-04 09:39:41 +01:00
Tobias Hunger
423cc4748b
janitor: Canonicalize a x.filter(f).next().is_none() sequence
Replace with !x.any(f) (as suggested by clippy).
2022-01-03 21:39:53 +01:00
Tobias Hunger
75e97a43fa
janitor: Fix clippy::to_string_in_format_args warning
Do not use to_string() when formating something that has the `Display`
trait.
2022-01-03 21:35:21 +01:00
Olivier Goffart
c69c583ad2 Fix wrong count of sub components in the item tree
Fixes #781
2022-01-03 14:40:36 +01:00
Tobias Hunger
e3eebfaa4a
janitor: Fix clippy error about duplicated branches in if 2022-01-03 14:37:49 +01:00
Olivier Goffart
34cc89ced6 Fix fluent Slider when the minimum value is set
Fixes #787
2022-01-03 14:32:33 +01:00
Olivier Goffart
0b5648c2f8 Fix default_geometry and visibility combination
Regression since 684a8c29a2

(This fixes the issue 107 on the cw. gitlab)
2021-12-28 18:05:02 +01:00
Olivier Goffart
44cfd452a6 The NativeTab::pressed can be changed from the native code
Mark it as such Otherwise the const propagation will see this property
as constant and this will panic at runtime

Fixes #775
2021-12-28 11:52:13 +01:00
Olivier Goffart
ec26714cc0 Process the states before inlining
So that inlining don't merge the states

Since we need to apply default property before the states, we also needed
to move that.
But ensure_window can't be moved before the focus stuff that can't be move
before inlining, so set the default property of the Window in the ensure_window
pass

Fixes #752
2021-12-27 10:50:50 +01:00
Tobias Hunger
597467fae9 Manually update license information in Cargo.toml files
... that are not published or private or not processed by xtask for
other reasons.
2021-12-22 10:06:12 +01:00
Tobias Hunger
bfca0e3573 Mass update copyright messages to be more REUSE compliant 2021-12-22 10:06:12 +01:00
Frederick Vollbrecht
12c0ef38fb
Typos: repeating words in documentation, across the repository (#753)
* fixed typo in image.rs

* unnecessary repeated words in sixtyfps_runtime

* unnecessary repeated words in sixtyfps_compiler

* unnecessary repeated word in docs

* unnecessary repeated words in helper_crates
2021-12-19 17:40:45 +01:00
Simon Hausmann
ffd651d04c Fix rendering of opacity when used on repeated elements
Opacity, visible and shadows on repeated elements work by replacing the
root element with a new element (opacity, visible clip, etc.) and making
the old one a child.

A tree like this

```
l := VerticalLayout {
    for i in 1: Rectangle {
        background: green;
        opacity: 0.2;
    }
}
```

is lowered like so (pseudo):

```
l := VerticalLayout {
    for i in 1: Opacity {
        opacity <=> r.opacity;
        r := Rectangle {
            background: green;
            opacity: 0.2;
            y: layout_cache[i].y;
            width: l.width;
            height: layout_cache[i].height;
        }
    }
}
```

and when rendering, it's important that the opacity of the Opacity
element is applied on the item renderer before rendering the Rectangle
r.

The Opacity element has no width/height because the default geometry
pass won't apply that to children of a layout.

Without a geometry, the item rendere will not call render() (no
intersection with the current clip), and thus the opacity is not
applied.

The shadow lowering pass handles this correctly, by moving the geometry
property bindings to the new root and letting the default geometry pass
apply 100% defaults (in the above "r" is not a layout child).

This patch moves this logic into the common
inject_element_as_repeated_element, so that we end up with a lowering
like this (after the default geometry pass):

```
l := VerticalLayout {
    for i in 1: op := Opacity {
        opacity <=> r.opacity;
        width: l.width;
        height: layout_cache[i].height;
        y: layout_cache[i].y;
        r := Rectangle {
            background: green;
            opacity: 0.2;
            width: op.width;
            height: op.height;
        }
    }
}
```
2021-12-14 14:32:46 +01:00
Simon Hausmann
684a8c29a2 Fix opacity property not affecting the shadow color
The opacity on a rectangle should be applied before the shadow, so that it has
a visible effect.

This is a partial fix for #714 but needs also #725 to be entirely visually correct.
2021-12-14 14:32:46 +01:00
Simon Hausmann
e0a942dc1c Avoid the use of symlinks for source files
On Windows 10, the creation of symlinks by normal users requires
enabling the developer mode, which may or may not be acceptable in
corporate environments with restricted IT setups.

We introduced the symlinks for the shared special key codes mapping,
which instead this patch places into a shared sixtyfps-common crate.
2021-12-13 15:51:10 +01:00
Olivier Goffart
b8cc59afca Fix panic when compiling a property that references itself
Fixes #737
2021-12-13 15:00:19 +01:00
Olivier Goffart
afde21fdeb Handle the Up and Down arrow keys in the StandardListView
This change the current item, but doesn't scroll the view yet to
make sure it is visible.  We are missing the ability to know the
position of the visible item to be able to do that
2021-12-10 11:28:09 +01:00
Olivier Goffart
f7c92183db Add a Keys namespace in the .60 language with all the string constant for special keys 2021-12-10 11:28:09 +01:00
Olivier Goffart
733d4ed365 Handle more non printable key
Share the code that defines the key with a macro over all the backends using
a symlink.

This is a symlink rather than exposing the macro directly since we add this
module in every backend, and each backend re-declares the macro to handle
the part that it needs. This needs to be a symlink because it will also be shared
with the compiler that does not depends on sixtyfps-corelib
2021-12-10 11:28:09 +01:00
Olivier Goffart
963c44fd78 Put the global functions also in the Math namespace
So they can be accessible even if there is a property of the same name
2021-12-08 16:35:11 +01:00
Olivier Goffart
0436ce2399 Allow to access color names form the Colors namespace 2021-12-08 16:35:11 +01:00
Olivier Goffart
639c358896 Refactor the LookupResult
Separate Enumeration and Expression, so get rid of the isize::MAX hack
And this will allow having more non-expression results (eg: namespaces)
2021-12-08 16:35:11 +01:00
Lukas Jung
25dc48ae27 remove move cursor from MouseCursor 2021-12-07 22:41:24 +01:00
Lukas Jung
588a7b0c5c Format mouse-cursor changes with rustfmt 2021-12-07 22:41:24 +01:00