Commit graph

36 commits

Author SHA1 Message Date
Tobias Hunger
a3b86690ff [reorg]: Move the rendering backends into internal 2022-01-31 16:00:50 +01:00
Simon Hausmann
d74a4d4c14 Make the run_event_loop() function in the testing backend abort again on invocation
This helps detect call sites. One of them is in the timer doctests though, which we flag as no_run
as a consequence.
2022-01-31 14:29:09 +01:00
Simon Hausmann
3feb169639 Fix doctests in the corelib that need the event loop and compiler
Bite the bullet and introduce the public API and testing backend as
dev-dependencies, so that we can properly at least compile-test the
doctests, some of which were previously in the public API crate and
require the compiler macro.
2022-01-31 14:29:09 +01:00
Simon Hausmann
f31f4201c6 Improve sixtyfps::Image::size() API for consistency
Make size() return an unsigned integer size type instead of floats.

cc #431
2022-01-27 22:15:29 +01:00
Tobias Hunger
06346ab2e6
janitor: Derive some Default traits 2022-01-04 18:21:25 +01:00
Tobias Hunger
bfca0e3573 Mass update copyright messages to be more REUSE compliant 2021-12-22 10:06:12 +01:00
Lukas Jung
46c34a7a7e Add empty set_mouse_cursor function to TestingWindow 2021-12-07 22:41:24 +01:00
Olivier Goffart
d1cae710df preprocess the images at compile time
For the MCU port, we need to proccess the image to save them in the binary
in a convenient format.
This patch start this work by trying to anaylyze what format should an image
be using, and saving it as a texture in the binary.

The current graphical backend and the C++ frontend are not yet supported
2021-11-19 15:54:45 +01:00
Simon Hausmann
67579ec560 Simplify drop implementation of generated components
Avoid creating an intermediate array of items to free the graphics resources.
Instead call run-time function with the item tree as a parameter, which is traversed.

It's practically the same data structure that was previously created, except
that it is shared/global and has little holes for the dynamic tree items, but those are easy to skip.
2021-11-01 08:58:53 +01:00
Simon Hausmann
d57edfbb7c Simplify free_graphics_resources API in the backend
Take an iterator reference instead of a slice, so that we can change the call sites in the future.
2021-10-30 13:03:52 +02:00
Simon Hausmann
0e8efea2ff Further speed up font handling in the GL backend
Use the new fontdb API:

* When registering embedded fonts, we don't need to make a copy of the
  embedded font data anymore.
* We don't have to mmap the font files ourselves anymore, fontdb can
  do this now for us.
2021-10-04 15:11:55 +02:00
Simon Hausmann
ac0cc85d33 Simplify font resolution in the GL backend
The font resolution function querying fontdb is fast now, so we can
always call it when rendering text. That way we don't need all the
indirection in the text_size(), etc. functions, we don't need an entry
in the item graphics cache for the font and we can avoid a lot of
property dependencies.
2021-09-21 10:10:45 +02:00
Simon Hausmann
cc7ea5b92a GL renderer: fix rendering of Text/TextInput when the text property changes in a way that requires different fonts
Unfortunately the text property was not included in the property dependency chain
for the cached Font.
This is fixed by delaying that with a getter function, but in the mid term
we should be able to remove this again once
femtovg learns lazy font resolution.
2021-09-17 18:27:44 +02:00
Olivier Goffart
4f1eacd6d8 LineEdit is now able to scroll to keep the cursor visible 2021-09-02 17:20:44 +02:00
Simon Hausmann
8114e187b0 Unify mouse input event and draw handling between Qt and the GL backend
The unification reduces back-end specific fields for the window and
allows making all the property trackers in the run-time window private.
2021-09-01 18:20:23 +02:00
Simon Hausmann
549fcb049b Internal cleanup: Move the scale factor property into the shared runtime Window 2021-09-01 18:20:23 +02:00
Olivier Goffart
861edf94fd Remove FontMetrics trait
since there is only one function in it, just put that function in the Window
then there is no need to heap alocate a dyn FontMetrics just to call this function.
2021-08-31 13:27:32 +02:00
Olivier Goffart
c1fc242a9a Move the text_input_byte_offset_for_position from the FontMetrics to the Window
In preparation of having mutiple-lines TextInput, we will need to give more
data to this function so it no longer belong in FontMetrics

Also remove the unused FontMetric::line_height()
2021-08-31 13:27:32 +02:00
Simon Hausmann
f25f85844d Remove SharedImageBuffer from the public Rust API
and instead fold the constructor functions into Image as `new_rgb8`/`new_rgba8` and `new_rgba8_premultiplied`.
2021-08-10 15:56:01 +02:00
Simon Hausmann
8a3a68a4fa Add API to Rust sixtyfps::Image to enable creation from user supplied image buffers
This adds an ImageBuffer and PixelBuffer type for SharedVector
backed images. The documentation explains how to use this
with low-level rendering functions and the popular image crate.

Fixes #387
2021-08-10 15:56:01 +02:00
Olivier Goffart
1dab4c35d9 For embedded data, store the extension in the binary
This is usefull for the detection of SVG
2021-08-03 16:15:31 +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
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
Olivier Goffart
13bd828b96 Update license date 2021-07-02 15:55:54 +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
Olivier Goffart
6ed58fb041 Testing backend: don't panic on popup close 2021-06-23 15:25:29 +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
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
Olivier Goffart
142a8dc185 Rename ImageReference to ImageInner and make Immage.0 private 2021-05-28 17:05:16 +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
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
a0e910abf0 Use the testing backend for rust 2021-05-11 11:40:26 +02:00
Olivier Goffart
662c52abff Introduce a "testing" rendering backend and use it for the interpreter test
This way the tests can pass even if the tests would otherwise need a running
window, like they do with the GL backend
2021-05-11 11:40:26 +02:00