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. Scrolling writes it, and setting it scrolls, stopping a fling. 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 at once isn’t offered.

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 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. Its style’s background and radius draw the handle, and its width, 6 by default, is its thickness. Dragging the handle scrolls, and a press beside it pages toward the press. 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.

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