Commit graph

1514 commits

Author SHA1 Message Date
Simon Hausmann
78771e0e37 Fix panic when loading unsupported images in Rust
The call to load the image already prints a message to stderr, so don't
panic but return a null image instead - neither when calling load_from_path
nor when decoding embedded image data.

cc #4846
2024-03-14 23:04:43 +01:00
Tobias Hunger
28b96ca6f6 janitor: manual cargo clippy fixes
Semi-random selection of clippy topics that were
uncontroversial before:-).

Leaves about 84 deduplicated issues in the code base
according to clippy from nightly.
2024-03-14 13:42:38 +01:00
Olivier Goffart
b844f76842 Add test and fixup color red/green/blue fields 2024-03-12 11:36:30 +01:00
Luke D. Jones
8c60cc74be feat: color: add channel properties to color
Add extra properties to the `color` type.
- `red`
- `green`
- `blue`
- `alpha`
2024-03-12 09:42:30 +01:00
Olivier Goffart
c3a2ad1c45 fmt: format two way bindings 2024-03-11 10:39:55 +01:00
Olivier Goffart
255dc59ef4 Rename @image-url(..., 9slice(...)) to @image-url(..., nine-slice(...))
As per API review:
 - In the Rust and C++ API we use `set_nine_slice_edges` because the getter couldn't start with 9
 - in english we spell number less than 10 with letters and this is a name
