Commit graph

8246 commits

Author SHA1 Message Date
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
Tobias Hunger
7f95614a98
online editor: Only offer export options when appropriate
Gist: Whenever an editor is open.
permalink: Whenever exactly one editor is open.
2023-03-24 11:35:41 +01:00
Tobias Hunger
badd2730ee
online editor: Fix wrong name when adding a page
When the name of the new page did not end in .slint, then it would get
broken. Fix this.
2023-03-24 11:34:31 +01:00
Olivier Goffart
6711bf6ea6 Apply suggestions from code review
Co-authored-by: Simon Hausmann <simon.hausmann@slint-ui.com>
2023-03-24 11:15:05 +01:00
Olivier Goffart
35c5325fa5 Review the items that should have a stretch of 1 in a layout 2023-03-24 11:15:05 +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
b180661ff6 const propagation: simplyfy struct access
so that `{ min: 10px, max: 20px }.min`  get optimized
2023-03-24 11:15:05 +01:00
Olivier Goffart
8f52015fe5 WIP: layouting attempt to document the behavior we would like to have
For issue #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
9529be2162 Fix some warnings 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
Olivier Goffart
8cefde7c3a Remove space before => in quote_spanned
That's the style encouraged by the documentation
2023-03-24 11:14:48 +01:00
Olivier Goffart
20973bdb7b Report warnings from the slint! macro 2023-03-24 11:14:48 +01:00
Tobias Hunger
84fabee539 online editor: Allow exporting a project with multiple files to a gist 2023-03-24 10:58:40 +01:00
Tobias Hunger
973eae7d90 online editor: Allow to store a github access token
Not very comfortable, we should definitely allow for github logins! But
it gets us started.
2023-03-24 10:58:40 +01:00
Tobias Hunger
95dd7f862f online editor: Load slint files from gist
If a `slint.json` file is found, that one is parsed for extra
information like what is the main file and what extra mappings exists
(e.g. so you can redirect to images, etc. in different repositories).
2023-03-24 10:58:40 +01:00
Tobias Hunger
3c7587e972 online editor: Allow to add empty files to the edit session 2023-03-24 10:58:40 +01:00
Tobias Hunger
d4ebeb4718 online editor: Collect and expose information on mapped URLs and files
Expose more information on known (and unknown) files.
2023-03-24 10:58:40 +01:00
Tobias Hunger
bd17cf9433 online editor: Map file names to internal URLs
We have a lot of fun with the URLs/file names we use:

 * We need to map URLs (e.g. to store them in Gists), so we can not just use
   the external URLs everywhere :-(
 * We need some way to tell "internal" URLs from external ones
 * We want "https" as that works best in a browser: "file" tends to
   fail to load for security reasons, "inmemory" is no proper scheme.
 * LSP/Previewer and Editor disagree on the "inmemory" scheme, which has
   caused me headaches before.

So use https URLs with an authority of "<UUID>.slint.rs" and treat them
as internal URLs.
2023-03-24 10:58:40 +01:00
Tobias Hunger
dc391be74a online editor: Wait for service worker to be up in index.ts
Wait for the service worker to come up fully. The API is a bit unwieldy,
but we tell to not wait and to claim all clients, so it should come up
the first time round.
2023-03-24 10:58:40 +01:00
Tobias Hunger
4108d49430 online editor: Add a service worker
This service worker can be used to report and remap access to resources
from the previewer. We will need this feature to be able to meaningfully
export data.

This is not used yet!
2023-03-24 10:58:40 +01:00
Tobias Hunger
f7ea09e31c online editor: Update typescript config to newer JS flavor in lib
The code uses those features, so be explicit about them.
2023-03-24 10:58:40 +01:00
Tobias Hunger
799c9a9389
docs: fix some more links from rust docs into other docs 2023-03-24 10:18:04 +01:00
Tobias Hunger
96e477eaa7
ci: Fix up link-fix in nightly docs generation
We produced the wrong link till yesterday and now that this is fixed,
the link fixer needs a poke.
2023-03-24 09:50:53 +01:00
Simon Hausmann
ef07da4893 Add comment about resizing tweak on macOS 2023-03-23 15:36:42 +01:00
Simon Hausmann
c54e1cba43 Fix support on GLX displays with FemtoVG
In order for GLX support to work, we need to create the X11 window with
the same visual as in the GLX configuration. That requires delaying
the creation of the window.

This is done in four parts:

- The window builder is re-introduced in the winit backend create
  internal renderer interface.
- The glcontext helper code for wasm was moved into a separate function
  (less indentation).
- The loop over different display preferences was replaced with a
  preference to the "window system native GL interface" over EGL,
  which should achieve the same as the fix for #2162. Upstream glutin
  defaults to this and so do various downstream projects.
- Use glutin-winit for the actual display selection.

This covers the FemtoVG bits of #2269
2023-03-23 15:36:42 +01:00
Simon Hausmann
128fb25629 Enable support for additional image formats (webp, etc.) in the viewer, previewer, and nodejs bindings 2023-03-23 15:35:13 +01:00
Simon Hausmann
3839033300 Make it possible to use more than png and jpeg with Slint C++
Enable all the image formats the image-rs crate enables by default.
2023-03-23 13:28:39 +01:00
Olivier Goffart
88f9d0aed5 Slint docs style cleanups
- refresh copyright
 - link to slint-ui.com
 - add footer icons
2023-03-23 12:23:31 +01:00
Tobias Hunger
da95051db1
docs: Fix dead links between docs
... and add in text that went missing in the Globals section of the rust
docs.
2023-03-23 11:22:51 +01:00
Simon Hausmann
4ca6fd53c9 Re-add syntax highlighting in the Slint Language Docs 2023-03-23 09:34:16 +01:00
Simon Hausmann
4af7ea8ab7 Switch to the Furo theme for the Slint Language and C++ documentation 2023-03-23 09:34:16 +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
Simon Hausmann
89f5344b6b Disable automatic example preview in the docs for Safari 2023-03-22 12:42:41 +01:00
Olivier Goffart
c7a3a4139c Add a bunch of items to changelog 2023-03-22 12:31:46 +01:00
Olivier Goffart
cc28d24065 femtovg: speedup TextEdit with many lines
The break_text algorithm was O(N²) in the number of lines because
break_text needs to layout the whole text dspite it would in theory
only need the first line.
Trim the text we pass to break_text so we don't need to re-layout the
end for the text for every call.

This is still O(N²) if there are very long lines.
Not sure we can fix that with the current femtovg break_text api

This makes TextEdit with many lines much faster.  Still a bit slow, but
at least usable
2023-03-22 11:10:03 +01:00
Olivier Goffart
d5a4ec87e0 femtovg: increase font cache size
Otherwise, the cache is trashed with already moderate text size causing
TextEdit to become quickly very slow (unusable) when the text becomes a
bit big.

Big text are horribly still slow but at least now it can be used without
freezing the app for minutes
2023-03-22 11:10:03 +01:00
Olivier Goffart
ff89a38062 Update serde-wasm-bindgen 2023-03-22 09:49:54 +01:00
Olivier Goffart
0f29b9e434 i-slint-core-macros: update to syn 2 2023-03-22 09:49:54 +01:00
Olivier Goffart
8169b5629e const-field-offset: update to syn 2 2023-03-22 09:49:54 +01:00
Olivier Goffart
a2a29862a2 vtable: update syn 2023-03-22 09:49:54 +01:00
Simon Hausmann
c14ec0fb9c Update Skia
- This allows creating the Skia GL interface without string allocations
- Port the item renderer to use SkImageFilters::Shader instead of
  SkImageFilter::Paint
2023-03-21 09:36:39 +01:00
Olivier Goffart
47ac396bc0 compiler: turn a warning into an error
cc #2024
2023-03-20 19:13:10 +01:00
Olivier Goffart
c82bb1515e C++ image: add some docs
Note: Don't use cbindgen to generate `operator==` for public types.
Because it doesn't have docs and the documentation show warnings
otherwise
2023-03-20 17:22:56 +01:00
Olivier Goffart
ef7fb6422a C++ Image API: introduce the SharedPixelBuffer 2023-03-20 17:22:56 +01:00
Olivier Goffart
be47c8464c C++: implement creation of image from raw data
Issue #616
2023-03-20 17:22:56 +01:00
Simon Hausmann
c1dbe974ef Fix missing navigation sidebar in the slint language docs
The navigation sidebar requires jquery, which from Sphinx >= 6.0 needs
to be bundled via a separate extension. In the C++ docs Sphinx remains
at version 4.5.0 (due to exhale), but the slint language site doesn't
need exhale (no C++) and thus Pip ends up picking a newer Sphinx
version.
2023-03-20 16:04:07 +01:00
Tobias Hunger
fcf899cc6f online_editor: Add energy monitor demo 2023-03-20 15:31:51 +01:00
Tobias Hunger
28c35279e4 accessibility: Do not freeze trying to find items at position
Fix the code to always return a direct child widget or nullptr. The
documentation says to return a direct or indirect child, but the
implementation expects a direct child.

Fixes: #2195
2023-03-20 15:29:40 +01:00
Tobias Hunger
babe3cae2a
online_editor: Do not raise alerts abouts errors opening URLs the user did not explicitly open (#2380)
Do not raise an alert for URLs the LSP/previewer requested. This prevents breaking the flow as the user types an import statement which the LSP/previewer then can not find.

Continue to alert about problems with URLs explicitly opened by the user. This is important so that we do not silently fail when trying to open a file from an URL.

Fixes: #2377
2023-03-19 19:54:45 +01:00