@@ -86,6 +86,7 @@ cpp! {{
86
86
#include <QtCore /QUrl >
87
87
88
88
#include <QtGui /QImage >
89
+ #include <QtGui /QPixmap >
89
90
} }
90
91
91
92
cpp_class ! (
@@ -1006,10 +1007,19 @@ impl QRectF {
1006
1007
} )
1007
1008
}
1008
1009
1009
- // XXX: shouldn't it be a wrapper for cpp call?
1010
+ /// Same as the [`topLeft`][method] method.
1011
+ ///
1012
+ /// [method]: https://doc.qt.io/qt-5/qrectf.html#topLeft
1010
1013
pub fn top_left ( & self ) -> QPointF {
1011
1014
QPointF { x : self . x , y : self . y }
1012
1015
}
1016
+
1017
+ /// Same as the [`isValid`][method] method.
1018
+ ///
1019
+ /// [method]: https://doc.qt.io/qt-5/qrectf.html#isValid
1020
+ pub fn is_valid ( & self ) -> bool {
1021
+ self . width > 0. && self . height > 0.
1022
+ }
1013
1023
}
1014
1024
1015
1025
/// Bindings for [`QPointF`][class] class.
@@ -1039,6 +1049,16 @@ impl std::ops::AddAssign for QPointF {
1039
1049
}
1040
1050
}
1041
1051
1052
+ /// Bindings for [`QSizeF`][class] class.
1053
+ ///
1054
+ /// [class]: https://doc.qt.io/qt-5/qsizef.html
1055
+ #[ repr( C ) ]
1056
+ #[ derive( Default , Clone , Copy , PartialEq , Debug ) ]
1057
+ pub struct QSizeF {
1058
+ pub width : qreal ,
1059
+ pub height : qreal ,
1060
+ }
1061
+
1042
1062
#[ test]
1043
1063
fn test_qpointf_qrectf ( ) {
1044
1064
let rect = QRectF { x : 200. , y : 150. , width : 60. , height : 75. } ;
@@ -1136,6 +1156,28 @@ pub struct QSize {
1136
1156
pub height : u32 ,
1137
1157
}
1138
1158
1159
+ /// Bindings for [`QPoint`][class] class.
1160
+ ///
1161
+ /// [class]: https://doc.qt.io/qt-5/qpoint.html
1162
+ #[ repr( C ) ]
1163
+ #[ derive( Default , Clone , Copy , PartialEq , Debug ) ]
1164
+ pub struct QPoint {
1165
+ pub x : i32 ,
1166
+ pub y : i32 ,
1167
+ }
1168
+
1169
+ /// Bindings for [`QMargins`][class] class.
1170
+ ///
1171
+ /// [class]: https://doc.qt.io/qt-5/qmargins.html
1172
+ #[ repr( C ) ]
1173
+ #[ derive( Default , Clone , Copy , PartialEq , Debug ) ]
1174
+ pub struct QMargins {
1175
+ pub left : i32 ,
1176
+ pub top : i32 ,
1177
+ pub right : i32 ,
1178
+ pub bottom : i32 ,
1179
+ }
1180
+
1139
1181
/// Bindings for [`QImage::Format`][class] enum class.
1140
1182
///
1141
1183
/// [class]: https://doc.qt.io/qt-5/qimage.html#Format-enum
@@ -1178,6 +1220,7 @@ cpp_class!(
1178
1220
/// Wrapper around [`QImage`][class] class.
1179
1221
///
1180
1222
/// [class]: https://doc.qt.io/qt-5/qimage.html
1223
+ #[ derive( Default , Clone , PartialEq ) ]
1181
1224
pub unsafe struct QImage as "QImage"
1182
1225
) ;
1183
1226
impl QImage {
@@ -1232,9 +1275,37 @@ impl QImage {
1232
1275
/// Wrapper around [`pixelColor(const QPoint &)`][method] method.
1233
1276
///
1234
1277
/// [method]: https://doc.qt.io/qt-5/qimage.html#pixelColor
1235
- pub fn get_pixel_color ( & mut self , x : u32 , y : u32 ) -> QColor {
1236
- cpp ! ( unsafe [ self as "QImage*" , x as "int" , y as "int" ] -> QColor as "QColor" {
1278
+ pub fn get_pixel_color ( & self , x : u32 , y : u32 ) -> QColor {
1279
+ cpp ! ( unsafe [ self as "const QImage*" , x as "int" , y as "int" ] -> QColor as "QColor" {
1237
1280
return self ->pixelColor( x, y) ;
1238
1281
} )
1239
1282
}
1240
1283
}
1284
+
1285
+ cpp_class ! (
1286
+ /// Wrapper around [`QPixmap`][class] class.
1287
+ ///
1288
+ /// [class]: https://doc.qt.io/qt-5/qpixmap.html
1289
+ pub unsafe struct QPixmap as "QPixmap"
1290
+ ) ;
1291
+
1292
+ impl QPixmap {
1293
+ /// Wrapper around [`size()`][method] method.
1294
+ ///
1295
+ /// [method]: https://doc.qt.io/qt-5/qpixmap.html#size
1296
+ pub fn size ( & self ) -> QSize {
1297
+ cpp ! ( unsafe [ self as "const QPixmap*" ] -> QSize as "QSize" { return self ->size( ) ; } )
1298
+ }
1299
+ }
1300
+
1301
+ impl From < QPixmap > for QImage {
1302
+ fn from ( pixmap : QPixmap ) -> Self {
1303
+ cpp ! ( unsafe [ pixmap as "QPixmap" ] -> QImage as "QImage" { return pixmap. toImage( ) ; } )
1304
+ }
1305
+ }
1306
+
1307
+ impl From < QImage > for QPixmap {
1308
+ fn from ( image : QImage ) -> Self {
1309
+ cpp ! ( unsafe [ image as "QImage" ] -> QPixmap as "QPixmap" { return QPixmap :: fromImage( image) ; } )
1310
+ }
1311
+ }
0 commit comments