Commit graph

5155 commits

Author SHA1 Message Date
Simon Hausmann
8eda32cf3f Fix build / formatting 2021-10-06 22:03:01 +02:00
Simon Hausmann
bf6aaf4657 Rename the embed_resources pass to embed_images
... because that's what it does, it only looks at image references.
2021-10-06 21:28:35 +02:00
Simon Hausmann
7aa6545046 Enable support for gzipped SVG
usvg detects gzipped SVG by looking at the first bytes, and Qt supports it as well.
2021-10-06 21:24:44 +02:00
Olivier Goffart
72d556113f Visit globals when finding usages of structs
Otherwise some used struct might not be found, and they can cause
compilation failure in the generated C++ or Rust code

Fixes #549
2021-10-06 18:48:06 +02:00
Olivier Goffart
7939d834d4 Fix panic in the interpreter if there are properties that are aliased to struct 2021-10-06 18:33:27 +02:00
Simon Hausmann
7102f9b997 Fix standard button OK text
Ok -> OK
2021-10-06 16:16:39 +02:00
Simon Hausmann
0bfb0fce4e Fix capitalization of simple input dialog 2021-10-06 16:15:32 +02:00
Olivier Goffart
aad9921ed2 Revert "Update link of the interpreter in the documentation"
This reverts commit 2fffeba7cb.
2021-10-06 15:55:05 +02:00
Olivier Goffart
a1069e94f0 Fixup the publish script
the GL bakcend don't compile alone without specifying a feature
2021-10-06 15:55:05 +02:00
Simon Hausmann
301f142001 Add missing colon for simple input dialog eaxmple 2021-10-06 15:24:48 +02:00
Olivier Goffart
2fffeba7cb Update link of the interpreter in the documentation 2021-10-06 14:55:32 +02:00
Olivier Goffart
4844450d01 Update the version in docs 2021-10-06 14:54:22 +02:00
Simon Hausmann
6dce5ab32e Fix rendering of push buttons with QStyle on macOS
The button bevel was rendered upside down, which happens due to some
weird double y-axis inversion, which goes away when passing the QWidget
pointer to the style. When using the Qt backend, we can do that.
2021-10-06 14:39:56 +02:00
Olivier Goffart
db10bf2187 Fix embedded window icon with the Qt backend
Also add a window icon to the gallery
2021-10-06 12:39:22 +02:00
Olivier Goffart
106f1b756b Fix sixtyfps-build always forcing a rebuild when a builtin image is include
We can't call return-if-changed with "builtin:" URL, otherwise cargo
thinks the build script always need to be re-run

Fix the gallery example always being rebuilt because it uses AboutSixtyFPS
2021-10-06 12:28:30 +02:00
Simon Hausmann
4c6c8233c0 Qt style: Improve default layout spacing on macOS
When the PM_LayoutHorizontalSpacing pixel metric is negative, we're supposed to call
layoutSpacing() on the style. Until we have a detailed
overview over the controls, a default spacing is better than -1 :-)
2021-10-06 11:10:58 +02:00
Olivier Goffart
a1b27c47ae Small cleanup
The is_standard_button is alays true because the None path returns a few line before
2021-10-06 10:53:30 +02:00
Simon Hausmann
d43e0a1c83 Qt style: Only show icons in standard buttons if the style permits 2021-10-06 10:45:31 +02:00
Olivier Goffart
aa05e96d22 Native style: properly initialize the layout padding 2021-10-06 10:43:32 +02:00
Olivier Goffart
db4bc5338a Make the upgrade_version.yaml also upgrade the version string in AboutSixtyFPS 2021-10-06 10:43:32 +02:00
Simon Hausmann
cabc06ad30 Provide a section for the 0.1.3 release in the changelog
This way we can link to it. More edits to be done on the changelog later.
2021-10-06 09:59:53 +02:00
Simon Hausmann
2ecf6c61d4 Minor cleanup: include the path in the error message when embedding an image fails 2021-10-06 09:44:06 +02:00
Olivier Goffart
d5ad9ebe0e Improve the macro from the previous commit
I have the feeling that having less 'write!' will lead to better code
2021-10-06 09:02:43 +02:00
Olivier Goffart
521bf192f8 Improve error message for parse error
print the literal token symbol instead of the internal token name
2021-10-06 08:54:14 +02:00
Simon Hausmann
517b731e7b Fix CI build
Turn message about inability to embed images into a warning for now

