Commit graph

181 commits

Author SHA1 Message Date
Olivier Goffart
7b2ff89f1c Fix nightly warnings
eg:
```
warning: the item `Box` is imported redundantly
```
2024-02-21 10:52:04 +01:00
Tobias Hunger
a8f912900b janitor: Fix warnings in nightly about redandant use 2024-02-19 17:05:21 +01:00
Olivier Goffart
2a63df6ed6 Implementation of border image in the software renderer 2024-02-13 14:46:27 +01:00
Olivier Goffart
97067c3d65 Add 9slice information at runtime 2024-02-13 14:46:27 +01:00
Olivier Goffart
926786fb59 Remove ImageHorizontalAlignement::Start/End
Since RTL language are not yet implemented, let's leave that out for now
2024-02-08 18:59:26 +01:00
Olivier Goffart
ce6c7f5527 Image: add horizontal and vertical alignment 2024-02-08 18:59:26 +01:00
Olivier Goffart
cb92ba1132 Add ImageFit.preserve and de-duplicate the fitting code 2024-02-08 10:10:56 +01:00
J-P Nurmi
9644f62f00 Add BorderRadius helper type 2024-02-06 18:01:35 +01:00
Olivier Goffart
2ede92b3f1 Fix 90deg gradients
Fix #4495
2024-01-31 20:44:45 +01:00
Olivier Goffart
91c2b38fa2 Fix gradiant drawing
Fixes #4459
2024-01-30 09:59:31 +01:00
Olivier Goffart
01336be871 Fix svg loading on android after update of resvg
It would incoditionally try to load the FONTDB that can't load any font
from the system using libloading

Instead, hardcode the path to the font to a known android font
2024-01-23 23:04:59 +01:00
Olivier Goffart
c7aae4b77e Update resvg and related dependencies 2024-01-22 16:16:35 +01:00
Olivier Goffart
f1f141896f
Fix linear gradiant rendering in non square rectangle
Fixes https://github.com/slint-ui/slint/issues/3730
2024-01-17 17:44:51 +01:00
Simon Hausmann
05079f79fb doc: Fix typo 2024-01-08 10:08:05 +01:00
Olivier Goffart
672820be0e Inline the Color accesor functions
Profiling reveal they are not always inlined, despite they are only a
single instruction and can be used in a tight loop. So there is no
excuse to not inline them.
2023-12-19 13:24:48 +01:00
George Hopkins
0a56f43ae4 Implement std::error::Error for LoadImageError 2023-11-20 11:43:13 +01:00
Olivier Goffart
1a0e065a54 Speedup SharedPixelBuffer::clone_from_slice in debug mode
Discussed in https://github.com/slint-ui/slint/discussions/3912
2023-11-17 12:06:44 +01:00
Olivier Goffart
2f6410515c Assign value to ImageInnner enum
To make sure there are no binary incompatibilities when features are missing
2023-11-07 12:01:38 +01:00
Olivier Goffart
1864257f29 Silence error when rendering SVG in an 0x0 size
Make the size argument to svg::render optional to mean that it is the
default size of the image.
Otherwise, passing None as the size to ImageInner::render_to_buffer
would not render the image which is possible in some backend (eg: the
button image icon with the qt backend)

And if the image is really rendered on an empty because of layouting or
so, we don't need to show a warning anyway.

Fix #3790
2023-11-02 11:09:20 +01:00
Tobias Hunger
b12575a4c4 janitor: Go over our spell checking setup
* Extend the cspell word list
* Remove those extensions from individual source files
* white-list licenses and such as we should not meddle with those
* Fix spelling
2023-10-16 09:01:51 +02:00
Olivier Goffart
e0ac0ed319
Frame per second counter for the software renderer 2023-09-28 16:23:07 +02:00
Simon Hausmann
2b14806cd5 Default for false for ImageInner's PartialEq::eq fallback
This may help to reduce the risk of introducing issues similar to #3510.
2023-09-20 11:18:29 +02:00
Simon Hausmann
a7b6bcae6e Skia renderer: Fixed the source property of Image elements sometimes not changing when setting dynamically loaded images
After loading an image with `Image::load_from_path` and setting to a
source property, upon rendering with Skia, it would get replaced with a
Skia renderer specific image representation. When later setting another
image that was also using `ImageInner::BackedStorage`, the property
would not get set because PartialEq::eq would return true because the
image inner types are the same, instead of comparing the vtable
pointers.

Fixes #3510
2023-09-20 11:18:29 +02:00
Guilhem Vallat
5cf1a45e41 Remove duplicated geometry properties from items 2023-09-13 16:08:37 +02:00
Adam Obuchowicz
644a39f1e8 Derive serde for Color 2023-09-06 11:15:34 +02:00
Olivier Goffart
8f16b519a2 use #repr(uX) instead of repr(C) for fieldless enums
Otherwise the ABI may differ between the C++ and the Rust
2023-08-31 10:22:03 +02:00
Simon Hausmann
e73ad733fc API fixes to the OpenGL texture borrowing API
- Make BorrowedOpenGLTextureOrigin non_exhaustive
- Mark BorrowedOpenGLTextureBuilder::new_gl_2d_rgba_texture as unsafe instead of build(). The former takes the arguments that may be garbage, not the latter.
2023-08-30 16:18:42 +02:00
Simon Hausmann
91d0747d06 Make use of the ItemCache more robust when the window scale factor changes
Previously, all the closures passed to `get_or_update_cache_entry` would
have to make sure that the scale factor is an included dependency. This
is error prone, as the parent commits show.

