Commit graph

253 commits

Author SHA1 Message Date
Simon Hausmann
cb0aeb0db7 Minor GenericWindow trait cleanup
The trait functions don't need to consume an Rc, it turns out.
2020-06-16 14:42:13 +02:00
Simon Hausmann
8d7395099c More main window cleanups
Fold the standalone functions of rendering and input event processing into the
generic window trait impl
2020-06-16 14:03:57 +02:00
Olivier Goffart
6122f91fba Begin with the generation of rhe repeater (rust only for now) 2020-06-16 13:47:02 +02:00
Simon Hausmann
2fba097e81 Clean up window registration
Automatically register the weak ref in the "constructor" of the main
window and de-register on drop.
2020-06-16 13:33:16 +02:00
Simon Hausmann
0e0ace8591 Separate window from the event loop
Remove the window parameter from the run_event_loop function. Instead
the windows are kept in a global hash map, keyed and retrieved by window
id.
2020-06-16 13:06:56 +02:00
Simon Hausmann
0dd1d953aa Prepare for cleaner separation between window and event loop, part 5
Make the main window a reference counted type. That'll allow keeping
track of all windows safely in the future.
2020-06-16 13:04:43 +02:00
Simon Hausmann
3451048842 Prepare for cleaner separation between window and event loop, part 4
Make run_event_loop operate on a GenericWindow trait. It's still an impl
right now (so static dispatch), but that's just cosmetic.
2020-06-16 11:34:21 +02:00
Simon Hausmann
d3c6ae5c81 Prepare for cleaner separation between window and event loop, part 3
Make run_event_loop a standalone function that takes a mainwindow
parameter. This is in preparation for running with multiple windows.
2020-06-16 11:06:45 +02:00
Simon Hausmann
4b1f50a452 Prepare for cleaner separation between window and event loop, part 2
Move the event loop member out of MainWindow.
2020-06-16 11:03:52 +02:00
Simon Hausmann
91e7107f9e Prepare for cleaner separation between window and event loop, part 1
Move the rendering preparation, actual rendering and input processing
callbacks into standalone functions. They don't
really need to be variable parameters.
2020-06-16 11:03:49 +02:00
Simon Hausmann
0aa4d85c92 Start with data structures for animations, with a duration and basic controls 2020-06-15 18:02:23 +02:00
Olivier Goffart
e9b75d30b7 Add a bunch of deny(unsafe_code) 2020-06-12 21:04:27 +02:00
Olivier Goffart
95f63795d5 Gate the corelib::rtti module on the rtti feature 2020-06-12 21:04:27 +02:00
Olivier Goffart
7c5ce4fea5 Add missing file 2020-06-12 21:04:27 +02:00
Olivier Goffart
30b201d946 Reduce the use of unsafe in corelib and in the rust backend 2020-06-12 19:03:15 +02:00
Olivier Goffart
bbb2b487b9 Implement a way to create a VRef for non static vtable 2020-06-12 17:09:51 +02:00
Olivier Goffart
e7644eba94 Fix C++ compilation with the new item visitor 2020-06-12 17:09:51 +02:00
Olivier Goffart
66dc643bf9 WIP: refactor the item visitor
The C++ part hasn't been ported yet and some things still need polish

Introduce a visitor to not rely on the unsafe ItemTreeNode array.
2020-06-12 13:32:40 +02:00
Olivier Goffart
0d4f370e95 Fix linking error in the tests
We also need to link against corelib
2020-06-10 19:53:06 +02:00
Olivier Goffart
9c23326c60 Layout for the C++ as well 2020-06-10 19:41:24 +02:00
Olivier Goffart
907bea3d3b Layout for rust 2020-06-10 19:41:24 +02:00
Olivier Goffart
96a372e45d Grid layout in the interpreter
current imploementation is just a prototype
2020-06-10 19:40:47 +02:00
Olivier Goffart
ed69f4c432 WIP layouts 2020-06-10 19:40:47 +02:00
Olivier Goffart
89968e0722 Add a Slice type which can be used in FFI 2020-06-10 14:23:57 +02:00
Olivier Goffart
7106e354a3 Fix C++ compilation
The generated cbindgen would otherwise not compile
2020-06-10 13:45:01 +02:00
Olivier Goffart
bd4bcdfeb3 Even better way to use enums from C++ 2020-06-10 10:18:27 +02:00
Simon Hausmann
1404cb73ae Add support for embedding resources in the rust generator
This is relatively straight-forward via a pass in the compiler to
collect the resources to embed and then use include_bytes! (once per
resource).

What's really annoying is that the rust resource enum can't store a
&'static [u8] because cbindgen doesn't represent that, probably because
the slice representation isn't guaranteed to stay as it is. So instead
this, for now, uses raw pointers.
2020-06-09 22:54:29 +02:00
Simon Hausmann
5bae6e01a5 Prepare for the ability to embed image data
The Image's source property used to be a string. Now it is a Resource
enum, which can either be None or an absolute file path to the image on
disk. This also replaces the internal Image type.

The compiler internally resolves the img bang expression to a resource
reference, which shall remain just an absolute path. For now the target
generator passes that through, but in the future the target generator
may choose a target specific way of embedding the data and thus
generating a different Resource type in the final code (through
compile_expression in the cpp and rust generator).

