slint/tools/viewer
Olivier Goffart 38d7ac42eb Add compatibility feature to our public crates
We want to be able to put existing functionality behind a feature flag while keeping
the semver compatibility.
This is only possible if that new feature flag is enabled by default, but this is not
working if the users have done `default-features = false` in their Cargo.toml.
So we add new `compat-x-y-z` feature that is mandatory to have and which is
enforced with a `compile_error!`

Now, users that whishes to not have the default features must enable it explicitly.
Say we want only x11 but not qt and wayland, the user will do
```toml
sixtyfps = { version = "0.2", default-features = false, features = ["x11", "compat-0-2-0"] }
```

Now, imagine that in the version 0.2.3, we put the SVG support behind a feature flag.
we will do this in out Cargo.toml:

```toml
[features]
default = ["compat-0-2-0", "x11", "wayland"]
compat-0-2-0 = ["compat-0-2-3", "svg"]
compat-0-2-3 = []

svg = [...]
...
```

That way, the svg feature will be enabled by default for all the users who used previous version
of SixtyFPS, and people that want to disable "svg" can just change from compat-0-2-0 to
compat-0-2-3 in their Cargo.toml
2022-01-31 17:30:24 +01:00
..
LICENSES Update license information 2022-01-20 14:45:02 +01:00
Cargo.toml Add compatibility feature to our public crates 2022-01-31 17:30:24 +01:00
main.rs [reorg]: Move the rendering backends into internal 2022-01-31 16:00:50 +01:00
README.md Remove path to non-existent bin directory 2021-10-22 17:15:07 +02:00

Viewer for SixtyFPS

This program is a viewer for .60 files from the SixtyFPS Project.

Installation

The viewer can be installed from crates.io:

cargo install sixtyfps-viewer

Alternatively, you can download one of our pre-built binaries for Linux or Windows:

  1. Open https://github.com/sixtyfpsui/sixtyfps/releases
  2. Click on the latest release
  3. From "Assets" download either sixtyfps-viewer-linux.tar.gz for a Linux x86-64 binary or sixtyfps-viewer-windows.zip for a Windows x86-64 binary.
  4. Uncompress the downloaded archive and run sixtyfps-viewer/sixtyfps-viewer.exe.

Usage

You can open .60 files by just passing it as an argument:

sixtyfps-viewer path/to/myfile.60

Command line arguments

  • --auto-reload: Automatically watch the file system, and reload when it changes
  • --save-data <file>: When exiting, write the value of public properties to a json file. Only property whose types can be serialized to json will be written. This option is incompatible with --auto-reload
  • --load-data <file>: Load the values of public properties from a json file.
  • -I <path>: Add an include path to look for imported .60 files or images.
  • --style <style>: Set the style. Defaults to native if the Qt backend is compiled, otherwise fluent
  • --backend <backend>: Override the SixtyFPS rendering backend
  • --on <callback> <handler>: Set a callback handler, see callback handler

Instead of a path to a file, one can use - for the standard input or the standard output.

Callback handler

It is possible to tell the viewer to execute some shell commands when a callback is recieved. You can use the --on command line argument, followed by the callback name, followed by the command. Within the command arguments, $1, $2, ... will be replaced by the first, second, ... argument of the callback. These will be shell escaped.

Example: Imagine we have a myfile.60 looking like this:

MyApp := Window {
  callback open-url(string);
  //...
}

It is possible to make the open-url callback to execute a command by doing

sixtyfps-viewer --on open-url 'xdg-open $1' myfile.60

Be carefull to use single quote or to escape the $ so that the shell don't expand the $1

Dialogs

If the root element of the .60 file is a Dialog, the different StandardButton might close the dialog if no callback was set on the button.

  • ok, yes, or close buttons accepts the dialog
  • cancel, no buttons reject the dialog

Result code

The program returns with the following error code:

  • If the command line argument parsing fails, the exit code will be 1
  • If the .60 compilation fails, the compilation error will be printed to stderr and the exit code will be -1
  • If a Window is closed, the exit code will be 0
  • If a Dialog is closed with the "Ok" or "Closed" or "Yes" button, the exit code will be 0
  • If a Dialog is closed with the "Cancel" or "No" button, or using the close button in the window title bar, the exit code will be 1

Examples

sixtyfps-viewer can be used to display an GUI from a shell script. For examples check out the examples/bash folder in our repository.