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 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150
use crate::sys;
use crate::Ui;
/// # Window scrolling
impl Ui {
/// Returns the horizontal scrolling position.
///
/// Value is between 0.0 and self.scroll_max_x().
#[doc(alias = "GetScrollX")]
pub fn scroll_x(&self) -> f32 {
unsafe { sys::igGetScrollX() }
}
/// Returns the vertical scrolling position.
///
/// Value is between 0.0 and self.scroll_max_y().
#[doc(alias = "GetScrollY")]
pub fn scroll_y(&self) -> f32 {
unsafe { sys::igGetScrollY() }
}
/// Returns the maximum horizontal scrolling position.
///
/// Roughly equal to content size X - window size X.
#[doc(alias = "GetScrollMaxX")]
pub fn scroll_max_x(&self) -> f32 {
unsafe { sys::igGetScrollMaxX() }
}
/// Returns the maximum vertical scrolling position.
///
/// Roughly equal to content size Y - window size Y.
#[doc(alias = "GetScrollMaxY")]
pub fn scroll_max_y(&self) -> f32 {
unsafe { sys::igGetScrollMaxY() }
}
/// Sets the horizontal scrolling position
#[doc(alias = "SetScrollX")]
pub fn set_scroll_x(&self, scroll_x: f32) {
unsafe {
cfg_if::cfg_if! {
if #[cfg(feature = "docking")] {
sys::igSetScrollX_Float(scroll_x);
} else {
sys::igSetScrollX(scroll_x);
}
}
}
}
/// Sets the vertical scroll position
#[doc(alias = "SetScrollY")]
pub fn set_scroll_y(&self, scroll_y: f32) {
unsafe {
cfg_if::cfg_if! {
if #[cfg(feature = "docking")] {
sys::igSetScrollY_Float(scroll_y);
} else {
sys::igSetScrollY(scroll_y);
}
}
}
}
/// Adjusts the horizontal scroll position to make the current cursor position visible.
///
/// This is the same as [set_scroll_here_x_with_ratio](Self::set_scroll_here_x_with_ratio) but with `ratio` at 0.5.
#[doc(alias = "SetScrollHereX")]
pub fn set_scroll_here_x(&self) {
self.set_scroll_here_x_with_ratio(0.5);
}
/// Adjusts the horizontal scroll position to make the current cursor position visible.
///
/// center_x_ratio:
///
/// - `0.0`: left
/// - `0.5`: center
/// - `1.0`: right
#[doc(alias = "SetScrollHereX")]
pub fn set_scroll_here_x_with_ratio(&self, center_x_ratio: f32) {
unsafe { sys::igSetScrollHereX(center_x_ratio) };
}
/// Adjusts the vertical scroll position to make the current cursor position visible
///
/// This is the same as [set_scroll_here_y_with_ratio](Self::set_scroll_here_y_with_ratio) but with `ratio` at 0.5.
#[doc(alias = "SetScrollHereY")]
pub fn set_scroll_here_y(&self) {
self.set_scroll_here_y_with_ratio(0.5);
}
/// Adjusts the vertical scroll position to make the current cursor position visible.
///
/// center_y_ratio:
///
/// - `0.0`: top
/// - `0.5`: center
/// - `1.0`: bottom
#[doc(alias = "SetScrollHereY")]
pub fn set_scroll_here_y_with_ratio(&self, center_y_ratio: f32) {
unsafe { sys::igSetScrollHereY(center_y_ratio) };
}
#[doc(alias = "SetScrollFromPosX")]
/// Adjusts the horizontal scroll position to make the given position visible
///
/// This is the same as [set_scroll_from_pos_x_with_ratio](Self::set_scroll_from_pos_x_with_ratio)
/// but with `ratio` at 0.5.
pub fn set_scroll_from_pos_x(&self, local_x: f32) {
self.set_scroll_from_pos_x_with_ratio(local_x, 0.5);
}
/// Adjusts the horizontal scroll position to make the given position visible.
///
/// center_x_ratio:
///
/// - `0.0`: left
/// - `0.5`: center
/// - `1.0`: right
#[doc(alias = "SetScrollFromPosX")]
pub fn set_scroll_from_pos_x_with_ratio(&self, local_x: f32, center_x_ratio: f32) {
unsafe {
cfg_if::cfg_if! {
if #[cfg(feature = "docking")] {
sys::igSetScrollFromPosX_Float(local_x, center_x_ratio)
} else {
sys::igSetScrollFromPosX(local_x, center_x_ratio)
}
}
};
}
/// Adjusts the vertical scroll position to make the given position visible
///
/// This is the same as [set_scroll_from_pos_y_with_ratio](Self::set_scroll_from_pos_y_with_ratio)
/// but with `ratio` at 0.5.
#[doc(alias = "SetScrollFromPosY")]
pub fn set_scroll_from_pos_y(&self, local_y: f32) {
self.set_scroll_from_pos_y_with_ratio(local_y, 0.5);
}
/// Adjusts the vertical scroll position to make the given position visible.
///
/// center_y_ratio:
///
/// - `0.0`: top
/// - `0.5`: center
/// - `1.0`: bottom
#[doc(alias = "SetScrollFromPosY")]
pub fn set_scroll_from_pos_y_with_ratio(&self, local_y: f32, center_y_ratio: f32) {
unsafe {
cfg_if::cfg_if! {
if #[cfg(feature = "docking")] {
sys::igSetScrollFromPosY_Float(local_y, center_y_ratio);
} else {
sys::igSetScrollFromPosY(local_y, center_y_ratio);
}
}
}
}
}