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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
use crate::{impl_into_node, layout::layout_kind::ScrollState, node::Element};
impl_into_node!(ScrollVertical);
impl_into_node!(ScrollHorizontal);
impl_into_node!(ScrollBoth);
impl ScrollVertical {
pub fn new(child: impl Into<Element>) -> Self {
Self::from_node(crate::node::dsl::scroll_vertical(child.into().into_node()))
}
pub fn with_scroll_state(mut self, existing: ScrollState) -> Self {
self.update_node(|node| crate::node::NodeUpdate::with_scroll_state(node, existing));
self
}
/// Keeps the bars beside what scrolls: the vertical one starts under what sticks at the top (a table's
/// header) and stands before what sticks at the right (a column pinned at the end), the horizontal one runs
/// from what sticks at the start (its first column) to what sticks at the end, and the thumb is the share of
/// what scrolls that shows. Off unless set: a page with a banner that stays keeps its bar along the whole
/// height, as a browser's does.
pub fn scrollbars_clear_of_sticky(mut self, clear: bool) -> Self {
self.update_node(|node| crate::node::NodeUpdate::scrollbars_clear_of_sticky(node, clear));
self
}
pub fn culling(mut self, enabled: bool) -> Self {
self.update_node(|node| crate::node::NodeUpdate::culling(node, enabled));
self
}
/// Middle-button autoscroll, off by default; see
/// `Node::middle_button_autoscroll`.
pub fn middle_button_autoscroll(mut self, enabled: bool) -> Self {
self.update_node(|node| crate::node::NodeUpdate::middle_button_autoscroll(node, enabled));
self
}
}
impl Default for ScrollVertical {
fn default() -> Self {
Self::new(Element::new())
}
}
impl ScrollHorizontal {
pub fn new(child: impl Into<Element>) -> Self {
Self::from_node(crate::node::dsl::scroll_horizontal(child.into().into_node()))
}
/// Scrolls sideways by a wheel turned up and down, where the wheel is not also turned sideways, as a browser's
/// strip of tabs does: the wheel's turn is taken across, and nothing around it scrolls with it. Off by default:
/// a list across inside a page lets the page take the wheel.
pub fn wheel_across(mut self, across: bool) -> Self {
self.update_node(|node| crate::node::NodeUpdate::wheel_across(node, across));
self
}
/// Lays the content out at least as wide as the viewport, as [`ScrollBoth::fill_width`] does: items that share
/// the room there is, and scroll sideways only where they need more (a timeline across).
pub fn fill_width(mut self, fills: bool) -> Self {
self.update_node(|node| crate::node::NodeUpdate::fills_viewport_width(node, fills));
self
}
/// Lays content that is wider than the viewport out in the viewport's width first, so that a line gives way
/// there by its own rules (its children shrink, or drop out of it,
/// [`ShrinkLimit::Drop`](crate::layout::layout_kind::ShrinkLimit::Drop)), and is as wide as what still has no
/// room after that: the container scrolls sideways only to what its content could not give up. A toolbar, whose
/// controls go into a menu as it narrows and which scrolls to the ones that stay. Off by default: content is
/// laid out at its natural width, and scrolled to all of it.
pub fn fit_width(mut self, fits: bool) -> Self {
self.update_node(|node| crate::node::NodeUpdate::fits_viewport_width(node, fits));
self
}
pub fn with_scroll_state(mut self, existing: ScrollState) -> Self {
self.update_node(|node| crate::node::NodeUpdate::with_scroll_state(node, existing));
self
}
/// Keeps the bars beside what scrolls: the vertical one starts under what sticks at the top (a table's
/// header) and stands before what sticks at the right (a column pinned at the end), the horizontal one runs
/// from what sticks at the start (its first column) to what sticks at the end, and the thumb is the share of
/// what scrolls that shows. Off unless set: a page with a banner that stays keeps its bar along the whole
/// height, as a browser's does.
pub fn scrollbars_clear_of_sticky(mut self, clear: bool) -> Self {
self.update_node(|node| crate::node::NodeUpdate::scrollbars_clear_of_sticky(node, clear));
self
}
/// Gives the bar a lane of its own under the content while the content is wider than the view; see
/// `ScrollBoth::reserve_bar_across`.
pub fn reserve_bar_across(mut self, reserve: bool) -> Self {
self.update_node(|node| crate::node::NodeUpdate::reserve_bar_across(node, reserve));
self
}
pub fn culling(mut self, enabled: bool) -> Self {
self.update_node(|node| crate::node::NodeUpdate::culling(node, enabled));
self
}
/// Middle-button autoscroll, off by default; see
/// `Node::middle_button_autoscroll`.
pub fn middle_button_autoscroll(mut self, enabled: bool) -> Self {
self.update_node(|node| crate::node::NodeUpdate::middle_button_autoscroll(node, enabled));
self
}
}
impl Default for ScrollHorizontal {
fn default() -> Self {
Self::new(Element::new())
}
}
impl ScrollBoth {
pub fn new(child: impl Into<Element>) -> Self {
Self::from_node(crate::node::dsl::scroll_both(child.into().into_node()))
}
/// Scrolls sideways by a wheel turned up and down, where the wheel is not also turned sideways, as a browser's
/// strip of tabs does: the wheel's turn is taken across, and nothing around it scrolls with it. Off by default:
/// a list across inside a page lets the page take the wheel.
pub fn wheel_across(mut self, across: bool) -> Self {
self.update_node(|node| crate::node::NodeUpdate::wheel_across(node, across));
self
}
/// Lays the content out at least as wide as the viewport: what is in it fills the width it is shown in, and
/// scrolls sideways only where it needs more. A table, whose columns share the room there is.
pub fn fill_width(mut self, fills: bool) -> Self {
self.update_node(|node| crate::node::NodeUpdate::fills_viewport_width(node, fills));
self
}
/// Gives the bar across a lane of its own under the content while the content is wider than the view: the
/// viewport ends above it, so nothing it shows is ever under the bar (a table's last row). Content that fits
/// has no lane and no strip. Off unless set: the bar lies over the content, as an overlay bar does.
pub fn reserve_bar_across(mut self, reserve: bool) -> Self {
self.update_node(|node| crate::node::NodeUpdate::reserve_bar_across(node, reserve));
self
}
pub fn with_scroll_state(mut self, existing: ScrollState) -> Self {
self.update_node(|node| crate::node::NodeUpdate::with_scroll_state(node, existing));
self
}
/// Keeps the bars beside what scrolls: the vertical one starts under what sticks at the top (a table's
/// header) and stands before what sticks at the right (a column pinned at the end), the horizontal one runs
/// from what sticks at the start (its first column) to what sticks at the end, and the thumb is the share of
/// what scrolls that shows. Off unless set: a page with a banner that stays keeps its bar along the whole
/// height, as a browser's does.
pub fn scrollbars_clear_of_sticky(mut self, clear: bool) -> Self {
self.update_node(|node| crate::node::NodeUpdate::scrollbars_clear_of_sticky(node, clear));
self
}
pub fn culling(mut self, enabled: bool) -> Self {
self.update_node(|node| crate::node::NodeUpdate::culling(node, enabled));
self
}
/// Middle-button autoscroll, off by default; see
/// `Node::middle_button_autoscroll`.
pub fn middle_button_autoscroll(mut self, enabled: bool) -> Self {
self.update_node(|node| crate::node::NodeUpdate::middle_button_autoscroll(node, enabled));
self
}
}
impl Default for ScrollBoth {
fn default() -> Self {
Self::new(Element::new())
}
}