[−][src]Struct druid::widget::ClipBox
A widget exposing a rectangular view into its child, which can be used as a building block for widgets that scroll their child.
Implementations
impl<T, W: Widget<T>> ClipBox<T, W>
[src]
pub fn new(child: W) -> Self
[src]
Creates a new ClipBox
wrapping child
.
pub fn child(&self) -> &W
[src]
Returns a reference to the child widget.
pub fn child_mut(&mut self) -> &mut W
[src]
Returns a mutable reference to the child widget.
pub fn viewport(&self) -> Viewport
[src]
Returns a the viewport describing this ClipBox
's position.
pub fn viewport_size(&self) -> Size
[src]
Returns the size of the rectangular viewport into the child widget.
To get the position of the viewport, see viewport_origin
.
pub fn content_size(&self) -> Size
[src]
Returns the size of the child widget.
pub fn constrain_horizontal(self, constrain: bool) -> Self
[src]
Builder-style method for deciding whether to constrain the child horizontally. The default
is false
. See constrain_vertical
for more details.
pub fn set_constrain_horizontal(&mut self, constrain: bool)
[src]
Determine whether to constrain the child horizontally.
See constrain_vertical
for more details.
pub fn constrain_vertical(self, constrain: bool) -> Self
[src]
Builder-style method for deciding whether to constrain the child vertically. The default
is false
.
This setting affects how a ClipBox
lays out its child.
- When it is
false
(the default), the child does receive any upper bound on its height: the idea is that the child can be as tall as it wants, and the viewport will somehow get moved around to see all of it. - When it is
true
, the viewport's maximum height will be passed down as an upper bound on the height of the child, and the viewport will set its own height to be the same as its child's height.
pub fn set_constrain_vertical(&mut self, constrain: bool)
[src]
Determine whether to constrain the child vertically.
See constrain_vertical
for more details.
pub fn pan_by(&mut self, delta: Vec2) -> bool
[src]
Changes the viewport offset by delta
.
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
.
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, region: Rect) -> bool
[src]
Adjust the viewport to display as much of the target region as is possible.
Returns true
if the viewport changes.
This will move the viewport the smallest distance that fully shows the target region. If the target region is larger than the viewport, we will display the portion that fits, prioritizing the portion closest to the origin.
pub fn viewport_origin(&self) -> Point
[src]
Returns the origin of the viewport rectangle.
pub fn with_port<F: FnOnce(&mut Viewport)>(&mut self, f: F)
[src]
Allows this ClipBox
's viewport rectangle to be modified. The provided callback function
can modify its argument, and when it is done then this ClipBox
will be modified to have
the new viewport rectangle.
Trait Implementations
impl<T: Data, W: Widget<T>> Widget<T> for ClipBox<T, W>
[src]
pub fn event(
&mut self,
ctx: &mut EventCtx<'_, '_>,
ev: &Event,
data: &mut T,
env: &Env
)
[src]
&mut self,
ctx: &mut EventCtx<'_, '_>,
ev: &Event,
data: &mut T,
env: &Env
)
pub fn lifecycle(
&mut self,
ctx: &mut LifeCycleCtx<'_, '_>,
ev: &LifeCycle,
data: &T,
env: &Env
)
[src]
&mut self,
ctx: &mut LifeCycleCtx<'_, '_>,
ev: &LifeCycle,
data: &T,
env: &Env
)
pub fn update(
&mut self,
ctx: &mut UpdateCtx<'_, '_>,
_old_data: &T,
data: &T,
env: &Env
)
[src]
&mut self,
ctx: &mut UpdateCtx<'_, '_>,
_old_data: &T,
data: &T,
env: &Env
)
pub fn layout(
&mut self,
ctx: &mut LayoutCtx<'_, '_>,
bc: &BoxConstraints,
data: &T,
env: &Env
) -> Size
[src]
&mut self,
ctx: &mut LayoutCtx<'_, '_>,
bc: &BoxConstraints,
data: &T,
env: &Env
) -> Size
pub fn paint(&mut self, ctx: &mut PaintCtx<'_, '_, '_>, data: &T, env: &Env)
[src]
Auto Trait Implementations
impl<T, W> !RefUnwindSafe for ClipBox<T, W>
[src]
impl<T, W> !Send for ClipBox<T, W>
[src]
impl<T, W> !Sync for ClipBox<T, W>
[src]
impl<T, W> Unpin for ClipBox<T, W> where
T: Unpin,
W: Unpin,
[src]
T: Unpin,
W: Unpin,
impl<T, W> !UnwindSafe for ClipBox<T, W>
[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> RoundFrom<T> for T
pub fn round_from(x: T) -> T
impl<T, U> RoundInto<U> for T where
U: RoundFrom<T>,
U: RoundFrom<T>,
pub fn round_into(self) -> U
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,