2024-03-07 17:01:57 +01:00
Wilston Oreo
bef532b5fc
Optional C++ namespaces (#4759)
Co-authored-by: Michael Winkelmann <michael@winkelmann.site>
2024-03-06 19:43:11 +01:00
Tobias Hunger
2e035fd0d1 compiler: Document function added in d0fc025bc8
... and remove code needlessly added in that commit,
too.
2024-03-06 14:25:21 +01:00
Tobias Hunger
d0fc025bc8 live preview: Do not drop on elements that can not have children
Slpit up `lookup_type_for_child_elemnt` (in the compiler) into the
part that looks at the element itself only (called `accepts_child_element`)
and the part that looks at the child.

When deciding whether we can drop something into another element in
the live preview, we know the child type is going to be OK, even when
the `TypeRegister` does not contain it yet (as it is not imported yet).
2024-03-06 12:15:10 +01:00
Florian Blasius
82d784a4d4
Cupertino: added pressed state to tab, fix animation (#4751) 2024-03-05 14:40:18 +01:00
Olivier Goffart
5fe68e1746 Fix animation when started from a different item tree
Fixes #4741

This commit move the property_binding_and_analysis from the inlining
pass to an associated funciton in the context.
Then re-use that from the rust and c++ generator to actually get the
right animation
2024-03-05 12:27:11 +01:00
Florian Blasius
22095ccf03
Cupertino TabWidget: Tweaked visual appearance (#4743) 2024-03-04 09:11:45 +01:00
Tobias Hunger
f62d5e0d4b Update internal/compiler/lib.rs
Co-authored-by: Simon Hausmann <hausmann@gmail.com>
2024-03-01 12:59:08 +01:00
Tobias Hunger
121cda19fd interpreter: Make sure the root document is in the TypeLoader
Refactor the code in the compiler a bit to allow using the
`TypeLoader` for the root document itself and use that in the
interpreter.

You need to run passes *before* the `TypeLoader` takes ownership
of the Document, so the `load_file` in `TypeLoader` needed a bit of
changing.
2024-03-01 12:59:08 +01:00
Tobias Hunger
06b04e71b5 compiler: Return the TypeLoader from compile_syntax_node 2024-02-29 19:35:52 +01:00
Olivier Goffart
100123901a Rust: move the call to ItemTreeVTable_static at mod level
... instead of having it in the drop implementation.
This is required to fix the `non_local_definitions` warning in nightly rust.

Part of #4706
2024-02-28 11:19:26 +01:00
Olivier Goffart
c71b58e556 Fix rust nightly warnings about unused import in tests 2024-02-28 11:19:26 +01:00
Tobias Hunger
48de2f83e4 compiler: Add layout debug info to all nodes when lowering layouts
This enables us to find all layouts e.g. in

```slint
component MyLayout inherits GridLayout { @children }

component FooBar {
   my-layout := MyLayout {
      Rectangle {
      }
   }
}
```
2024-02-26 22:19:29 +01:00
Paul Zinselmeyer
73e05aebdb Added flicked-Callback on Flickable
As requested in #1462, I've added a `flicked`-Callback that gets
triggered when the `viewport_x`- or `viewport_y` -Properties are changed
by a mouse drag or mouse wheel movement.
2024-02-26 12:17:31 +01:00
Olivier Goffart
11e8070726 Compiler: fix lookup of the model not seeing that the element is being repeated
The problem is that we were taking the whole `repeated` field and as a
result we wouldn't see that the element was being repeated and that we
shouldn't have to lookup id within it

Fix #4683
2024-02-26 12:16:51 +01:00
Olivier Goffart
5e7ddf3a19 Image Tiling
(Doesn't work yet with 9slice)
2024-02-26 12:16:41 +01:00
Olivier Goffart
190273d293 C++: fix enum with dashes 2024-02-22 10:41:45 +01:00
Olivier Goffart
b5abee6c8d C++: fix compilation when class name has an underscore
Fixes: #4659
2024-02-22 10:41:45 +01:00
Olivier Goffart
2ab71db4f7 Update deps, including resvg 2024-02-21 12:30:33 +01:00
Olivier Goffart
fac0921579 Compiler: keep the layout debugging info next to its node 2024-02-21 11:33:37 +01:00
ogoffart
a0eed4e58e Bump version number to 1.5.0 2024-02-20 17:33:11 +00:00
Tobias Hunger
a8f912900b janitor: Fix warnings in nightly about redandant use 2024-02-19 17:05:21 +01:00
Olivier Goffart
dab4ea44cd Fix C++ compilation with nightly rust
```
error: casting references to a bigger memory layout than the backing allocation is undefined behavior, even if the reference is unused
    --> internal/core/item_tree.rs:1035:32
     |
1035 |             Pin::new_unchecked(&*(&**component as *const Dyn as *const u8)),
     |                                ^^^^-----------^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     |                                    |
     |                                    backing allocation comes from here
     |
     = note: casting from `vtable::Dyn` (0 bytes) to `u8` (1 bytes)
     = note: `#[deny(invalid_reference_casting)]` on by default
```
2024-02-14 10:15:07 +01:00
Olivier Goffart
97067c3d65 Add 9slice information at runtime 2024-02-13 14:46:27 +01:00
Olivier Goffart
22d9fc9cf9 @image-url: Semantic analysis of the 9slice 2024-02-13 14:46:27 +01:00
Olivier Goffart
6e2280ece3 Parse 9slice in @image-url 2024-02-13 14:46:27 +01:00
Olivier Goffart
ce6c7f5527 Image: add horizontal and vertical alignment 2024-02-08 18:59:26 +01:00
Florian Blasius
9d3f2ed08e
Fixed edited callback for SpinBox material and cupertino style (#4578) 2024-02-08 07:52:57 +01:00
J-P Nurmi
cc5d2b24e5 Add BasicBorderRectangle to avoid unnecessary xxx-border-radius bindings 2024-02-06 18:01:35 +01:00
J-P Nurmi
031742246c Implement clipping 2024-02-06 18:01:35 +01:00
J-P Nurmi
51457025bf Add BorderRectangle::border_top|bottom_left|right_radius 2024-02-06 18:01:35 +01:00
Olivier Goffart
da9fb9fa1b Fix warning in Rust 1.77 with unused exported globals 2024-02-05 12:50:44 +01:00
Olivier Goffart
a464877934 Janitor: update strum dependency 2024-02-01 17:12:33 +01:00
ogoffart
fec2b961db Bump version number to 1.4.1 2024-02-01 09:12:42 +00:00
Florian Blasius
3fec65822c Fixed cosmic SpinBox buttons doing the opposite operation 2024-01-30 15:00:37 +01:00
Simon Hausmann
54d8b9adb3 Add missing debug assertion
As suggested in #4477, amends 7ce0bd493a
2024-01-30 13:44:16 +01:00
Simon Hausmann
7ce0bd493a Fix panic when using foward-focus with non-element binding
Since commit 6fefe75a1c the handling
of forward-focus bindings happens before the resolve_expressions pass,
which means that we cannot rely on type mismatch
error handling yet.

Fixes #4475
2024-01-30 10:09:07 +01:00
Simon Hausmann
72802a4106
Don't require inlining if an animated property is private and local (#4449)
* Don't require inlining if an animated property is private and local

This avoids inlining Button elements from our widget set.

This is covered by tests/cases/properties/animation_merging.slint
2024-01-26 14:51:58 +01:00
Tobias Hunger
91e4a1bfa7 compiler: Do not duplicate nodes when inserting a Window
Do not duplicate the root element's node(s) when the compiler adds a
Window element above the root element.
2024-01-26 13:19:48 +01:00
Simon Hausmann
6fefe75a1c Don't require components that use forward-focus to be inlined
Achieve this by generating a `focus()` function for such components
and call it from the outside.

This replaces the previous focus handling with what should be cleaner:

- Any `forward-focus: some-element;` is basically syntactic sugar for
 `public function focus() { some-element.focus(); }`.
- The init code gets simplified to calling focus() on the root, if it's
  available.

Since the `focus()` functions are now generated in the imports pass,
they become visible in the style checker. That means the checker
requires consistent focus handling between the styles.
2024-01-26 12:16:09 +01:00
Olivier Goffart
09dc25f107 Keep all nodes for a given element (even if it is optimized out) 2024-01-25 14:45:22 +01:00
Olivier Goffart
ffaf19812c Refactoring: use Element::to_source_location instead of the node directly 2024-01-25 14:45:22 +01:00
Olivier Goffart
7d255a1a18 Fix (native) preview not taking account change in other files than the main file
Because it wouldn't take the files from the cache
2024-01-25 14:44:30 +01:00
Olivier Goffart
1e19e0a754 Rust codegen: fix compile if slint names matches internal names
Fixes #4419
2024-01-24 22:47:58 +01:00
1plus
367b5c5a76
Make the parentheses optional in if else statement (#4417)
* remove expect of parents in if else

* fix parser for parentless if

* add test for non-parentheses if
2024-01-24 20:07:33 +01:00