Commit graph

8435 commits

Author SHA1 Message Date
Olivier Goffart
4076df928d Fix panic when getting the line, column of diagnostic with invalid span
Introduced in cbc0c790a3
2023-04-19 12:35:17 +02:00
Simon Hausmann
84c4f817f1 Fix resizing of the preview in SlintPad after selecting a new demo
I misread the spec about the name conversion for the DOMStringMap used in JS for the dataset
attribute and the name used in the DOM.
Both, the setting in preview_widget.ts as well as
reading it in windowadapter.rs counts as JavaScript access, so use camel case.

The old variant happened to work in Safari.

Amends 43234dafc5
2023-04-19 11:40:14 +02:00
Olivier Goffart
cbc0c790a3 Make Disagnostice::line_colunm 1 based
Commit 893983e8d3 "fixed" it to be 0 based as it was
documented. But that's a change of behavior so restore the previous behavior and
document it properly
2023-04-19 11:02:33 +02:00
Olivier Goffart
c11415dbbb Docs: Remove link to old video
The old video still use the old syntax and the name SixtyFPS.
Used the video that creates a small calculator for Rust
2023-04-19 09:27:46 +02:00
Tobias Hunger
893983e8d3
Slintpad: Add picker mode where you can click on something in the preview and the editor focuses on that (#2567)
* compiler: Make mapping from source offset to line/column more reusable
* compiler: Improve mapping of offset to line/column
* Fix unit tests after line mapping update
* interpreter: Add code to have a element picker mode
* slintpad: Add picker mode to the preview
* slintpad: Do not try to highlight "empty" highlight requests
* Slintpad: Cycle through all the possible elements in design mode
* Slintpad: Ignore builtins and eat less clicks
* Slintpad: Highlight the element selected in design mode
* Slintpad: Do not use static mut variable in design mode
* slintpad: Rename `set_current_element_information_callback`
* Interpreter: Do not use unsafe in design mode code

Done with: @ogoffart and @tronical
2023-04-18 23:11:08 +02:00
ogoffart
bd63218412 Bump version number to 1.0.1 2023-04-18 14:56:40 +00:00
Olivier Goffart
a1ea00553f Compiler: hint when an id has the same name as a property or enum value 2023-04-18 16:16:31 +02:00
Arthur Araruna
3c9d6c8b70 Round values when converting from f32 to u8 in RgbaColor 2023-04-18 13:48:27 +02:00
Simon Hausmann
f9e561e21f Prospective fix for panic when running material style under Wayland/Gnome
When for example only a maximum height is set, but no maximum width,
avoid passing -1 or 0 to winit for the width. Instead use the same large
value was for Qt.

cc #2562
2023-04-18 08:57:01 +02:00
Olivier Goffart
875a7ea179 Parser: Nicer error when extra top-level semicolon
Recover from extra semicolon
2023-04-17 15:13:20 +02:00
Olivier Goffart
646450b758 Ci: test that the formatter don't introduce compilation error 2023-04-17 13:47:39 +02:00
Olivier Goffart
e54f4b45b8 fmt: Do what's required so that the test passes after formating 2023-04-17 13:47:39 +02:00
Olivier Goffart
d1dbd266ce fmt: fix @children 2023-04-17 13:47:39 +02:00
Olivier Goffart
8817921012 fmt: format if-else blocks 2023-04-17 13:47:39 +02:00
Tobias Hunger
9f527750e6 slintpad: Report problem when no service worker is available
This happens e.g. in firefox in private browsing mode. So suggest to
disable private browsing mode when this happens.

I think that is the best I can do in this circumstance: Without the
service worker a lot of stuff just breaks.

Closes: #2548
2023-04-17 13:29:32 +02:00
Simon Hausmann
d93d411031 doc: Explain a little how the virtual keyboard interacts with text input and visibility 2023-04-17 08:54:47 +02:00
Olivier Goffart
a30a5290e9 fmt: end the document with one newline
We used to end the file with the component without any newline.
But previous commit added eof in the document, so we end with the \n\n after the
component. Override that to only have one newline before the end
2023-04-17 07:58:18 +02:00
Olivier Goffart
a7b8bafdf9 Ensure completion in the document in case of parse error or empty document
Every token must be part of a document, including the EOF,
otherwise completion don't work at the end of the document.
2023-04-17 07:58:18 +02:00
Olivier Goffart
ee9f730a6d Parser: Don't parse everything as a component
The old parser always try first to find `Foo :=` from the old syntax so it
would error saying it expect an identifier or `:=`
But if we don't find a component, don't try to parse it as a component too early
This way we get better error and better auto-completions
2023-04-17 07:58:18 +02:00
Olivier Goffart
530fbf586c LSP: add auto-completion in the document top-level
Also add std-widgets.slint in the list of files to import
2023-04-17 07:58:18 +02:00
Olivier Goffart
40922874fa parser: don't parse error on empty import statement
Report the error later when loading the import.
That way, we get a more complete AST for auto-completion
2023-04-17 07:58:18 +02:00
Tobias Hunger
7d3968f025
contributing: Make the pre-commit section clearer: It is not required! 2023-04-15 18:22:38 +02:00
Cole Lawrence
af30896e4a Add always-on-top property to Window element 2023-04-15 13:58:47 +02:00
Olivier Goffart
82ae83ce8c Parser: don't have the whitespace as part of an expression
That way the error for an expression is at a better location, and
this also prevent the formater that removes space in expressions to
remove the spaces before the expression that shouldn't be removed
2023-04-14 17:46:19 +02:00
Simon Hausmann
2cb0b2233a Attempt at making the C/C++ ABI more robust
Add explicit enum values for repr(C) enums that have attributes like
cfg, so that even if there's a cfg gap in an enum (say cfg(feature =
"svg")) it won't break the ABI.

