use crate::ffi;
use glib::{
prelude::*,
signal::{connect_raw, SignalHandlerId},
translate::*,
};
use std::boxed::Box as Box_;
glib::wrapper! {
#[doc(alias = "HeSpringParams")]
pub struct SpringParams(Object<ffi::HeSpringParams, ffi::HeSpringParamsClass>);
match fn {
type_ => || ffi::he_spring_params_get_type(),
}
}
impl SpringParams {
pub const NONE: Option<&'static SpringParams> = None;
#[doc(alias = "he_spring_params_new")]
pub fn new(damping_ratio: f64, mass: f64, stiffness: f64) -> SpringParams {
assert_initialized_main_thread!();
unsafe { from_glib_full(ffi::he_spring_params_new(damping_ratio, mass, stiffness)) }
}
#[doc(alias = "he_spring_params_new_full")]
pub fn full(damping: f64, mass: f64, stiffness: f64) -> SpringParams {
assert_initialized_main_thread!();
unsafe { from_glib_full(ffi::he_spring_params_new_full(damping, mass, stiffness)) }
}
pub fn builder() -> SpringParamsBuilder {
SpringParamsBuilder::new()
}
}
impl Default for SpringParams {
fn default() -> Self {
glib::object::Object::new::<Self>()
}
}
#[must_use = "The builder must be built to be used"]
pub struct SpringParamsBuilder {
builder: glib::object::ObjectBuilder<'static, SpringParams>,
}
impl SpringParamsBuilder {
fn new() -> Self {
Self {
builder: glib::object::Object::builder(),
}
}
pub fn damping(self, damping: f64) -> Self {
Self {
builder: self.builder.property("damping", damping),
}
}
pub fn damping_ratio(self, damping_ratio: f64) -> Self {
Self {
builder: self.builder.property("damping-ratio", damping_ratio),
}
}
pub fn mass(self, mass: f64) -> Self {
Self {
builder: self.builder.property("mass", mass),
}
}
pub fn stiffness(self, stiffness: f64) -> Self {
Self {
builder: self.builder.property("stiffness", stiffness),
}
}
#[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
pub fn build(self) -> SpringParams {
self.builder.build()
}
}
mod sealed {
pub trait Sealed {}
impl<T: super::IsA<super::SpringParams>> Sealed for T {}
}
pub trait SpringParamsExt: IsA<SpringParams> + sealed::Sealed + 'static {
#[doc(alias = "he_spring_params_get_damping")]
#[doc(alias = "get_damping")]
fn damping(&self) -> f64 {
unsafe { ffi::he_spring_params_get_damping(self.as_ref().to_glib_none().0) }
}
#[doc(alias = "he_spring_params_set_damping")]
fn set_damping(&self, value: f64) {
unsafe {
ffi::he_spring_params_set_damping(self.as_ref().to_glib_none().0, value);
}
}
#[doc(alias = "he_spring_params_get_damping_ratio")]
#[doc(alias = "get_damping_ratio")]
fn damping_ratio(&self) -> f64 {
unsafe { ffi::he_spring_params_get_damping_ratio(self.as_ref().to_glib_none().0) }
}
#[doc(alias = "he_spring_params_set_damping_ratio")]
fn set_damping_ratio(&self, value: f64) {
unsafe {
ffi::he_spring_params_set_damping_ratio(self.as_ref().to_glib_none().0, value);
}
}
#[doc(alias = "he_spring_params_get_mass")]
#[doc(alias = "get_mass")]
fn mass(&self) -> f64 {
unsafe { ffi::he_spring_params_get_mass(self.as_ref().to_glib_none().0) }
}
#[doc(alias = "he_spring_params_set_mass")]
fn set_mass(&self, value: f64) {
unsafe {
ffi::he_spring_params_set_mass(self.as_ref().to_glib_none().0, value);
}
}
#[doc(alias = "he_spring_params_get_stiffness")]
#[doc(alias = "get_stiffness")]
fn stiffness(&self) -> f64 {
unsafe { ffi::he_spring_params_get_stiffness(self.as_ref().to_glib_none().0) }
}
#[doc(alias = "he_spring_params_set_stiffness")]
fn set_stiffness(&self, value: f64) {
unsafe {
ffi::he_spring_params_set_stiffness(self.as_ref().to_glib_none().0, value);
}
}
#[doc(alias = "damping")]
fn connect_damping_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_damping_trampoline<
P: IsA<SpringParams>,
F: Fn(&P) + 'static,
>(
this: *mut ffi::HeSpringParams,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(SpringParams::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::damping\0".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
notify_damping_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "damping-ratio")]
fn connect_damping_ratio_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_damping_ratio_trampoline<
P: IsA<SpringParams>,
F: Fn(&P) + 'static,
>(
this: *mut ffi::HeSpringParams,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(SpringParams::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::damping-ratio\0".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
notify_damping_ratio_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "mass")]
fn connect_mass_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_mass_trampoline<P: IsA<SpringParams>, F: Fn(&P) + 'static>(
this: *mut ffi::HeSpringParams,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(SpringParams::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::mass\0".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
notify_mass_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "stiffness")]
fn connect_stiffness_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_stiffness_trampoline<
P: IsA<SpringParams>,
F: Fn(&P) + 'static,
>(
this: *mut ffi::HeSpringParams,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(SpringParams::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::stiffness\0".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
notify_stiffness_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
}
impl<O: IsA<SpringParams>> SpringParamsExt for O {}