Commit graph

70 commits

Author SHA1 Message Date
Simon Hausmann
628e6fdb38 Add a BoxShadow element
This intends to provide a configurable rectangular "drop shadow". The
API is modeled after CSS/HTML5 Canvas where the element can be "bound"
to an existing rectangular shape (geometry and radius), the offset can
be used to place the shadow and color and blur configure the shadow.

The shadow's color fades into transparent.

TODO (in subsequent changes):
 * Documentation
 * Qt implementation
2021-01-26 13:56:12 +01:00
Olivier Goffart
7931896027 GL: Remove the Backend generic in the GenericWindow 2021-01-14 17:33:12 +01:00
Olivier Goffart
fff024731b Don't pass Pin by reference
(consistant with other method in that trait)
2021-01-14 11:54:17 +01:00
Olivier Goffart
84c7b28256 Decouple the ItemRenderer from QPainter so it can hold a cache 2021-01-14 08:53:13 +01:00
Olivier Goffart
10dffa7d79 Use the QPainter directly when using the Qt paint engine 2021-01-14 08:53:13 +01:00
Simon Hausmann
73a1313072 Add some missing internal documentation 2021-01-14 08:53:13 +01:00
Simon Hausmann
a684f36b8d Simplify children clip handling
Use a save/restore state pattern for the entire renderer instead of passing around clip rectangles as data structure.

That's less data copying and maps naturally to existing mechanisms,
which in turn can use their own dirty handling to make
save_state/restore_state as cheap as possible.
2021-01-14 08:53:13 +01:00
Olivier Goffart
ab08502c77 Move the GraphicsWindow to the graphics backend 2021-01-14 08:53:13 +01:00
Olivier Goffart
e4900f52b8 Fix some warnings 2021-01-14 08:52:22 +01:00
Olivier Goffart
c7ff67d0fc Move the ItemRenderer to the item_rendering module 2021-01-14 08:52:22 +01:00
Simon Hausmann
5906f39a47 Silence some warnings 2021-01-14 08:52:22 +01:00
Simon Hausmann
de4194c9ba Make ItemRenderer take &mut again
It's cleaner and indeed possible
2021-01-14 08:52:22 +01:00
Simon Hausmann
43127cb059 Implement releasing of textures when items are destroyed
This means going back to an immutable renderer reference and interior
mutability for the canvas and the gpu cache. This is because while
traversing the item tree for rendering we may end up destroying
other items due to the lazyness of the models.
2021-01-14 08:52:22 +01:00
Simon Hausmann
1f9ba94c59 Rename the image cache
... to a more general gpu_cache and store an enum. That way we can
encapsulate the resource releasing - in the future - entirely in the
backend through run-time polymorphism in the backend (gpu cache data
enum) instead of a vtable method in the item to destruct the correct
type of data.
2021-01-14 08:52:22 +01:00
Simon Hausmann
e334efbcc5 Fix borrow error panic
Don't try to borrow the backend mutably when destroying items.
2021-01-14 08:52:22 +01:00
Simon Hausmann
d159a3b523 Implement caching of images
Don't re-load/decode the image every frame (and leak it), just load it
once per source change.
2021-01-14 08:52:22 +01:00
Simon Hausmann
d92fe445d5 Remove the old GL renderer
and try to stub in the hooks to trigger the new one
2021-01-14 08:52:22 +01:00
Simon Hausmann
607fecdb18 Simplify rendering interface
Instead of passing through a generic transformation matrix, let's just
pass through what we actually use: a translation point
2021-01-14 08:52:22 +01:00
Olivier Goffart
852eeb1c11 WIP popup 2020-11-30 15:20:51 +01:00
Simon Hausmann
89e0b57627 Rework and simplify the focus handling
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.
2020-11-20 15:33:15 +01:00
Simon Hausmann
78fae068dd Use ComponentRc during item tree traversal
This is in preparation for allowing the run-time / items to clone VRc's
of the component.

ComponentVTable functions like visit_children_item contine to take a
ComponentRefPin as "self" parameter type, as a VRc would not be
supported by rust right now. That means the implementation then uses
self_weak to obtain a strong self-reference.
2020-11-19 17:04:01 +01:00
Simon Hausmann
7a5113ece1 Free graphics resources without item tree traversal 2020-11-18 08:49:57 +01:00
Simon Hausmann
dd89c384a6 Avoid a mutable borrow when rendering
We only fetch from the rendering cache, no need for a mutable reference.
2020-10-02 17:49:03 +02:00
Simon Hausmann
ade110894d Fix borrow error when destroying an item during rendering
Destroying a component releases the item's graphics resources, which requires
a mutable reference to the rendering cache. That reference is acquired fine grained,
but when rendering items itself we also acquired a mutable reference
at the start of the rendering phase. That is too early and too long, and not necessary.
2020-10-02 17:43:18 +02:00
Simon Hausmann
88b94a26ea Add support for clip rectangles in the GL rendering backend 2020-09-29 11:42:02 +02:00
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