When the text selection end follows right after a grapheme that uses less
glyphs than characters, then there may not be a matching glyph with the byte
index, therefore we wouldn't set the selection_end_x and draw incorrectly.
Take the visual tail of the last glyph then.
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.
* 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
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
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.
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.
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.
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.
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.
Move the item graphics cache into the GraphicsWindow and then, together
with the new femtovg::TextContext, we can provide the metrics and can
stop using the window_map_pending notifier for this query.
With wasm there is no current context (can alwasy render) but we own the
winit::Window. With glutin own the ContextWrapper and have to make it
current (and resize). This patch hides all that behind the OpenGLContext
type.
This is primarly search & replace for now, slightly simplifying function
signatures.
However this paves the way to a thread-local font cache that can share
fonts across windows (not glyph atlas) and also measure without a canvas.
Let's keep source compatibility and define `drop-shadow-blur` to be a radius.
The CSS spec says that the standard deviation is half of the radius.
We just need to scale again and increase the shadow rect to make sure that no borders are visible.
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.
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.
Rendering tests/cases/examples/rectangle_clip.60 shows a border radius
for the clipped area that's not identical with the border radius of the
inner edge of the rectangle stroke.
It appears that the stroke's inner radius is not exactly the difference
of the line (border) width but rather scaled by kappa.
Fix issue in
https://github.com/sixtyfpsui/sixtyfps/issues/207#issuecomment-825780094
For the purpose of alignment, we need to use the font height, not the actual
text height, because otherwise it does not look visualy centered if the
text does not have letters that goes under the baseline
When rendering into a layer, we applied the y coordinate system flip
using a transform. That transform is incompatible with
Canvas::fill/stroke_text, which uses transform_point to transform the
glyph quads. That appears to not work, as opposed to the
y-flip in the main vertex shader.
Fortunately we can work around it by doing the flip when rendering the
layer image (as part of the fill).
Closes#199