use std::cell::Cell;
use std::rc::Rc;
#[allow(unused_imports)]
use std::marker::PhantomData;
#[allow(unused_imports)]
use std::os::raw::c_void;
#[allow(unused_imports)]
use std::mem::transmute;
#[allow(unused_imports)]
use std::ffi::{CStr, CString};
use rute_ffi_base::*;
#[allow(unused_imports)]
use auto::*;
#[derive(Clone)]
pub struct RectF<'a> {
#[doc(hidden)]
pub data: Rc<Cell<Option<*const RUBase>>>,
#[doc(hidden)]
pub all_funcs: *const RURectFAllFuncs,
#[doc(hidden)]
pub owned: bool,
#[doc(hidden)]
pub _marker: PhantomData<::std::cell::Cell<&'a ()>>,
}
impl<'a> RectF<'a> {
pub fn new() -> RectF<'a> {
let data = Rc::new(Cell::new(None));
let ffi_data = unsafe {
((*rute_ffi_get()).create_rect_f)(
::std::ptr::null(),
transmute(rute_object_delete_callback as usize),
Rc::into_raw(data.clone()) as *const c_void,
)
};
data.set(Some(ffi_data.qt_data));
RectF {
data,
all_funcs: ffi_data.all_funcs,
owned: true,
_marker: PhantomData,
}
}
#[allow(dead_code)]
pub(crate) fn new_from_rc(ffi_data: RURectF) -> RectF<'a> {
RectF {
data: unsafe { Rc::from_raw(ffi_data.host_data as *const Cell<Option<*const RUBase>>) },
all_funcs: ffi_data.all_funcs,
owned: false,
_marker: PhantomData,
}
}
#[allow(dead_code)]
pub(crate) fn new_from_owned(ffi_data: RURectF) -> RectF<'a> {
RectF {
data: Rc::new(Cell::new(Some(ffi_data.qt_data as *const RUBase))),
all_funcs: ffi_data.all_funcs,
owned: true,
_marker: PhantomData,
}
}
#[allow(dead_code)]
pub(crate) fn new_from_temporary(ffi_data: RURectF) -> RectF<'a> {
RectF {
data: Rc::new(Cell::new(Some(ffi_data.qt_data as *const RUBase))),
all_funcs: ffi_data.all_funcs,
owned: false,
_marker: PhantomData,
}
}
pub fn is_null(&self) -> bool {
let (obj_data, funcs) = self.get_rect_f_obj_funcs();
unsafe {
let ret_val = ((*funcs).is_null)(obj_data);
ret_val
}
}
pub fn is_empty(&self) -> bool {
let (obj_data, funcs) = self.get_rect_f_obj_funcs();
unsafe {
let ret_val = ((*funcs).is_empty)(obj_data);
ret_val
}
}
pub fn is_valid(&self) -> bool {
let (obj_data, funcs) = self.get_rect_f_obj_funcs();
unsafe {
let ret_val = ((*funcs).is_valid)(obj_data);
ret_val
}
}
pub fn normalized(&self) -> RectF {
let (obj_data, funcs) = self.get_rect_f_obj_funcs();
unsafe {
let ret_val = ((*funcs).normalized)(obj_data);
let t = ret_val;
let ret_val;
if t.host_data != ::std::ptr::null() {
ret_val = RectF::new_from_rc(t);
} else {
ret_val = RectF::new_from_owned(t);
}
ret_val
}
}
pub fn left(&self) -> f32 {
let (obj_data, funcs) = self.get_rect_f_obj_funcs();
unsafe {
let ret_val = ((*funcs).left)(obj_data);
ret_val
}
}
pub fn top(&self) -> f32 {
let (obj_data, funcs) = self.get_rect_f_obj_funcs();
unsafe {
let ret_val = ((*funcs).top)(obj_data);
ret_val
}
}
pub fn right(&self) -> f32 {
let (obj_data, funcs) = self.get_rect_f_obj_funcs();
unsafe {
let ret_val = ((*funcs).right)(obj_data);
ret_val
}
}
pub fn bottom(&self) -> f32 {
let (obj_data, funcs) = self.get_rect_f_obj_funcs();
unsafe {
let ret_val = ((*funcs).bottom)(obj_data);
ret_val
}
}
pub fn x(&self) -> f32 {
let (obj_data, funcs) = self.get_rect_f_obj_funcs();
unsafe {
let ret_val = ((*funcs).x)(obj_data);
ret_val
}
}
pub fn y(&self) -> f32 {
let (obj_data, funcs) = self.get_rect_f_obj_funcs();
unsafe {
let ret_val = ((*funcs).y)(obj_data);
ret_val
}
}
pub fn set_left(&self, pos: f32) -> &Self {
let (obj_data, funcs) = self.get_rect_f_obj_funcs();
unsafe {
((*funcs).set_left)(obj_data, pos);
}
self
}
pub fn set_top(&self, pos: f32) -> &Self {
let (obj_data, funcs) = self.get_rect_f_obj_funcs();
unsafe {
((*funcs).set_top)(obj_data, pos);
}
self
}
pub fn set_right(&self, pos: f32) -> &Self {
let (obj_data, funcs) = self.get_rect_f_obj_funcs();
unsafe {
((*funcs).set_right)(obj_data, pos);
}
self
}
pub fn set_bottom(&self, pos: f32) -> &Self {
let (obj_data, funcs) = self.get_rect_f_obj_funcs();
unsafe {
((*funcs).set_bottom)(obj_data, pos);
}
self
}
pub fn set_x(&self, pos: f32) -> &Self {
let (obj_data, funcs) = self.get_rect_f_obj_funcs();
unsafe {
((*funcs).set_x)(obj_data, pos);
}
self
}
pub fn set_y(&self, pos: f32) -> &Self {
let (obj_data, funcs) = self.get_rect_f_obj_funcs();
unsafe {
((*funcs).set_y)(obj_data, pos);
}
self
}
pub fn top_left(&self) -> PointF {
let (obj_data, funcs) = self.get_rect_f_obj_funcs();
unsafe {
let ret_val = ((*funcs).top_left)(obj_data);
let t = ret_val;
let ret_val;
if t.host_data != ::std::ptr::null() {
ret_val = PointF::new_from_rc(t);
} else {
ret_val = PointF::new_from_owned(t);
}
ret_val
}
}
pub fn bottom_right(&self) -> PointF {
let (obj_data, funcs) = self.get_rect_f_obj_funcs();
unsafe {
let ret_val = ((*funcs).bottom_right)(obj_data);
let t = ret_val;
let ret_val;
if t.host_data != ::std::ptr::null() {
ret_val = PointF::new_from_rc(t);
} else {
ret_val = PointF::new_from_owned(t);
}
ret_val
}
}
pub fn top_right(&self) -> PointF {
let (obj_data, funcs) = self.get_rect_f_obj_funcs();
unsafe {
let ret_val = ((*funcs).top_right)(obj_data);
let t = ret_val;
let ret_val;
if t.host_data != ::std::ptr::null() {
ret_val = PointF::new_from_rc(t);
} else {
ret_val = PointF::new_from_owned(t);
}
ret_val
}
}
pub fn bottom_left(&self) -> PointF {
let (obj_data, funcs) = self.get_rect_f_obj_funcs();
unsafe {
let ret_val = ((*funcs).bottom_left)(obj_data);
let t = ret_val;
let ret_val;
if t.host_data != ::std::ptr::null() {
ret_val = PointF::new_from_rc(t);
} else {
ret_val = PointF::new_from_owned(t);
}
ret_val
}
}
pub fn center(&self) -> PointF {
let (obj_data, funcs) = self.get_rect_f_obj_funcs();
unsafe {
let ret_val = ((*funcs).center)(obj_data);
let t = ret_val;
let ret_val;
if t.host_data != ::std::ptr::null() {
ret_val = PointF::new_from_rc(t);
} else {
ret_val = PointF::new_from_owned(t);
}
ret_val
}
}
pub fn set_top_left<P: PointFTrait<'a>>(&self, p: &P) -> &Self {
let (obj_p_1, _funcs) = p.get_point_f_obj_funcs();
let (obj_data, funcs) = self.get_rect_f_obj_funcs();
unsafe {
((*funcs).set_top_left)(obj_data, obj_p_1);
}
self
}
pub fn set_bottom_right<P: PointFTrait<'a>>(&self, p: &P) -> &Self {
let (obj_p_1, _funcs) = p.get_point_f_obj_funcs();
let (obj_data, funcs) = self.get_rect_f_obj_funcs();
unsafe {
((*funcs).set_bottom_right)(obj_data, obj_p_1);
}
self
}
pub fn set_top_right<P: PointFTrait<'a>>(&self, p: &P) -> &Self {
let (obj_p_1, _funcs) = p.get_point_f_obj_funcs();
let (obj_data, funcs) = self.get_rect_f_obj_funcs();
unsafe {
((*funcs).set_top_right)(obj_data, obj_p_1);
}
self
}
pub fn set_bottom_left<P: PointFTrait<'a>>(&self, p: &P) -> &Self {
let (obj_p_1, _funcs) = p.get_point_f_obj_funcs();
let (obj_data, funcs) = self.get_rect_f_obj_funcs();
unsafe {
((*funcs).set_bottom_left)(obj_data, obj_p_1);
}
self
}
pub fn move_left(&self, pos: f32) -> &Self {
let (obj_data, funcs) = self.get_rect_f_obj_funcs();
unsafe {
((*funcs).move_left)(obj_data, pos);
}
self
}
pub fn move_top(&self, pos: f32) -> &Self {
let (obj_data, funcs) = self.get_rect_f_obj_funcs();
unsafe {
((*funcs).move_top)(obj_data, pos);
}
self
}
pub fn move_right(&self, pos: f32) -> &Self {
let (obj_data, funcs) = self.get_rect_f_obj_funcs();
unsafe {
((*funcs).move_right)(obj_data, pos);
}
self
}
pub fn move_bottom(&self, pos: f32) -> &Self {
let (obj_data, funcs) = self.get_rect_f_obj_funcs();
unsafe {
((*funcs).move_bottom)(obj_data, pos);
}
self
}
pub fn move_top_left<P: PointFTrait<'a>>(&self, p: &P) -> &Self {
let (obj_p_1, _funcs) = p.get_point_f_obj_funcs();
let (obj_data, funcs) = self.get_rect_f_obj_funcs();
unsafe {
((*funcs).move_top_left)(obj_data, obj_p_1);
}
self
}
pub fn move_bottom_right<P: PointFTrait<'a>>(&self, p: &P) -> &Self {
let (obj_p_1, _funcs) = p.get_point_f_obj_funcs();
let (obj_data, funcs) = self.get_rect_f_obj_funcs();
unsafe {
((*funcs).move_bottom_right)(obj_data, obj_p_1);
}
self
}
pub fn move_top_right<P: PointFTrait<'a>>(&self, p: &P) -> &Self {
let (obj_p_1, _funcs) = p.get_point_f_obj_funcs();
let (obj_data, funcs) = self.get_rect_f_obj_funcs();
unsafe {
((*funcs).move_top_right)(obj_data, obj_p_1);
}
self
}
pub fn move_bottom_left<P: PointFTrait<'a>>(&self, p: &P) -> &Self {
let (obj_p_1, _funcs) = p.get_point_f_obj_funcs();
let (obj_data, funcs) = self.get_rect_f_obj_funcs();
unsafe {
((*funcs).move_bottom_left)(obj_data, obj_p_1);
}
self
}
pub fn move_center<P: PointFTrait<'a>>(&self, p: &P) -> &Self {
let (obj_p_1, _funcs) = p.get_point_f_obj_funcs();
let (obj_data, funcs) = self.get_rect_f_obj_funcs();
unsafe {
((*funcs).move_center)(obj_data, obj_p_1);
}
self
}
pub fn move_to(&self, x: f32, y: f32) -> &Self {
let (obj_data, funcs) = self.get_rect_f_obj_funcs();
unsafe {
((*funcs).move_to)(obj_data, x, y);
}
self
}
pub fn move_to_2<P: PointFTrait<'a>>(&self, p: &P) -> &Self {
let (obj_p_1, _funcs) = p.get_point_f_obj_funcs();
let (obj_data, funcs) = self.get_rect_f_obj_funcs();
unsafe {
((*funcs).move_to_2)(obj_data, obj_p_1);
}
self
}
pub fn set_rect(&self, x: f32, y: f32, w: f32, h: f32) -> &Self {
let (obj_data, funcs) = self.get_rect_f_obj_funcs();
unsafe {
((*funcs).set_rect)(obj_data, x, y, w, h);
}
self
}
pub fn set_coords(&self, x1: f32, y1: f32, x2: f32, y2: f32) -> &Self {
let (obj_data, funcs) = self.get_rect_f_obj_funcs();
unsafe {
((*funcs).set_coords)(obj_data, x1, y1, x2, y2);
}
self
}
pub fn adjust(&self, x1: f32, y1: f32, x2: f32, y2: f32) -> &Self {
let (obj_data, funcs) = self.get_rect_f_obj_funcs();
unsafe {
((*funcs).adjust)(obj_data, x1, y1, x2, y2);
}
self
}
pub fn adjusted(&self, x1: f32, y1: f32, x2: f32, y2: f32) -> RectF {
let (obj_data, funcs) = self.get_rect_f_obj_funcs();
unsafe {
let ret_val = ((*funcs).adjusted)(obj_data, x1, y1, x2, y2);
let t = ret_val;
let ret_val;
if t.host_data != ::std::ptr::null() {
ret_val = RectF::new_from_rc(t);
} else {
ret_val = RectF::new_from_owned(t);
}
ret_val
}
}
pub fn size(&self) -> SizeF {
let (obj_data, funcs) = self.get_rect_f_obj_funcs();
unsafe {
let ret_val = ((*funcs).size)(obj_data);
let t = ret_val;
let ret_val;
if t.host_data != ::std::ptr::null() {
ret_val = SizeF::new_from_rc(t);
} else {
ret_val = SizeF::new_from_owned(t);
}
ret_val
}
}
pub fn width(&self) -> f32 {
let (obj_data, funcs) = self.get_rect_f_obj_funcs();
unsafe {
let ret_val = ((*funcs).width)(obj_data);
ret_val
}
}
pub fn height(&self) -> f32 {
let (obj_data, funcs) = self.get_rect_f_obj_funcs();
unsafe {
let ret_val = ((*funcs).height)(obj_data);
ret_val
}
}
pub fn set_width(&self, w: f32) -> &Self {
let (obj_data, funcs) = self.get_rect_f_obj_funcs();
unsafe {
((*funcs).set_width)(obj_data, w);
}
self
}
pub fn set_height(&self, h: f32) -> &Self {
let (obj_data, funcs) = self.get_rect_f_obj_funcs();
unsafe {
((*funcs).set_height)(obj_data, h);
}
self
}
pub fn set_size<S: SizeFTrait<'a>>(&self, s: &S) -> &Self {
let (obj_s_1, _funcs) = s.get_size_f_obj_funcs();
let (obj_data, funcs) = self.get_rect_f_obj_funcs();
unsafe {
((*funcs).set_size)(obj_data, obj_s_1);
}
self
}
pub fn contains<R: RectFTrait<'a>>(&self, r: &R) -> bool {
let (obj_r_1, _funcs) = r.get_rect_f_obj_funcs();
let (obj_data, funcs) = self.get_rect_f_obj_funcs();
unsafe {
let ret_val = ((*funcs).contains)(obj_data, obj_r_1);
ret_val
}
}
pub fn contains_2<P: PointFTrait<'a>>(&self, p: &P) -> bool {
let (obj_p_1, _funcs) = p.get_point_f_obj_funcs();
let (obj_data, funcs) = self.get_rect_f_obj_funcs();
unsafe {
let ret_val = ((*funcs).contains_2)(obj_data, obj_p_1);
ret_val
}
}
pub fn contains_3(&self, x: f32, y: f32) -> bool {
let (obj_data, funcs) = self.get_rect_f_obj_funcs();
unsafe {
let ret_val = ((*funcs).contains_3)(obj_data, x, y);
ret_val
}
}
pub fn united<R: RectFTrait<'a>>(&self, other: &R) -> RectF {
let (obj_other_1, _funcs) = other.get_rect_f_obj_funcs();
let (obj_data, funcs) = self.get_rect_f_obj_funcs();
unsafe {
let ret_val = ((*funcs).united)(obj_data, obj_other_1);
let t = ret_val;
let ret_val;
if t.host_data != ::std::ptr::null() {
ret_val = RectF::new_from_rc(t);
} else {
ret_val = RectF::new_from_owned(t);
}
ret_val
}
}
pub fn intersected<R: RectFTrait<'a>>(&self, other: &R) -> RectF {
let (obj_other_1, _funcs) = other.get_rect_f_obj_funcs();
let (obj_data, funcs) = self.get_rect_f_obj_funcs();
unsafe {
let ret_val = ((*funcs).intersected)(obj_data, obj_other_1);
let t = ret_val;
let ret_val;
if t.host_data != ::std::ptr::null() {
ret_val = RectF::new_from_rc(t);
} else {
ret_val = RectF::new_from_owned(t);
}
ret_val
}
}
pub fn intersects<R: RectFTrait<'a>>(&self, r: &R) -> bool {
let (obj_r_1, _funcs) = r.get_rect_f_obj_funcs();
let (obj_data, funcs) = self.get_rect_f_obj_funcs();
unsafe {
let ret_val = ((*funcs).intersects)(obj_data, obj_r_1);
ret_val
}
}
pub fn to_rect(&self) -> Rect {
let (obj_data, funcs) = self.get_rect_f_obj_funcs();
unsafe {
let ret_val = ((*funcs).to_rect)(obj_data);
let t = ret_val;
let ret_val;
if t.host_data != ::std::ptr::null() {
ret_val = Rect::new_from_rc(t);
} else {
ret_val = Rect::new_from_owned(t);
}
ret_val
}
}
pub fn to_aligned_rect(&self) -> Rect {
let (obj_data, funcs) = self.get_rect_f_obj_funcs();
unsafe {
let ret_val = ((*funcs).to_aligned_rect)(obj_data);
let t = ret_val;
let ret_val;
if t.host_data != ::std::ptr::null() {
ret_val = Rect::new_from_rc(t);
} else {
ret_val = Rect::new_from_owned(t);
}
ret_val
}
}
}
pub trait RectFTrait<'a> {
#[inline]
#[doc(hidden)]
fn get_rect_f_obj_funcs(&self) -> (*const RUBase, *const RURectFFuncs);
}
impl<'a> RectFTrait<'a> for RectF<'a> {
#[doc(hidden)]
fn get_rect_f_obj_funcs(&self) -> (*const RUBase, *const RURectFFuncs) {
let obj = self.data.get().unwrap();
unsafe { (obj, (*self.all_funcs).rect_f_funcs) }
}
}