Commit graph

1488 commits

Author SHA1 Message Date
Arnold Loubriat
53fd7b12e4 Add the accessible-expandable property 2025-02-03 20:32:45 +01:00
Arnold Loubriat
e442965889 Set accessible-value on ComboBox widgets 2025-02-03 20:32:45 +01:00
Olivier Goffart
13f07018c9 C++: initialize the backend before the translations
Otherwise initializing the translation won't work.

This can't be tested because the testing backend is always initialized before.
And also hasn't been a problem on MCU where the feature is the most usefull
because it also uses custom backend there initialized before
2025-02-03 14:00:59 +01:00
Olivier Goffart
4fc2a3ef92 Fix empty MenuBar
The callbacks would be optimized causing a panic later.
2025-02-03 11:02:10 +01:00
Olivier Goffart
7fba31a7b0
Refactor: use Struct instead of Type for the type in a Expression::Struct 2025-02-03 10:19:30 +01:00
Olivier Goffart
0d72bb0a72 Remove experimental flag for MenuBar and ContextMenu 2025-01-31 14:05:28 +01:00
Olivier Goffart
094ff8f56b Refrersh the menubar when one of the property get changed
Install a PropertyTracker to update the shadow tree if something changes
2025-01-30 17:43:33 +01:00
Olivier Goffart
010126992e MenuItem with for and if 2025-01-30 10:08:22 +01:00
Olivier Goffart
86426087c8
Silence 2024 edition warnings
Add a check for 2024 edition warnings so we make sure users can use Slint
in a crate using the 2024 edition when it gets released.

The warnings can be silenced as we don't handle types in Slint that
have Drop with side effects other than memory allocations
2025-01-28 14:04:19 +01:00
Olivier Goffart
bb793da832
Prospective CI fix with Rust nightly
New warning introduced in nightly rust

