Olivier Goffart
a094ce7a2a
Add a warning on the internal crates documentation that we don't follow semver
2021-08-16 18:26:33 +02:00
Olivier Goffart
073447a47d
Fix the clippy error about comparing address of virtual table
...
Fix one vtable_address_comparisons clippy link.
It is fine to only compare the data pointer.
Two different model with the same data pointer in a Rc could only be obtained
with tricks like transmute because each model is allocated on a different Rc.
2021-08-16 10:53:28 +02:00
Olivier Goffart
ec529f088b
Fix the native style drawn from the GL backend
...
Femtovg wants RGBA, not ARGB
2021-08-13 18:12:18 +02:00
Simon Hausmann
386d61d648
Simplify Rust’s SharedVector::clear() when the vector is shared
...
Co-authored-by: Olivier Goffart <ogoffart@sixtyfps.io>
2021-08-12 13:41:08 +02:00
Simon Hausmann
d65af654d7
Changed Rust's SharedVector::clear() to not preserve capacity when shared
2021-08-12 13:41:08 +02:00
Simon Hausmann
856a049627
Implement SharedVector::clear() for Rust
2021-08-12 13:41:08 +02:00
Simon Hausmann
e5c2a4f996
Avoid hardcoding the rgb crate version for rustdoc builds
2021-08-11 08:46:55 +02:00
Simon Hausmann
ea663955bd
Fix links to rgb crate in the sixtyfps.io hosted online docs
...
Use the external docs rustdoc feature to link to the rgb docs on docs.rs.
2021-08-10 22:30:37 +02:00
Simon Hausmann
e23dcc336f
Fix doc build
...
Amends commit 0852a7661b
2021-08-10 16:53:37 +02:00
Simon Hausmann
0852a7661b
Fix mutable slice API
...
* Change SharedVector::as_mut_slice() to SharedVector::make_mut_slice()
* SharedPixelBuffer::as_mut_slice and SharedPixelBuffer::make_mut_slice()
* SharedPixelBuffer::as_bytes_mut() to SharedPixelBuffer::make_mut_bytes()
This is consistent with Rc::make_mut() and is supposed to emphasize
that, unlike the usual as_* operations, it is not a free operation but
may involve work (detaching the data by cloning it).
Amends commit 7384ebdc32
2021-08-10 16:37:34 +02:00
Simon Hausmann
1fca971fa8
Rename RGB(A)8Pixel to Rgb(a)8Pixel
...
That's consistent casing with RgbaColor.
2021-08-10 15:56:01 +02:00
Simon Hausmann
4e9b2725a7
doc fix: Remove mention of SharedVector in SharedPixelBuffer
...
It's an implementation detail
2021-08-10 15:56:01 +02:00
Simon Hausmann
a0f06e35d7
Fix rustdoc link
...
Co-authored-by: Olivier Goffart <ogoffart@sixtyfps.io>
2021-08-10 15:56:01 +02:00
Simon Hausmann
0d3c38899f
minor doc fix: capitalize Rust
2021-08-10 15:56:01 +02:00
Simon Hausmann
d023475f1c
Rename Image::new_rgb*()
to Image::from_rgb*
2021-08-10 15:56:01 +02:00
Simon Hausmann
76041684c0
Simplify scenario description in Image docs
...
It doesn't have to be an external crate that renders images, just Rust code generally.
Co-authored-by: Olivier Goffart <ogoffart@sixtyfps.io>
2021-08-10 15:56:01 +02:00
Simon Hausmann
2a420d7a86
Remove imgref dependency from the public Image API
...
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.
2021-08-10 15:56:01 +02:00
Simon Hausmann
cfb6caca01
Fix calling Image::size()
on default or pixel-buffer constructed images
...
For such images we do not need a backend and can avoid the panic.
2021-08-10 15:56:01 +02:00
Simon Hausmann
6016007c6f
Avoid the need for SharedPixelBuffer
users to depend on rgb
...
Re-export the two typical pixel types, for convenience. Of course other
types can be used, too, if the user depends on rgb directly.
2021-08-10 15:56:01 +02:00
Simon Hausmann
c18b289e62
Provide convenience as_bytes(_mut)
for SharedPixelBuffer
...
This avoids the need for users of the API to import the ComponentBytes trait from rgb.
2021-08-10 15:56:01 +02:00
Simon Hausmann
8b62564a4b
Fix incorrect self parameter in SharedPixelBuffer
...
We don't need a mutable reference for `as_slice()`
2021-08-10 15:56:01 +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
12916e7488
Fix C++ build after Image API changes
...
Export missing types
2021-08-10 15:56:01 +02:00
Simon Hausmann
2e9e818691
Mark SharedPixelBuffer as repr(C)
...
For use in the ffi later
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
ogoffart
53f286258c
Bump version number to 0.1.1
2021-08-10 08:06:20 +00:00
Simon Hausmann
7384ebdc32
Deprecated SharedVector::as_slice_mut() in favor of SharedVector::as_mut_slice()
...
The standard library uses the latter name.
2021-08-09 14:51:09 +02:00
Tobias Hunger
c3ce321429
Janitor: Fix clippy::ptr_arg
2021-08-09 13:19:34 +02:00
Tobias Hunger
cbdea7c9c7
Janitor: Fix clippy::missing_safety_doc
2021-08-09 13:19:34 +02:00
Tobias Hunger
bac4d895ce
Janitor: Fix clippy::while_let_on_iterator
2021-08-09 13:19:34 +02:00
Simon Hausmann
b4ba77dba7
Fix SharedVector creation from iterators with default size hints
...
* In capacity_for_grow, don't compare the number of elements
(current_cap) with the size of an element in bytes, but
with the required capacity instead (to detect that we don't need
to grow). Not all call sites check for that (i.e. push), so there's
a new test for that.
* When re-allocating due to growth and copying elements from the old
inner to the new inner, make sure to copy all old elements from the beginning,
not only the last element repeatedly.
2021-08-06 16:18:33 +02:00
Tobias Hunger
ff76aa8953
Janitor: Fix clippy::blocks_in_if_conditions
2021-08-05 23:41:56 +02:00
Simon Hausmann
acb10caea3
internal cleanup: don't bother with Cargo.toml files
...
Crates names just create noise
2021-08-05 13:54:17 +02:00
Tobias Hunger
cbeecfefba
Remove unnecessary clone() calls
...
window is just &self once the redundant clone() call has been removed,
so remove that variable entirely.
2021-08-04 22:50:35 +02:00
Tobias Hunger
ce976a1dbb
Janitor: Fix clippy::useless_conversion
2021-08-04 22:50:35 +02:00
Tobias Hunger
24a2021226
Janitor: Fix clippy::needless_borrow
2021-08-04 22:50:35 +02:00
Tobias Hunger
22c65707b2
Janitor: Fix clippy::len_zero
2021-08-04 22:50:35 +02:00
Tobias Hunger
60ef093aaa
Janitor: Fix clippy::len_without_is_empty
2021-08-04 22:50:35 +02:00
Tobias Hunger
57ed130380
Janitor: Fix clippy::from_over_into
2021-08-04 22:50:35 +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
bd556e03be
minor cleanup: add transparent marker
...
to make the reinterpret casting between the inner and outer types a bit ... safer
2021-08-03 10:32:04 +02:00
Simon Hausmann
29f5853332
Provide sixtyfps::Window
by reference in the Rust API
...
This also removes Clone from the Window again, to avoid having to face
the question: Does cloning a window duplicate it on the screen?
2021-08-03 10:32:04 +02:00
Simon Hausmann
d87cfb4b1e
internal cleanup
...
Move the WindowHandleAccess impl for api::Window into the super module
so that we don't need the #[doc(hidden)] attribute.
2021-08-03 10:32:04 +02:00
Simon Hausmann
66891a299c
Start a new sixtyfps::Window API for Rust, C++, the interpreters and JS
...
The generated component now provides access to a Window type
via the window() accessor function.
This is part of #333
2021-08-03 10:32:04 +02:00
Simon Hausmann
17b3fbc7cf
Fix cursor navigation when using combining characters
...
The cursor navigation left/right (and subsequently text selection) needs
to respect grapheme boundaries. Since we already depend on the
unicode-segmentation crate through femtovg, we might as well use the
functionality for determining grapheme boundaries from there.
The only place where the cursor navigation is allowed to break that is
when using backspace, as that allows the user to break glyph clusters.
2021-08-01 09:35:19 +02:00
Tobias Hunger
f1f0182826
Janitor: Fix clippy::needless_return
2021-07-30 09:27:48 +02:00
Olivier Goffart
bd52f4d444
Allow the clip property to be a dynamic property
2021-07-29 15:02:25 +02:00
Tobias Hunger
9539a53480
Janitor: Fix clippy::redundant_clone
2021-07-23 13:48:52 +02:00
Tobias Hunger
d64291245e
Janitor: Fix clippy::len_zero
2021-07-23 13:48:52 +02:00
Tobias Hunger
3e0534afea
Janitor: Fix clippy::needless_lifetimes
2021-07-23 13:48:52 +02:00