[−][src]Struct druid::WidgetPod
A container for one widget in the hierarchy.
Generally, container widgets don't contain other widgets directly,
but rather contain a WidgetPod
, which has additional state needed
for layout and for the widget to participate in event flow.
This struct also contains the previous data for a widget, which is
essential for the update
method, both to decide when the update
needs to propagate, and to provide the previous data so that a
widget can process a diff between the old value and the new.
Methods
impl<T, W: Widget<T>> WidgetPod<T, W>
[src]
pub fn new(inner: W) -> WidgetPod<T, W>
[src]
Create a new widget pod.
In a widget hierarchy, each widget is wrapped in a WidgetPod
so it can participate in layout and event flow. The process of
adding a child widget to a container should call this method.
pub fn is_active(&self) -> bool
[src]
Query the "active" state of the widget.
pub fn has_active(&self) -> bool
[src]
Returns true
if any descendant is active.
pub fn is_hot(&self) -> bool
[src]
Query the "hot" state of the widget.
See EventCtx::is_hot
for
additional information.
pub fn widget(&self) -> &W
[src]
Return a reference to the inner widget.
pub fn widget_mut(&mut self) -> &mut W
[src]
Return a mutable reference to the inner widget.
pub fn id(&self) -> WidgetId
[src]
Get the identity of the widget.
pub fn set_layout_rect(&mut self, layout_rect: Rect)
[src]
Set layout rectangle.
Intended to be called on child widget in container's layout
implementation.
pub fn layout_rect(&self) -> Rect
[src]
The layout rectangle.
This will be same value as set by set_layout_rect
.
pub fn paint_rect(&self) -> Rect
[src]
Get the widget's paint Rect
.
This is the Rect
that widget has indicated it needs to paint in.
This is the same as the layout_rect
with the paint_insets
applied;
in the general case it is the same as the layout_rect
.
pub fn paint_insets(&self) -> Insets
[src]
Return the paint Insets
for this widget.
If these Insets
are nonzero, they describe the area beyond a widget's
layout rect where it needs to paint.
These are generally zero; exceptions are widgets that do things like paint a drop shadow.
A widget can set its insets by calling set_paint_insets
during its
layout
method.
pub fn compute_parent_paint_insets(&self, parent_size: Size) -> Insets
[src]
Given a parents layout size, determine the appropriate paint Insets
for the parent.
This is a convenience method to be used from the layout
method
of a Widget
that manages a child; it allows the parent to correctly
propogate a child's desired paint rect, if it extends beyond the bounds
of the parent's layout rect.
impl<T: Data, W: Widget<T>> WidgetPod<T, W>
[src]
pub fn paint(&mut self, ctx: &mut PaintCtx, data: &T, env: &Env)
[src]
Paint a child widget.
Generally called by container widgets as part of their paint
method.
Note that this method does not apply the offset of the layout rect.
If that is desired, use paint_with_offset
instead.
pub fn paint_with_offset(&mut self, ctx: &mut PaintCtx, data: &T, env: &Env)
[src]
Paint the widget, translating it by the origin of its layout rectangle.
This will recursively paint widgets, stopping if a widget's layout rect is outside of the currently visible region.
pub fn paint_with_offset_always(
&mut self,
ctx: &mut PaintCtx,
data: &T,
env: &Env
)
[src]
&mut self,
ctx: &mut PaintCtx,
data: &T,
env: &Env
)
Paint the widget, even if its layout rect is outside of the currently visible region.
pub fn layout(
&mut self,
layout_ctx: &mut LayoutCtx,
bc: &BoxConstraints,
data: &T,
env: &Env
) -> Size
[src]
&mut self,
layout_ctx: &mut LayoutCtx,
bc: &BoxConstraints,
data: &T,
env: &Env
) -> Size
Compute layout of a widget.
Generally called by container widgets as part of their layout
method.
pub fn event(
&mut self,
ctx: &mut EventCtx,
event: &Event,
data: &mut T,
env: &Env
)
[src]
&mut self,
ctx: &mut EventCtx,
event: &Event,
data: &mut T,
env: &Env
)
Propagate an event.
Generally the event
method of a container widget will call this
method on all its children. Here is where a great deal of the event
flow logic resides, particularly whether to continue propagating
the event.
pub fn lifecycle(
&mut self,
ctx: &mut LifeCycleCtx,
event: &LifeCycle,
data: &T,
env: &Env
)
[src]
&mut self,
ctx: &mut LifeCycleCtx,
event: &LifeCycle,
data: &T,
env: &Env
)
pub fn update(&mut self, ctx: &mut UpdateCtx, data: &T, env: &Env)
[src]
Propagate a data update.
Generally called by container widgets as part of their update
method.
impl<T, W: Widget<T> + 'static> WidgetPod<T, W>
[src]
pub fn boxed(self) -> WidgetPod<T, Box<dyn Widget<T>>>
[src]
Box the contained widget.
Convert a WidgetPod
containing a widget of a specific concrete type
into a dynamically boxed widget.
Auto Trait Implementations
impl<T, W> !RefUnwindSafe for WidgetPod<T, W>
impl<T, W> !Send for WidgetPod<T, W>
impl<T, W> !Sync for WidgetPod<T, W>
impl<T, W> Unpin for WidgetPod<T, W> where
T: Unpin,
W: Unpin,
T: Unpin,
W: Unpin,
impl<T, W> !UnwindSafe for WidgetPod<T, W>
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,
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
fn round_from(x: T) -> T
impl<T, U> RoundInto<U> for T where
U: RoundFrom<T>,
U: RoundFrom<T>,
fn round_into(self) -> U
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.
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>,