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