When processing window specific events, or generally when accessing
the ALL_WINDOWS refcell, keep the time for borrow to an absolute
miniumum. That way any subsequent method calls may further acquire the
refcell.
This patch re-organizes the entire deeply nested window event handling
in a function with slightly less indentation.
Fixes a panic when calling hide on a Window from within a callback
handler.
Fixes#539
The variable "geometry_changed" was true when the geometry was not updated.
Rename the variable and make it sure it has a proper meaning.
(Doesn't change the logic of the program)
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.
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).
This can be reproduced by deleting the last item of the printer queue in the
printer demo.
It is a regression showing up because we now emit the MouseExit event after
the mouse grab as released.
The problem is that we upgrade the weak item, and call geometry() on it.
Calling geometry will re-evaluate the layout cache which will re-evaluate
the model which will result in the component being removed and the cache
entry having less item than expected.
It is ok to simply return 0. for these layout location since the item will
disapear anyway.
As tests/cases/examples/image_rendering.60 itself demonstrates, the png file
should be loaded into the CPU side image cache once, but the two textures
should be cached independently.
cc #465
Normaly, fields od structure exposed to .60 need to be in lexicographic order
for themto work in C++ with agregate initialization, but since that field is not
in the .60 Struct, it needs to be last so it is default initilalized
Like CSS image-rendering it has "smooth" and "pixelated" options.
Only OpenGL has been tested right now, have not tested WASM or Qt.
Right now the first instance of a @image-url() will set the scaling
for that specific image. The same image used from memory on the otherhand
can all have a different scaling property.
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()
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.