```
error: use of a double negation
  --> /home/runner/work/slint/slint/target/debug/build/test-driver-rust-805d926ab786688f/out/expr_arithmetic.rs:10:55
   |
10 |     assert_eq!(instance.get_t4(), 3 + - 5 - 8 - -9 * --- 120);
   |                                                       ^^^^^^
   |
   = note: the prefix `--` could be misinterpreted as a decrement operator which exists in other languages
   = note: use `-= 1` if you meant to decrement the value
help: add parentheses for clarity
   |
10 |     assert_eq!(instance.get_t4(), 3 + - 5 - 8 - -9 * --(- 120));
   |
```
2025-01-28 11:37:26 +01:00
Arnold Loubriat
95715b6610
Set accessible-action-default on ListView items (#7465)
* Set `accessible-action-default` on `ListView` items

* Set `accessible-role` on `ListItem` for Qt style

* Set `accessible-label` on `ListItem` for Qt style
2025-01-27 13:53:57 +01:00
Olivier Goffart
6c7a50bd3d LLR: used typed index for vectors in the LLR
type-safety+=1

This would avoid for example using a sub-component index in an array of
instances or items.
It also self-document what the index is for.

There are still a couple of cast from repeater-index to u32 because we
do some hack with the repeater-index number for component containers
We also cast back to numbers in order to convert it to string in the
generated code.
2025-01-26 11:44:54 +01:00
Olivier Goffart
1aeeba7d6b llr: Store a GlobalIndex in the EvaluationContext instead of a reference
So that the CompilationUnit is only borrowed once and can be made
mutable
2025-01-26 11:00:42 +01:00
Olivier Goffart
3e586edd1a llr: Rename ExpressionContext to ExpressionLoweringCtx
So it is not confused with EvaluationContext
2025-01-26 11:00:42 +01:00
Olivier Goffart
5c1ee625d0 llr: Pass the lowering ExpressionContext as mutable ref and get rid of a RefCell 2025-01-26 11:00:42 +01:00
Olivier Goffart
55bafbb51b llr: don't store Rc<SubComponent> but an index instead
The goal eventually is to serialize the LLR and we can't do it if it
uses Rc inside.
2025-01-26 11:00:42 +01:00
Arnold Loubriat
c739f1e9ba Slider widget: react to Home and End keys 2025-01-25 21:30:22 +01:00
Olivier Goffart
98e8386aee
MenuBar/ContextMenu: hide the entries interface
This can only be used internally by the style to implement the actual
ContextMenu

Only the declarative `MenuItem` interface is exposed.

* [autofix.ci] apply automated fixes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2025-01-25 11:06:31 +01:00
Olivier Goffart
ed179cd5b1
Refactoring: get rid in the callable in the Expression tree
Have a special node for them in FunctionCall
2025-01-24 20:26:35 +01:00
Olivier Goffart
edbcab7d96 Lower MenuItem to entries 2025-01-23 22:02:08 +01:00
Olivier Goffart
c0fe0be643 Add the MenuItem Element type to be added to MenuBar and ContextMenu 2025-01-23 22:02:08 +01:00
Olivier Goffart
8cf6f97962 Refactoring: Use BuiltinElement in additional_accepted_child_types
Simplifies code a bit
2025-01-23 22:02:08 +01:00
Olivier Goffart
d8d0bb2115 Rework lookup of sub-elements with regard to special accepted elements
Consider
```slint
// Some code in the wild actually have made their own menubar before
component MenuBar { /* ... */ }

component Row { /* ... */ }

export component Main inherits Window {
  // This should find the declared component and not the builtin component
  MenuBar { }

  GridLayout {
     Row {}
  }
}
```

Previously, `MenuBar` and `Row` were first resolved against
`additional_accepted_child_types` and so it would always find the
builtin one.
But this patch changes that to find the builtin one only if it hasn't
been replaced by another component with the name name.
(So we'd use the cusom MenuBar and the custom Row)

Another change is that we also lookup the
additional_accepted_child_types if they are in a @children.

```slint
component MyGrid {
   GridLayout { @children }
}
export component Main {
   MyGrid {
      // This used to be an error but is now accepted
      Row { }
   }
}
```
2025-01-23 14:28:11 +01:00
andber1
813e790431 Ignore pedantic and nursery clippy warnings in generated code 2025-01-23 12:16:57 +01:00
Olivier Goffart
3f54e6cbc1 Fix ScrollView on cupertino not showing the last few pixels
Within the cupertino's ScrollView, the Flickable is positioned
with a 2 pixel margin with the `x` and `y` properties
property, so the width and height should also account for that margin.

Fix the test_cpp_elements_listview in test-driver-cpp
2025-01-22 19:52:02 +01:00
Olivier Goffart
0ef44195f7 Add contextmenu syntax test 2025-01-21 15:41:25 +01:00
Olivier Goffart
2df0b8bf20 ListView: adapt the viewport's width based on the minimum-width of delegate
(Instead of their `width` property)
2025-01-21 14:31:55 +01:00
Olivier Goffart
7e37f19e2c ListView: fix continuous redraw with fluent style
Because we set the viewport-width several time to different value during
the layouting of the ListView, it will cause this property to always be
dirty. In particular, this causes permanent restart of the fluent's
scrollbar animation on the size of the handle, causing continous
repaints.
2025-01-21 14:31:55 +01:00
Simon Hausmann
0d723953f9 Add support for line caps in Path Strokes
ChangeLog: Added `Path::stroke-line-cap` property.

Fixes #4676
2025-01-20 22:28:45 +01:00
Olivier Goffart
4da79ac69a Fix layouting of huge ListView with millions of items
The problem is that the precision of f32 for coordinate wouldn't be
accurate enough with such big viewport to put the elements so that they
are next to eachother.
So put the elements relative to the Flickable instead of relative to the
created moving viewport Rectangle.

Fixes #3700

Note that the ListView still use f32 for the scrollbar value, meaning
that at some point, the wheel stops working as the wheel increment is
smaller than the f32 increment, and scrolling becomes somehow fuzzy.
But this only happens after one more billions pixels now, so one can
have more than 50 millions of elements without much problems
2025-01-20 17:41:38 +01:00
Olivier Goffart
387e4202ea Rust: one more fix for computations on big numbers 2025-01-20 16:47:49 +01:00
Olivier Goffart
90f5621985 Fix string formatting of big integer
Don't lower the precision to f32 for big enough numbers
2025-01-20 15:55:44 +01:00
Olivier Goffart
de80bb0a2c Rust: Fix comparison of big integers
Don't convert integer to f32 in the rust generated code
2025-01-20 15:55:44 +01:00
Olivier Goffart
0dc068524c Fix panic in the compiler when having a changed callback over a property that is not materlialized
Fixes #7316
2025-01-17 12:19:20 +01:00
Olivier Goffart
28e54175f6 Work on the ContextMenu
- Add the `entries` property in the ContextMenu
 - Make right click on the ContextMenu show the menu
 - Use the proper technique to register ContextMenu and MenuBar as
   experimental (same as ComponentContainer)
2025-01-16 20:21:06 +01:00
Olivier Goffart
f72e8a1c01 C++/Interpreter: Be consistant with rust in the order in which we create the window
Same as previous commit for Rust
2025-01-16 19:11:31 +01:00
Olivier Goffart
9d1be5209c Don't panic in the generated rust ComponentHandle::window()
It can panic if lazily constructing the window adapter.
Make sure it is actially not lasily constructed, we don't need lazy constructor when not embedding anyway.
2025-01-16 19:11:31 +01:00
Tasuku Suzuki
68b9dfc247 String: Add .is-empty and .character-count properties
Introduce two new properties for string in .slint:
- .is-empty: Checks if a string is empty.
- .character-count: Retrieves the number of grapheme clusters
  https://www.unicode.org/reports/tr29/#Grapheme_Cluster_Boundaries

These additions enhance functionality and improve convenience when working with string properties.
2025-01-14 19:29:05 +01:00
Olivier Goffart
8a5df27469
Update to Image 0.25 (#7365)
Added image-default-formats with all the format supported by image by
default, and enable that feature by default.
Also put that feature in compat-1-2 for compatibility with user that
have used image 0.24 with enabled features.
Make a new compat-1-10 feature that does not enable default format by
default

ChangeLog: upgraded image crate to 0.25, added a new cargo feature
to enable all image formats. (that feature is enabled by default with
compat-1-2, added compat-1-10 to disable it

Fixes https://github.com/slint-ui/slint/issues/7251
2025-01-14 16:31:05 +01:00
Simon Hausmann
53f2d572b1 Remove some uses of once_cell 2025-01-14 14:18:24 +01:00
Olivier Goffart
5cf9c6806e LSP: don't auto-compete private properties 2025-01-14 11:26:57 +01:00
Olivier Goffart
7056515f6c Detect binding loops when it involve the condition of a if in a layout
Fixes #7126
2025-01-13 14:40:18 +01:00
ogoffart
c83af3ca5c Bump version number to 1.10.0 2025-01-13 13:38:41 +00:00
Tasuku Suzuki
346d1c2df3 Fix typos
Ran `typos .` and fixed all typos that do make sense.
https://crates.io/crates/typos
2025-01-13 08:35:20 +01:00
Simon Hausmann
aa332202c5 Rename AccessibleRole.GroupBox to AccessibleRole.Groupbox
While unfortunate in casing, this is consistent with Checkbox, Combobox, and Spinbox.
2025-01-10 16:27:14 +01:00
Olivier Goffart
3e94bd2167 Janitor: Remove trailing whitespaces from all files
`git grep -I -l -O'sed -i "s/[[:space:]]*$//"' -e ''`
2025-01-10 13:23:22 +01:00
Simon Hausmann
c764da4aab
Add property to toggle anti-aliasing on Path elements (#7308)
This enables working around bugs in GPU drivers. Especially the GC7000UL
plus its driver on imx8mp has been observed to sometimes horribly degrade in
performance when Skia renders anti-aliased paths (when a function like
`gcoSURF_BlitCPU` shows up at the top of `perf` that's a bad sign).
2025-01-10 10:28:01 +01:00
Olivier Goffart
cfbcf0b1d7
Introduce Window::try_dispatch_event (#7313)
That is the same as Window::dispatch_event, but it reports an error
instead of panicking
2025-01-09 19:39:38 +01:00
Olivier Goffart
6b4c822a4a MenuBar: C++/Rust native menubar implementation
introduce a SetupMenuBar builtin function to ease C++/Rust lowering
2025-01-08 21:16:17 +01:00
Olivier Goffart
846664ad45 WIP: native menubar using muda
Only the interpreter is implemented so far

MacOs won't work yet because we don't disable the default winit menubar

The viewer don't support removing the MenuBar yet
2025-01-08 14:05:35 +01:00