Commit graph

511 commits

Author SHA1 Message Date
Tobias Hunger
97be634b9b Janitor: Fix clippy::match_like_matches_macro 2021-07-23 13:48:52 +02:00
Tobias Hunger
8d83ce88d7 Janitor: Fix clippy::excessive_precision 2021-07-23 13:48:52 +02:00
Tobias Hunger
3e0534afea Janitor: Fix clippy::needless_lifetimes 2021-07-23 13:48:52 +02:00
Tobias Hunger
2a6560b073 Janitor: Remove unecessary cast
Prefer a u8 literal over an i32 literal that is then cast to a u8
2021-07-23 13:48:52 +02:00
Simon Hausmann
eaddbe664e internal cleanup: Rename ComponentWindow to WindowRc
That's all it is nowadays, it's a wrapper around Rc<Window>. It's not an
alias because we need to also "wrap" it to C++ via cbindgen, but that's
about it.
2021-07-21 20:33:02 +02:00
Tobias Hunger
57389c1731 Janitor: Fix remaining instance of clippy::redundant_clone 2021-07-21 19:44:57 +02:00
Tobias Hunger
aeebbb1d96 Janitor: Fix remaining clippy::option_map_unit_fn 2021-07-21 19:44:57 +02:00
Simon Hausmann
1c285694d7 internal cleanup: Remove the use of ComponentWindow in the interpreter 2021-07-21 17:41:12 +02:00
Simon Hausmann
2553dd1459 Trim the Rust ComponentWindow API and implementation a little bit
* Remove the `new` function from the main impl and use the slightly
  less visible From conversion trait
* Make the inner Rc<Window> pub(crate) instead of pub
* Instead, provide a public as_any() accessor that the Qt backend can use
2021-07-21 17:41:12 +02:00
Simon Hausmann
492af0f67c Rename the implementation of the Window item to WindowItem
If we were to add `sixtyfps:🪟:Window` to the re_exports, then
this clashes. We might rename the former, but this is a cleaner naming
in any case.

Relates to #333
2021-07-20 17:50:17 +02:00
Olivier Goffart
b194c62c22 GL backend: Use the cache for the Window icon 2021-07-20 17:02:24 +02:00
Olivier Goffart
1360f1e26e Added icon property to the Window element 2021-07-20 16:34:19 +02:00
Simon Hausmann
68626e27fb internal cleanup: simplify free_graphics_resources trait signature
This allows then routing the call through window::Window's Deref impl
2021-07-20 16:19:45 +02:00
Simon Hausmann
1273391f3a Don't show non-existent glyph boxes for emojis on macOS
Instead, include the emoji font in the fallback list.
Once femtovg learns to render color fonts, they will show up.
2021-07-20 08:45:10 +02:00
Simon Hausmann
91e2154a66 Remove the freetype dependency on Windows and macOS
It's not needed and this would fix #315
2021-07-13 19:29:49 +02:00
Tobias Hunger
b105d6add3 Janitor: Do the float comparision dance
I think it is actually makes sense in this case!
2021-07-09 17:00:46 +02:00
Olivier Goffart
13bd828b96 Update license date 2021-07-02 15:55:54 +02:00
Simon Hausmann
035dfc3d1f A few harmless spelling fixes 2021-06-30 22:14:10 +02:00
Simon Hausmann
8dc6ee6fb1 Fix font fallback list on macOS with default family
Even with an empty font family we should produce a font fallback list, and we can.
Fixes the missing checkmark (when not affected by clipping).
2021-06-30 15:46:30 +02:00
Olivier Goffart
bc8bc616ed GL backend: elide Text also when word-wrapping
In this case, the last line will have elipsis on the last line
when no more line can be printed

Note that the behavior is different with the Qt backend
2021-06-30 13:33:19 +02:00
Simon Hausmann
a0e827e200 Work around black window with vmware/glutin/windows10
Glutin's desire to default to srgb mysteriously creates a black window
on Windows 10 under Vmware. I tested this with many glutin apps and examples,
they all exhibit the same: black window,
working when query for srgb is turned off.

