Commit graph

8816 commits

Author SHA1 Message Date
Olivier Goffart
18ba3c2ae2 Slint enums in Rust and C++ 2023-06-12 13:02:14 +02:00
Olivier Goffart
ac6f473a64 WIP: support for enum in slint
Parser and interpreter part
2023-06-12 13:02:14 +02:00
Olivier Goffart
a017265376 Fix 32bit build
The alignment of a HashMap within a Struct is 8 bytes because of the
RandomState.
This is important because the C++ allocated `interpreter::Struct` could
be mis-aligned
2023-06-12 10:40:56 +02:00
Olivier Goffart
85f32ca014 fixup previous commit 2023-06-12 08:57:28 +02:00
Olivier Goffart
690dbd723b C++: ensure that the alignment if the Opaque structures is big enough
CC: #2859
2023-06-12 08:53:15 +02:00
Update Translations Bot
be11cb0770 Update Translations: extract strings 2023-06-12 03:09:26 +00:00
Update Translations Bot
e1d6f60a70 Update Translations: extract strings 2023-06-11 03:14:21 +00:00
Simon Hausmann
ca3a6bd586 Fix Qt High-DPI support with the interpreter
See parent commit for details.
2023-06-10 11:41:04 +02:00
Simon Hausmann
e663282c65 Fix support for High-DPI with Qt
Preserve the early backend initialization of commit
f0b047057b
2023-06-10 11:41:04 +02:00
Simon Hausmann
d98c6773e1 Make window adapter creation lazy in the interpreter
The main change is that the window adapter is not copied into
sub-components anymore - instead it is accessed through the root.  This
is especially important for globals.

In order to add the root, a little extra dance had to be performance on
instantiation: The self_rc/self_weak is created first and the
ComponentExtraData's fields are populated via once_cells.
2023-06-10 11:41:04 +02:00
Simon Hausmann
fd2bb7fe73 Fix running nodejs tests with winit backend
Several tests rely on the testing backend being in place, as it starts
out with a scale factor of 1. The nodejs crate can't depend on the
unpublished testing backend to achieve that, so instead the selector's
backend is used. If that's Qt, then the scale factor is one. If it's
winit, it might be different. To override that, set
`SLINT_SCALE_FACTOR=1` for the nodejs process.
2023-06-10 11:41:04 +02:00
Simon Hausmann
5665df2cb8 interpreter: Clean up Rc<&dyn WindowAdapter> vs. &Rc<dyn WindowAdapter>
Consume the Rc in the function signature where the implementation would clone it anyway.

This is also needed in preparation for InstanceRef::window_adapter()
walking up the tree of components,
by which it's not possible to return a reference anymore as
parent_instance() returns a new lifetime that's shorter than &self
inside window_adapter().
2023-06-10 11:41:04 +02:00
Simon Hausmann
9b25bdb1d1 interpreter: Remove one more direct use of window_adapter_offset
That we we can encapsulate the lazy creation in the getter function.
2023-06-10 11:41:04 +02:00
Simon Hausmann
3604bdbf69 Prepare interpreter for lazy window adapter creation
Replace all call sites that call unwrap() on window_adapter_ref() with a call
that returns a &Rc<dyn WindowAdapter> and use an Option variant for register/unregister component.

For the former, in the future, we want to create the adapter if it doesn't exist.
For the latter we don't want to do that.
2023-06-10 11:41:04 +02:00
Simon Hausmann
4bb27d3196 Minor cleanup in interpreter WindowInner handling
Replace `fn window_ref(component) -> Option<& WindowInner)` with
`component.access_window(cb: impl FnOnce(&WindowInner))` as
all call sites unconditionally called unwrap() on them and by using the
pattern with a closure, we can in the future get the WindowInner from an
Rc<dyn Adapter> instead of an &Rc<dyn WindowAdapter>.
2023-06-10 11:41:04 +02:00
Simon Hausmann
01b00d26eb Rust: Allocate the window adapter lazily
This will be needed for embedding - to avoid creating two window
adapters - and it will be needed for the API to allow creating a
component from an existing window.
2023-06-10 11:41:04 +02:00
Update Translations Bot
2a7b20b794 Update Translations: extract strings 2023-06-10 03:04:02 +00:00
Olivier Goffart
1b03777642 Fr translation: Apply patch from Laurent Montel 2023-06-09 15:36:28 +02:00
Olivier Goffart
b690f789ab
LSP: code action for wrapping a string in @tr()
It only suggest the transformation for string that are directly within
an expression, so that's only string literals. (Not import, not image
macro, not already translated strings)

