Commit graph

1092 commits

Author SHA1 Message Date
Simon Hausmann
6ae940433e Fix typo
Installing that code spell checker is distracting :)
2021-06-29 10:23:45 +02:00
Olivier Goffart
ae114cf79d C++: don't re-export private symbol in the public API
Use the cbindgen_private namespace dirrectly from the generated code
2021-06-28 12:03:49 +02:00
Olivier Goffart
98cec35080 Increase version numbers 2021-06-28 10:39:43 +02:00
Tobias Hunger
13d7f5e7bd Janitor: Fix typos in comments and user-facing strings
Also adapt tests for error messages containing the fixed strings.

No behavior change is intended!
2021-06-28 08:32:25 +02:00
Tobias Hunger
87460c4ac8 Janitor: Fix typo in struct field name
No behavior change is intended here!
2021-06-28 08:32:00 +02:00
Olivier Goffart
be8c890bec Close the popup when reloading the component
Fix panic when reloading the interpreter when a popup is shown

Fixes #210
2021-06-23 13:32:46 +02:00
Olivier Goffart
32e59cf040 Fix division by 0 when layouting empty images 2021-06-22 14:27:01 +02:00
Olivier Goffart
dcbbd0cd7d Update dependencies 2021-06-22 11:15:20 +02:00
Olivier Goffart
d0923bd82f Height for width for Image in layout 2021-06-21 12:24:36 +02:00
Simon Hausmann
85474f7670 Add support for sixtyfps::Image::size() in C++
Also added a unit test for the C++ implementation.
2021-06-20 11:18:28 +02:00
Simon Hausmann
0fdb87cc69 Add Image::size()
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.
2021-06-20 11:18:28 +02:00
Olivier Goffart
aed0e9849a Remove debug output 2021-06-18 20:31:33 +02:00
Olivier Goffart
4e0a91c35a Test for Flickable layout and small layout fix
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
2021-06-18 14:27:01 +02:00
Simon Hausmann
6734c369c8 Fix internal docs of image_size() function
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.
2021-06-18 14:21:02 +02:00
Olivier Goffart
a0bea36e43 Fix preferred size of the Window with a layout
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.
2021-06-18 13:51:25 +02:00
Olivier Goffart
51d532d209 Fix grid layout tests
One must make sure the initial preferred size is clamped within the
max and min size
2021-06-18 11:37:58 +02:00
Olivier Goffart
ef84923285 Get rid of the stretch dependency
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
2021-06-18 10:28:43 +02:00
Olivier Goffart
a95ed99c4e Layout: properly propagate the preferred size 2021-06-17 11:23:58 +02:00
Olivier Goffart
c1a144c282 Layout height for width for the Text 2021-06-17 11:23:58 +02:00
Olivier Goffart
ce37cd2552 Rename a function to avoid confusion with a field 2021-06-16 15:14:07 +02:00
Olivier Goffart
deaa0fddb0 WIP layout: split vertical and horizontal cache
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
2021-06-16 15:14:07 +02:00
Olivier Goffart
ee00c9eb92 Rename maximum- and minimum- properties to max- and min-
Issue #259
2021-06-14 10:28:30 +02:00
Olivier Goffart
0d09f69fb9 Upgrade lyon_path version since the PR in lyon_path was merged.
This should help for #253
2021-06-06 09:37:32 +02:00
Olivier Goffart
e7b75a2f2d ListView: Attempt to be a bit better as filling the element
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
2021-06-01 17:27:09 +02:00
Simon Hausmann
3c0cf6390d Fix loop handling of animations on bindings
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
2021-06-01 15:49:14 +02:00
Olivier Goffart
ea0abe3031 Fix a few UB found by miri
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
2021-06-01 11:52:43 +02:00
Simon Hausmann
538f1e5624 Fix min_size.width calculation with word-wrap is enabled
Apply Olivier's suggestion

Co-authored-by: Olivier Goffart <ogoffart@sixtyfps.io>
2021-06-01 10:52:26 +02:00
Simon Hausmann
5cad61bcd0 Fix disappearing text in vertical layouts with word-wrap and alignment
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
2021-06-01 10:52:26 +02:00
Simon Hausmann
4a13bba32a Clean up GL resource handling
Make sure that we have a current GL context before deleting textures or other GL resources
2021-06-01 08:29:39 +02:00
Olivier Goffart
b5b715651d More replacement from ptr::read to drop_in_place
Should fix the asserts in C++.
2021-05-31 21:25:41 +02:00
Olivier Goffart
dc1cf645db Interpreter: Fix crash when dropping
the ptr::read will move the object in memory, which is not
allowed for our items which contains Pin'ed property.
2021-05-31 18:48:03 +02:00
Olivier Goffart
56a2225238 Make explicit that a the PropertyTracker need to be Pin
Even if it is a private function, it need to be pined as it register pointers
2021-05-31 18:48:03 +02:00
Olivier Goffart
142a8dc185 Rename ImageReference to ImageInner and make Immage.0 private 2021-05-28 17:05:16 +02:00
Olivier Goffart
8e44ac2351 Image type: some more docs 2021-05-28 17:05:16 +02:00
Olivier Goffart
0b3fecf300 WIP: API to expose image loading from C++ and Rust 2021-05-28 17:05:16 +02:00
Olivier Goffart
4584c40544 Rename items::Image to ImageItem
Because there will be soon a sixtyfps::Image and the names
can't clash
2021-05-28 17:05:16 +02:00
Simon Hausmann
d4385280eb Fix disappearing images or panics when hiding and showing a window with wayland
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.
2021-05-28 09:16:24 +02:00
Simon Hausmann
7ddbfbdd64 Clean up font_metrics interface on corelib:🪟:Window
Since the GL backend can't really fail on this anymore we can now
remove the Option from the return value.
2021-05-27 17:04:45 +02:00
Simon Hausmann
d7b20de859 Fix panic when showing a previously hidden window again
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
    }
```
2021-05-26 10:53:24 +02:00
Simon Hausmann
cc9d5e09f0 Add support for clip on Path elements
This allows clipping the viewbox conveniently.
2021-05-21 19:51:00 +02:00
Simon Hausmann
e7bc91c804 Add support for specifying the viewbox of path elements 2021-05-21 19:51:00 +02:00
Simon Hausmann
9a4dc4a8dc Clean up femtovg crate dependencies
Let only the GL backend depend on femtovg, by moving the color functions.
This way it's easier to change the femtovg version in one place.
2021-05-20 08:56:11 +02:00
Simon Hausmann
bb7b301b10 GL backend: new box drop shadow implementation
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.
2021-05-20 08:50:02 +02:00
Olivier Goffart
76a42cd757 Added support for static constant z ordering
Just re-order the children at compile time
2021-05-14 16:17:34 +02:00
Simon Hausmann
ea358d9b2c Simplify internal image_size API
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.
2021-05-12 19:40:09 +02:00
Olivier Goffart
7b2653db23 MouseWheel support for the Flickable
cc #222
2021-05-12 13:28:39 +02:00
Olivier Goffart
5f74475224 Refactor the MouseEvent 2021-05-12 12:03:03 +02:00
Simon Hausmann
379e645c80 Replace arena allocator
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.
2021-05-12 11:25:50 +02:00
Olivier Goffart
ba1aff84d0 Layout refactoring: C++ part 2021-05-11 14:59:57 +02:00
Olivier Goffart
b01884f3b9 Layout refactor: do the rust part 2021-05-11 14:59:57 +02:00