pub struct ScrollpaneBuilder<'a> { /* private fields */ }
Expand description

A WidgetBuilder specifically for creating scrollpanes.

Create this using WidgetBuilder.scrollpane. Scrollpanes can have fairly complex behavior, and can include optional horizontal and vertical scrollbars. Scrollbars are, by default, only shown when the content size exceeds the pane’s inner size. There is also a scrollpane method on Frame as a convenience for simple cases.

Once you are finished setting up the scrollpane, you call children to add children to the scrollpane content and add the widget to the frame. Note that the children are added to the scrollpane’s content, not directly to the scrollpane itself.

Example

fn build_scrollpane(ui: &mut Frame, unique_id: &str) {
    ui.start("scrollpane")
    .scrollpane(unique_id)
    .show_horizontal_scrollbar(ShowElement::Never)
    .children(|ui| {
        // scrollable UI here
    })
}

Theme definition

An example of a theme definition for a scrollpane:

  scrollpane:
    width_from: Parent
    height_from: Parent
    border: { all: 5 }
    children:
      content:
        height_from: Parent
        width_from: Parent
        align: TopLeft
        layout: Vertical
        size: [-15, -15]
        child_align: TopLeft
      scrollbar_horizontal:
        from: scrollbar_horizontal
      scrollbar_vertical:
        from: scrollbar_vertical
  scroll_button:
    wants_mouse: true
    background: gui/small_button
    size: [20, 20]
    border: { all: 4 }
  scrollbar_horizontal:
    size: [10, 20]
    pos: [-5, -5]
    align: BotLeft
    width_from: Parent
    children:
      left:
        from: scroll_button
        align: Left
        foreground: gui/arrow_left
      right:
        from: scroll_button
        align: Right
        pos: [20, 0]
        foreground: gui/arrow_right
      scroll:
        wants_mouse: true
        background: gui/small_button
        align: Left
        border: { all: 4 }
  scrollbar_vertical:
    size: [20, 10]
    pos: [-5, -5]
    align: TopRight
    height_from: Parent
    children:
      up:
        from: scroll_button
        align: Top
        foreground: gui/arrow_up
      down:
        from: scroll_button
        align: Bot
        foreground: gui/arrow_down
        pos: [0, 20]
      scroll:
        wants_mouse: true
        background: gui/small_button
        align: Top
        border: { all: 4 }

Implementations§

source§

impl<'a> ScrollpaneBuilder<'a>

source

pub fn show_vertical_scrollbar(self, show: ShowElement) -> ScrollpaneBuilder<'a>

Specify when to show the vertical scrollbar in this scrollpane. If show is equal to Sometimes, will show the vertical scrollbar if the pane content height is greater than the scrollpane’s inner height.

Examples found in repository?
examples/demo.rs (line 396)
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
fn inventory_panel(ui: &mut Frame, character: &mut Character) {
    ui.start("top_panel")
    .children(|ui| {
        if ui.child("buy").clicked {
            ui.open_modal("item_picker");
        }

        ui.label("gold", format!("{} Gold", character.gp));
    });
    
    ui.start("items_panel")
    .scrollpane("items_content")
    .show_vertical_scrollbar(ShowElement::Always)
    .children(|ui| {
        items_panel(ui, character);
    });
}
source

pub fn show_horizontal_scrollbar( self, show: ShowElement ) -> ScrollpaneBuilder<'a>

Specify when to show the horizontal scrollbar in this scrollpane. If show is equal to Sometimes, will show the horizontal scrollbar if the pane content width is greater than the scrollpane’s inner width.

source

pub fn children<F: FnOnce(&mut Frame)>(self, children: F)

Consumes this builder to create a scrollpane. Calls the specified children closure to add children to the scrollpane.

Examples found in repository?
examples/demo.rs (lines 397-399)
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
fn inventory_panel(ui: &mut Frame, character: &mut Character) {
    ui.start("top_panel")
    .children(|ui| {
        if ui.child("buy").clicked {
            ui.open_modal("item_picker");
        }

        ui.label("gold", format!("{} Gold", character.gp));
    });
    
    ui.start("items_panel")
    .scrollpane("items_content")
    .show_vertical_scrollbar(ShowElement::Always)
    .children(|ui| {
        items_panel(ui, character);
    });
}

Auto Trait Implementations§

§

impl<'a> !RefUnwindSafe for ScrollpaneBuilder<'a>

§

impl<'a> !Send for ScrollpaneBuilder<'a>

§

impl<'a> !Sync for ScrollpaneBuilder<'a>

§

impl<'a> Unpin for ScrollpaneBuilder<'a>

§

impl<'a> !UnwindSafe for ScrollpaneBuilder<'a>

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
§

impl<T> Downcast<T> for T

§

fn downcast(&self) -> &T

source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere 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 Twhere U: Into<T>,

§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

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

§

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.
§

impl<T> Upcast<T> for T

§

fn upcast(&self) -> Option<&T>