[][src]Struct druid::widget::Viewport

pub struct Viewport {
    pub content_size: Size,
    pub rect: Rect,
}

Represents the size and position of a rectangular "viewport" into a larger area.

Fields

content_size: Size

The size of the area that we have a viewport into.

rect: Rect

The view rectangle.

Implementations

impl Viewport[src]

pub fn clamp_view_origin(&self, origin: Point) -> Point[src]

Tries to find a position for the view rectangle that is contained in the content rectangle.

If the supplied origin is good, returns it; if it isn't, we try to return the nearest origin that would make the view rectangle contained in the content rectangle. (This will fail if the content is smaller than the view, and we return 0.0 in each dimension where the content is smaller.)

pub fn pan_by(&mut self, delta: Vec2) -> bool[src]

Changes the viewport offset by delta, while trying to keep the view rectangle inside the content rectangle.

Returns true if the offset actually changed. Even if delta is non-zero, the offset might not change. For example, if you try to move the viewport down but it is already at the bottom of the child widget, then the offset will not change and this function will return false.

pub fn pan_to(&mut self, origin: Point) -> bool[src]

Sets the viewport origin to pos, while trying to keep the view rectangle inside the content rectangle.

Returns true if the position changed. Note that the valid values for the viewport origin are constrained by the size of the child, and so the origin might not get set to exactly pos.

pub fn pan_to_visible(&mut self, rect: Rect) -> bool[src]

Pan the smallest distance that makes the target Rect visible.

If the target rect is larger than viewport size, we will prioritize the region of the target closest to its origin.

Trait Implementations

impl Clone for Viewport[src]

impl Copy for Viewport[src]

impl Debug for Viewport[src]

impl Default for Viewport[src]

impl PartialEq<Viewport> for Viewport[src]

impl StructuralPartialEq for Viewport[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> AnyEq for T where
    T: PartialEq<T> + Any
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> RoundFrom<T> for T

impl<T, U> RoundInto<U> for T where
    U: RoundFrom<T>, 

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.