1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
use cxx::{type_id, ExternType};
use std::fmt;
#[cxx::bridge]
mod ffi {
#[namespace = "Qt"]
unsafe extern "C++" {
include!("cxx-qt-lib/qt.h");
type AspectRatioMode = crate::AspectRatioMode;
}
unsafe extern "C++" {
include!("cxx-qt-lib/qmargins.h");
type QMargins = crate::QMargins;
include!("cxx-qt-lib/qsize.h");
type QSize = super::QSize;
include!("cxx-qt-lib/qstring.h");
type QString = crate::QString;
#[rust_name = "bounded_to"]
fn boundedTo(self: &QSize, other_size: &QSize) -> QSize;
#[rust_name = "expanded_to"]
fn expandedTo(self: &QSize, other_size: &QSize) -> QSize;
fn height(self: &QSize) -> i32;
#[rust_name = "is_empty"]
fn isEmpty(self: &QSize) -> bool;
#[rust_name = "is_null"]
fn isNull(self: &QSize) -> bool;
#[rust_name = "is_valid"]
fn isValid(self: &QSize) -> bool;
#[rust_name = "grown_by"]
fn grownBy(self: &QSize, margins: QMargins) -> QSize;
fn scale(self: &mut QSize, size: &QSize, mode: AspectRatioMode);
fn scaled(self: &QSize, s: &QSize, mode: AspectRatioMode) -> QSize;
#[rust_name = "set_height"]
fn setHeight(self: &mut QSize, height: i32);
#[rust_name = "set_width"]
fn setWidth(self: &mut QSize, width: i32);
#[rust_name = "shrunk_by"]
fn shrunkBy(self: &QSize, margins: QMargins) -> QSize;
fn transpose(self: &mut QSize);
fn transposed(self: &QSize) -> QSize;
fn width(self: &QSize) -> i32;
}
#[namespace = "rust::cxxqtlib1"]
unsafe extern "C++" {
include!("cxx-qt-lib/common.h");
#[doc(hidden)]
#[rust_name = "qsize_init_default"]
fn construct() -> QSize;
#[doc(hidden)]
#[rust_name = "qsize_init"]
fn construct(w: i32, h: i32) -> QSize;
#[doc(hidden)]
#[rust_name = "qsize_to_qstring"]
fn toQString(value: &QSize) -> QString;
#[doc(hidden)]
#[rust_name = "qsize_plus"]
fn operatorPlus(a: &QSize, b: &QSize) -> QSize;
#[doc(hidden)]
#[rust_name = "qsize_minus"]
fn operatorMinus(a: &QSize, b: &QSize) -> QSize;
#[doc(hidden)]
#[rust_name = "qsize_mul"]
fn operatorMul(a: f64, b: &QSize) -> QSize;
#[doc(hidden)]
#[rust_name = "qsize_div"]
fn operatorDiv(a: f64, b: &QSize) -> QSize;
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[repr(C)]
pub struct QSize {
width: i32,
height: i32,
}
impl QSize {
pub fn new(width: i32, height: i32) -> Self {
ffi::qsize_init(width, height)
}
}
impl Default for QSize {
fn default() -> Self {
ffi::qsize_init_default()
}
}
impl fmt::Display for QSize {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", ffi::qsize_to_qstring(self))
}
}
impl std::ops::Add for QSize {
type Output = Self;
fn add(self, other: Self) -> Self {
ffi::qsize_plus(&self, &other)
}
}
impl std::ops::Sub for QSize {
type Output = Self;
fn sub(self, other: Self) -> Self {
ffi::qsize_minus(&self, &other)
}
}
impl std::ops::Mul<f64> for QSize {
type Output = Self;
fn mul(self, rhs: f64) -> Self {
ffi::qsize_mul(rhs, &self)
}
}
impl std::ops::Div<f64> for QSize {
type Output = Self;
fn div(self, rhs: f64) -> Self {
ffi::qsize_div(rhs, &self)
}
}
unsafe impl ExternType for QSize {
type Id = type_id!("QSize");
type Kind = cxx::kind::Trivial;
}