Commit graph

950 commits

Author SHA1 Message Date
ogoffart
53cce5bf44 Bump version number to 1.0.2 2023-04-26 11:33:16 +02:00
Olivier Goffart
b9d139fd6e Fix focussing element whose base is focusable
Fixes #2622
2023-04-24 18:03:33 +02:00
Simon Hausmann
6c8fa5f215
Fix duplicated loading/embedding of images (#2612)
For .slint files that are included, we canonicalize the path before
adding it into the import stack, to avoid duplicates. We didn't do that
for images in the global_embedded_resources.

Ensure this by canonicalizing as early as possible.

Fixes #2608
2023-04-21 13:15:22 +02:00
ogoffart
bd63218412 Bump version number to 1.0.1 2023-04-18 14:56:40 +00:00
Olivier Goffart
946552b0c5 Fixes access to unset layout property
The previous code was only re-creating the layout properties for these
that had a binding, but that wasn't done if the property was just read,
leading to access to non-existing properties later.

Fixes #2483
2023-04-14 13:51:57 +02:00
Olivier Goffart
0e92ab7b95 Fix TouchArea::has-hover not becoming false when items become invisible
We need to take in account that the items might be clipped when sending
mouse exit events to items.

Note that the test needed a fix to use the actual windows state.
2023-04-14 10:28:27 +02:00
Olivier Goffart
4f6fce0962 Fix the JS test for text-input-focused
Invoking functions are not yet implemented in JS
2023-04-12 14:49:08 +02:00
Olivier Goffart
a57c7eb6bc Added TextInputInterface.text-input-focused 2023-04-12 14:49:08 +02:00
Simon Hausmann
77895d3a2a doc: Document the enabled property of FocusScope
Also add a test for the described behavior.
2023-04-12 08:48:24 +02:00
Simon Hausmann
9a35989eea Fix outer FocusScope objects stealing click-focus
After the `FocusScope` accepted the input event by transferring focus, stop
propagating the event and avoid it being sent to a parent,
which in turn will steal the focus.
2023-04-12 08:48:24 +02:00
Olivier Goffart
6d0d6911f4 Fix visitation of init code
This patch merges the changes from #2344 and #2491 and do some cleanup

In particular, this visit the init code expression when visiting the
root element expression

Closes #2344
Closes #2491
Fixes #2487
2023-04-11 21:30:01 +02:00
Olivier Goffart
cdaf2abb47
C++: sort the member of a struct in the same order as in the .slint file 2023-03-29 19:11:33 +02:00
Simon Hausmann
8ffb5131c7
Introduce error handling in the FemtoVG and Skia renderers (#2402)
Avoid unwrap() and expect() and instead propagate errors all the way
down to run_event_loop(), show(), and hide() in the Slint AIP.
2023-03-24 14:18:11 +01:00
Olivier Goffart
1089d29ebb Make Empty not fill the parent by default
Unless `preferred-*:100%` is set

Part of #2284
2023-03-24 11:15:05 +01:00
Olivier Goffart
259444b577 Silent "warnings" in the rust test driver when using the macro
Otherwse they show up as error because of the deny(warning) in the test.
This is not a problem in the CI because CI uses --all-features that use
the build-time thing, but this is a problem when running locally
2023-03-24 11:14:48 +01:00
Olivier Goffart
74c0fcc88e Don't load the rust tutorial from the doctest
they are already tested by the --workspace flag on the CI.
And it causes problem because the compiler can't load the image from the
doctest dir
2023-03-24 11:14:48 +01:00
Simon Hausmann
00471449b4 Fix compilation of Rust generated code when the generated code uses a return statement inside a block
We cast the result of the body of functions or binding expressions to
the target type via `as _`. When the code contains a return expression,
that works fine, because `return`'s type is the never type, which can be
coerced to a value of any type. However when the return statement is
inside a sub-block, the type becomes `()`, for which the `as _` cast
fails.

Work around this by attempting to detect the situation (return produces
Type::Invalid) and omit the trailing cast.
2023-03-22 18:07:34 +01:00
Olivier Goffart
233bc61c8e Flickable: capture the event if the flickable can flick even if it is at the end
When scrolling the printer demo, I often end up closing or opening
element i don't want to because we reached the end and therefore it is
not scrolling and forwarding the event
2023-03-09 11:35:57 +01:00
Olivier Goffart
db12795032 swrenderer: gradient with opacity 2023-03-07 07:16:31 +01:00
Simon Hausmann
f4c30ce46e Fix panic when accessing a global from init that's not used otherwise
Make sure to visit the named references in the init code, when
collecting globals.

Fixes #2312
2023-03-03 15:23:57 +01:00
Simon Hausmann
1d82c179d1 Fix panic when invoking unused callback aliases with the interpreter
Don't try to install a callback handler that captures an invalid
expression. The llr pass has an invalid expression guard, and so does
the rest of this handle_property_bindings_init callback.

Fixes #2319
2023-03-02 19:02:25 +01:00
Olivier Goffart
a89c5db8db Fix crash when a state condition is detected as constant
States are never constant because the generated state binding depend on
the time as it register the time it was set for the pottential animation

Also adjust the assert so it assert correctly which the right message

Fixes: #2274
2023-02-24 16:43:48 +01:00
Simon Hausmann
7e843a30d8 doc: Move the recipes into the Slint Language Documentation 2023-02-23 14:20:10 +01:00
Simon Hausmann
8272e486a2 Re-add missing 15 additional doc tests 2023-02-23 13:10:37 +01:00
Tobias Hunger
0867aa1ed9 docs: Move slint language docs from langref to language folder 2023-02-22 21:13:47 +01:00
Tobias Hunger
d9d99fa4de Fix compile fail with nightly
A new warning was added and we deny warnings.
2023-02-21 08:58:19 +01:00
Olivier Goffart
5146c52d20 Flickable: Shift + mouse scroll reverts scroll dirrection
Closes #2228
2023-02-16 14:01:34 +01:00
Olivier Goffart
8450e01a3f
Change the name of the compat feature (#2230)
And remove the compat-0-2-0 and compat-0-3-0 features
2023-02-16 09:40:44 +01:00
Olivier Goffart
8934bf3bf5 Layouting: When propagating constraint to parent, use the explicit constraints...
in addition to the implicit constraints

Finishes #783
2023-02-15 17:07:33 +01:00
Olivier Goffart
5b3cde87ab Update dependencies 2023-02-15 10:28:02 +01:00
Olivier Goffart
03e9edee64 Fix compiler panic when an component's base is not inlined
An element with children must be fully inlined or the children array
can't be easily computed.
But the code wouldn't work if the base of a component was not inlined
2023-02-15 09:20:12 +01:00
Olivier Goffart
41157b9984 Fix visible property on the root of a component
Just like opacity and other properties, it needs to prevent inlining.

And also add the same warning as for opacity if it is used on the root
(the Window)
2023-02-14 13:28:54 +01:00
Olivier Goffart
6889dfa5f5 Rust: Make new(), run() and show() report errors from the backend
Fixes #2198
2023-02-10 05:00:03 +01:00
Olivier Goffart
9fec9992b4 Prospective fix for the test on MSVC
The CI gets the error

```
C:\Users\RUNNER~1\AppData\Local\Temp\.tmpUISeUr.cpp(11): error C2665: 'Color::Color': no overloaded function could convert all the argument types
C:\Users\RUNNER~1\AppData\Local\Temp\.tmpUISeUr.cpp(11): note: could be 'Color::Color(Color &&)'
C:\Users\RUNNER~1\AppData\Local\Temp\.tmpUISeUr.cpp(11): note: 'Color::Color(Color &&)': cannot convert argument 1 from 'slint::SharedString' to 'Color &&'
C:\Users\RUNNER~1\AppData\Local\Temp\.tmpUISeUr.cpp(11): note: Reason: cannot convert from 'slint::SharedString' to 'Color'
C:\Users\RUNNER~1\AppData\Local\Temp\.tmpUISeUr.cpp(11): note: No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
C:\Users\RUNNER~1\AppData\Local\Temp\.tmpUISeUr.cpp(11): note: or       'Color::Color(const Color &)'
C:\Users\RUNNER~1\AppData\Local\Temp\.tmpUISeUr.cpp(11): note: 'Color::Color(const Color &)': cannot convert argument 1 from 'slint::SharedString' to 'const Color &'
C:\Users\RUNNER~1\AppData\Local\Temp\.tmpUISeUr.cpp(11): note: Reason: cannot convert from 'slint::SharedString' to 'const Color'
C:\Users\RUNNER~1\AppData\Local\Temp\.tmpUISeUr.cpp(11): note: No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
C:\Users\RUNNER~1\AppData\Local\Temp\.tmpUISeUr.cpp(11): note: while trying to match the argument list '(slint::SharedString)'
C:\Users\RUNNER~1\AppData\Local\Temp\.tmpUISeUr.cpp(11): note: This diagnostic occurred in the compiler generated function 'Color::Color(Color &&)'
C:\Users\RUNNER~1\AppData\Local\Temp\.tmpUISeUr.cpp(140): note: see reference to function 'Color::Color(Color &&)'
C:\Users\RUNNER~1\AppData\Local\Temp\.tmpUISeUr.cpp(140): note: see reference to function template instantiation 'Color TestCase::init::<lambda_2>::operator ()<std::tuple<slint::SharedString>>(const _T1 &) const' being compiled
        with
        [
            _T1=std::tuple<slint::SharedString>
        ]
C:\Users\RUNNER~1\AppData\Local\Temp\.tmpUISeUr.cpp(31): error C3511: 'SharedString': a call to a delegating constructor shall be the only member-initializer
C:\Users\RUNNER~1\AppData\Local\Temp\.tmpUISeUr.cpp(31): note: This diagnostic occurred in the compiler generated function 'SharedString::SharedString(SharedString &&)'
C:\Users\RUNNER~1\AppData\Local\Temp\.tmpUISeUr.cpp(147): note: see reference to function 'SharedString::SharedString(SharedString &&)'
C:\Users\RUNNER~1\AppData\Local\Temp\.tmpUISeUr.cpp(148): note: see reference to function template instantiation 'SharedString TestCase::init::<lambda_4>::()::<lambda_1>::operator ()<slint::SharedString,slint::SharedString,int>(const _T1 &,const _T2 &,const _T3 &) const' being compiled
        with
        [
            _T1=slint::SharedString,
            _T2=slint::SharedString,
            _T3=int
        ]
C:\Users\RUNNER~1\AppData\Local\Temp\.tmpUISeUr.cpp(31): error C2665: 'SharedString::SharedString': no overloaded function could convert all the argument types
C:\Users\RUNNER~1\AppData\Local\Temp\.tmpUISeUr.cpp(31): note: could be 'SharedString::SharedString(SharedString &&)'
C:\Users\RUNNER~1\AppData\Local\Temp\.tmpUISeUr.cpp(31): note: 'SharedString::SharedString(SharedString &&)': cannot convert argument 1 from 'slint::SharedString' to 'SharedString &&'
C:\Users\RUNNER~1\AppData\Local\Temp\.tmpUISeUr.cpp(31): note: Reason: cannot convert from 'slint::SharedString' to 'SharedString'
C:\Users\RUNNER~1\AppData\Local\Temp\.tmpUISeUr.cpp(31): note: No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
C:\Users\RUNNER~1\AppData\Local\Temp\.tmpUISeUr.cpp(31): note: or       'SharedString::SharedString(const SharedString &)'
C:\Users\RUNNER~1\AppData\Local\Temp\.tmpUISeUr.cpp(31): note: 'SharedString::SharedString(const SharedString &)': cannot convert argument 1 from 'slint::SharedString' to 'const SharedString &'
C:\Users\RUNNER~1\AppData\Local\Temp\.tmpUISeUr.cpp(31): note: Reason: cannot convert from 'slint::SharedString' to 'const SharedString'
C:\Users\RUNNER~1\AppData\Local\Temp\.tmpUISeUr.cpp(31): note: No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
C:\Users\RUNNER~1\AppData\Local\Temp\.tmpUISeUr.cpp(31): note: while trying to match the argument list '(slint::SharedString)'
C:\Users\RUNNER~1\AppData\Local\Temp\.tmpUISeUr.cpp(31): note: This diagnostic occurred in the compiler generated function 'SharedString::SharedString(SharedString &&)'
C:\Users\RUNNER~1\AppData\Local\Temp\.tmpUISeUr.cpp(147): note: see reference to function 'SharedString::SharedString(SharedString &&)'
C:\Users\RUNNER~1\AppData\Local\Temp\.tmpUISeUr.cpp(31): error C2437: 'Component': has already been initialized
C:\Users\RUNNER~1\AppData\Local\Temp\.tmpUISeUr.cpp(31): note: This diagnostic occurred in the compiler generated function 'SharedString::SharedString(SharedString &&)'
C:\Users\RUNNER~1\AppData\Local\Temp\.tmpUISeUr.cpp(147): note: see reference to function 'SharedString::SharedString(SharedString &&)'
C:\Users\RUNNER~1\AppData\Local\Temp\.tmpUISeUr.cpp(31): error C2437: 'Model': has already been initialized
C:\Users\RUNNER~1\AppData\Local\Temp\.tmpUISeUr.cpp(31): note: This diagnostic occurred in the compiler generated function 'SharedString::SharedString(SharedString &&)'
C:\Users\RUNNER~1\AppData\Local\Temp\.tmpUISeUr.cpp(147): note: see reference to function 'SharedString::SharedString(SharedString &&)'
```

Which I don't feel like debugging now
2023-02-08 18:34:52 +01:00
Olivier Goffart
11d404a216 Rust: Avoid use statement in the generated code
So we avoid name conflict between user types and internal types

Fixes #2207
2023-02-08 18:34:52 +01:00
Olivier Goffart
a19efc30db
Replace the MAX_BUFFER_AGE const generic with a runtime enum
Having a const generic for that didn't turn to be a good API.
Also made the C++ side more difficult

(Also renamed buffer_stride to pixel_stride)

Closes #2135
2023-02-08 14:44:01 +01:00
Olivier Goffart
dddfcf572d Fix const detection with two ways binding
The const detection for two way binding was not detecting change if one
of the property was set to a const value in a component using it.

This would cause the compiler to generate call set_content on one of the
property in a two way bindings, and later, the "const sentinel" be
present in the dependency list, causing crash.

To avoid segfault for similar bug in the future, added added an assert!
in the property system to detect that.

Fixes #2185
2023-02-07 10:27:37 +01:00
Olivier Goffart
96c17e9563 TextImput: Shift+Click selects 2023-02-06 09:14:29 +01:00
Olivier Goffart
9e48e5eee3 TextInput: implement double-click and drag
(and tripple-click and drag)
2023-02-06 09:14:29 +01:00
ogoffart
e7f48512ee Bump version number to 1.0.0 2023-02-03 11:07:15 +01:00
Olivier Goffart
7e56af7c6d screenshot test: Test gradients
Allow for a small differences as "roundeing error" while drawing gradients.
Note that when stops are involved, we still get artifacts and bigger difference
than tollerable when clipping
2023-02-02 15:54:07 +01:00
Tobias Hunger
aaddac9933 docs: Doc-test files in docs/langref/src
... in addition to the files tested earlier.

This changes the modules generated to include the relative path to the
project root. Otherwise we got errors due to the widgets module getting
defined twice (once in docs/ and once in docs/langref/src).

I think this is saver, as we can end up with files with the same name in
different directories quite easily.
2023-01-31 15:08:52 +01:00
Florian Blasius
d84de623b4
TextEdit select text with double and dribble click (#2088)
* Select word in `TextEdit` by double click
* Select paragraph in `TextEdit` by dribble click
2023-01-31 15:04:19 +01:00
Simon Hausmann
8c807cb1da
Remove slint::Image::stride() (#2147)
cc #2138
2023-01-30 13:59:31 +01:00
Olivier Goffart
aafc9ceaaf Screenshot test: test partial rendering
Test what when we do a screenshot for a region of the image, it gives the right result.
(Otherwise we might see flickering arounf the clipped region)
2023-01-27 13:15:25 +01:00
Simon Hausmann
448b216bd8 Second stage of cleaning up the export handling of the slint root component
Commit 24dcef5fed added a warning for the
implicit export of last component. For 1.0, this commit makes it so that
the root component is determined by the last export in the file.
2023-01-26 15:52:40 +01:00
Olivier Goffart
ae20ec59c8 Rename PointerEventButton::None to PointerEventButton::Other
And mark the enum non_exhaustive

closes #1903
2023-01-26 13:36:54 +01:00
Olivier Goffart
7c55b9f925 Only apply the constraint to the parent with the new syntax
Also attempt to document it
2023-01-24 19:18:59 +01:00
Olivier Goffart
bc1afb6f8f Fix TabWidget::current-index bindings
The property set by the user was not kept because the binding went the
wrong way.

Also remove the undocumented (and equaly not working)
TabWidget::current-focused property from the public API.
The current-focused property is initialized by the tab.
2023-01-24 11:34:35 +01:00
Simon Hausmann
33d68687c2 Fix key input not working after loss of focus due to global shortcut
When a global shortcut, like ^-Cmd-Q on macOS to lock the screen, causes
a loss of window focus, we'll receive a key event from the windowing
system for the modifier, but we'll never receive the "Q" in this example
(as press or release). So later, when we regain focus, we'd assume that
our keyboard modifier state is still "pressed ^/Cmd", which is
incorrect. Therefore assume that a loss of window focus implies a reset
keyboard of keyboard modifier state.

Fixes #2098
2023-01-23 14:07:57 +01:00