arcdps_imgui\window/scroll.rs
1use crate::sys;
2use crate::Ui;
3
4/// # Window scrolling
5impl<'ui> Ui<'ui> {
6 /// Returns the horizontal scrolling position.
7 ///
8 /// Value is between 0.0 and self.scroll_max_x().
9 #[doc(alias = "GetScrollX")]
10 pub fn scroll_x(&self) -> f32 {
11 unsafe { sys::igGetScrollX() }
12 }
13 /// Returns the vertical scrolling position.
14 ///
15 /// Value is between 0.0 and self.scroll_max_y().
16 #[doc(alias = "GetScrollY")]
17 pub fn scroll_y(&self) -> f32 {
18 unsafe { sys::igGetScrollY() }
19 }
20 /// Returns the maximum horizontal scrolling position.
21 ///
22 /// Roughly equal to content size X - window size X.
23 #[doc(alias = "GetScrollMaxX")]
24 pub fn scroll_max_x(&self) -> f32 {
25 unsafe { sys::igGetScrollMaxX() }
26 }
27 /// Returns the maximum vertical scrolling position.
28 ///
29 /// Roughly equal to content size Y - window size Y.
30 #[doc(alias = "GetScrollMaxY")]
31 pub fn scroll_max_y(&self) -> f32 {
32 unsafe { sys::igGetScrollMaxY() }
33 }
34 /// Sets the horizontal scrolling position
35 #[doc(alias = "SetScrollX")]
36 pub fn set_scroll_x(&self, scroll_x: f32) {
37 unsafe { sys::igSetScrollX(scroll_x) };
38 }
39 /// Sets the vertical scroll position
40 #[doc(alias = "SetScrollY")]
41 pub fn set_scroll_y(&self, scroll_y: f32) {
42 unsafe { sys::igSetScrollY(scroll_y) };
43 }
44 /// Adjusts the horizontal scroll position to make the current cursor position visible.
45 ///
46 /// This is the same as [set_scroll_here_x_with_ratio](Self::set_scroll_here_x_with_ratio) but with `ratio` at 0.5.
47 #[doc(alias = "SetScrollHereX")]
48 pub fn set_scroll_here_x(&self) {
49 self.set_scroll_here_x_with_ratio(0.5);
50 }
51 /// Adjusts the horizontal scroll position to make the current cursor position visible.
52 ///
53 /// center_x_ratio:
54 ///
55 /// - `0.0`: left
56 /// - `0.5`: center
57 /// - `1.0`: right
58 #[doc(alias = "SetScrollHereX")]
59 pub fn set_scroll_here_x_with_ratio(&self, center_x_ratio: f32) {
60 unsafe { sys::igSetScrollHereX(center_x_ratio) };
61 }
62 /// Adjusts the vertical scroll position to make the current cursor position visible
63 ///
64 /// This is the same as [set_scroll_here_y_with_ratio](Self::set_scroll_here_y_with_ratio) but with `ratio` at 0.5.
65 #[doc(alias = "SetScrollHereY")]
66 pub fn set_scroll_here_y(&self) {
67 self.set_scroll_here_y_with_ratio(0.5);
68 }
69 /// Adjusts the vertical scroll position to make the current cursor position visible.
70 ///
71 /// center_y_ratio:
72 ///
73 /// - `0.0`: top
74 /// - `0.5`: center
75 /// - `1.0`: bottom
76 #[doc(alias = "SetScrollHereY")]
77 pub fn set_scroll_here_y_with_ratio(&self, center_y_ratio: f32) {
78 unsafe { sys::igSetScrollHereY(center_y_ratio) };
79 }
80 #[doc(alias = "SetScrollFromPosX")]
81 /// Adjusts the horizontal scroll position to make the given position visible
82 ///
83 /// This is the same as [set_scroll_from_pos_x_with_ratio](Self::set_scroll_from_pos_x_with_ratio)
84 /// but with `ratio` at 0.5.
85 pub fn set_scroll_from_pos_x(&self, local_x: f32) {
86 self.set_scroll_from_pos_x_with_ratio(local_x, 0.5);
87 }
88 /// Adjusts the horizontal scroll position to make the given position visible.
89 ///
90 /// center_x_ratio:
91 ///
92 /// - `0.0`: left
93 /// - `0.5`: center
94 /// - `1.0`: right
95 #[doc(alias = "SetScrollFromPosX")]
96 pub fn set_scroll_from_pos_x_with_ratio(&self, local_x: f32, center_x_ratio: f32) {
97 unsafe { sys::igSetScrollFromPosX(local_x, center_x_ratio) };
98 }
99 /// Adjusts the vertical scroll position to make the given position visible
100 ///
101 /// This is the same as [set_scroll_from_pos_y_with_ratio](Self::set_scroll_from_pos_y_with_ratio)
102 /// but with `ratio` at 0.5.
103 #[doc(alias = "SetScrollFromPosY")]
104 pub fn set_scroll_from_pos_y(&self, local_y: f32) {
105 self.set_scroll_from_pos_y_with_ratio(local_y, 0.5);
106 }
107 /// Adjusts the vertical scroll position to make the given position visible.
108 ///
109 /// center_y_ratio:
110 ///
111 /// - `0.0`: top
112 /// - `0.5`: center
113 /// - `1.0`: bottom
114 #[doc(alias = "SetScrollFromPosY")]
115 pub fn set_scroll_from_pos_y_with_ratio(&self, local_y: f32, center_y_ratio: f32) {
116 unsafe { sys::igSetScrollFromPosY(local_y, center_y_ratio) };
117 }
118}