The C++ binding is a bit messy as cbindgen doesn't really support
exporting enums that can be constructed on the C++ side. So instead we
use cbindgen to merely export the type internally and only use the tag
from it then. The public API is then a custom Resource type that is
meant to be binary compatible.
2020-06-09 22:54:29 +02:00
Simon Hausmann
afd7319ae5 Rename corelib to sixtyfps_corelib
This is consistent with the other packages and since corelib is now also
a cdylib, libsixtyfps_corelib.so looks much better than libcorelib.so
:-)
2020-06-09 13:27:18 +02:00
Simon Hausmann
547a732e33 Fix rebuild issues, part 10523
By setting RUSTFLAGS in the Cargo config we run into the situation that
when doing a host build, all rust files are compiled with the flags,
including build.rs. When cross-compiling, build.rs is not build with the
RUSTFLAGS specified. That makes kind of sense, but it also means that
all the build scripts are always recompiled when switching between a
target and a host build - and that applies to *all* packages, including
dependencies.

So short of a better solution, this patch removes the need to set
RUSTFLAGS. It was used to extract the system library dependencies for
the static library we'd create. Instead we're now building two shared
libraries and are linking against them. They contain the rust library
twice, so that's not really a desirable final state either, but
productivity wins right now :-)

It might make sense to go back to creating *one* shared library through
a dedicated crate and -- since 'pub extern "C"' functions are not
transitively exported, it may require re-exporting them by hand or using
some clever build trick perhaps.
2020-06-09 13:08:59 +02:00
Olivier Goffart
c05da294a1 Add GridLayout and Row
The compiler currently lowers them to nothing
2020-06-09 12:46:16 +02:00
Olivier Goffart
34931e58c0 Polishing of the documentation 2020-06-08 17:57:18 +02:00
Olivier Goffart
89b77937bb Put some sensible value into the LayoutInfo struct 2020-06-08 17:55:10 +02:00
Simon Hausmann
fb2b12c28a Implement basic text rendering on the wasm port
Based on Olivier's suggestion, the text rendering primitive is created
by painting the text onto a temporary HTML canvas
element and binding that to a texture.
2020-06-08 17:00:59 +02:00
Simon Hausmann
2c1ecc7478 Revert attempts to make emscripten build work
This reverts commit aef96cb7d8, commit
1b2d0a309f, and commit
82214dc2d7.

The wasm32-unknown-emscripten target is not very well supported right
now, from build issues in instant/winit to toolchain issues
(https://github.com/rust-lang/rust/issues/66916).

So let's not go down that route for now.
2020-06-08 14:54:24 +02:00
Simon Hausmann
aef96cb7d8 Refine winit stdweb feature selection
Amend commit 1b2d0a309f by restricting the
stdweb choice only when targeting emscripten.
2020-06-08 13:14:32 +02:00
Simon Hausmann
1b2d0a309f Fix wasm32-unknown-emscripten build of corelib
Depend on a version of winit that enables the use within emscripten.
2020-06-08 13:04:48 +02:00
Olivier Goffart
4b7f8e2d04 Fix building of corelib for wasm
Wasm does not have the run_return function, so use the trick with
scoped_tls to have non-static functions
2020-06-08 09:22:38 +02:00
Olivier Goffart
9fc60e104f Add another way to load .60 files from a build script 2020-06-05 13:45:38 +02:00
Olivier Goffart
0553ab8b1a Use env::var_os instead of env::var
For the unliekly case in which the git repository is checked out in a directory
that cannot be represented with unicode
2020-06-05 13:45:37 +02:00
Simon Hausmann
33cfe03dc9 Rework the C++ facing build system, part 1
The objective is to automatically create a propery cmake module, with a
FindSixtyFPSConfig.cmake, corresponding targets .cmake files, etc. This
should encapsulate the build profile (debug vs. release) and also allow
making the choice of shared vs. static transparent.

Unfortunately it does not seem to be possible to easily combine different
crates into one cdylib crate that can re-export symbols from the
statically linked rust crates (cbindgen generated, as well as manual
extern "C").

That means for the dynamic case (not cared for right now), we're going
to need to create either one cdylib per crate that has public symbols or
manually re-export the symbols.

For the static case, linking just against the "last crate" in the chain
(the gl renderer backend) is sufficient to pull in all needed symbols.

In addition for the static case we need to specify the linkage of some
external libraries. This can be extracted manually via

    cargo rustc -p gl -- --print=native-static-libs

for example. For now that's in the changed CMakeLists.txt, but the plan
going forward is to automate this extraction in an xtask, to paste that
into the cmake target.

Finally, both linkage scenarios require access to the headers. This is
for now solved by generating them simply in an include sub-directory of
the build folder ($root/target/${profile}/include).
2020-06-04 15:29:19 +02:00
Olivier Goffart
7b8df5ca9d Use interior mutability for the cache
So we do not need a mutable reference to the Component
2020-06-04 14:03:30 +02:00
Olivier Goffart
e4366efb67 Do not require the component to be static to show a window 2020-06-04 13:44:40 +02:00
Olivier Goffart
adaadc30a9 Remove the "Rendering..." debug message.
This just polute the output while debugging other stuff
2020-06-04 12:49:33 +02:00
Olivier Goffart
88b7f7c0bf Signal support in the viewer 2020-05-31 02:03:02 +02:00
Olivier Goffart
5f01ec30ee Fix the viewer using generated rtti from a macro
One thing that needed to change is that we needed the vtable to be unique
2020-05-30 15:08:51 +02:00
Olivier Goffart
a883da3281 WIP: Use a macro to generate the RTTI 2020-05-30 15:01:50 +02:00
Olivier Goffart
74898a1386 Make property conneciton binding in the C++
(somehow plus/minus is not working yet)
2020-05-28 14:52:43 +02:00
Olivier Goffart
f6d1151832 Use the EvaluationContext in the signal handler 2020-05-28 14:26:35 +02:00
Simon Hausmann
f2df9293a9 Fix the C++ build
Remove the Optional from the evaluation context passing for property
evaluation. Unfortunately there are nullptr uses left on the C++ side,
that need to be replaced with passing through.
2020-05-28 12:07:11 +02:00