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
Don't expose the internal type but create a public wrapper with the
builder pattern. That makes it easier to change defaults and it hides
internals like the callback futures.
For now the compiler also generates FooRc next to Foo, which wraps a
strong reference (VRc) to Foo.
This is an intermediate step and at the end of the series FooRc should
replace Foo and sixtyfps::ComponentHandle.
For regular builds this is done by adding Rust API that allows
registering a font, and for the web the font is installed into the
browser using JavaScript API.
This is an initial approach to just add this ability. It might make
sense to introduce a syntax in the `.60` file to allow for the
registration of fonts and letting the compiler generate code that
performs this embedding and registration automatically.
When referencing an image a repeated element and were targeting a
configuration that requires resource embedding, then that image would
not embedded.
This was due to the fact that we didn't recurse into sub-components in
the resource collection phase and the generators made a per-component
embedding decision. The field responsible for that was also not
propagated to sub-components.
This patch addresses these two bugs by cleaning up the entire mechanism:
The compiler first generates the new ResourceReference::AbsolutePath for
all img!"foo.png" expressions. If the compiler is configured to embed
resources, then the embed_resources pass will traverse all
sub-components and expressions in them to change them to
ResourceReference::EmbeddedData with a unique integer id. Simultaenously
all the resources to be embedded get also collected in the root
component, so that the build script as well as the generator can take
care of dependency handling and actual resource embedding.
Instead of determining the focus item through item tree traversal and
pointer comparison and storing the intermediate indices in the
components in the tree, remember the focus item by a pair of
VWeak<ComponentVTable, Dyn> and item_index: usize.
This speeds up determining the focus item as well as delivering events,
which can now be done directly after retrieving an ItemRef with
get_item_ref.
This also fixes the duplicate line edit focus in the 7gui cells
test case.
Last commit broke for structures containing models, because models are not PartialEq.
So we need to implement PartialEq for ModelHandle. Which means a struct needs to
be created
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
Currenly, dashes are normalized to '_'.
Dashes are not allowed at the begining of an identifier.
If an identifier with a dash is not found, we also look for identifier
without a dash and if that exist, we hint the user to use spaces.
Issue #52
Our language reference .md file contains a refernce to
builtin_elements.md. Since rustdoc doesn't further process the embedded
markdown file, the .md link remains as-is and is broken. But we can fix
it up using a small snippet of JavaScript.
Fixes#87