[][src]Trait druid::WidgetExt

pub trait WidgetExt<T: Data>: Widget<T> + Sized + 'static {
    fn padding(self, insets: impl Into<Insets>) -> Padding<T> { ... }
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: f64) -> SizedBox<T> { ... }
fn fix_height(self, height: f64) -> SizedBox<T> { ... }
fn fix_size(self, width: f64, height: 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 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: Controller<T, Self>>(
        self,
        controller: C
    ) -> ControllerHost<Self, C> { ... }
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: Data, L: Lens<S, T>>(self, lens: L) -> LensWrap<T, L, Self> { ... }
fn parse(self) -> Parse<Self>
    where
        Self: Widget<String>
, { ... }
fn with_id(self, id: WidgetId) -> IdentityWrapper<Self> { ... }
fn boxed(self) -> Box<dyn Widget<T>> { ... } }

A trait that provides extra methods for combining Widgets.

Provided methods

fn padding(self, insets: impl Into<Insets>) -> Padding<T>

Wrap this widget in a Padding widget with the given Insets.

fn center(self) -> Align<T>

Wrap this widget in an Align widget, configured to center it.

fn align_left(self) -> Align<T>

Wrap this widget in an Align widget, configured to align left.

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>

Wrap this widget in an Align widget, configured to align vertically.

fn align_horizontal(self, align: UnitPoint) -> Align<T>

Wrap this widget in an Align widget, configured to align horizontally.

fn fix_width(self, width: f64) -> SizedBox<T>

Wrap this widget in a SizedBox with an explicit width.

fn fix_height(self, height: f64) -> SizedBox<T>

Wrap this widget in a SizedBox with an explicit width.

fn fix_size(self, width: f64, height: f64) -> SizedBox<T>

Wrap this widget in an SizedBox with an explicit width and height

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>

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>

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>

Wrap this widget in a Container with the provided background.

See Container::background for more information.

fn border(
    self,
    color: impl Into<KeyOrValue<Color>>,
    width: impl Into<KeyOrValue<f64>>
) -> Container<T>

Wrap this widget in a Container with the given border.

Arguments can be either concrete values, or a Key of the respective type.

fn env_scope(self, f: impl Fn(&mut Env, &T) + 'static) -> EnvScope<T, Self>

Wrap this widget in a EnvScope widget, modifying the parent Env with the provided closure.

fn controller<C: Controller<T, Self>>(
    self,
    controller: C
) -> ControllerHost<Self, C>

Wrap this widget with the provided Controller.

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.

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>

Draw the layout Rects of this widget and its children.

fn debug_widget_id(self) -> EnvScope<T, Self>

Display the WidgetIds 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>

Draw a color-changing rectangle over this widget, allowing you to see the invalidation regions.

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 lens<S: Data, L: Lens<S, T>>(self, lens: L) -> LensWrap<T, L, Self>

Wrap this widget in a LensWrap widget for the provided Lens.

fn parse(self) -> Parse<Self> where
    Self: Widget<String>, 

Parse a Widget<String>'s contents

fn with_id(self, id: WidgetId) -> IdentityWrapper<Self>

Assign the widget a specific WidgetId.

You must ensure that a given WidgetId is only ever used for a single widget at a time.

An id may be reused over time; for instance if you replace one widget with another, you may reuse the first widget's id.

fn boxed(self) -> Box<dyn Widget<T>>

Wrap this widget in a Box.

Loading content...

Implementors

impl<T: Data, W: Widget<T> + 'static> WidgetExt<T> for W[src]

Loading content...