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;
}