pub struct ScrollView { /* private fields */ }Expand description
A box that shows part of its child, which may be taller, and scrolls it with the mouse wheel or touchpad. Children are cut to the box. Give it a height through its style, or let its parent size it.
use crabshell_ui::{Column, ScrollView, Style, Text};
let log = ScrollView::new(Column::new().child(Text::new("first line")))
.style(Style::new().height(200.0));Implementations§
Source§impl ScrollView
impl ScrollView
Sourcepub fn new(child: impl Widget) -> ScrollView
pub fn new(child: impl Widget) -> ScrollView
A scroll view of child.
Sourcepub fn offset(self, offset: Signal<f32>) -> ScrollView
pub fn offset(self, offset: Signal<f32>) -> ScrollView
Shares the offset: how many logical pixels of the child are
scrolled out of view above, or to the left in a horizontal view. In
a view that scrolls both ways it is always the
vertical offset. Scrolling writes it, and setting it scrolls,
stopping a fling along that axis. Values past either end show that
end.
Sourcepub fn horizontal(self, horizontal: impl IntoProp<bool>) -> ScrollView
pub fn horizontal(self, horizontal: impl IntoProp<bool>) -> ScrollView
Scrolls sideways instead: the child is laid out at its full width
rather than its full height, and the wheel, tilted or turned, and the
touchpad’s sideways motion scroll it. both wins over
it.
Sourcepub fn both(self, both: impl IntoProp<bool>) -> ScrollView
pub fn both(self, both: impl IntoProp<bool>) -> ScrollView
Scrolls down and across: the child is laid out at its full width and
height, and the wheel, the touchpad, a drag and a fling move it along
both, each axis going past its ends and coming to rest on its own.
offset is then the vertical offset and
offset_x the horizontal one, and a scroll bar
shows along each axis the child is longer on. Off by default.
Sourcepub fn offset_x(self, offset: Signal<f32>) -> ScrollView
pub fn offset_x(self, offset: Signal<f32>) -> ScrollView
Sourcepub fn kinetic(self, kinetic: impl IntoProp<bool>) -> ScrollView
pub fn kinetic(self, kinetic: impl IntoProp<bool>) -> ScrollView
Keeps the child moving after a touchpad fling or a drag of the child
ends, slowing down by 1500 logical pixels a second each second from
at most 2500 a second, as Qt’s Flickable. On by default. A mouse
wheel’s notch still moves 48 pixels at once.
Sourcepub fn overshoot(self, overshoot: impl IntoProp<bool>) -> ScrollView
pub fn overshoot(self, overshoot: impl IntoProp<bool>) -> ScrollView
Lets a touchpad, a drag or a fling carry the child past either end,
against a pull that grows with the distance and stops it within a
quarter of the box, and springs it back once let go, as Qt’s
DragAndOvershootBounds. Only shown: the offset stays within the
content. On by default.
Sourcepub fn mouse_drag(self, mouse_drag: impl IntoProp<bool>) -> ScrollView
pub fn mouse_drag(self, mouse_drag: impl IntoProp<bool>) -> ScrollView
Lets a mouse drag the child with its left button, as a finger does,
as Qt’s Flickable does. Off, only a finger on a touchscreen and a
touchpad move it, and a mouse press that moves and comes up over a
button clicks it. On by default.
Sourcepub fn scroll_bar(self, style: impl IntoProp<Option<Style>>) -> ScrollView
pub fn scroll_bar(self, style: impl IntoProp<Option<Style>>) -> ScrollView
Draws a scroll bar while the child is longer than the box: a handle
along the right edge, or the bottom of a horizontal view, inside the
border, as long as the part shown and placed by the offset, over
the child. A view that scrolls both ways draws one
along each axis the child is longer on, and each leaves the other
the corner they would share. Its style’s background and radius
draw the handle, and its width, 6 by default, is its thickness.
Dragging the handle scrolls, and counts as moving, so a list’s
current doesn’t scroll it until the button comes up. A press beside
the handle pages toward the press, and held, pages again after
300 ms and then every 50 ms until the handle reaches the pointer.
None, the default, draws none.
Sourcepub fn style(self, style: impl IntoProp<Style>) -> ScrollView
pub fn style(self, style: impl IntoProp<Style>) -> ScrollView
Sets the style. A scroll view cuts its child to the inside of its
border whatever clip says.
Sourcepub fn visible(self, visible: impl IntoProp<bool>) -> Self
pub fn visible(self, visible: impl IntoProp<bool>) -> Self
Shows or hides the widget. Hidden, it is taken out of the layout, so its space goes to the others, and it isn’t drawn, hit or reached by Tab; it drops the keyboard focus and the pointer. Its bindings and state stay, so it shows again as it was. Shown by default.
Sourcepub fn geometry(self, geometry: Signal<Rect>) -> Self
pub fn geometry(self, geometry: Signal<Rect>) -> Self
Shares where the widget is: after each layout that moves or
resizes it, its laid-out rectangle in the window’s logical
pixels, scrolled with any scroll view around it but not moved by
a style’s translate, scale or rotate, is written to geometry. A
hidden widget writes nothing. An effect that reads it may change
the layout: the window is laid out again at once, until nothing
moves.
Sourcepub fn mapped_geometry(self, geometry: Signal<Rect>) -> Self
pub fn mapped_geometry(self, geometry: Signal<Rect>) -> Self
Shares where the widget is drawn: the box around it once its own and its ancestors’ translate, scale and rotate have moved it, in the window’s logical pixels, scrolled with any scroll view around it. It is written after each layout that moves it and after each change of a transform or an offset that does, every frame of an animated one. A hidden widget writes nothing. Where the window itself is on its output is unknown: Wayland doesn’t tell a client.