Commit graph

1514 commits

Author SHA1 Message Date
Olivier Goffart
6195fc8567 Fix compilation when dividing by zero at compile time
Rust would have panicked and C++ generated wrong code.

CC #3982
2023-11-27 17:09:57 +01:00
Florian Blasius
c00a21d651
make use of textinputbase (#4014) 2023-11-27 08:50:29 +01:00
Olivier Goffart
a3e48c4950 Const propagation of min and max
Since we generate a lot of max(min, preferred) in the geometry code,
this allow to simplify some expressions in the generated code
2023-11-24 14:20:27 +01:00
Olivier Goffart
fdfa4b31e4 Visit the geometry property as root from binding_analysis
We need to visit them from there to mark them as used externally,
otherwise the remove_alias passes might remove them.

Fixes #4002
2023-11-24 14:07:42 +01:00
Olivier Goffart
e27a662019 Revert "Clip button texts"
This reverts commit 19e1cd8ac2.

This caused regressions as the button no longer have the proper minimum
size.

Fixes #3985
Reverts #3977
2023-11-23 08:53:12 +01:00
ogoffart
0a5bf6c37b Bump version number to 1.3.1 2023-11-23 07:47:07 +00:00
Tobias Hunger
2ad8774a61 Add clamp function to slint language 2023-11-22 12:27:54 +01:00
George Hopkins
19e1cd8ac2 Clip button texts 2023-11-22 06:49:33 +01:00
Florian Blasius
62e5fb43bf
align styling resources (#3973) 2023-11-21 14:45:07 +01:00
Olivier Goffart
678afb3ba0 Throw an error when returning no value when one is expected.
Previously we were likely to get error in the compiled code anyway.
(although the interpreter worked fine)

Fixes #3962
2023-11-20 13:50:57 +01:00
Olivier Goffart
8d91ff7dea
Fix compiler panic when there is a component called "Window"
the ensure_window and popupwindow passes were looking up the "Window"
builtin in the global register instead of in the builtin register,
causing the presence of an user-defined "Window" to cause panic.

The "Clip" and "BoxShadow" calls are not affected because they were
looking up in the builtin reguister, but using the appropriate function
is more future-proof

Fix #3916
2023-11-20 13:10:31 +01:00
Florian Blasius
aeace4c4ed
fluent: fixed scrollbar width / height (#3939) 2023-11-16 06:49:34 +01:00
Florian Blasius
95582e6794
fluent: make scrollbars overlay (#3932) 2023-11-15 19:04:02 +01:00
Olivier Goffart
7a04b9a643 Qt Spinner: different design without hardcoded strong colors 2023-11-08 12:04:18 +01:00
Florian Blasius
110689bad1
Added Spinner widget (#3871) 2023-11-07 15:04:24 +01:00
Simon Hausmann
a5c3692fbc Add progress-indicator accessible role 2023-11-07 13:37:12 +01:00
Olivier Goffart
34ea148c48 Fluent combobox: always put the first item on top
Currently it's always the second, but that's not great.
Ideally it should be the current active element, but that's hard to
compute

This becomes extra-relevent when our preview UI has a combobox on the
top and that it is clipped to the window by winit

Fixes https://github.com/slint-ui/slint/issues/3345
2023-11-07 11:12:27 +01:00
Tobias Hunger
d53cebd3e1 lsp: Get signalled by the preview 2023-11-03 22:14:20 +01:00
Olivier Goffart
f043234890 C++: fix (private) properties of type EasingCurve
tests/cases/properties/animation_props_depends.slint in previous commit
added a property<easing> and that didn't work with C++
2023-11-03 15:11:06 +01:00
Olivier Goffart
89c80f3b6d Fix animation expression not being visited for use count of property
resulting in properties being optimized when they shouldn't
2023-11-03 15:11:06 +01:00
Ken Carpenter
b20536131f
Add more easing formulas (#3812)
Closes #2655
2023-11-03 09:20:44 +01:00
Tobias Hunger
c2056075c0 janitor: Disable clippy::overly_complex_bool_expr in generated rust code
This makes clippy error out in our users code (using a nightly compiler).
2023-11-02 16:33:19 +01:00
Tobias Hunger
d62c98d574 janitor: Do not spam the build output with empty lines 2023-11-02 10:17:59 +01:00
Tobias Hunger
2adc3713fa janitor: Do not warn about unused imports in generated rust code
When testing, we have `deny(wanrings)` set, so this actully makes the
tests error out.
2023-11-02 10:17:59 +01:00
Tobias Hunger
b5c433dada janitor: Fix build warning about DefaultParser 2023-11-02 10:17:59 +01:00
Simon Hausmann
1e579eeb4e Make it possible to focus Cupertino and Fluent buttons
The Material button already has the forward-focus.
2023-11-02 07:24:42 +01:00
Tobias Hunger
83e37f7c51 component_container: Do not auto-match the parent's size
This fixes the widget having the right size and sifes some strange
issues I had been wondering about for a while now!

Pass own size to children instead, so that they will always have
matching sizes.
2023-11-01 17:25:42 +01:00
Olivier Goffart
ac8fd60091 Fix regression with empty array
Regression noticed in this line:
3f97d98bff/ui/tabs/downloads.slint (L77)

The following used to work:

```slint
import { Button, VerticalBox } from "std-widgets.slint";
export component Demo {
    in property <[int]> mods;
    VerticalBox {
        alignment: start;
        for xxx in true ? mods : [] : HorizontalLayout { alignment: center; Button { text: "OK!"; } }
    }
}
```

But we fixed array conversion and this caused a regression with empty
array
2023-11-01 11:30:59 +01:00
Olivier Goffart
8df1217261 Fix slint compiler panic in chiptrack
If a branch that always return has a "void value" and the side that
doesn't return has a value, we need to synthetize a default value
so the struct is complete, even if that value is not used.
2023-11-01 09:51:33 +01:00
Florian Blasius
10066c5eef
cleanup widgets according to upcoming code guidelines (#3771) 2023-10-30 10:45:25 +01:00
Olivier Goffart
85ca10d32e Disallow access to internal globals (NativeStyleMetrics and SlintInternal)
It only stay accessible in our builtin styles

Fixes #3793
2023-10-28 16:07:38 +02:00
Olivier Goffart
9ffe26459f Layout: when using a fixed window size, dissociate the WiondowItem's size with the slint size
If you have a window like so:
```
component W inherits Window {
   width: 200px; // or some other bindings
}
```

Before this patch, it will be converted by the compiler to something like

```
component W inherits Window {
   width: 200px; // or some other bindings
   min-width: width; // (not actual property, but part of the layout_info)
   max-width: width;
}
```

When the window is on the screen, the platform backend will set the max
with and min width on the window manager window to the value from the
layout info.
But slint will also set the width and the height of the WindowItem to
the actual value.  This will break the binding for width if any, and
will also cause the min and max with do be updated, which is wrong.

We haven't had much problem with that before, but with the
ComponentContainer, this becomes a problem as we want to set the width
and height of the inner from the outer by adding a two way binding,
which cause a binding loop at runtime.

The behavior change is that if you have a fixed window size and use that
on a MCU or platform that has a different size, the window will be
cropped or padded but will no longer be resized
2023-10-27 17:45:46 +02:00
Tobias Hunger
46b7839db2 i-slint-compiler: Add some tests for fileaccess 2023-10-25 14:25:53 +02:00
Tobias Hunger
a76c3ec789 Fix loading of sources from relative paths
They used to fail to load resources from locations relative to the relative path of the source.

Closes: #3746
2023-10-25 14:25:53 +02:00
Florian Blasius
74219f833c
Make fluent light scroll bars more visible (#3759) 2023-10-25 09:30:23 +02:00
Olivier Goffart
db0eb6efbe Fix drop shadow
commit 975abf3c42 introduced a regression.
Two problem:
 - we were taking the geometry from the parent instead of the element
   that need the shadow
 - Element::make_rc override the geometry with its own properties

Unfortunately annot be tested as this only visual, and the software
renderer don't support shadow yet

Fixes #3743
2023-10-24 16:01:33 +02:00
Olivier Goffart
3b7c2d0c5e compiler: Add layout information the the Element 2023-10-24 15:49:12 +02:00
Simon Hausmann
30c810be00 winit: Propagate errors when winit fails to initialize the event loop
For the backend selector, this means that when a backend is selected explicitly,
and initialization fails, don't try `create_default_backend()` but
propagate the error.

For the Rust code generator, propagate the first ensure_backend()
errors. Any subsequent onces (unlikely, since the first thing any
public new() calls is ensure_backend) will unwrap.
2023-10-24 15:47:08 +02:00
Olivier Goffart
ae4debafe2 Compiler: Don't panic when a Row is repeated in a GridLayout
Fixes #3729
2023-10-23 19:43:46 +02:00
Olivier Goffart
12cd8e71f1 WIP: some polish over the winit update to 0.29 2023-10-23 14:22:48 +02:00
Olivier Goffart
5bf2c7192b Fix panic with very large ListView
In `ItemRc::find_sibling` we currently do:
 1. get the range
 2. check that the next index is within the range
 3. call `get_subtree`

The problem is that get_subtree itselg will call 'ensure_updated' which
will do the relayout of the ListView and may get a different range of
element.

So don't query the range before and just have get_subtree to return an
empty ItemWeak if we are out of the actual range.

Couldn't really find a way to make a test since this is called from
the accessibility code which is hard to test as is

For #3700
2023-10-21 14:03:39 +02:00
Olivier Goffart
975abf3c42 Don't steal the x and y properties for dummy parents
Parents surch as Opacity, Clip, and co, used to steal the x and y
property of their children, making the property not what they ought to
be.

Now that we refactored recently the code so that geometry need not to be
always linked to a property of the same name, we can dissociate the x
and y property of these generated elements and their content so that the
actual "x" property of the former elementstay some value, despite its
relative item property is now 0.

Had to change a bit of code that was still assuming a literal "height"
or "width" or "y" or "x" property that no longer worked when the
geometry is dissociated from its property

Fix #1072
2023-10-21 07:30:46 +02:00
J-P Nurmi
c5248c005e Allow specifying paths for @library imports 2023-10-20 16:47:00 +02:00
Olivier Goffart
172dcfa775 C++: fix crash when accessing empty model from Slint
Fixes #3704
2023-10-19 18:09:14 +02:00
Tobias Hunger
c1456e5153 component_container: Add background rectangle 2023-10-19 13:22:39 +02:00
Florian Blasius
3e3dd03566
Added focus-changed-event callback to FocusScope (#3650) 2023-10-17 17:30:19 +02:00
Olivier Goffart
166f19aeff
Fix compiler panic when trying to resolve aliases in invalid import
Fixes #3674
2023-10-16 16:37:49 +02:00
Tobias Hunger
caee0b2f9d janitor: Fix a semi-random selection of clippy warnings
Nothing serious in there.
2023-10-16 13:44:37 +02:00
Tobias Hunger
88170937e9 janitor: Fix clippy error
That's the only one this time round.
2023-10-16 13:44:37 +02:00
Florian Blasius
030cf2cd19
Update scroll offset on ScrollView on ScrollBar scroll-event (#3668) 2023-10-16 10:41:39 +02:00