mirror of
https://github.com/slint-ui/slint.git
synced 2025-10-01 06:11:16 +00:00
Add support for sixtyfps::Image::size() in C++
Also added a unit test for the C++ implementation.
This commit is contained in:
parent
0fdb87cc69
commit
85474f7670
6 changed files with 66 additions and 9 deletions
|
@ -15,6 +15,20 @@ LICENSE END */
|
|||
|
||||
namespace sixtyfps {
|
||||
|
||||
#if !defined(DOXYGEN)
|
||||
using cbindgen_private::types::Size;
|
||||
#else
|
||||
/// The Size structure is used to represent a two-dimensional size
|
||||
/// with width and height.
|
||||
struct Size
|
||||
{
|
||||
/// The width of the size
|
||||
float width;
|
||||
/// The height of the size
|
||||
float height;
|
||||
};
|
||||
#endif
|
||||
|
||||
/// An image type that can be displayed by the Image element
|
||||
struct Image
|
||||
{
|
||||
|
@ -22,7 +36,8 @@ public:
|
|||
Image() : data(Data::None()) { }
|
||||
|
||||
/// Load an image from an image file
|
||||
static Image load_from_path(const SharedString &file_path) {
|
||||
static Image load_from_path(const SharedString &file_path)
|
||||
{
|
||||
Image img;
|
||||
img.data = Data::AbsoluteFilePath(file_path);
|
||||
return img;
|
||||
|
@ -35,12 +50,12 @@ public:
|
|||
return img;
|
||||
}
|
||||
*/
|
||||
friend bool operator==(const Image &a, const Image &b) {
|
||||
return a.data == b.data;
|
||||
}
|
||||
friend bool operator!=(const Image &a, const Image &b) {
|
||||
return a.data != b.data;
|
||||
}
|
||||
|
||||
/// Returns the size of the Image in pixels.
|
||||
Size size() const { return cbindgen_private::types::sixtyfps_image_size(&data); }
|
||||
|
||||
friend bool operator==(const Image &a, const Image &b) { return a.data == b.data; }
|
||||
friend bool operator!=(const Image &a, const Image &b) { return a.data != b.data; }
|
||||
|
||||
private:
|
||||
using Tag = cbindgen_private::types::ImageInner::Tag;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue