rute 0.0.6

UI library implemented on top of Qt
Documentation
// This file is auto-generated by rute_gen. DO NOT EDIT.
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::*;

/// **Notice these docs are heavy WIP and not very relevent yet**
///
/// The size of the surface is accessible with the size() function. The rendering
/// specific attributes of the surface are accessible through the format() function.
/// # Licence
///
/// The documentation is an adoption of the original [Qt Documentation](http://doc.qt.io/) and provided herein is licensed under the terms of the [GNU Free Documentation License version 1.3](http://www.gnu.org/licenses/fdl.html) as published by the Free Software Foundation.
#[derive(Clone)]
pub struct Surface<'a> {
    #[doc(hidden)]
    pub data: Rc<Cell<Option<*const RUBase>>>,
    #[doc(hidden)]
    pub all_funcs: *const RUSurfaceAllFuncs,
    #[doc(hidden)]
    pub owned: bool,
    #[doc(hidden)]
    pub _marker: PhantomData<::std::cell::Cell<&'a ()>>,
}

impl<'a> Surface<'a> {
    #[allow(dead_code)]
    pub(crate) fn new_from_rc(ffi_data: RUSurface) -> Surface<'a> {
        Surface {
            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: RUSurface) -> Surface<'a> {
        Surface {
            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: RUSurface) -> Surface<'a> {
        Surface {
            data: Rc::new(Cell::new(Some(ffi_data.qt_data as *const RUBase))),
            all_funcs: ffi_data.all_funcs,
            owned: false,
            _marker: PhantomData,
        }
    }
    ///
    /// Returns the surface class of this surface.
    pub fn surface_class(&self) -> SurfaceClass {
        let (obj_data, funcs) = self.get_surface_obj_funcs();
        unsafe {
            let ret_val = ((*funcs).surface_class)(obj_data);
            let ret_val = { transmute::<u32, SurfaceClass>(ret_val) };
            ret_val
        }
    }
    ///
    /// Returns the format of the surface.
    pub fn format(&self) -> SurfaceFormat {
        let (obj_data, funcs) = self.get_surface_obj_funcs();
        unsafe {
            let ret_val = ((*funcs).format)(obj_data);
            let t = ret_val;
            let ret_val;
            if t.host_data != ::std::ptr::null() {
                ret_val = SurfaceFormat::new_from_rc(t);
            } else {
                ret_val = SurfaceFormat::new_from_owned(t);
            }
            ret_val
        }
    }
    ///
    /// Returns the type of the surface.
    pub fn surface_type(&self) -> SurfaceType {
        let (obj_data, funcs) = self.get_surface_obj_funcs();
        unsafe {
            let ret_val = ((*funcs).surface_type)(obj_data);
            let ret_val = { transmute::<u32, SurfaceType>(ret_val) };
            ret_val
        }
    }
    ///
    /// Returns true if the surface is OpenGL compatible and can be used in
    /// conjunction with QOpenGLContext; otherwise returns false.
    ///
    ///
    /// Returns the size of the surface in pixels.
    pub fn size(&self) -> Size {
        let (obj_data, funcs) = self.get_surface_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 = Size::new_from_rc(t);
            } else {
                ret_val = Size::new_from_owned(t);
            }
            ret_val
        }
    }

    pub fn build(&self) -> Self {
        self.clone()
    }
}
pub trait SurfaceTrait<'a> {
    #[inline]
    #[doc(hidden)]
    fn get_surface_obj_funcs(&self) -> (*const RUBase, *const RUSurfaceFuncs);
}

impl<'a> SurfaceTrait<'a> for Surface<'a> {
    #[doc(hidden)]
    fn get_surface_obj_funcs(&self) -> (*const RUBase, *const RUSurfaceFuncs) {
        let obj = self.data.get().unwrap();
        unsafe { (obj, (*self.all_funcs).surface_funcs) }
    }
}
#[repr(u32)]
pub enum SurfaceClass {
    Window = 0,
    Offscreen = 1,
}

#[repr(u32)]
pub enum SurfaceType {
    RasterSurface = 0,
    OpenGlSurface = 1,
    RasterGlSurface = 2,
    OpenVgSurface = 3,
    VulkanSurface = 4,
}