This requires the image size query to be window independent and go
through the backend instead.
This implies minor changes for the Qt backend and bigger ones for the GL
backend:
* There exists now a thread-local IMAGE_CACHE, which is used by the
backend's image_size() function as well as by the renderer for
loading CPU side images.
* The image remain as decoded images in there (including SVG tree)
and the window now has a texture_cache, which holds CachedImage
with ImageData::Texture.
* Rendering an image item therefore fetches the CPU side image,
calls upload_to_gpu() on it, which creates a new Rc<CachedImage>
and that's stored in the texture_cache.
* The texture cache continues to be pruned when hiding the window.
Test for issue #194 which was already fixed.
And also fix a small other issue where the preferred size was not properly
computed in layouts.
Closes#194
All implementations of the function return the actual source size in
pixels, disregarding the window scale factor. The function is called in
Image's layout_info() to return the image size as preferred size. Since
the logical length is the default length, there's no need to do any
scaling anyway.
A few problem:
- the horizontal and vertical property were swapped
- The implementation of the "preferred_xxx" property was not materialized properly
because the `bindings` were borrowed in the materialize_fake_properties pass
- Since the Window has a stretch factor of 0., the preferred size of the inner layout
was not taken into account when merging the LayoutInfo. I believe taking the
maximum preferred size is the right solution when merging them.
Since we split the horizontal and vertical part, the stretch dependency is a bit overkill
and we can re-implement it ourselves.
This will also allow us to support colspan and rowspan properly
Split the vertical and horizontal pass into different property cache
This will allow to implement "height for with"
This patch does not port the Rust or C++ binding yet
Be sure to always instentiate at least enought element.
This is a problem if the items don't have the same height.
This only covers Rust and the interpreter
(The C++ code logic for the Listview currently instentiate all elements anyway)
Should help for issue #228
For regularly animated values, the loop count was always applied. For animations
triggered through bindings, the iteration count wasn't reset when the
animation restarted and therefore it looked like the loop count was only
applied once.
Fixes#250
An empty vector is not a `SharedVectorInner<T>`, it is a `SharedVectorInner<()>`
And so it is UB to take a reference of a `SharedVectorInner<T>` for the empty vector
When a Text element has wrapping enabled, it should not have zero
minimum size. Otherwise the layout will give it a height of zero in the
layout in the test case and that'll make the text disappear. There are
different options but this patch goes for minimum height as if no
wrapping was enabled (so at least one line plus forced line breaks).
Fixes#246
Properly release GL resource when unmapping a window and detect stale
cache indices using a generation count. This fixes the disappearing
images (GL textures would be invalid and need to be re-created) as well
as the panics when an item's cache index ended up being re-used because
some other item was drawn first and allocated that indices. The latter
is fixed by using a generational counter on the cache that's bumped when
clearing, instead of a single "cache_ok" bool.
The follow basic example reproduces the issue that the items remain around
but the item cache has been destroyed and re-created, which causes get_mut() to fail:
```
let app = App::new();
loop {
app.run(); // now close the window via the close button in the window decoration
}
```
This replaces the box gradient with a new implementation that
behaves like the HTML Canvas element, by applying a gaussian
blur to the alpha of the rectangle to shadow.
The drop-shadow-blur property is changed to be now just a "level", like
the HTML Canvas shadowBlur property, which is defined to be half of the
standard deviation of the gaussian blur to be applied.
We don't need a property reference anymore, a plain image reference is fine AFAICS.
Dirtyness of the source is tracked on the caller side of layouting_info()
or in the draw_image_impl anyway.
Use slab instead of the deprecated vec_arena, both of which appear to
use the same Vec based storage of an enum that's either the entry or an
index to the next free slot.