pub struct Split<'a> { /* private fields */ }Expand description
Splits the area in multiple parts and renders a UI that allows changing the sizes.
- Can hide/show regions.
- Resize
- neighbours only
- all regions
- Horizontal / vertical split. Choose one.
The widget doesn’t hold references to the content widgets, instead it gives back the regions where the content can be rendered.
- Construct the Split.
- Call Split::into_widgets to create the actual widget and the layout of the regions.
- Render the content areas.
- Render the split widget last. There are options that will render above the widgets and use part of the content area.
Implementations§
Source§impl<'a> Split<'a>
impl<'a> Split<'a>
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new split.
To have any split-areas you must set a list of [constraints] for both the number and initial sizes of the areas.
Sourcepub fn horizontal() -> Self
pub fn horizontal() -> Self
Horizontal split.
Sourcepub fn constraints(
self,
constraints: impl IntoIterator<Item = Constraint>,
) -> Self
pub fn constraints( self, constraints: impl IntoIterator<Item = Constraint>, ) -> Self
Set constraints for the initial area sizes. If the window is resized the current widths are used as constraints for recalculating.
The number of constraints determines the number of areas.
Sourcepub fn resize_constraint(self, n: usize, constraint: ResizeConstraint) -> Self
pub fn resize_constraint(self, n: usize, constraint: ResizeConstraint) -> Self
Set the behaviour for each area when resizing the split-widget itself.
Sourcepub fn direction(self, direction: Direction) -> Self
pub fn direction(self, direction: Direction) -> Self
Layout direction of the widgets. Direction::Horizontal means the widgets are laid out left to right, with a vertical split area in between.
Sourcepub fn split_type(self, split_type: SplitType) -> Self
pub fn split_type(self, split_type: SplitType) -> Self
Controls rendering of the splitter.
Sourcepub fn resize(self, resize: SplitResize) -> Self
pub fn resize(self, resize: SplitResize) -> Self
Controls resizing the split areas.
Sourcepub fn join(self, border: BorderType) -> Self
pub fn join(self, border: BorderType) -> Self
Draw a join character between the split and the borders. This sets the border type used for the surrounding border.
Sourcepub fn join_0(self, border: BorderType) -> Self
pub fn join_0(self, border: BorderType) -> Self
Draw a join character between the split and the border on the left/top side. This sets the border type used for the left/top border.
Sourcepub fn join_1(self, border: BorderType) -> Self
pub fn join_1(self, border: BorderType) -> Self
Draw a join character between the split and the border on the right/bottom side. This sets the border type used for the right/bottom border.
Sourcepub fn styles(self, styles: SplitStyle) -> Self
pub fn styles(self, styles: SplitStyle) -> Self
Set all styles.
Sourcepub fn arrow_style(self, style: Style) -> Self
pub fn arrow_style(self, style: Style) -> Self
Style for the arrows.
Sourcepub fn drag_style(self, style: Style) -> Self
pub fn drag_style(self, style: Style) -> Self
Style while dragging the splitter.
Sourcepub fn mark_offset(self, offset: u16) -> Self
pub fn mark_offset(self, offset: u16) -> Self
Offset for the split marker from the top/left.
Sourcepub fn into_widget(self, area: Rect, state: &mut SplitState) -> SplitWidget<'a>
👎Deprecated since 2.4.0: use into_widgets() instead
pub fn into_widget(self, area: Rect, state: &mut SplitState) -> SplitWidget<'a>
Constructs the widget for rendering.
Returns the SplitWidget that actually renders the split decorations.
Use SplitState::widget_areas to render your contents, and then render the SplitWidget. This allows it to render some decorations on top of your widgets.
Sourcepub fn into_widget_layout(
self,
area: Rect,
state: &mut SplitState,
) -> (SplitWidget<'a>, Vec<Rect>)
👎Deprecated since 2.4.0: use into_widgets() instead
pub fn into_widget_layout( self, area: Rect, state: &mut SplitState, ) -> (SplitWidget<'a>, Vec<Rect>)
Constructs the widgets for rendering.
Returns the SplitWidget that actually renders the split.
Returns a Vec<Rect> with the regions for each split.
Render your content first, using the layout information. And the SplitWidget as last to allow rendering over the content widgets.
Sourcepub fn into_widgets(self) -> (LayoutWidget<'a>, SplitWidget<'a>)
pub fn into_widgets(self) -> (LayoutWidget<'a>, SplitWidget<'a>)
Constructs the widgets for rendering.
Returns the LayoutWidget that must run first. It doesn’t actually render anything, it just calculates the layout for the split regions.
Use the layout in SplitState::widget_areas to render your widgets.
The SplitWidget actually renders the split itself. Render it after you finished with the content.
Trait Implementations§
Source§impl<'a> StatefulWidget for &Split<'a>
impl<'a> StatefulWidget for &Split<'a>
Source§impl<'a> StatefulWidget for Split<'a>
impl<'a> StatefulWidget for Split<'a>
Auto Trait Implementations§
impl<'a> Freeze for Split<'a>
impl<'a> RefUnwindSafe for Split<'a>
impl<'a> Send for Split<'a>
impl<'a> Sync for Split<'a>
impl<'a> Unpin for Split<'a>
impl<'a> UnwindSafe for Split<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more