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