Commit graph

149 commits

Author SHA1 Message Date
Simon Hausmann
ad0c020aa4 Rename the sixtyfps-corelib crate 2022-02-01 18:04:30 +01:00
Tobias Hunger
a3b86690ff [reorg]: Move the rendering backends into internal 2022-01-31 16:00:50 +01:00
Olivier Goffart
929166f06c Change what is accepted by ModelRc::new and ModelRc::from
- ModelRc::new constructs a ModelRc from a impl Model
 - ModelRc::form constructs a ModelRc from a `Rc<dyn Model>` or `Rc<impl Model>`
2022-01-31 14:44:35 +01:00
Simon Hausmann
fb64e308b3 Align Rust interpreter instance handling API with the main Rust API crate
Implement `sixtyfps::ComponentHandle` for `ComponentInstance`, instead of providing a copy of the API.

This also removes `WeakComponentInstance` and enables the use of `sixtyfps::Weak` for weak handles. This has the advantage that `sixtyfps:Weak`'s `upgrade_in_event_loop` becomes available with the interpreter, and the
weak handle is Send.
2022-01-31 14:29:09 +01:00
Tobias Hunger
018c1a6666 Rename ModelHandle to SharedModel
This patch is mostly a rename now, but also contains a few small
cleanups.

SharedModel implements the Model trait itself and gracefully falls back
to an empty model is no Model was provided. This allows for some small
simplifications.

Also make sure to use the same comparision for SharedModels everywhere.
This fixes the last remaining clippy errors we had.
2022-01-30 01:26:35 +01:00
Olivier Goffart
02bfdda0e3 Use ModelHandle in Value::Model
As a drive by change, remove the special comparison
for the SharedVectorModel. Two different model that have the
same elements are still not equal
2022-01-27 18:37:36 +01:00
Simon Hausmann
de40e002c3 WIP: Remove sixtyfps_interpreter::Value::Array
This is never created
2022-01-27 18:37:36 +01:00
Tobias Hunger
c02da14dc8 Move from stuctopt to clap 3
* Do not explicitly enable color output: That is default anyway
* Consistently use from_os_str() for file pathes
* Fix wrong types used in some places
2022-01-10 16:53:08 +01:00
Tobias Hunger
11d46892e4
janitor: Remove some unnecessary lazy evaluation 2022-01-04 18:22:49 +01:00
Tobias Hunger
767704a88b
janitor: Remove some redundant closures 2022-01-04 18:21:07 +01:00
Tobias Hunger
bfca0e3573 Mass update copyright messages to be more REUSE compliant 2021-12-22 10:06:12 +01:00
Olivier Goffart
82a1cc1e83 Viewer: Added way to execute commands on callbacks 2021-10-12 13:58:52 +02:00
Olivier Goffart
d058e4c10e Viewer: Make the "Close" button properly close 2021-10-07 11:26:09 +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
Olivier Goffart
cf2e189245 Small fix to the viewer docs 2021-09-30 11:48:09 +02:00
Olivier Goffart
7db9f3dfa9 Dialog: automatically add clicked callback for the standard button
And make the viewer listen to them and set them to automatically close dialogs
2021-09-30 10:21:13 +02:00
Simon Hausmann
21f9850b43 Small spelling fix 2021-09-29 14:55:08 +02:00
Olivier Goffart
0eb223b2ca Update tools/viewer/main.rs
Co-authored-by: Simon Hausmann <simon.hausmann@sixtyfps.io>
2021-09-24 09:23:48 +02:00
Olivier Goffart
321d985242 Viewer: add ability to load and save property values from/to json
issue #238
2021-09-24 09:23:48 +02:00
Olivier Goffart
fe015a8086 Allow the sixtyfps-compiler and sixtyfps-viewer to read from stdin
By specifing `-` as a path
2021-09-09 15:30:52 +02:00
Tobias Hunger
1d71a2beeb Janitor: Fix clippy::collapsible_if 2021-08-09 13:19:34 +02:00
Tobias Hunger
24a2021226 Janitor: Fix clippy::needless_borrow 2021-08-04 22:50:35 +02:00
Simon Hausmann
29f5853332 Provide sixtyfps::Window by reference in the Rust API
This also removes Clone from the Window again, to avoid having to face
the question: Does cloning a window duplicate it on the screen?
2021-08-03 10:32:04 +02:00
Tobias Hunger
4bd8920ac4 Janitor: Fix clippy::declare_interior_mutable_const 2021-07-21 19:44:57 +02:00
Tobias Hunger
dc51d4ccda Use impl Default instead of new() constructors 2021-07-12 13:22:25 +02:00
Olivier Goffart
13bd828b96 Update license date 2021-07-02 15:55:54 +02:00
Simon Hausmann
cec7dde6e6 Small typo fixes 2021-06-30 16:12:39 +02:00
Olivier Goffart
ffb0a9881b Add command line arguments to the LSP
To set the include path, the style, or the backend
2021-06-09 17:15:49 +02:00
Olivier Goffart
1c505edd09 Revert the change to depends on the public crate from our tools
We should probablt re-ecport the function from the interpreter, but one
shouldn't depends both on sixtyfps and sixtyfps-interpreter at the same
time
2021-05-25 15:53:49 +02:00
Simon Hausmann
73f647c2e1 Add the Rust equivalent of sixtyfps::invoke_from_event_loop
The same API exists in C++.
2021-05-25 15:53:49 +02:00
Olivier Goffart
31a830e66d viewer: when watching, we also need to watch the main file 2021-04-15 15:05:09 +02:00
Simon Hausmann
afe3df6381 Remove the public API for registering fonts by path or memory chunk
This is not needed anymore in the light of being able to write `import "blah.ttf"` in .60 markup
2021-04-14 10:01:33 +02:00
Olivier Goffart
15298f5626 Add the --auto-reload option to the viewer 2021-04-13 13:55:01 +02:00
Simon Hausmann
4a9cd954b8 Rework the Rust entry point API for the interpreter
Switch to the stateful `ComponentCompiler` concept that we discussed for the C++ API.
2021-03-18 18:20:50 +01:00
Olivier Goffart
48333370a6 Use the new interpreter API in things that depends on it 2021-03-15 17:29:27 +01:00
Simon Hausmann
409475aed2 Rename viewer --font=blah.ttf to viewer --load-font=blah.ttf 2021-02-17 15:30:20 +01:00
Simon Hausmann
445ddd58d5 API cleanup
Remove the `application` infix from `register_application_font`, to
reduce the changes that it might be interpreted to be a function that
also changes the default font in all text elements.
2021-02-17 14:37:31 +01:00
Simon Hausmann
45fe6c3e8d Add the ability to load application fonts by path
The viewer command line tool also gains the ability to specify them via `--app-font=/path/to/font.ttf` , which can be specified multiple times.
2021-02-17 14:16:52 +01:00
Simon Hausmann
5f265ffc09 Split up ComponentWindow::run() into show(), hide() and sixtyfps::run_event_loop()
This allows creating multiple windows for example, and it will allow for
showing windows in those tests that require a mapped window.

