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,
impl<'a, U> WindowBuilder<'a, U>where
U: Ui,
sourcepub fn new(window: &'a mut Window<U>, context: Context<U>) -> Self
pub fn new(window: &'a mut Window<U>, context: Context<U>) -> Self
Creates a new FileBuilder<U>.
sourcepub fn push<W: PassiveWidget<U>>(&mut self) -> (U::Area, Option<U::Area>)
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
sourcepub fn push_cfg<W: PassiveWidget<U>>(
&mut self,
cfg: impl WidgetCfg<U, Widget = W>,
) -> (U::Area, Option<U::Area>)
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
sourcepub fn push_to<W: PassiveWidget<U>>(
&mut self,
area: U::Area,
) -> (U::Area, Option<U::Area>)
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───╮│ │╰──────╯╰───────╯│ │╰──────╯╰───────╯│ ╰─────────────────╯ ╰─────────────────╯
sourcepub fn push_cfg_to<W: PassiveWidget<U>>(
&mut self,
pushable: impl WidgetCfg<U, Widget = W>,
area: U::Area,
) -> (U::Area, Option<U::Area>)
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───╮│ │╰──────╯╰───────╯│ │╰──────╯╰───────╯│ ╰─────────────────╯ ╰─────────────────╯