Commit graph

1514 commits

Author SHA1 Message Date
Olivier Goffart
bd18d8dc0a Fix compiler crash when const propagating a property of component-factory with its default value
We couldn't represent an empty component factory in the exrpession tree,
so add Expression::EmptyComponentFactory for that
2024-06-25 20:25:01 +02:00
Olivier Goffart
42a2c6a569
Only generate code for the exported Window
Have a warning when a component is exported from the main file and
doesn't inherit Window.
Unless it's the last component, for compatibility with Slint 1.6

Also don't warn in the interpreter
2024-06-25 15:13:06 +02:00
Olivier Goffart
539abfc550 Revert "Add a warning if a PopupWindow is in a layout"
This reverts commit 66652cdc1d.

The warning in the gallery are hard to fix because the component inherit
from a layout and there is nowhere to place the popups
2024-06-24 16:38:37 +02:00
Tobias Hunger
1c8b3733f7 janitor: Fix clippy "manual char comparison can be written more succinctly" 2024-06-24 14:59:47 +02:00
Tobias Hunger
0639b9a61b janitor: Fix clippy "bound is already specified as the supertrait" 2024-06-24 14:59:47 +02:00
Tobias Hunger
9a253dc571 janitor: Fix clippy "match for destructuring a single pattern" 2024-06-24 14:59:47 +02:00
Tobias Hunger
f8e4072d0c janitor: Fix clippy "unneeded return" 2024-06-24 14:59:47 +02:00
Tobias Hunger
cd3b60c889 janitor: Fix clippy "creates a reference which is immediately dereferenced" 2024-06-24 14:59:47 +02:00
Tobias Hunger
f78ea5e7cf janitor: Fix clippy "field assignment outside of initializer
... for an instance created with Default::default()"
2024-06-24 14:59:47 +02:00
Olivier Goffart
3764312561
Generate multiple components in Rust and C++ (#5449)
When lowering to the LLR, generate one PulbicComponent for each exported
component in the main file

Closes #784
2024-06-24 10:03:19 +02:00
Olivier Goffart
c89ea56abb Update a bunch of dependencies
Bigger change is cause by resvg/usvg which now takes the font database
in a Arc, so we must store it in a Arc ourself to cheaply lend it to usvg
2024-06-23 16:47:13 +02:00
Olivier Goffart
408637a677 Remove the is_root_component within the component
There will be serveral roots, so this makes no sense.
2024-06-21 11:58:09 +02:00
Olivier Goffart
8933f3308c Remove the error when using @children on the root component
This complicates multi-component handling
2024-06-21 11:58:09 +02:00
Olivier Goffart
acb7da11d2 fix missing warning of missing export
... for last component when globals are exported
2024-06-21 11:57:49 +02:00
Olivier Goffart
a4c0cc9f09 Move the used_types from the (root) Component in the Document
Preparation for multi-components

Note that this had to rename one instance of TextStyle because it
conflicts with the struct of the same name used in the FontSettings
in the style. This wasn't a problem before because it shares some
property in common, and the the order of processing of component has
changed leading to the other one being generated.
(But that is a wider bug in the compiler outside of the scope of this
refactoring)
2024-06-20 12:03:38 +02:00
Olivier Goffart
2fd8744cfc compiler: Move embedded_file_resources from the root Component to the Document 2024-06-20 12:03:38 +02:00
Olivier Goffart
11e7b12a81 compiler: perform remove return pass before const propagation
Otherwise we end up inlining "returns" in the wrong property

Fixes #5430
2024-06-19 12:51:47 +02:00
Olivier Goffart
b5aea0ed64
Spinner: simplify the arc path (#5420)
Since we use the stroke and stroke with, then a single arc is enough
instead of two connected by lines
2024-06-18 15:52:17 +02:00
Daniel Stuart
9f63d157d1 Add character wrapping for Qt Backend
This adds a new wrapping mode called `char-wrap`, which allows for wrapping at any character.
Currently, it only supports the Qt backend, with the other backends falling back to `word-wrap` when this option is selected.
2024-06-17 23:52:04 -07:00
Olivier Goffart
62e0fdd5bd Rust: Attempt to fix the stack overflow when constructing the item array
Workaround from https://github.com/rust-lang/rust/issues/53827
2024-06-17 10:16:53 +02:00
Olivier Goffart
d0ed0438ce
LLR: peliminary support for multiple public components
There currently still can only be one because the passes expect that,
but now the LLR and generator should be ready to accept multiple public
component later
2024-06-15 14:44:11 +02:00
Tobias Hunger
f55ef8fa08 compiler: Add current document into snapshot
It went missing before as it gets added to the `TypeLoader` that gets
snapshot only after the function we snapshot in...
2024-06-14 16:59:39 +02:00
Olivier Goffart
d0cdebfee6 C++: move globals in a different struct
So that subcomponent don't depend on the root component name
which will hallow to have several root components
2024-06-14 16:26:53 +02:00
Florian Blasius
1d92d29649 DatePicker: Fix bug where switch from input to selection clears date text 2024-06-14 06:43:28 +00:00
Florian Blasius
029ed7e4c2 DatePicker: fix selection on month navigation 2024-06-14 06:43:28 +00:00
Olivier Goffart
f343780462 Rust generated code: move globals and window in a separate Rc...
... that is independent on the root component type, so we could support
several different root component sharing the same sub-components and
globals
2024-06-13 16:05:59 +02:00
Olivier Goffart
4cc6337c42 Rust: Don't get the default font size through the root component
Planning for multi-component support
2024-06-13 13:53:07 +02:00
Tobias Hunger
c55f0a9b0e compiler: Add a snapshotter to help create snapshots of compiler state
Use this snapshot to keep a unoptimized typeloader around, so that the preview
does not need to do another parsing run.

Move the document cache in the preview over to use the snapshot.
2024-06-12 10:15:29 +02:00
Tobias Hunger
c68d5a6a0f compiler: small docs fixes 2024-06-11 22:25:05 +02:00
Tobias Hunger
c945e11a40 janitor: Make by_address a workspace dependency 2024-06-11 21:58:59 +02:00
Olivier Goffart
60e7d54e67 Compiler better test coverage in case of error and fix panics
The compile_syntax_node was used by the syntax_test in case of error
to still cover the coverage, but commit e3908cfce6
made this function a noop when there is an error already.

The LSP does try to build an object tree even though there are error in
order to have the most information even in that case, so we must ensure
that it doesn't panic left and right.

This commit also fix some of these panics.
2024-06-11 19:22:59 +02:00
Olivier Goffart
47a61dda10 Fix compiler crash with invalid code 2024-06-11 19:22:59 +02:00
Olivier Goffart
b3de1e848e Fix inlining of PopupWindow
ammend previous commit to fix building the examples

When inlining things inside a Popup, we must process the popups first.
But in order to inline the popup inside another component, we must
process the popups last.
This makes the code a bit more complicated
2024-06-10 22:18:06 +02:00
Olivier Goffart
42704eee65 Fix @children in a PopupWindow
Fixes #5375
2024-06-10 22:18:06 +02:00
Olivier Goffart
a780dd4905 Testing: Fix duplicated accessibility element
This fix the C++ todo test that wasn't run because of a typo

When an element is optimized in another one, only the first one should
report the accessible properties. (because element with accessible
properties cannot be optimized so they are always the first)
2024-06-07 13:18:12 +02:00
Olivier Goffart
3f80b5ba59 Ignore all clippy warnings in generated code
We don't want user to see clippy warnings from our generated code

Relates to #1874
2024-06-06 11:55:37 +02:00
Luc Fauvel
44a537d902
Implemented resizing for non-decorated winit windows (#5026)
Fixes #5023

* Implemented resizing for non-decorated winit windows

* Fixed formatting

* Changed direction match to use a tuple, reduced resize border size, returned after handling resize

* Added is resizable check for before resizing winit window

* Added resize-border property to window

* Formatted code

* Change resize-border from float to length
2024-06-06 11:17:05 +02:00
Simon Hausmann
97dc776557 Add missing accessible-action-default for Switch
... and fix Switch defaults to match the docs for all styles.
2024-06-06 01:15:05 -07:00
Florian Blasius
557c95d0eb TimePicker: Fix foreground of selected input for cosmic 2024-06-06 09:53:29 +02:00
Simon Hausmann
8cc2620dee Fix up clock and keyboard icon in the qt style
These were originally copied from cosmic but should come from material, as the other icons from the date picker PR.
2024-06-06 09:28:56 +02:00
Olivier Goffart
445802c46d date_time: simplification and cleanups 2024-06-06 09:03:50 +02:00
Olivier Goffart
3da0ee5bb9 DatePicker: Logic in C++
Had to simplify a bit the rust logic to make it work
2024-06-06 09:03:50 +02:00
Florian Blasius
973ecac989 DatePicker: finished features 2024-06-06 09:03:50 +02:00
Florian Blasius
f75cedb893 DatePicker: calendar 2024-06-06 09:03:50 +02:00
Florian Blasius
fe6dba9779 DatePicker: base setup 2024-06-06 09:03:50 +02:00
Simon Hausmann
b162e9df45 Make it possible to toggle the state of checkboxes via accessibility 2024-06-05 09:51:41 -07:00
Florian Blasius
3ccee816be
Added TimePicker widget (#5251) 2024-06-05 15:23:06 +02:00
Olivier Goffart
7f014050ac Qt StandardTableView: properly elide the cell in the text
Contrary to the ListView that needs a minimum size and can be scrolled,
the TableView needs the cell to be ellided and don't have a minimum size

Fixes #5285
2024-06-05 12:29:43 +02:00
Simon Hausmann
15b517a554 Emit a warning to stderr (debug_log) when using the ElementHandle API but there's no debug info present 2024-06-05 01:29:58 -07:00
Simon Hausmann
1a8ce3c659 Add support for optimized rectangles in ElementHandle
Keep merging elements, but remember the boundaries in the debug info, separated by a slash.

Also fixed tests that rely on accessible-label being set only once. For example

```
Button { text: "foo"; }
```

will certainly have "foo" as accessible-label on `Button`, but its internal `Text` element has
an implicit "accessible-label" set to the same
value.

So don't rely on that for now but search by id instead.
2024-06-05 01:29:58 -07:00