gtk4/auto/
scroll_info.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;
6use glib::translate::*;
7
8glib::wrapper! {
9    /// The [`ScrollInfo`][crate::ScrollInfo] can be used to provide more accurate data on how a scroll
10    /// operation should be performed.
11    ///
12    /// Scrolling functions usually allow passing a [`None`] scroll info which will cause
13    /// the default values to be used and just scroll the element into view.
14    #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
15    pub struct ScrollInfo(Shared<ffi::GtkScrollInfo>);
16
17    match fn {
18        ref => |ptr| ffi::gtk_scroll_info_ref(ptr),
19        unref => |ptr| ffi::gtk_scroll_info_unref(ptr),
20        type_ => || ffi::gtk_scroll_info_get_type(),
21    }
22}
23
24impl ScrollInfo {
25    /// Creates a new scroll info for scrolling an element into view.
26    ///
27    /// # Returns
28    ///
29    /// A new scroll info
30    #[doc(alias = "gtk_scroll_info_new")]
31    pub fn new() -> ScrollInfo {
32        assert_initialized_main_thread!();
33        unsafe { from_glib_full(ffi::gtk_scroll_info_new()) }
34    }
35
36    /// Checks if horizontal scrolling is enabled.
37    ///
38    /// # Returns
39    ///
40    /// [`true`] if horizontal scrolling is enabled.
41    #[doc(alias = "gtk_scroll_info_get_enable_horizontal")]
42    #[doc(alias = "get_enable_horizontal")]
43    pub fn enables_horizontal(&self) -> bool {
44        unsafe {
45            from_glib(ffi::gtk_scroll_info_get_enable_horizontal(
46                self.to_glib_none().0,
47            ))
48        }
49    }
50
51    /// Checks if vertical scrolling is enabled.
52    ///
53    /// # Returns
54    ///
55    /// [`true`] if vertical scrolling is enabled.
56    #[doc(alias = "gtk_scroll_info_get_enable_vertical")]
57    #[doc(alias = "get_enable_vertical")]
58    pub fn enables_vertical(&self) -> bool {
59        unsafe {
60            from_glib(ffi::gtk_scroll_info_get_enable_vertical(
61                self.to_glib_none().0,
62            ))
63        }
64    }
65
66    /// Turns horizontal scrolling on or off.
67    /// ## `horizontal`
68    /// if scrolling in the horizontal direction
69    ///     should happen
70    #[doc(alias = "gtk_scroll_info_set_enable_horizontal")]
71    pub fn set_enable_horizontal(&self, horizontal: bool) {
72        unsafe {
73            ffi::gtk_scroll_info_set_enable_horizontal(
74                self.to_glib_none().0,
75                horizontal.into_glib(),
76            );
77        }
78    }
79
80    /// Turns vertical scrolling on or off.
81    /// ## `vertical`
82    /// if scrolling in the vertical direction
83    ///     should happen
84    #[doc(alias = "gtk_scroll_info_set_enable_vertical")]
85    pub fn set_enable_vertical(&self, vertical: bool) {
86        unsafe {
87            ffi::gtk_scroll_info_set_enable_vertical(self.to_glib_none().0, vertical.into_glib());
88        }
89    }
90}
91
92#[cfg(feature = "v4_12")]
93#[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
94impl Default for ScrollInfo {
95    fn default() -> Self {
96        Self::new()
97    }
98}