pub struct SplitLayoutWidget<'a> { /* private fields */ }Expand description
A widget that wraps SplitLayout with mouse interaction support.
This widget manages hover state, drag state, and handles mouse events to resize dividers. It also provides styling options for visual feedback during interactions.
§Example
use ratatui_toolkit::widgets::split_layout::{SplitLayoutWidget, SplitLayoutWidgetState};
use ratatui_toolkit::primitives::split_layout::SplitLayout;
let mut layout = SplitLayout::new(0);
layout.split_pane_vertically(0);
let mut state = SplitLayoutWidgetState::default();
let widget = SplitLayoutWidget::new(&mut layout)
.with_divider_width(1)
.with_hit_threshold(2);Implementations§
Source§impl<'a> SplitLayoutWidget<'a>
impl<'a> SplitLayoutWidget<'a>
Sourcepub fn new(layout: &'a mut SplitLayout) -> Self
pub fn new(layout: &'a mut SplitLayout) -> Self
Create a new SplitLayoutWidget wrapping a SplitLayout.
Sourcepub fn with_state(self, state: SplitLayoutWidgetState) -> Self
pub fn with_state(self, state: SplitLayoutWidgetState) -> Self
Set the widget state (for preserving hover/drag across frames).
Sourcepub fn state(&self) -> SplitLayoutWidgetState
pub fn state(&self) -> SplitLayoutWidgetState
Get the current widget state (for saving after frame).
Sourcepub fn optimal_poll_duration(&self) -> Duration
pub fn optimal_poll_duration(&self) -> Duration
Sourcepub fn layout(&self) -> &SplitLayout
pub fn layout(&self) -> &SplitLayout
Get a reference to the underlying layout.
Sourcepub fn layout_mut(&mut self) -> &mut SplitLayout
pub fn layout_mut(&mut self) -> &mut SplitLayout
Get a mutable reference to the underlying layout.
Sourcepub fn with_divider_width(self, width: u16) -> Self
pub fn with_divider_width(self, width: u16) -> Self
Set the width of divider lines.
Sourcepub fn with_hit_threshold(self, threshold: u16) -> Self
pub fn with_hit_threshold(self, threshold: u16) -> Self
Set the hit detection threshold for dividers.
Sourcepub fn with_hover_style(self, style: Style) -> Self
pub fn with_hover_style(self, style: Style) -> Self
Set the style for hovered dividers.
Sourcepub fn with_drag_style(self, style: Style) -> Self
pub fn with_drag_style(self, style: Style) -> Self
Set the style for dragging dividers.
Sourcepub fn with_divider_style(self, style: Style) -> Self
pub fn with_divider_style(self, style: Style) -> Self
Set the style for normal dividers.
Sourcepub fn with_block(self, block: Block<'a>) -> Self
pub fn with_block(self, block: Block<'a>) -> Self
Set the block to render around the widget.
Sourcepub fn with_pane_borders(self, show: bool) -> Self
pub fn with_pane_borders(self, show: bool) -> Self
Enable or disable pane borders.
Sourcepub fn is_hovering(&self) -> bool
pub fn is_hovering(&self) -> bool
Check if currently hovering over any divider.
Sourcepub fn is_dragging(&self) -> bool
pub fn is_dragging(&self) -> bool
Check if currently dragging any divider.
Sourcepub fn hovered_divider(&self) -> Option<usize>
pub fn hovered_divider(&self) -> Option<usize>
Get the currently hovered divider index, if any.
Sourcepub fn dragging_divider(&self) -> Option<usize>
pub fn dragging_divider(&self) -> Option<usize>
Get the currently dragging divider index, if any.
Sourcepub fn handle_mouse(&mut self, mouse: MouseEvent, area: Rect)
pub fn handle_mouse(&mut self, mouse: MouseEvent, area: Rect)
Handle a mouse event.
This method processes mouse events and updates the widget’s state:
- Mouse move: Update hover state
- Mouse down: Start dragging if on a divider
- Mouse drag: Resize the divider
- Mouse up: Stop dragging
§Arguments
mouse- The mouse event to handlearea- The area the widget is rendered in
Sourcepub fn pane_layouts(&self, area: Rect) -> Vec<PaneLayout>
pub fn pane_layouts(&self, area: Rect) -> Vec<PaneLayout>
Get the layout rectangles for all panes.
This allows callers to render pane contents after the widget has drawn borders and overlays.
Trait Implementations§
Source§impl<'a> Debug for SplitLayoutWidget<'a>
impl<'a> Debug for SplitLayoutWidget<'a>
Auto Trait Implementations§
impl<'a> Freeze for SplitLayoutWidget<'a>
impl<'a> RefUnwindSafe for SplitLayoutWidget<'a>
impl<'a> Send for SplitLayoutWidget<'a>
impl<'a> Sync for SplitLayoutWidget<'a>
impl<'a> Unpin for SplitLayoutWidget<'a>
impl<'a> !UnwindSafe for SplitLayoutWidget<'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> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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