WidgetCreated

Struct WidgetCreated 

Source
pub struct WidgetCreated<W: Widget<U>, U: Ui>(/* private fields */);
Expand description

Hookable: Triggers when a Widget’s cfg is created

§Arguments

§Aliases

Since every Widget implements the HookAlias trait, instead of writing this in the config crate:

setup_duat!(setup);
use duat::prelude::*;

fn setup() {
    hook::add::<WidgetCreated<LineNumbers<Ui>>>(|pa, (ln, _)| ln.rel_abs());
}

You can just write this:

setup_duat!(setup);
use duat::prelude::*;

fn setup() {
    hook::add::<LineNumbers<Ui>>(|_, (ln, _)| ln.rel_abs());
}

§Changing the layout

Assuming you are using duat-term, you could make it so every LineNumbers comes with a VertRule on the right, like this:

setup_duat!(setup);
use duat::prelude::*;

fn setup() {
    hook::add::<LineNumbers<Ui>>(|_, (ln, builder)| {
        builder.push(VertRule::cfg().on_the_right());
        ln
    });
}

Now, every time a LineNumberss Widget is inserted in Duat, a VertRule will be pushed on the right of it. You could even further add a hook on VertRule, that would push further Widgets if you wanted to.

Trait Implementations§

Source§

impl<W: Widget<U>, U: Ui> Hookable for WidgetCreated<W, U>

Source§

type Input<'h> = (<W as Widget<U>>::Cfg, &'h mut UiBuilder<U>)

The arguments that are passed to each hook.
Source§

type Output = <W as Widget<U>>::Cfg

The output of triggering hooks. Mostly never used Read more
Source§

fn get_input(&mut self) -> Self::Input<'_>

How to get the arguments from the Hookable
Source§

fn take_output_back(&mut self, output: Self::Output)

When a Hookable has an Output, you can define how it takes it back Read more

Auto Trait Implementations§

§

impl<W, U> !Freeze for WidgetCreated<W, U>

§

impl<W, U> !RefUnwindSafe for WidgetCreated<W, U>

§

impl<W, U> !Send for WidgetCreated<W, U>

§

impl<W, U> !Sync for WidgetCreated<W, U>

§

impl<W, U> Unpin for WidgetCreated<W, U>
where <W as Widget<U>>::Cfg: Unpin, <U as Ui>::Area: Unpin,

§

impl<W, U> !UnwindSafe for WidgetCreated<W, U>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<H, U> HookAlias<U> for H
where H: Hookable, U: Ui,

Source§

type Hookable = H

The actual Hookable that this HookAlias is supposed to map to
Source§

type Input<'h> = <H as Hookable>::Input<'h>

Just a shorthand for less boilerplate in the function definition
Source§

type Output = <H as Hookable>::Output

Just a shorthand for less boilerplate in the function definition
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.