Commit graph

814 commits

Author SHA1 Message Date
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
Tobias Hunger
d785f2d5df compiler: Store an optional version number with the document
A None value means the file on disk is the golden version.

We have an editor, the LSP and the preview that all need to at least
notice when they have newer data then their peers. So IMHO it makes
sense to have an optional document version around.

The language server protocol makes use of a version number already. This
patch moves that code into the compiler so that it is stored with the
actual data getting versioned.
2023-12-18 14:21:50 +01:00
Olivier Goffart
4484fe647b Fix wrongly optimized properties with aliases
If we don't see that a native property is modified, it could get inlined
and we wouldn't detect changes

Fix #4072
2023-12-18 12:22:20 +01:00
Florian Blasius
e587c09d9c
Added colorize-icon to Button (#4152)
Co-authored-by: Simon Hausmann <simon.hausmann@slint.dev>
2023-12-14 12:07:55 +01:00
Olivier Goffart
5d4c390b0f
Compiler: Error when assigning to compile time properties
Some property need to be known at compile time. We already had checks
that the binding is a compile time constant, but there was no check to
prevent, say

    self.row = 42;

which wouldn't work or could even cause panic or miscompilation of
generated code

Closes #4037
2023-12-12 21:51:56 +01:00
Olivier Goffart
6ebfad14db Fix panic in the interpreter when using visible in a ListView
This doesn't solve the issue #2537, but at least prevent the panic

Drive by change to fix compile when a struct is named `Box`
2023-12-12 14:01:55 +01:00
Florian Blasius
6da8120dfa
added palette global (#3984)
* Update docs/reference/src/language/builtins/globals.md

Co-authored-by: Simon Hausmann <simon.hausmann@slint.dev>

* Update docs/reference/src/language/builtins/globals.md

Co-authored-by: Simon Hausmann <simon.hausmann@slint.dev>

* Update docs/reference/src/language/builtins/globals.md

Co-authored-by: Simon Hausmann <simon.hausmann@slint.dev>

* Update docs/reference/src/language/builtins/globals.md

Co-authored-by: Simon Hausmann <simon.hausmann@slint.dev>

* Update docs/reference/src/language/builtins/globals.md

Co-authored-by: Simon Hausmann <simon.hausmann@slint.dev>


---------

Co-authored-by: Florian Blasius <florian.blasius@slint-ui.com>
Co-authored-by: Simon Hausmann <simon.hausmann@slint.dev>
Co-authored-by: Florian Blasius <flovansl@fedora.fritz.box>
2023-12-11 14:44:05 +00:00
ogoffart
b081c489d6 Bump version number to 1.4.0 2023-12-11 11:21:37 +00:00
Olivier Goffart
63d199a728 Rust&C++: Fix Return value of complex expression
We were using the has_value of the previous expression of a sequence of
expression, instead of using the last expression type to know if there
is a value.

Fixes #4070
2023-12-08 17:28:38 +01:00
Tobias Hunger
2bdcbc8e9f
core: Add a double-click callback to the TouchArea (#4060)
Co-authored-by: Simon Hausmann <hausmann@gmail.com>
Co-authored-by: Olivier Goffart <olivier.goffart@slint.dev>
2023-12-08 12:12:41 +01:00
Florian Blasius
6d6b18300a
added focus state to StandardLIstView (#4086)
* added focus state to StandardLIstView

* (wip) focus handling for qt style

* Update CHANGELOG.md

Co-authored-by: Thorbjørn Lindeijer <bjorn@lindeijer.nl>

* Share StandardListView between all styles

* Update internal/compiler/widgets/material-base/combobox.slint

Co-authored-by: Thorbjørn Lindeijer <bjorn@lindeijer.nl>

* code review feedback

---------

Co-authored-by: Thorbjørn Lindeijer <bjorn@lindeijer.nl>
2023-12-08 10:58:58 +01:00
Florian Blasius
c53a70db8d
fixed cupertino spinbox, move more code to base (#4083) 2023-12-07 14:53:31 +01:00
Florian Blasius
5d34c8307b
combobox fix mouse wheel selection direction (#4091) 2023-12-07 14:53:02 +01:00
Olivier Goffart
44ec841609 Fix lookup relative to the manifest path in .rs file
For the slint! macro, we need to lookup files in the manifest path.
The base_directory function regressed in commit 0ff8e2c.
This was not cought by the test because it had falled back to the `pwd`
with a warning, as we used to load ressources relative to `pwd` as a
fallback.
So also check that there are no warning (meaning updating the rest of
the test so that there isn't any warnings)

Fix #4045
2023-12-02 13:11:59 +01:00
ogoffart
b9255ab8e2 Bump version number to 1.3.2 2023-12-01 08:05:15 +00:00
Olivier Goffart
41f7275c35 Fluent: fix disabled LineEdit
The `color` is the Rectangle's deprecated alias to background. I wonder why we don't get a warning though.
It was meant to change the text-color
2023-12-01 07:25:00 +01:00
今何求
607bdbfcf8
Upgrade to fontdue 0.8
Co-authored-by: Simon Hausmann <simon.hausmann@slint.dev>
2023-11-29 10:52:27 +01:00
Florian Blasius
e55bde4c97
fix lineedit callbacks (#4028) 2023-11-29 06:13:23 +01:00
Tobias Hunger
2ad9e07225 component_container: Add has-component property
... that returns a bool when a component is set up in the
ComponentContainer.
2023-11-28 10:38:46 +01:00
Florian Blasius
6963aefb7b make fluent scrollbar bigger 2023-11-27 22:21:52 +01:00
Olivier Goffart
017448893a
Fix LineEdit with right alignment (#4016)
* Fix LineEdit with right alignement

 - Align the placeholder the same way
 - Make sure the cursor is visible to the right (it is drawn outside of
   the TextInput, so some size need to be accounted for

(Discussed in https://github.com/slint-ui/slint/discussions/3996 )
2023-11-27 18:52:54 +01:00