pub trait WidgetExt<T>: Widget<T> + Sized + 'staticwhere
T: Data,{
Show 28 methods
// Provided methods
fn padding(self, insets: impl Into<KeyOrValue<Insets>>) -> Padding<T, Self> { ... }
fn center(self) -> Align<T> { ... }
fn align_left(self) -> Align<T> { ... }
fn align_right(self) -> Align<T> { ... }
fn align_vertical(self, align: UnitPoint) -> Align<T> { ... }
fn align_horizontal(self, align: UnitPoint) -> Align<T> { ... }
fn fix_width(self, width: impl Into<KeyOrValue<f64>>) -> SizedBox<T> { ... }
fn fix_height(self, height: impl Into<KeyOrValue<f64>>) -> SizedBox<T> { ... }
fn fix_size(
self,
width: impl Into<KeyOrValue<f64>>,
height: impl Into<KeyOrValue<f64>>
) -> SizedBox<T> { ... }
fn expand(self) -> SizedBox<T> { ... }
fn expand_width(self) -> SizedBox<T> { ... }
fn expand_height(self) -> SizedBox<T> { ... }
fn background(self, brush: impl Into<BackgroundBrush<T>>) -> Container<T> { ... }
fn foreground(self, brush: impl Into<BackgroundBrush<T>>) -> Container<T> { ... }
fn border(
self,
color: impl Into<KeyOrValue<Color>>,
width: impl Into<KeyOrValue<f64>>
) -> Container<T> { ... }
fn env_scope(self, f: impl Fn(&mut Env, &T) + 'static) -> EnvScope<T, Self> { ... }
fn controller<C>(self, controller: C) -> ControllerHost<Self, C>
where C: Controller<T, Self> { ... }
fn on_added(
self,
f: impl Fn(&mut Self, &mut LifeCycleCtx<'_, '_>, &T, &Env) + 'static
) -> ControllerHost<Self, Added<T, Self>> { ... }
fn on_click(
self,
f: impl Fn(&mut EventCtx<'_, '_>, &mut T, &Env) + 'static
) -> ControllerHost<Self, Click<T>> { ... }
fn debug_paint_layout(self) -> EnvScope<T, Self> { ... }
fn debug_widget_id(self) -> EnvScope<T, Self> { ... }
fn debug_invalidation(self) -> DebugInvalidation<T, Self> { ... }
fn debug_widget(self) -> EnvScope<T, Self> { ... }
fn lens<S, L>(self, lens: L) -> LensWrap<S, T, L, Self>
where S: Data,
L: Lens<S, T> { ... }
fn with_id(self, id: WidgetId) -> IdentityWrapper<Self> { ... }
fn boxed(self) -> Box<dyn Widget<T> + 'static, Global> { ... }
fn scroll(self) -> Scroll<T, Self> { ... }
fn disabled_if(
self,
disabled_if: impl Fn(&T, &Env) -> bool + 'static
) -> DisabledIf<T, Self> { ... }
}
Expand description
A trait that provides extra methods for combining Widget
s.
Provided Methods§
fn padding(self, insets: impl Into<KeyOrValue<Insets>>) -> Padding<T, Self>
fn padding(self, insets: impl Into<KeyOrValue<Insets>>) -> Padding<T, Self>
fn align_left(self) -> Align<T>
fn align_left(self) -> Align<T>
Wrap this widget in an Align
widget, configured to align left.
fn align_right(self) -> Align<T>
fn align_right(self) -> Align<T>
Wrap this widget in an Align
widget, configured to align right.
fn align_vertical(self, align: UnitPoint) -> Align<T>
fn align_vertical(self, align: UnitPoint) -> Align<T>
Wrap this widget in an Align
widget, configured to align vertically.
fn align_horizontal(self, align: UnitPoint) -> Align<T>
fn align_horizontal(self, align: UnitPoint) -> Align<T>
Wrap this widget in an Align
widget, configured to align horizontally.
fn fix_width(self, width: impl Into<KeyOrValue<f64>>) -> SizedBox<T>
fn fix_width(self, width: impl Into<KeyOrValue<f64>>) -> SizedBox<T>
Wrap this widget in a SizedBox
with an explicit width.
fn fix_height(self, height: impl Into<KeyOrValue<f64>>) -> SizedBox<T>
fn fix_height(self, height: impl Into<KeyOrValue<f64>>) -> SizedBox<T>
Wrap this widget in a SizedBox
with an explicit height.
fn fix_size(
self,
width: impl Into<KeyOrValue<f64>>,
height: impl Into<KeyOrValue<f64>>
) -> SizedBox<T>
fn fix_size( self, width: impl Into<KeyOrValue<f64>>, height: impl Into<KeyOrValue<f64>> ) -> SizedBox<T>
Wrap this widget in an SizedBox
with an explicit width and height
fn expand(self) -> SizedBox<T>
fn expand(self) -> SizedBox<T>
Wrap this widget in a SizedBox
with an infinite width and height.
Only call this method if you want your widget to occupy all available
space. If you only care about expanding in one of width or height, use
expand_width
or expand_height
instead.
fn expand_width(self) -> SizedBox<T>
fn expand_width(self) -> SizedBox<T>
Wrap this widget in a SizedBox
with an infinite width.
This will force the child to use all available space on the x-axis.
fn expand_height(self) -> SizedBox<T>
fn expand_height(self) -> SizedBox<T>
Wrap this widget in a SizedBox
with an infinite width.
This will force the child to use all available space on the y-axis.
fn background(self, brush: impl Into<BackgroundBrush<T>>) -> Container<T>
fn background(self, brush: impl Into<BackgroundBrush<T>>) -> Container<T>
Wrap this widget in a Container
with the provided background brush
.
See Container::background
for more information.
fn foreground(self, brush: impl Into<BackgroundBrush<T>>) -> Container<T>
fn foreground(self, brush: impl Into<BackgroundBrush<T>>) -> Container<T>
Wrap this widget in a Container
with the provided foreground brush
.
See Container::foreground
for more information.
fn border(
self,
color: impl Into<KeyOrValue<Color>>,
width: impl Into<KeyOrValue<f64>>
) -> Container<T>
fn border( self, color: impl Into<KeyOrValue<Color>>, width: impl Into<KeyOrValue<f64>> ) -> Container<T>
fn controller<C>(self, controller: C) -> ControllerHost<Self, C>where
C: Controller<T, Self>,
fn controller<C>(self, controller: C) -> ControllerHost<Self, C>where C: Controller<T, Self>,
Wrap this widget with the provided Controller
.
fn on_added(
self,
f: impl Fn(&mut Self, &mut LifeCycleCtx<'_, '_>, &T, &Env) + 'static
) -> ControllerHost<Self, Added<T, Self>>
fn on_added( self, f: impl Fn(&mut Self, &mut LifeCycleCtx<'_, '_>, &T, &Env) + 'static ) -> ControllerHost<Self, Added<T, Self>>
Provide a closure that will be called when this widget is added to the widget tree.
You can use this to perform any initial setup.
This is equivalent to handling the LifeCycle::WidgetAdded
event in a
custom Controller
.
fn on_click(
self,
f: impl Fn(&mut EventCtx<'_, '_>, &mut T, &Env) + 'static
) -> ControllerHost<Self, Click<T>>
fn on_click( self, f: impl Fn(&mut EventCtx<'_, '_>, &mut T, &Env) + 'static ) -> ControllerHost<Self, Click<T>>
Control the events of this widget with a Click
widget. The closure
provided will be called when the widget is clicked with the left mouse
button.
The child widget will also be updated on LifeCycle::HotChanged
and
mouse down, which can be useful for painting based on ctx.is_active()
and ctx.is_hot()
.
fn debug_paint_layout(self) -> EnvScope<T, Self>
fn debug_paint_layout(self) -> EnvScope<T, Self>
Draw the layout
Rect
s of this widget and its children.
fn debug_widget_id(self) -> EnvScope<T, Self>
fn debug_widget_id(self) -> EnvScope<T, Self>
Display the WidgetId
s for this widget and its children, when hot.
When this is true
, widgets that are hot
(are under the mouse cursor)
will display their ids in their bottom right corner.
These ids may overlap; in this case the id of a child will obscure the id of its parent.
fn debug_invalidation(self) -> DebugInvalidation<T, Self>
fn debug_invalidation(self) -> DebugInvalidation<T, Self>
Draw a color-changing rectangle over this widget, allowing you to see the invalidation regions.
fn debug_widget(self) -> EnvScope<T, Self>
fn debug_widget(self) -> EnvScope<T, Self>
Set the DEBUG_WIDGET
env variable for this widget (and its descendants).
This does nothing by default, but you can use this variable while debugging to only print messages from particular instances of a widget.
fn with_id(self, id: WidgetId) -> IdentityWrapper<Self>
fn with_id(self, id: WidgetId) -> IdentityWrapper<Self>
fn disabled_if(
self,
disabled_if: impl Fn(&T, &Env) -> bool + 'static
) -> DisabledIf<T, Self>
fn disabled_if( self, disabled_if: impl Fn(&T, &Env) -> bool + 'static ) -> DisabledIf<T, Self>
Wrap this widget in a DisabledIf
widget.
The provided closure will determine if the widget is disabled.
See is_disabled
or set_disabled
for more info about disabled state.