Commit graph

1484 commits

Author SHA1 Message Date
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
Olivier Goffart
2564eede9f Compiler: avoid two error message when trying to call a non-existing function 2024-01-24 20:06:48 +01:00
Florian Blasius
866300c34b
Improved Slider drag and click behaviour (#4406) 2024-01-24 13:12:36 +01:00
Olivier Goffart
a19a2cfc8d Material style: make the ScrollView pan with the mouse
Other style are more desktop oriented, but this is important on android
to pan with the finger
2024-01-23 17:44:16 +01:00
Simon Hausmann
ec1b991c53 Fix calling builtin member functions on the root item when a window item is injected
The element references, just like the named references, need to be fixed up.
2024-01-23 11:04:13 +01:00
Simon Hausmann
0e53b1529c Fix compilation of Rust generated code when calling builtin item member function through child component 2024-01-23 09:56:38 +01:00
Olivier Goffart
c7aae4b77e Update resvg and related dependencies 2024-01-22 16:16:35 +01:00
Florian Blasius
2871fadd5c
Added SliderBase and use it in non qt styles. (#4384) 2024-01-19 13:14:17 +01:00
Florian Blasius
c8f58be7c9
Reject events on disabled ComboBox (#4359) 2024-01-17 15:41:32 +01:00
Tobias Hunger
6224d0afb5 compiler: Fix repeater_offset calculation
Only set the repeater_offset after the needed input data is in place.
2024-01-17 15:21:14 +01:00
Tobias Hunger
382b5486ca
Component container subcomponent (#4355)
This changes the component containers away from using a "MAGIC" index in the
placeholder dynamic item tree node it creates. These are hard to
integrate across sub-components.

Use index numbers right after the index numbers used by repeaters and
"extend" the repeater offset by the number of component containers in
the sub-component. This way we can piggy-back on the forwarding of
repeaters.

This has one annoying side-effect: We do have indices in our item tree
that are out of range for a repeater. But I think that is acceptable
considering that we never materialize that array anyway.
2024-01-17 11:26:08 +01:00
Florian Blasius
0a2147c6a8 Revert "Disable keyboard input on disabled ComboBox"
This reverts commit 33578d8898.
2024-01-16 15:21:55 +01:00
Florian Blasius
33578d8898 Disable keyboard input on disabled ComboBox 2024-01-16 15:18:07 +01:00
Florian Blasius
2cf2a36b1d Fix style issues on the cosmic style 2024-01-16 15:16:04 +01:00
Florian Blasius
1ca8ff517e
Added cosmic style for std-widgets. (#4350) 2024-01-16 13:21:17 +01:00
Tobias Hunger
77a97ed6b5 compiler: Export to_url from pathutils
The LSP will need this to unify code paths between WASM and binary
builds.
2024-01-15 14:46:39 +01:00
Simon Hausmann
fef9c446a4
Fix missing invocation of init callbacks due to inlining (#4322)
When a component declares an init callback as well as the element that
instantiates it, the init callback of the container would not
get invoked if the container was inlined:

```
component InlinedContainer {
    init => { ... } // not invoked
    @children // force inlining
}

component UseSite {
    InlinedContainer {
        init => { ... }
    }
}
```

That's because the inlining happens very early, before the init
callbacks are collected into the init code. And during inlining that
would be treated like a property binding and the "binding" at the
element site overrides the one at the component site.

One natural approach would be to move the init code collection to an
earlier place before inlining, but that isn't possible because the
boundaries of the compiler components (Rc<Component>) aren't set
up yet (repeated component extraction phase happens much later).

An alternative would be to re-introduce the init callback code in
ElementRc and place it in there at *::from_node() time.

This patch chooses to solve this at the inlining time: When we're in the
first phase of the inlining (the optional one), do what
with the init binding what collect_init_code would do later: Move it
straight into the init_code of the component we're inlining into.

Fixes #4317
2024-01-12 10:14:27 +01:00
Olivier Goffart
638985612c Test purity of model expression 2024-01-11 15:13:01 +01:00
Brandon Fowler
3e8940660b
Add set-selection-offsets function to TextInput, TextEdit, and LineEdit (#4197)
The function accepts two arguments that specify the start and the end of the text to select.

Fixes #4164
2024-01-06 11:12:53 +01:00
Olivier Goffart
96324a8300 Fix property wrongly considered as const if it is modified through an alias
Fixes #4241
2024-01-02 17:36:22 +01:00
Simon Hausmann
5f69857926
Fix missing font fallback handling on Windows when pre-rendering glyphs for the software renderer (#4245)
Add some symbol/emoji fonts for Windows, next to the existing options for macOS and Linux.
2024-01-02 13:37:08 +01:00
Olivier Goffart
6ca9a9b884 SpinBox: enabled by default 2024-01-02 12:11:41 +01:00
Simon Hausmann
617d0921ca Fix Switch element in Cupertino & Fluent style not showing text when font size is large
Take the minimum height of the layout into account, like in the material style implementation.

Fixes #4201
2024-01-02 10:07:03 +01:00
Olivier Goffart
01e6429bfa Janitor: fix warning about unused import in Rust 1.75
Prospective fix for the CI breaking with Rust 1.75
2023-12-29 14:40:02 +01:00
Olivier Goffart
5aa6b424e3 Janitor: Optimize usage of is_dir/is_file
As suggested in https://github.com/slint-ui/slint/issues/4219

Closes #4219
2023-12-27 10:36:25 +01:00
Carter Hunt Fogelman
ff27bc79ae Wrap all non-test uses of in a BufWriter/BufReader for efficiency 2023-12-27 09:15:53 +01:00
Tobias Hunger
ca1263c3e5 lsp: Handle selections and highlighting in the LSP
Ask the interpreter for all the necessary information, but handle the
look and feel in the LSP preview UI.
2023-12-20 19:28:35 +01:00
Tobias Hunger
9142336d5c interpreter: Add highlighting feature-gated functions
The preview can not leave it up to the interpreter to handle element selection
and highlighting. So add new functions to the interpreter (behind the
"highlight" feature-gate) to query positions of elements.

This exposes some of the code that is used by the existing highlighting code
and extends it where needed.

Two use-cases need to be covered:

1. Query the positions of a component (given by source file path and offset).
   This is then used to highlight all occurences of a component as the
   cursor position in a source file changes.

2. Query the position of an element (given as `ElementRc`).
   This is used when selecting elements in the UI. We need to work at
   the element level for this, not at the component level.

Also make the `highlight` module public but feature-gated, so that we
can put helper-types there.
2023-12-20 19:28:35 +01:00
Olivier Goffart
2ce161ced8 Parser: Hint for the mod function when parsing %
Was reported several times:
 - https://github.com/slint-ui/slint/discussions/4190
 - https://github.com/slint-ui/slint/issues/3980
2023-12-19 17:23:30 +01:00
Tobias Hunger
2404cce0bc janitor: Fix typos 2023-12-19 17:04:33 +01:00
Olivier Goffart
85526d772e Fix detection of properties when they are only used in two way bindings
Fixes #2166
2023-12-19 11:14:53 +01:00