Commit graph

103 commits

Author SHA1 Message Date
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
30b201d946 Reduce the use of unsafe in corelib and in the rust backend 2020-06-12 19:03:15 +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
89968e0722 Add a Slice type which can be used in FFI 2020-06-10 14:23:57 +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
Olivier Goffart
34931e58c0 Polishing of the documentation 2020-06-08 17:57:18 +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
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
a883da3281 WIP: Use a macro to generate the RTTI 2020-05-30 15:01:50 +02:00
Simon Hausmann
c4dd857e0d Add an evaluation context to property evaluations
The context is not used yet or passed on to the binding closure.
2020-05-28 09:20:11 +02:00
Simon Hausmann
bcc6c6a60a Move Color and RenderingPrimitive into abi::datastructures
This paves the way to replace RenderingInfo.
2020-05-22 16:07:06 +02:00
Simon Hausmann
230870a292 Style cleanup
Remove some where clauses that leads to less verbose signatures. Also
use impl FnFoo, which is shorter as well.
2020-05-22 16:07:06 +02:00
Simon Hausmann
d48faf711f Update cached rendering data only when there are changes
This introduces a separate rendering preparation step in the main
window. As a consequence, the component becomes a parameter and the
graphicstest example can't use the main window anymore.

The decision whether a new low-level primitive needs to be created or
not is made by comparing the last RenderingPrimitive against the new
one.

On the upside, this means that property changes are now reflected in the
graphics.
2020-05-22 16:07:06 +02:00
Olivier Goffart
83d206ea39 runtime: Add a Signal class
Not very functional yet
2020-05-20 16:13:04 +02:00
Olivier Goffart
94c58dc1c4 Add an mouse handler for the TouchArea 2020-05-20 12:03:36 +02:00
Olivier Goffart
cdeb3a4312 Import of a basic property system 2020-05-19 12:47:52 +02:00
Olivier Goffart
25bf149e13 Add a shared string that can be used in properties 2020-05-18 17:09:40 +02:00
Olivier Goffart
4988fcb543 More fix to use vtable for component. All rust code compiles 2020-05-18 11:06:31 +02:00
Olivier Goffart
686f4c9591 More work on the vtable macro to adapt the Component
This does not work yet
2020-05-18 11:04:54 +02:00
Olivier Goffart
4b19818f6c WIP: port Component to vtable 2020-05-18 11:04:54 +02:00
Simon Hausmann
6110e4952d Move item rendering related code into a separate module
.. and keep less code in the central lib.rs.
2020-05-13 10:55:13 +02:00
Simon Hausmann
3142883ca8 Render the contents of image elements
The source property is a path relative to the path of the executable.
That is still rather inconvenient. It would be more convenient to make
it relative to the source file, but the corresponding proc-macro span
source_file() accessor is not public/stable.

Perhaps there's a way of doing this also through the generated code and
std::file!().
2020-05-13 10:27:09 +02:00
Simon Hausmann
e144e885e1 Generalize the offset state in the rendering loop
Using a transform allows for additional properties such as scale and rotation
later.
2020-05-13 08:17:30 +02:00
Simon Hausmann
6ba90975b8 Further cleanup of the internal run_event_loop
Let the callback take a frame and that's it. Then the caller can take
care of presenting it, etc.
2020-05-12 22:16:04 +02:00
Simon Hausmann
5117452e94 Remove TODO comment fixed by previous commit 2020-05-12 22:12:11 +02:00
Simon Hausmann
c26a2a1562 Fix GL context state handling
Make our GL context not current when done with the initialization
and make it current for the duration fo primitive creation and frame
rendering.

Fixes #4
2020-05-12 21:42:34 +02:00
Simon Hausmann
ea03e08306 Clean up rectangle creation
Use a simple shared convenience method in the GraphicsBackend trait
2020-05-12 19:22:01 +02:00
Simon Hausmann
5986d5f2b8 More visitor cleanups
Provide a non-mutable visitor as well, as the actual rendering loop doesn't need
to change the items fortunately.
2020-05-12 16:33:50 +02:00
Simon Hausmann
f22b18584e Remove the cells in CachedRenderingData
Since we have a mutable accessor to this structure, we can skip the cells and make the code easier to read.
2020-05-12 16:26:58 +02:00
Simon Hausmann
93de9cf90c Change visit_items to take a mutable ref
This is safer, Olivier says :-)
2020-05-12 16:17:39 +02:00
Simon Hausmann
573a2bb0a9 Minor cleanup
Rename dirty_bit to cache_ok -- that makes the code slightly more readable.
2020-05-12 16:05:26 +02:00
Simon Hausmann
c5bcba2c3c Added basic rendering of cache primitives to the Items 2020-05-12 16:00:41 +02:00
Olivier Goffart
638c445cf9 Support for rendering sub-elements with proper offset 2020-05-12 15:38:50 +02:00
Simon Hausmann
7efcbd5816 Simplify geometry handing
Replace the use of kurbo's primitives with lyon/euclid. This means less data copying,
conversion and also no annoying precision
casts.
2020-05-11 19:23:03 +02:00
Olivier Goffart
471dd0f778 Make run_component safe 2020-05-11 15:35:17 +02:00
Olivier Goffart
88e904d228 Draft of the layouting runtime code 2020-05-11 15:33:38 +02:00
Simon Hausmann
c966f6e546 Add primitive rectangle rendering
This is still uncached, but gets something onto the screen.
2020-05-11 15:33:14 +02:00
Simon Hausmann
83eb00b080 Run the C++ generated component through the GL backend
... which in turn forward to the corelib, but with the GL renderer attached.
2020-05-11 15:05:33 +02:00
Simon Hausmann
63d3f5125e Move the main loop implementation into the core library 2020-05-11 14:30:41 +02:00
Olivier Goffart
bd039be10c Introduce the datastructure to allow models and repeater 2020-05-11 10:10:25 +02:00
Olivier Goffart
9ad39d835e move the abi in its own module 2020-05-06 10:27:09 +02:00
Olivier Goffart
35fde11515 Use cbindgen to generate the internal abi 2020-05-06 10:11:32 +02:00