We do test our tutorial and in the CI build we enforce embedding,
so the icon paths there don't work.
2021-10-05 23:16:46 +02:00
Simon Hausmann
b3a5cfb74d Fix typo in about widget text 2021-10-05 23:16:46 +02:00
Simon Hausmann
29f9dd5f5c Minor cleanup in about widget
Remove the copyright statement, as it may give a misleading
impression about the copyright of the app.
2021-10-05 23:16:46 +02:00
Simon Hausmann
c23f98968e Add missing newline for doctests 2021-10-05 23:16:46 +02:00
Simon Hausmann
88ad176008 Improve diagnostics when images cannot be located for embedding
This is a two-stage change, that first centralizes the file I/O code
path for on-disk and builtin:/ files. Secondly the resource embedding
pass now produces diagnostics if a file cannot be located.
2021-10-05 23:16:46 +02:00
Simon Hausmann
4b267a8e9b Internal cleanup: Simplify string handling when accessing compiler-embedded files
For loading images that are included in the widget library that's included in turn
in the compiler binary, we need to create ImageInner::EmbeddedData
with &'static data and &'static file extension. The latter was
created using string interning, but we can also access the path of the
widget library data structure.
2021-10-05 23:16:46 +02:00
Simon Hausmann
df9e9dd1de Minor cleanup in C++ code generator
Use Cow<[u8]> to avoid making a copy of the file data embedded in the compiler.
2021-10-05 23:16:46 +02:00
Simon Hausmann
332b149610 Add support for accessing resources from the embedded widget library in the interpreter 2021-10-05 23:16:46 +02:00
Simon Hausmann
4a26faef9a Add AboutSixtyFPS element 2021-10-05 23:16:46 +02:00
Tobias Hunger
d79894769b viewer: Prettify help output
The options in sixtyfps-viewer --help used to look like this:

```
OPTIONS:
        --backend <backend>                         The rendering backend [default: ]
    -I <include path for other .60 files>...
        --load-data <load data file>                Load properties from a json file ('-' for stdin)
        --save-data <save data file>                Store properties values in a json file at exit ('-' for stdout)
        --style <style name>                        The style name ('native', 'fluent', or 'ugly') [default: ]
```

This patch removes the useless "[default: ]" part. These are options,
so even without this text it should be very obvious that the `--style`
and the `--backend` parameters are indeed optional.
2021-10-05 21:40:13 +02:00
Simon Hausmann
b8ecbadea9 Embed files in the internal "library" in the compiler as binary
That way we can also embed PNG files or others in the future
2021-10-05 15:06:25 +02:00
Simon Hausmann
ac5ee89537 Enable resource embedding C++ build coverage
In the CMake build on Linux, enable resource embedding.

This is a compromise clearly - it would be best to enable it on all, but
OTOH this slows down compilation. There's also no test for whether this
works at run-time, it would be best to have an API for that, i.e. the
ability to annotate an @image-url.
2021-10-05 15:05:50 +02:00
Simon Hausmann
4058f95ebb C++: Improve the embedded image generation code
* Allocate less by using only two format!() calls
* Escape the extension properly and mark the string as u8 literal, like
  we also do for paths.
2021-10-05 15:05:50 +02:00
Simon Hausmann
7cb30e1e07 C++: Reduce extra allocations when formatting string for data embedding 2021-10-05 15:05:50 +02:00
Simon Hausmann
19b2415ba4 Minor formatting cleanups 2021-10-05 15:05:50 +02:00
Simon Hausmann
c91a38cdce Add support for embedding data in generated C++ code
This allows compiling with SIXTYFPS_EMBED_RESOURCES=true and
images/fonts are embedded as inline variables.

Generated data is emitted into the header file as

   inline uint8_t sfps_embedded_resources_123[789] = {
       0x1, 0x2, 0x3,
   };
2021-10-05 15:05:50 +02:00
Simon Hausmann
30e79d3ea2 Fix panic with GL backend when using non-existent font families
The database is not empty, as the changed expect() suggests, but instead
it just means that the family could not be found. This can happen for
example with something like this:

export App := Window {
    Text {
        text: "Ok";
        font-family: "Non-existent";
    }
}

or it can also happen when loading the printer demo in the online
editor, where a custom font is supposed to be available but that's not
implemented for wasm builds.

So instead of panicing, fall back to querying for a last-resort
sans-serif family.

For Linux, we register fontconfig's choice for sans-serif, otherwise
fontdb has defaults for macOS and Windows, and for wasm we register our
copy of DejaVu. So that cannot really fail....
2021-10-05 14:03:17 +02:00
Olivier Goffart
80d7b2ebe8 Hard error when not calling a callback
While before it was silently ignored or caused error in the generated code.

Fixes #542
2021-10-05 12:56:26 +02:00
Simon Hausmann
05b7d3e2ee Avoid over-eager animation ticks
Only update animations on input events and when the windowing system requests a redraw.
2021-10-05 12:43:11 +02:00
Simon Hausmann
e987a4aba3 Fix granularity of run-time borrows in GL backend window handling
When processing window specific events, or generally when accessing
the ALL_WINDOWS refcell, keep the time for borrow to an absolute
miniumum. That way any subsequent method calls may further acquire the
refcell.

This patch re-organizes the entire deeply nested window event handling
in a function with slightly less indentation.

Fixes a panic when calling hide on a Window from within a callback
handler.

Fixes #539
2021-10-05 12:43:11 +02:00
ogoffart
8b9717633e Bump version number to 0.1.3 2021-10-05 10:31:45 +00:00
Olivier Goffart
a516a3c568 Bump toml_edit version 2021-10-05 12:24:45 +02:00
Olivier Goffart
ae3e1b4680 Allow normal Element to be in the Dialog's button row with dialog-button-role 2021-10-05 09:46:20 +02:00
Simon Hausmann
fcf55084ab Show the OS name in the sysinfo example 2021-10-04 16:47:28 +02:00
Simon Hausmann
02e01ba04f Show host uptime information 2021-10-04 16:38:18 +02:00
Simon Hausmann
f0fc877f4e Combine the CPU and Mem tab into a General one 2021-10-04 16:38:18 +02:00