Struct duat_core::ui::WindowBuilder

source ·
pub struct WindowBuilder<'a, U>
where U: Ui,
{ /* private fields */ }

Implementations§

source§

impl<'a, U> WindowBuilder<'a, U>
where U: Ui,

source

pub fn new(window: &'a mut Window<U>, context: Context<U>) -> Self

Creates a new FileBuilder<U>.

source

pub fn push<W: PassiveWidget<U>>(&mut self) -> (U::Area, Option<U::Area>)

Pushes a [Widget<U>] to the file’s area, given a [Widget<U>] builder function.

In Duat, windows have two parts: the central area and the periphery. The central part is the “file’s region”, it contains all FileWidget<U>s, as well as all directly related [Widget<U>]s (LineNumbers<U>s, StatusLine<U>s, etc.). These widgets are all “clustered” to their main file, that is, moving the file will move the widget with it.

The periphery contains all widgets that are not directly related to any file in particular. One example of this would be a file explorer, or a global status line, that switches to display information about the currently active file. These widgets may be clustered together (not with any widget in the central area), and be moved in unison. One could, for example, cluster a [CommandLine<U>] with a StatusLine<U>, to keep them together when moving either of them around. By default, no widgets are clustered together, but you can cluster them with the [cluster_to] function.

§Returns

The first element is the area occupied by the new widget. You can use push_to or [cluster_to] methods to push widgets to this one directly, instead of the parent area.

The second element is a possible newly created area to house the previously existing and newly created widgets. It may not be created, for example, if you push two widgets to another on the same axis, only one parent is necessary to house all three of them.

§Examples

This method would be used when defining how a new window will be opened, from Duat’s Session

source

pub fn push_cfg<W: PassiveWidget<U>>( &mut self, cfg: impl WidgetCfg<U, Widget = W>, ) -> (U::Area, Option<U::Area>)

Pushes a [Widget<U>] to the file’s area, given a [Widget<U>] builder function.

In Duat, windows have two parts: the central area and the periphery. The central part is the “file’s region”, it contains all FileWidget<U>s, as well as all directly related [Widget<U>]s (LineNumbers<U>s, StatusLine<U>s, etc.). These widgets are all “clustered” to their main file, that is, moving the file will move the widget with it.

The periphery contains all widgets that are not directly related to any file in particular. One example of this would be a file explorer, or a global status line, that switches to display information about the currently active file. These widgets may be clustered together (not with any widget in the central area), and be moved in unison. One could, for example, cluster a [CommandLine<U>] with a StatusLine<U>, to keep them together when moving either of them around. By default, no widgets are clustered together, but you can cluster them with the [cluster_to] function.

§Returns

The first element is the area occupied by the new widget. You can use push_to or [cluster_to] methods to push widgets to this one directly, instead of the parent area.

The second element is a possible newly created area to house the previously existing and newly created widgets. It may not be created, for example, if you push two widgets to another on the same axis, only one parent is necessary to house all three of them.

§Examples

This method would be used when defining how a new window will be opened, from Duat’s Session

source

pub fn push_to<W: PassiveWidget<U>>( &mut self, area: U::Area, ) -> (U::Area, Option<U::Area>)

Pushes a [Widget<U>] to a specific area, given [PushSpecs] and a constructor function.

§Examples

Given that [self] has an index of 0, and other widgets have already been pushed, one can push to a specific [Widget<U>], given an area index.

╭────────0────────╮ ╭────────0────────╮ │╭──2───╮╭───1───╮│ │╭──2───╮╭───1───╮│ ││ ││ ││ –> ││ │╰───────╯│ ││ ││ ││ ││ │╭───3───╮│ │╰──────╯╰───────╯│ │╰──────╯╰───────╯│ ╰─────────────────╯ ╰─────────────────╯

source

pub fn push_cfg_to<W: PassiveWidget<U>>( &mut self, pushable: impl WidgetCfg<U, Widget = W>, area: U::Area, ) -> (U::Area, Option<U::Area>)

Pushes a [Widget<U>] to a specific area, given [PushSpecs] and a constructor function.

§Examples

Given that [self] has an index of 0, and other widgets have already been pushed, one can push to a specific [Widget<U>], given an area index.

╭────────0────────╮ ╭────────0────────╮ │╭──2───╮╭───1───╮│ │╭──2───╮╭───1───╮│ ││ ││ ││ –> ││ │╰───────╯│ ││ ││ ││ ││ │╭───3───╮│ │╰──────╯╰───────╯│ │╰──────╯╰───────╯│ ╰─────────────────╯ ╰─────────────────╯

Auto Trait Implementations§

§

impl<'a, U> Freeze for WindowBuilder<'a, U>
where <U as Ui>::Area: Freeze,

§

impl<'a, U> !RefUnwindSafe for WindowBuilder<'a, U>

§

impl<'a, U> Send for WindowBuilder<'a, U>

§

impl<'a, U> Sync for WindowBuilder<'a, U>

§

impl<'a, U> Unpin for WindowBuilder<'a, U>
where <U as Ui>::Area: Unpin,

§

impl<'a, U> !UnwindSafe for WindowBuilder<'a, 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<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>,

§

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>,

§

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.