Struct nannou::ui::widget::scroll::State[][src]

pub struct State<A> {
    pub offset: f64,
    pub offset_bounds: Range,
    pub scrollable_range_len: f64,
    pub is_scrolling: bool,
    // some fields omitted
}
Expand description

Scroll state calculated for a single axis.

Fields

offset: f64

The distance that has been scrolled from the origin.

A positive offset pushes the scrollable range that is under the kid_area upwards.

A negative offset pushes the scrollable range that is under the kid_area downwards.

offset_bounds: Range

The start and end bounds for the offset along the axis.

scrollable_range_len: f64

The total range which may be “offset” from the “root” range (aka the kid_area).

The scrollable_range is determined as the bounding range around both the kid_area and all un-scrolled visible children widgets.

is_scrolling: bool

Whether or not the this axis is currently scrolling.

Implementations

Calculate the new scroll state for the single axis of a Widget.


          >     +---+
          |     |   |
          |   =========================
          |   | | a | scroll root     |
          |   | +---+ aka `kid_area`  |
          |   |            +--------+ |
          |   |            |        | |
          |   =========================
          |                |   b    |
          |                +--------+
scrollable|    +--------+
   range y|    |        |
          |    |        | +------+
          |    |    c   | |      |
          |    +--------+ |  d   |
          |               |      |
          >               +------+

               ^--------------------^
                    scrollable
                     range x

  • kid_area is the cropped area of the container widget in which kid widgets may be viewed.
  • a, b, c and d are widgets that are kids of the “scroll root” widget in their original, un-scrolled positions.
  • scrollable_range is the total range occuppied by all children widgets in their original, un-scrolled positions.

Everything above and below the set of ==== bars of the parent widget is hidden, i.e:


=========================
| | a | scroll root     |
| +---+ aka `kid_area`  |
|            +--------+ |
|            |   b    | |
=========================

The scrollable_range on each axis only becomes scrollable if its length exceeds the length of the kid_area on the same axis. Thus, in the above example, only the y scrollable_range is scrollable.

The offset_bounds are calculated as the amount which the original, un-scrolled, scrollable_range may be offset from its origin.


  offset +              >
  bounds v              |
  .start >              |   =========================
                        |   |                       |
                        |   |        kid_area       |
                        |   |                       |
                        |   |                       |
         >   scrollable |   =========================
         ^      range y |
         ^              |    
         ^              |    
  offset ^              |    
  bounds ^              |    
    .end ^              |    
         ^              |    
         ^              |    
         +              >    

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Auto Trait Implementations

Blanket Implementations

Convert the source color to the destination color using the specified method Read more

Convert the source color to the destination color using the bradford method by default Read more

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Convert into T with values clamped to the color defined bounds Read more

Convert into T. The resulting color might be invalid in its color space Read more

Convert into T, returning ok if the color is inside of its defined range, otherwise an OutOfBounds error is returned which contains the unclamped color. Read more

Performs the conversion.

Performs the conversion.

The alignment of pointer.

The type for initializers.

Initializes a with the given initializer. Read more

Dereferences the given pointer. Read more

Mutably dereferences the given pointer. Read more

Drops the object pointed to by the given pointer. Read more

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.