Skip to main content

ScrollView

Struct ScrollView 

Source
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

Source

pub fn new(child: impl Widget) -> ScrollView

A scroll view of child.

Source

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.

Source

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.

Source

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.

Source

pub fn offset_x(self, offset: Signal<f32>) -> ScrollView

Shares the horizontal offset of a view that scrolls both ways: how many logical pixels of the child are scrolled out of view to the left. It works as offset does, and stays as it is while the view scrolls one way only.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn accessible_name(self, name: impl IntoProp<String>) -> Self

What a screen reader calls the widget, instead of what it shows: a button’s text, a text’s own, or a field’s placeholder. An icon button needs one to be read at all.

Trait Implementations§

Source§

impl Widget for ScrollView

Source§

fn into_element(self: Box<Self>) -> Element

Turns the description, and everything inside it, into the element the window builds nodes from. It runs when the window is created or a list item first appears, before the window’s tree is touched and without recording what it reads, so it only describes.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more