Instead, this change adds a property tracker to each ItemCache and lets
the renderer clear the cache if the scale factor changes.

Strictly speaking this may delete too many entries from the cache (not
all depend on the scale factor), but on the other hand this doesn't
happen very often so we trade robustness over efficiency.
2023-08-16 16:37:07 +02:00
Simon Hausmann
4881bd1a87 Fix box-shadow cache not being invalidate when the scale factor changes
Include the scale factor in the dependency tracker of the item cache used for box shadows.
2023-08-16 16:37:07 +02:00
Simon Hausmann
0c9199b17f
Add support for flipping borrowed OpenGL textures vertically (#3205)
Closes #2986

Co-authored-by: Olivier Goffart <olivier.goffart@slint-ui.com>
2023-08-02 13:11:13 +02:00
Aurindam Jana
5a4a7fee63
Update royalty free license to 1.1 (#2994) 2023-07-10 10:12:11 +02:00
Olivier Goffart
aa8ef4e302 C++: add a "std" feature to the slint-cpp crate
And make it no_std otherwise

This is a first step towards getting C++ on MCU (#2136)
2023-07-05 21:48:01 +02:00
Tobias Hunger
e02c360000 Clippy polish 2023-06-28 14:22:30 +02:00
Simon Hausmann
d1daa8dbe4 doc: Document coordinate system expectations for borrowed textures 2023-06-26 12:49:22 +02:00
Simon Hausmann
aa41277df1 Improve safety notes on the slint::Image texture import functions
Elaborate how to call this function safely, and copy the same description to the C++ docs.
2023-06-22 22:31:51 +02:00
Simon Hausmann
a84aa70cd0 Fix rendering of scale SVGs
Commit c8f1f4354b accidentally inverted
the target size computation logic when porting away from FitTo, scaling
to the tree width instead of scaling the tree width to the image element
width but preserving aspect ratio.

Fixes rendering of AboutSlint in gallery.
2023-06-19 22:39:39 +02:00
Simon Hausmann
653b63a35e Port to resvg 0.34 2023-06-18 08:58:09 +02:00
Simon Hausmann
c8f1f4354b Port to resvg 0.33 2023-06-18 08:58:09 +02:00
Olivier Goffart
11dea135f7 Domain: slint-ui.com -> slint.dev 2023-06-16 10:55:08 +02:00
Aurindam Jana
039e54a5de
Add royalty free license to files except examples and docs (#2888) 2023-06-15 11:20:50 +02:00
Olivier Goffart
f7e61fdd37 Fix transparentize to multiply by 1-factor
Also add `[[nodicard]]` in C++
2023-06-02 17:02:08 +02:00
Olivier Goffart
5599bd44e0 Remove Color::opaque
It is not a right name and i don't think it is a so common operation
2023-06-02 17:02:08 +02:00
Olivier Goffart
4845241ebf Rename translucent to transparentize and mixed to mix 2023-06-02 17:02:08 +02:00
Arthur Araruna
64ad1ce357 Add some color and brush manipulation funcs (#2565)
The added functions enable mixing colors and manipulating the opacity
of colors and brushes.

They enable the behavior of some of the available functions from SASS and are
added for future use for adding the Adwaita style (future PR).
2023-06-02 17:02:08 +02:00
Simon Hausmann
e7320607a3 Remove BorrowedOpenGLTexture from the public API again and just provide a factory function in slint::Image 2023-06-01 15:56:55 +02:00
Simon Hausmann
084ff70079 C++: Improve reliability of comparison operator of slint::Image
Call into the Rust implementation, so that we have to maintain only one
implementation.
2023-06-01 15:56:55 +02:00
Simon Hausmann
eadfec64a3 Add support for importing OpenGL textures into Slint
This is the initial API for Slint to borrow OpenGL textures from the
application for rendering.
2023-06-01 15:56:55 +02:00
Simon Hausmann
6b8214c3f9 Add support for italic and bold text in the software renderer's bitmap font path
In the screenshot tests this works by setting SLINT_DEFAULT_FONT to
pointer to a directory, instead of a file. We then load all fonts in
that directory and consider their families the default unless a family
is specified. This way for "Noto Sans" a regular as well as an italic
version is registered in fontdb and returned in the list of font
fallback ids. embed_glyphs in the compiler then embeds those variants
and we find them at run-time.
2023-05-31 18:47:39 +02:00
Simon Hausmann
328cfc76b6 Move sharedfontdb from core to common
This way it is also accessible to the compiler.
2023-05-23 08:26:03 +02:00
Simon Hausmann
afd85a9a0b Remove outdated comment
This is handled in fixup_text now.
2023-05-19 10:40:51 +02:00