As a bonus, the run() function on generated components is not consuming
anymore.
2021-01-19 09:50:22 +01:00
Simon Hausmann
87e0cc7d85 Fix resource embedding doing a wasm build of a project using the sixtyfps! macro
We need to embed resources in wasm builds. Unfortunately we can't detect
that we're called by say wasm-pack and "TARGET"/"HOST" only works inside
build.rs. So instead, to keep things simple, this change always embeds
the image resources when targeting Rust.

The `SIXTYFPS_EMBED_RESOURCES` environment variable can be used to
override this anywhere for any language.

Fixes #130
2020-12-10 15:09:32 +01:00
Simon Hausmann
c258a907f0 Simplify event loop start-up
Move the layout constraint tracker into the window where we can apply
the constraints right before drawing, instead of doing that from within
the event loop. This allows to remove the component parameter from the
run function.
2020-11-12 15:04:48 +01:00
Simon Hausmann
5d744c86c2 Begin passing the VRC<ComponentVTable, Dyn> into the run-time library
First by changing the signature of run() and by adding a self_weak
to the C++ struct.
2020-11-11 18:31:51 +01:00
Simon Hausmann
02904c4014 Simplify signature of Component::run
We don't need to pass the root item anymore since ComponentVTable
has now get_item_ref.
2020-11-11 15:55:03 +01:00
Olivier Goffart
e4e7ae46f4 Support for for in box layout in the interpreter 2020-10-31 11:24:31 +01:00
Olivier Goffart
359f42c5f7 Prepare the compiler to be async
This will allow the online editor to load imports from URL asynchroniously later

Since currently the compiler is only working on a single thread, and that we
never await on a future that could block, it is allowed to use the spin_on executor
2020-10-30 15:00:04 +01:00
Olivier Goffart
d57ad389e0 Default to the native style in the viewer if it is available 2020-10-14 14:51:47 +02:00
Simon Hausmann
ff9c118e07 Propagate warnings to the end of the compilation step and print them 2020-09-04 20:34:20 +02:00
Olivier Goffart
f1ad78bc25 Qt style support for the rust backend
Need to set the SIXTYFPS_STYLE=native env variable while compiling
2020-09-01 12:25:11 +02:00
Olivier Goffart
6d41b1981d Move the Qt style to a new backend: the Qt backend
Currently the Qt backend still redirect everything to the GL backend,
but the goal is to use QPainter and QWindow

This also adds a "default" backend, whose goal is to select the proper
backend at compile time
2020-08-31 17:26:04 +02:00
Olivier Goffart
58cdaeb8dd Update license header to mention that commertial option are available 2020-08-26 13:23:42 +02:00