Commit graph

253 commits

Author SHA1 Message Date
Simon Hausmann
daf23f8736 Pass the evaluation context through the binding closure 2020-05-28 09:20:11 +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
Olivier Goffart
5580b5112f Fix number to string conversion in C++ 2020-05-27 16:18:08 +02:00
Olivier Goffart
93158e63e8 Fix crash in the viewer when there is a Text{}
Wrong vtable was used.
2020-05-25 13:15:10 +02:00
Simon Hausmann
50ecffe1f1 Replace RenderingInfo with RenderingPrimitive
This is one data structure less and it avoids converting from the one to
the other.
2020-05-22 16:07:06 +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
Simon Hausmann
cd80a4038f Clean up HasRenderingPrimitive trait API after transition
The extraction does not have to be optional anymore. That will make
future code using this simpler.
2020-05-22 16:07:06 +02:00
Simon Hausmann
21842bdd75 Remove the individual primitive factory functions from RenderingPrimitivesBuilder
Only use the new one that takes the new enum.
2020-05-22 16:07:06 +02:00
Simon Hausmann
9459578265 Add API to the RenderingPrimitivesBuilder to build the new style primitive 2020-05-22 16:07:06 +02:00
Simon Hausmann
5c8163d7a7 Introduce a new rendering primitive enum in the graphics module
This shall become the successor to RenderingInfo. For now it's just a
place holder, but the idea is that backend creates the opaque primitive
that holds this public rendering primitive, exposed via the
HasRenderingPrimitive trait.
2020-05-22 16:07:06 +02:00
Simon Hausmann
e7fd69bad1 Rename internal types
Rename the backend specific RenderingPrimitive to LowLevelRenderingPrimitive,
in order to make room for a high-level RenderingPrimitive enum that's public.
2020-05-22 16:07:06 +02:00
Simon Hausmann
f2662f0884 Simplify image primitives graphics API
Don't require a dest rect for now. Rendering is always at (0, 0) but
with the transformation applied. And the size shall for now not be a
parameter.
2020-05-22 16:07:06 +02:00
Simon Hausmann
bbc4c508f9 Minor cleanup
Replace lyon's rect import, which is a re-export of euclid's Rect<f32>,
with our own. Only the Path is
lyon specific, for now.
2020-05-22 16:07:06 +02:00
Olivier Goffart
0f977cbb25 Some documentation fixes for item generated with #[vtable] 2020-05-22 12:38:55 +02:00
Simon Hausmann
33dd2d765d Minor cleanup in item transform calculation
We can use the new geometry() getter to simplify the transform update by origin.
2020-05-22 09:33:08 +02:00
Simon Hausmann
8b854c32c3 Add Text::font_family and font_pixel_size properties
We can fine-tune the API, this works for now to change :-)
2020-05-21 21:04:07 +02:00
Simon Hausmann
4d26fe6674 Implement support for selecting the font family and pixel size in the GL renderer
The public API in the properties is still missing.
2020-05-21 20:55:34 +02:00
Olivier Goffart
4575011293 More work on signal: the C++ part is working 2020-05-20 19:28:58 +02:00
Olivier Goffart
83d206ea39 runtime: Add a Signal class
Not very functional yet
2020-05-20 16:13:04 +02:00
Olivier Goffart
4f22e2c341 Add a bool property type 2020-05-20 13:36:47 +02:00
Olivier Goffart
94c58dc1c4 Add an mouse handler for the TouchArea 2020-05-20 12:03:36 +02:00
Olivier Goffart
bf64e40476 Format 2020-05-20 09:34:14 +02:00
Olivier Goffart
6b3765857a Add a TouchArea builtin item (currently does nothing) 2020-05-20 09:32:01 +02:00
Simon Hausmann
81b5f70718 Implement colored text rendering 2020-05-19 21:58:01 +02:00
Simon Hausmann
cbd28bf745 Simplify image primitives API
Removed the source rectangle as that can also be done on the source image side,
if necessary.
2020-05-19 20:37:36 +02:00
Olivier Goffart
f4bfc3a5b4 Use the property system for our components 2020-05-19 15:15:23 +02:00
Olivier Goffart
8ec6fd5237 Change the representation of the Property to be more FFI friendly 2020-05-19 15:09:45 +02:00
Olivier Goffart
cdeb3a4312 Import of a basic property system 2020-05-19 12:47:52 +02:00
Simon Hausmann
23d3964a0d Add boilerplate for text items
Forward the text and color properties to the rendering backend, where
right now we just rendering all the glyphs into a dedicated texture.

Next steps are a glyph atlas texture, blending the specified color with
the alpha of the glyphs, configurable size and family, shaping with
Harfbuzz and may more things.
2020-05-18 19:04:12 +02:00
Olivier Goffart
b78f708786 Add SharedString::push_str 2020-05-18 18:45:33 +02:00
Olivier Goffart
ed842b3ae6 String: add comparison and simple test 2020-05-18 18:03:47 +02:00
Olivier Goffart
25bf149e13 Add a shared string that can be used in properties 2020-05-18 17:09:40 +02:00
Simon Hausmann
e6be2c91b8 Fix translation of children of images
Propagate the x/y of images also to the children.
2020-05-18 16:01:53 +02:00
Simon Hausmann
a7d5bd9f59 Minor rendering cleanup
Remove the x/y parameters from the rectangle primitive. They're always zero
since we always render with a transformation
matrix.
2020-05-18 16:01:53 +02:00
Olivier Goffart
5a9cbaae66 vtable add support for field offset in the vtable 2020-05-18 11:06:44 +02:00
Olivier Goffart
751a3fbe59 Work on const field offset crate to give type safe offsets 2020-05-18 11:06:44 +02:00
Olivier Goffart
aff3d7e14b vtable: add safe way to construct references 2020-05-18 11:06:44 +02:00
Olivier Goffart
b745c616f7 Add a trait to get the vtable for a type 2020-05-18 11:06:44 +02:00
Olivier Goffart
4ca45ca4da vtable crate: Some refactoring and simplifications 2020-05-18 11:06:44 +02:00
Olivier Goffart
0a973f65d5 vtable: Some more safety fix 2020-05-18 11:06:44 +02:00
Olivier Goffart
f74cfe73cd Use the vtable crate for the ItemVTable 2020-05-18 11:06:44 +02:00
Olivier Goffart
544cb1a198 Fix C++ compilation using the vtable crate 2020-05-18 11:06:42 +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
1ced4224b5 More work on the vtable crate 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