Commit graph

45 commits

Author SHA1 Message Date
Simon Hausmann
eeee4794b6 Remove the rest of the RenderingCache wrapper 2020-09-17 13:06:23 +02:00
Simon Hausmann
79ba5d9de8 Provide a window reference in various ItemVTable functions
Access to the window, in particular the scale factor, will be needed in a few places.
2020-09-15 15:55:47 +02:00
Olivier Goffart
58cdaeb8dd Update license header to mention that commertial option are available 2020-08-26 13:23:42 +02:00
Simon Hausmann
2823f32692 Apply license headers to all non-binary/non-json sources 2020-08-17 17:55:20 +02:00
Simon Hausmann
b96b627a4f Release graphics resources of items when destroying components
This is only implemented for Rust at the moment.
2020-08-13 13:31:29 +02:00
Simon Hausmann
3668234872 Use more fine-grained interior mutability for the rendering
Borrow the rendering and cache individually with different mutability.
We might later, for destruction handling, need to borrow the rendering
cache mutably. That in turn *may* happen even during rendering itself,
as the models are updated lazily during visitor traversal and that may
result in item destruction.
2020-08-13 11:33:34 +02:00
Simon Hausmann
c4d1a8f5fa Remove unnecessary lifetime specifier 2020-08-13 11:33:21 +02:00
Simon Hausmann
e655909e9f Adding missing missing_docs guards
Those used to be in the abi {} sub-module
2020-08-12 11:45:55 +02:00
Simon Hausmann
d3a474af26 Move corelib::Component and friends back into their dedicated component module 2020-08-12 11:39:07 +02:00
Simon Hausmann
62a8b15f09 Move ItemVTable and frieds to corelib::items
To avoid ambiguities regarding the use of FieldOffset, the BuiltinItem
proc-macro uses fully-qualified type names now.
2020-08-12 10:10:51 +02:00
Olivier Goffart
36243ccdf7 Traverse item front to back for input events 2020-08-10 10:45:02 +02:00
Simon Hausmann
829990f9b1 WIP
Co-authored-by: Olivier Goffart <ogoffart@woboq.com>
2020-08-07 16:06:49 +02:00
Simon Hausmann
48df8d0911 Rework the API between the items and the renderer
Move fields out of the HighLevelRenderingPrimitive that are suitable to
represent as uniform variables. That reduces fields like Image or
Rectangle to their image or dimension, and only if *they* change, then
we re-do the work of building geometry and uploading it to the GPU.

Instead, the typically animated properties such as the position or the
color are passed separately with each draw call. This avoids re-decoding
PNG files and uploading them again when moving an image element around
on the screen.
2020-08-05 09:44:12 +02:00
Simon Hausmann
a9297af00d Update the rendering primitives lazily using a property listener scope
This also allows avoiding the need to store the high-level rendering
primitive item in the low-level primitive struct for comparison later.
2020-08-04 22:48:03 +02:00
Simon Hausmann
8338bd4360 Move CachedRenderingData from datastructures into item_rendering 2020-08-03 14:17:38 +02:00
Olivier Goffart
e00491811b Get rid of the context in properties/signal 2020-07-13 18:49:06 +02:00
Olivier Goffart
905dca7d19 Remove debug output 2020-07-13 11:50:39 +02:00
Olivier Goffart
1b748792ad Visit the item as Pin
A preparation to have Property::get to take Pin<Self>
2020-06-25 18:50:20 +02:00
Olivier Goffart
caca0d0ba4 Put the component in a Pin<>
Removed the drop and create from the ComponentVTable:
since we are not using VBox<ComponentVTable>, this simplifies a bit
the code of the interpreter and everything else.

But there is still a lot of changes everywhere to support that the Component
is pinned.
This is just for the component. Which would be required if later we want
to access the properties as Pin<Property<_>>. But we have not yet ability
to do projections
2020-06-24 14:13:27 +02:00
Olivier Goffart
f8b7989c0b Access the properties in the parent component of a repeated element
This required some refactoring of the EvaluationContext structure to include the parent context
2020-06-22 14:38:38 +02:00
Olivier Goffart
d7fe69ff74 Lookup the index from a repeater expression 2020-06-16 17:23:38 +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
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
adaadc30a9 Remove the "Rendering..." debug message.
This just polute the output while debugging other stuff
2020-06-04 12:49:33 +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
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
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
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
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
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
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
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
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
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
f74cfe73cd Use the vtable crate for the ItemVTable 2020-05-18 11:06:44 +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