This used to work, so I suspect some change underneath on the vmware svga
driver perhaps, or Windows.
2021-06-29 22:53:48 +02:00
Olivier Goffart
a58daa31c9 Fix popup size 2021-06-29 09:30:07 +02:00
Simon Hausmann
61d533812d Bump femtovg and ttf_parser version
They are now in sync with the latest due to a new rustybuzz release
2021-06-28 11:08:06 +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
68259162c8 Janitor: Fix typo in local variable name
No behavior change is intended here.
2021-06-28 08:32:00 +02:00
Simon Hausmann
55d4a4f79e Bump femtovg to a released version 2021-06-22 18:06:43 +02:00
Olivier Goffart
dcbbd0cd7d Update dependencies 2021-06-22 11:15:20 +02:00
Simon Hausmann
930412d3bb Fix size of default constructed sixtyfps::Image with GL backend
An empty image should have a zero (empty) size, like it does with the
testing and Qt backend.

The datastructures test in the CI revealed this.
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
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
7f9bb18b9a Fix warning introduced in last commit 2021-06-10 11:18:35 +02:00
Olivier Goffart
9b8efbf5ad GL backend: Properly clip Text that has too many lines for its height
Qt already does that
2021-06-10 10:52:04 +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
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
5b9ce15ae2 GL backend: Implement image_size getter without mapped window
By moving the image cache to the GraphicsWindow we can now decode images
first without a window and later upload to the GPU.

This also allows removing the window_map_pending property hack.
2021-06-01 08:29:39 +02:00
Simon Hausmann
c38696f652 GL backend: Prepare for image cache without window
The HTMLImage only needs the event loop proxy to notify for a repaint, we can repaint all windows.
2021-06-01 08:29:39 +02:00
Simon Hausmann
ad24802fed GL backend: Clean up HTML image loading code
Decouple the Texture from the HTML image loading logic and introduce an
ImageData state that represents just the DOM element.

This will make it possible later to also load the images without a canvas.
2021-06-01 08:29:39 +02:00
Simon Hausmann
3ef6f95659 GL backend: minor cleanup
Move the image cache key also into the images module
2021-06-01 08:29:39 +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
Simon Hausmann
6fa6b28661 Simplify GL context handling further
Move the borrow/option business to work around the glutin enum API into
the OpenGLContext type, to simplify its use.
2021-06-01 08:29:39 +02:00
Simon Hausmann
e1be835942 Simplify wasm event loop invocation
We don't need the scoped_tls_hkt trick anymore
2021-05-31 18:03:23 +02:00
Simon Hausmann
357dd9826d Fix HTML images not being rendered after being loaded
Instead a "manual" refresh is needed (like mouse mover). This regressed
in commit 8d2554ff3b, which removed the
event loop proxy clone. For some reason that's not sending the event
from the DOM callback, but winit requires a clone of the proxy.
2021-05-31 12:56:35 +02:00
Olivier Goffart
32b92aba08 Fix the viewer and LSP preview when they reload the widow breaking the layout
the must_resize was not set to true when the with and height are set to the prefered
size, but it must be set for the layout to apply.

Note that even with this patch, the window will be resized to the preferred
size when reloading. Because we have no way to know there if this is the first time
the window is shown, or not.
2021-05-31 09:43:09 +02:00
Simon Hausmann
949dc9612b Use the new 0.2.0 release of femtovg 2021-05-28 20:26:37 +02:00
Simon Hausmann
f9df83d593 Fix initial rendering of widget gallery with GL backend
This issue is not quite specific to the gallery, a simpler test case is
this:

```
App := Window {
    preferred-width: 500px;
    preferred-height: 750px;
    HorizontalLayout {
        Rectangle {
            background: blue;
        }
    }
}
```

As there is no fixed width/height set, the size is calculated by layout and
apply_window_properties() sets the inner size correctly on the winit window.
However the width/height properties on the root Window item are not set, remain
zero and thus lead to incorrect rendering. They are not set because they are
identical with what window.inner_size() reports - we assume no change and that
they are in sync.

The bug however is in the creation phase, when we decide on an initial size to
pass to the window_builder, we should also set those on the root item. This is
where window.inner_size() and the root item's width/height get out of sync.
2021-05-28 17:54:30 +02:00
Olivier Goffart
142a8dc185 Rename ImageReference to ImageInner and make Immage.0 private 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