Drive by fix: fix the code action for showing the preview that was
broken because confusion between path and URL
2023-06-09 09:36:28 +02:00
Olivier Goffart
9e684d7c3e French translation of the printer demo 2023-06-09 07:57:38 +02:00
Tobias Hunger
ea8b5d3117
janitor: Another comment fix 2023-06-08 19:13:35 +02:00
Olivier Goffart
a6d8871d8d Printer Demo: improve a few strings 2023-06-08 19:13:24 +02:00
Olivier Goffart
9052fe09e8 Printer demo: wraps strings in @tr()
(doesn't include the native code, only .slint)
2023-06-08 19:13:24 +02:00
Tobias Hunger
9c50da9bde
janitor: Fix a few typos 2023-06-08 18:12:52 +02:00
Olivier Goffart
d8b0737b1d Translations: disable gettext by default for C++ and the viewer
Can cause problem when compiling on windows or mac
2023-06-08 16:56:10 +02:00
Olivier Goffart
95abde86e6 Translation: Use the (normalized) component name as context when none is provided
Note, this goes against the gettext documentation's recommendation:
https://www.gnu.org/software/gettext/manual/gettext.html#Contexts
> Finding a canonical msgctxt string that doesn’t change over time can be hard.
> But you shouldn’t use the file name or class name containing the pgettext
> call – because it is a common development task to rename a file or a class,
> and it shouldn’t cause translator work.
2023-06-08 16:55:52 +02:00
Simon Hausmann
764c0f4c7f Document the default context
As per #2850
2023-06-08 16:12:13 +02:00
Simon Hausmann
0ee603fe56 Rework the translation documentation
Provide an intro that outlines the overall steps, and then go into
details in each of them.

The C++ bit is marked with TODO, as I think we still have to sort out
some details there.
2023-06-08 16:12:13 +02:00
Olivier Goffart
15541bceeb slint-tr-extractor: extract the comment 2023-06-08 13:14:54 +02:00
Olivier Goffart
0ec1399f1b tr-extractor: allow to extract @tr from slint! macro in .rs files
This only understand the first slint! macro for now
2023-06-08 11:26:17 +02:00
Olivier Goffart
cb840660aa Make the extraction of slint! macro as part of the compiler core
This includes slint-viewer, slint-interpreter (when loading path, not
string), slint-compiler.

(This would also include internal things such as
`import { Xxx } from "foo.rs"`, if we didn't check for .slint or .60
extension before)

But that doesn't include anything that's not opening the source by path
(so not the lsp which use its own representation coming from the editor,
or varius tools like the updater and fmt which also open the files
themselves)
2023-06-08 11:26:17 +02:00
Olivier Goffart
1c033e7d72 CI: Cache Qt 2023-06-08 10:40:11 +02:00
Simon Hausmann
c813e80b48 Fix rendering of links in data structures where docs are shared between C++ and Rust
- in SetRenderingNotifierError using a rustdoc link breaks the C++ docs. Using a qualified backtick'ed slint::Window works perfect with both.
- In TimerMode, the same track unfortunately doesn't work with a function,
  but we can use [`Foo::bar()`] to make the link work with rustdoc and myst-parser.
  The look isn't perfect in C++, the square brackets are visible.
2023-06-08 10:02:15 +02:00
Simon Hausmann
031288b64c Fix broken link to NodeJS docs 2023-06-08 08:45:56 +02:00
Olivier Goffart
9b6093584d Ci: prospective fix for windows 2023-06-08 07:10:35 +02:00
Update Translations Bot
45c48a7b1a Update Translations: extract strings 2023-06-08 03:08:05 +00:00
Olivier Goffart
fcfb8ab8af CI: prospective fix of the macos build
I suspect DYLD_FRAMEWORK_PATH is reset to "" by some init script
when running /bin/bash that the github runner calls.

So reset it to wall cargo test
2023-06-07 21:46:12 +02:00
Olivier Goffart
db6110f3a9 janitor: move the test closer to the code they test 2023-06-07 17:32:56 +02:00
Olivier Goffart
1e80f010ea
Refactoring: Move the code to locate slint! macro to i-slint-compiler 2023-06-07 17:15:34 +02:00
Olivier Goffart
79ed90e848 CI: don't use deprecated actions-rs/cargo action
Just run cargo manually
2023-06-07 17:12:37 +02:00
Simon Hausmann
6bdddd94f8 janitor: Update to skia-safe 0.63 2023-06-07 13:58:20 +02:00
Simon Hausmann
fb1d37286f Clean up the Skia renderer API
Accept display and window handles with life time, instead of &dyn
HasRaw*Handle.
2023-06-07 12:20:57 +02:00
Simon Hausmann
af6b49a47d Simplify FemtoVG renderer API
For wasm builds, just require the canvas element.
2023-06-07 11:30:43 +02:00
Simon Hausmann
2b891b6097 winit: Remove the html canvas element from the GL context
It's not needed anymore. We can pass the canvas
element to the renderer once
and then we don't need it anymore.
2023-06-07 11:30:43 +02:00
Simon Hausmann
ff2a4ecb4e Cleanup: Use winit's HTML Canvas accessor instead of our own 2023-06-07 11:30:43 +02:00
Olivier Goffart
4100c5e63c Translations: documentation updates
Apply suggestions from code review

Co-authored-by: Simon Hausmann <simon.hausmann@slint-ui.com>
2023-06-07 10:34:34 +02:00
Olivier Goffart
16edca0030 More documentation for translations 2023-06-07 10:34:34 +02:00
Olivier Goffart
12e6b34e2d Translations: support for plurals 2023-06-07 10:34:34 +02:00
Simon Hausmann
92d461b4a2 Remove nodejs bit from the cache key for the build_and_test step
This step isn't using nodejs anymore
2023-06-07 09:57:08 +02:00
Simon Hausmann
0077cbd76c Run the node tests only with the stable rust 2023-06-07 09:56:26 +02:00