Due to a bug in Qt's implicit sharing in QPalette, the resolve mask of
QGuiApplicationPrivate::app_pal would get changed with an unrelated setColor
call and thus break color resolution from a new base palette when the theme changes.
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
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.
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.
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.
Set QStyle::State_Active conditional to whether the window is active,
which maps to Qt's active window concept and winit's has-focus (until we
render popups differently).
If the root item is a Window, then we use the default-font-* properties as the basis
for all unspecified font properties in text rendering.
This patch centralizes the code for retrieving that in the runtime window.
If this becomes a performance bottleneck, then we could cache it in a
box-pinned property in the run-time window.
- Have the cursor at the right place when clicking on end of line
- make sure not to render new lines if there are some when in single-line mode
- Enter should make a new line
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.
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()
Under these windowing systems, we receive a QString text from Qt that
contains a terminal control character (like \u{3} for ctrl+c). We
decided to supply the character for the key (for example 'c' for Ctrl+C)
to the application, so activate the conversion from the key code when
control characters are present.
With winit, we receive first a key down input event with the virtual key
code (for example C for Ctrl+C), followed by a ReceivedCharacter event
with a terminal control character. We choose to ignore that and instead
take the previously received key code and try to use that instead.
Fixes#441
The RenderCache (slab and generation) is always in a refcell, so we can
just pass that through. This also eliminates the ItemGraphicsCache
wrapper in the GL backend.
This will allow more fine grained borrowing in the future.
There's only one place where we need this ourselves and that's also
easily done by hand. Otherwise the `as_bytes(_mut)()` accessor provides the
functionality along with `width()` and `height()`.
Other than that the API is mostly consuming, given that `sixtyfps::Image`
has no way of extracting the data again.
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
We calculate the cursor position as byte offset in the utf-8 encoded string,
while Qt expects an index in the utf-16 encoded QString.
When those differ, the cursor is rendered at the wrong location.
Fixes#363
Sixtyfps uses euclid already, so let's use euclid for float comparisons
as well.
I changed the code to decide whether a number is a positive integer to
make do without a comparison along the way.