[go: up one dir, main page]

gtk4/auto/
gesture_rotate.rs

1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from gir-files (https://github.com/gtk-rs/gir-files)
3// DO NOT EDIT
4
5use crate::{ffi, EventController, Gesture, PropagationLimit, PropagationPhase};
6use glib::{
7    object::ObjectType as _,
8    prelude::*,
9    signal::{connect_raw, SignalHandlerId},
10    translate::*,
11};
12use std::boxed::Box as Box_;
13
14glib::wrapper! {
15    #[doc(alias = "GtkGestureRotate")]
16    pub struct GestureRotate(Object<ffi::GtkGestureRotate, ffi::GtkGestureRotateClass>) @extends Gesture, EventController;
17
18    match fn {
19        type_ => || ffi::gtk_gesture_rotate_get_type(),
20    }
21}
22
23impl GestureRotate {
24    #[doc(alias = "gtk_gesture_rotate_new")]
25    pub fn new() -> GestureRotate {
26        assert_initialized_main_thread!();
27        unsafe { Gesture::from_glib_full(ffi::gtk_gesture_rotate_new()).unsafe_cast() }
28    }
29
30    // rustdoc-stripper-ignore-next
31    /// Creates a new builder-pattern struct instance to construct [`GestureRotate`] objects.
32    ///
33    /// This method returns an instance of [`GestureRotateBuilder`](crate::builders::GestureRotateBuilder) which can be used to create [`GestureRotate`] objects.
34    pub fn builder() -> GestureRotateBuilder {
35        GestureRotateBuilder::new()
36    }
37
38    #[doc(alias = "gtk_gesture_rotate_get_angle_delta")]
39    #[doc(alias = "get_angle_delta")]
40    pub fn angle_delta(&self) -> f64 {
41        unsafe { ffi::gtk_gesture_rotate_get_angle_delta(self.to_glib_none().0) }
42    }
43
44    #[doc(alias = "angle-changed")]
45    pub fn connect_angle_changed<F: Fn(&Self, f64, f64) + 'static>(&self, f: F) -> SignalHandlerId {
46        unsafe extern "C" fn angle_changed_trampoline<F: Fn(&GestureRotate, f64, f64) + 'static>(
47            this: *mut ffi::GtkGestureRotate,
48            angle: std::ffi::c_double,
49            angle_delta: std::ffi::c_double,
50            f: glib::ffi::gpointer,
51        ) {
52            let f: &F = &*(f as *const F);
53            f(&from_glib_borrow(this), angle, angle_delta)
54        }
55        unsafe {
56            let f: Box_<F> = Box_::new(f);
57            connect_raw(
58                self.as_ptr() as *mut _,
59                c"angle-changed".as_ptr() as *const _,
60                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
61                    angle_changed_trampoline::<F> as *const (),
62                )),
63                Box_::into_raw(f),
64            )
65        }
66    }
67}
68
69impl Default for GestureRotate {
70    fn default() -> Self {
71        Self::new()
72    }
73}
74
75// rustdoc-stripper-ignore-next
76/// A [builder-pattern] type to construct [`GestureRotate`] objects.
77///
78/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
79#[must_use = "The builder must be built to be used"]
80pub struct GestureRotateBuilder {
81    builder: glib::object::ObjectBuilder<'static, GestureRotate>,
82}
83
84impl GestureRotateBuilder {
85    fn new() -> Self {
86        Self {
87            builder: glib::object::Object::builder(),
88        }
89    }
90
91    pub fn n_points(self, n_points: u32) -> Self {
92        Self {
93            builder: self.builder.property("n-points", n_points),
94        }
95    }
96
97    pub fn name(self, name: impl Into<glib::GString>) -> Self {
98        Self {
99            builder: self.builder.property("name", name.into()),
100        }
101    }
102
103    pub fn propagation_limit(self, propagation_limit: PropagationLimit) -> Self {
104        Self {
105            builder: self
106                .builder
107                .property("propagation-limit", propagation_limit),
108        }
109    }
110
111    pub fn propagation_phase(self, propagation_phase: PropagationPhase) -> Self {
112        Self {
113            builder: self
114                .builder
115                .property("propagation-phase", propagation_phase),
116        }
117    }
118
119    // rustdoc-stripper-ignore-next
120    /// Build the [`GestureRotate`].
121    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
122    pub fn build(self) -> GestureRotate {
123        assert_initialized_main_thread!();
124        self.builder.build()
125    }
126}