use cxx::{type_id, ExternType};
use std::fmt;
#[cxx::bridge]
mod ffi {
unsafe extern "C++" {
include!("cxx-qt-lib/qpoint.h");
type QPoint = crate::QPoint;
include!("cxx-qt-lib/qpointf.h");
type QPointF = super::QPointF;
include!("cxx-qt-lib/qstring.h");
type QString = crate::QString;
#[rust_name = "is_null"]
fn isNull(self: &QPointF) -> bool;
#[rust_name = "manhattan_length"]
fn manhattanLength(self: &QPointF) -> f64;
#[rust_name = "set_x"]
fn setX(self: &mut QPointF, x: f64);
#[rust_name = "set_y"]
fn setY(self: &mut QPointF, y: f64);
#[rust_name = "to_point"]
fn toPoint(self: &QPointF) -> QPoint;
fn transposed(self: &QPointF) -> QPointF;
fn x(self: &QPointF) -> f64;
fn y(self: &QPointF) -> f64;
}
#[namespace = "rust::cxxqtlib1"]
unsafe extern "C++" {
#[doc(hidden)]
#[rust_name = "qpointf_dot_product"]
fn qpointfDotProduct(p1: &QPointF, p2: &QPointF) -> f64;
}
#[namespace = "rust::cxxqtlib1"]
unsafe extern "C++" {
include!("cxx-qt-lib/common.h");
#[doc(hidden)]
#[rust_name = "qpointf_init_default"]
fn construct() -> QPointF;
#[doc(hidden)]
#[rust_name = "qpointf_init"]
fn construct(x: f64, y: f64) -> QPointF;
#[doc(hidden)]
#[rust_name = "qpointf_from_qpoint"]
fn construct(point: &QPoint) -> QPointF;
#[doc(hidden)]
#[rust_name = "qpointf_to_qstring"]
fn toQString(value: &QPointF) -> QString;
#[doc(hidden)]
#[rust_name = "qpointf_plus"]
fn operatorPlus(a: &QPointF, b: &QPointF) -> QPointF;
#[doc(hidden)]
#[rust_name = "qpointf_minus"]
fn operatorMinus(a: &QPointF, b: &QPointF) -> QPointF;
#[doc(hidden)]
#[rust_name = "qpointf_mul"]
fn operatorMul(a: f64, b: &QPointF) -> QPointF;
#[doc(hidden)]
#[rust_name = "qpointf_div"]
fn operatorDiv(a: f64, b: &QPointF) -> QPointF;
}
}
#[derive(Debug, Clone, PartialEq)]
#[repr(C)]
pub struct QPointF {
x: f64,
y: f64,
}
impl QPointF {
pub fn dot_product(p1: &QPointF, p2: &QPointF) -> f64 {
ffi::qpointf_dot_product(p1, p2)
}
pub fn new(x: f64, y: f64) -> Self {
ffi::qpointf_init(x, y)
}
}
impl Default for QPointF {
fn default() -> Self {
ffi::qpointf_init_default()
}
}
impl fmt::Display for QPointF {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", ffi::qpointf_to_qstring(self))
}
}
impl From<&ffi::QPoint> for QPointF {
fn from(point: &ffi::QPoint) -> Self {
ffi::qpointf_from_qpoint(point)
}
}
impl From<QPointF> for ffi::QPoint {
fn from(value: QPointF) -> Self {
value.to_point()
}
}
impl std::ops::Add for QPointF {
type Output = Self;
fn add(self, other: Self) -> Self {
ffi::qpointf_plus(&self, &other)
}
}
impl std::ops::Sub for QPointF {
type Output = Self;
fn sub(self, other: Self) -> Self {
ffi::qpointf_minus(&self, &other)
}
}
impl std::ops::Mul<f64> for QPointF {
type Output = Self;
fn mul(self, rhs: f64) -> Self {
ffi::qpointf_mul(rhs, &self)
}
}
impl std::ops::Div<f64> for QPointF {
type Output = Self;
fn div(self, rhs: f64) -> Self {
ffi::qpointf_div(rhs, &self)
}
}
unsafe impl ExternType for QPointF {
type Id = type_id!("QPointF");
type Kind = cxx::kind::Trivial;
}