Trait WidgetExt

Source
pub trait WidgetExt: Widget + Sized {
    // Provided methods
    fn centered(self) -> Centered<Self> { ... }
    fn with_window<F: Fn(Window<'_>, RenderingHints) -> Window<'_>>(
        self,
        f: F,
    ) -> WithWindow<Self, F> { ... }
    fn with_hints<F: Fn(RenderingHints) -> RenderingHints>(
        self,
        f: F,
    ) -> WithHints<Self, F> { ... }
    fn with_demand<F: Fn(Demand2D) -> Demand2D>(
        self,
        f: F,
    ) -> WithDemand<Self, F> { ... }
}
Expand description

An extension trait to Widget which access to convenience methods that alters the behavior of the wrapped widgets.

Provided Methods§

Source

fn centered(self) -> Centered<Self>

Center the widget according to the specified maximum demand within the supplied window. This is only useful if the widget has a defined maximum size and the window is larger than that.

Source

fn with_window<F: Fn(Window<'_>, RenderingHints) -> Window<'_>>( self, f: F, ) -> WithWindow<Self, F>

Alter the window before letting the widget draw itself in it.

Source

fn with_hints<F: Fn(RenderingHints) -> RenderingHints>( self, f: F, ) -> WithHints<Self, F>

Alter the rendering hints before rendering. to assume all space in the window or to artificially restrict the size of a widget.

Source

fn with_demand<F: Fn(Demand2D) -> Demand2D>(self, f: F) -> WithDemand<Self, F>

Alter the reported demand of the widget. This can be useful, for example, to force a widget to assume all space in the window or to artificially restrict the size of a widget.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<W: Widget + Sized> WidgetExt for W