See also 004dce6c0b
2023-04-14 14:57:47 +02:00
Simon Hausmann
4ff5394dd2 docs: Fix names of exported virtual keyboard types
There's no MyVirtualKeyboard in virtual_keyboard.slint
2023-04-14 14:49:54 +02:00
Olivier Goffart
8f593187b4 fmt: more adjustment to the new syntax 2023-04-14 14:30:49 +02: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
45b99a74ce fmt: some adaptation to work with new syntax
Fixes: #2476
2023-04-14 13:51:33 +02:00
Simon Hausmann
7e08231650 C++: Enable /bigobj by default when building with MSVC
Large C++ files generated from .slint files can cause link problems with MSVC.
When that happens, MSVC itself suggests /bigobj as remedy.

It's not apparent that there's a downside to using this option, apart from
backwaords binary compatibility - which is not a concern for us.

The discussion at https://developercommunity.visualstudio.com/t/Enable-bigobj-by-default/1031214 suggests that perhaps this
will become the default one day.

To simplify our examples and avoid users running into this, let's enable it by default.
2023-04-14 13:13:03 +02:00
Zajozor
79f19b5750 Add formatting of for loops and arrays 2023-04-14 12:23:03 +02:00
Simon Hausmann
db29d01892 C++ docs: Fix red warning in generated HTML for file and namespace listings
The Furo theme by default generates a "on this page" contents list in
the right column. The breathe output for C++ namespace and file pages
also includes a ::contents:: RST directive, to summarize the available
headings. The duplication of these two is warned about by furo with a
big fat red warning.

Solve this by not making breathe generate the contents directive
anymore. According to

    https://exhale.readthedocs.io/en/latest/reference/configs.html?highlight=contentsspecifier#exhale.configs.kindsWithContentsDirectives

it's by default used for files and namespace, so make it empty in our
config.

Fixes #2505
2023-04-14 11:46:53 +02:00
Simon Hausmann
f57bab3650 In the virtual keyboard example, simulate not only key press but also release 2023-04-14 11:39:02 +02:00
Simon Hausmann
4d502a9f96 Add a C++ version of the Virtual Keyboard example 2023-04-14 11:39:02 +02:00
Florian Blasius
4a39cdbc86
swr: display text on text input (#2550) 2023-04-14 11:14:00 +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
7b26d6e58f Native ScrollView: Forward the minimum size 2023-04-13 19:23:20 +02:00
Olivier Goffart
75f0c3cc83 Fix resizing a ListView to empty height would make all items invisible even if resized back
The problem is that we would end up with a division by zero and the NaN
value would be cached as the average item height

Fixes #2545
2023-04-13 19:23:20 +02:00
Simon Hausmann
d2d920c99b janitor: Capitalize Slint 2023-04-13 10:52:45 +02:00
Simon Hausmann
1beeac75a2 Add screenshot to uefi demo 2023-04-13 10:45:53 +02:00
Simon Hausmann
b2bb8a93e5 uefi-demo: Try to keep the pre-rendered about slint at its preferred size
So that it doesn't look pixelated.
2023-04-13 10:19:42 +02:00
Simon Hausmann
0494488c51 Polish the UEFI demo a little
- Move the about slint logo to the front page and center it
2023-04-13 09:51:07 +02:00
Florian Blasius
bcb9d1ef83
virtual keyboard example (#2490)
* Update examples/virtual_keyboard/rust/Cargo.toml

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

* Update internal/core/window.rs

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

* Update internal/core/api.rs

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

* Update internal/core/api.rs

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

* Update internal/core/api.rs

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

* Update internal/core/api.rs

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

* code review fixes

---------

Co-authored-by: Simon Hausmann <simon.hausmann@slint-ui.com>
2023-04-13 08:36:40 +02:00
Simon Hausmann
004dce6c0b
Fix memory corruption when loading encoded embedded images in C++ (#2542)
The ImageCacheKey enum has a gap when not targeting wasm:

```
pub enum ImageCacheKey {
    /// This variant indicates that no image cache key can be created for the image.
    /// For example this is the case for programmatically created images.
    Invalid,
    /// The image is identified by its path on the file system.
    Path(SharedString),
    /// The image is identified by a URL.
    #[cfg(target_arch = "wasm32")]
    URL(SharedString),
    /// The image is identified by the static address of its encoded data.
    EmbeddedData(usize),
}
```

In the C++ generated header, that cfg was not mapped, and thus the URL
variant was always there, while in a regular slint-cpp build it's not.
Consequently tag value 2 in Rust was used to represent the EmbeddedData
variant, while in the C++ generated code that become variant 3 and 2 was
interpreted as a URL. So the receiving code in C++ tried to interpret
the cache key as URL variant, while Rust created it as EmbeddedData.

Co-authored-by: Olivier Goffart <olivier.goffart@slint-ui.com>
2023-04-12 16:43:37 +02:00
Simon Hausmann
ea769cb10c C++: Make sure embedded image data is declared const 2023-04-12 16:14:13 +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
Olivier Goffart
b565eb8820 Merge all the pinned field of the window in a common allocation 2023-04-12 14:49:08 +02:00
Olivier Goffart
b444feb1ca vscode: use |null to indicate some variable might be null
As per review in #2500
2023-04-12 12:03:08 +02:00
Olivier Goffart
78e81299b0 vscode extension: Add an option to show the preview in a tab 2023-04-12 12:03:08 +02:00