pub struct SplitPanelState { /* private fields */ }Expand description
State for a SplitPanel component.
Manages the split ratio, orientation, and which pane has focus. The parent is responsible for rendering content into each pane.
Implementations§
Source§impl SplitPanelState
impl SplitPanelState
Sourcepub fn new(orientation: SplitOrientation) -> Self
pub fn new(orientation: SplitOrientation) -> Self
Creates a new split panel with the given orientation and a 50/50 split.
§Example
use envision::component::{SplitPanelState, SplitOrientation};
let state = SplitPanelState::new(SplitOrientation::Horizontal);
assert_eq!(state.ratio(), 0.5);
assert_eq!(state.orientation(), &SplitOrientation::Horizontal);Sourcepub fn with_ratio(orientation: SplitOrientation, ratio: f32) -> Self
pub fn with_ratio(orientation: SplitOrientation, ratio: f32) -> Self
Creates a split panel with a custom ratio.
The ratio is clamped to [min_ratio, max_ratio].
§Example
use envision::component::{SplitPanelState, SplitOrientation};
let state = SplitPanelState::with_ratio(SplitOrientation::Vertical, 0.3);
assert!((state.ratio() - 0.3).abs() < f32::EPSILON);Sourcepub fn orientation(&self) -> &SplitOrientation
pub fn orientation(&self) -> &SplitOrientation
Returns the current orientation.
Sourcepub fn set_orientation(&mut self, orientation: SplitOrientation)
pub fn set_orientation(&mut self, orientation: SplitOrientation)
Sets the orientation.
Sourcepub fn ratio(&self) -> f32
pub fn ratio(&self) -> f32
Returns the current split ratio.
0.5 means equal split. Values closer to 1.0 give more space to the first pane.
Sourcepub fn set_ratio(&mut self, ratio: f32)
pub fn set_ratio(&mut self, ratio: f32)
Sets the split ratio, clamped to [min_ratio, max_ratio].
Sourcepub fn is_first_pane_focused(&self) -> bool
pub fn is_first_pane_focused(&self) -> bool
Returns true if the first pane has focus.
Sourcepub fn is_second_pane_focused(&self) -> bool
pub fn is_second_pane_focused(&self) -> bool
Returns true if the second pane has focus.
Sourcepub fn resize_step(&self) -> f32
pub fn resize_step(&self) -> f32
Returns the resize step size (default 0.1 = 10%).
Sourcepub fn with_resize_step(self, step: f32) -> Self
pub fn with_resize_step(self, step: f32) -> Self
Sets the resize step size.
§Example
use envision::component::{SplitPanelState, SplitOrientation};
let state = SplitPanelState::new(SplitOrientation::Vertical)
.with_resize_step(0.05);
assert!((state.resize_step() - 0.05).abs() < f32::EPSILON);Sourcepub fn with_bounds(self, min: f32, max: f32) -> Self
pub fn with_bounds(self, min: f32, max: f32) -> Self
Sets the minimum and maximum ratio bounds.
§Example
use envision::component::{SplitPanelState, SplitOrientation};
let state = SplitPanelState::new(SplitOrientation::Vertical)
.with_bounds(0.2, 0.8);Sourcepub fn is_focused(&self) -> bool
pub fn is_focused(&self) -> bool
Returns true if the component is focused.
Sourcepub fn set_focused(&mut self, focused: bool)
pub fn set_focused(&mut self, focused: bool)
Sets the focus state.
Sourcepub fn is_disabled(&self) -> bool
pub fn is_disabled(&self) -> bool
Returns true if the component is disabled.
Sourcepub fn set_disabled(&mut self, disabled: bool)
pub fn set_disabled(&mut self, disabled: bool)
Sets the disabled state.
Sourcepub fn with_disabled(self, disabled: bool) -> Self
pub fn with_disabled(self, disabled: bool) -> Self
Sets the disabled state (builder pattern).
Sourcepub fn handle_event(&self, event: &Event) -> Option<SplitPanelMessage>
pub fn handle_event(&self, event: &Event) -> Option<SplitPanelMessage>
Maps an input event to a split panel message.
Sourcepub fn dispatch_event(&mut self, event: &Event) -> Option<SplitPanelOutput>
pub fn dispatch_event(&mut self, event: &Event) -> Option<SplitPanelOutput>
Dispatches an event, updating state and returning any output.
Sourcepub fn update(&mut self, msg: SplitPanelMessage) -> Option<SplitPanelOutput>
pub fn update(&mut self, msg: SplitPanelMessage) -> Option<SplitPanelOutput>
Updates the state with a message, returning any output.
Trait Implementations§
Source§impl Clone for SplitPanelState
impl Clone for SplitPanelState
Source§fn clone(&self) -> SplitPanelState
fn clone(&self) -> SplitPanelState
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for SplitPanelState
impl Debug for SplitPanelState
Source§impl Default for SplitPanelState
impl Default for SplitPanelState
Source§impl<'de> Deserialize<'de> for SplitPanelState
impl<'de> Deserialize<'de> for SplitPanelState
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl PartialEq for SplitPanelState
impl PartialEq for SplitPanelState
Auto Trait Implementations§
impl Freeze for SplitPanelState
impl RefUnwindSafe for SplitPanelState
impl Send for SplitPanelState
impl Sync for SplitPanelState
impl Unpin for SplitPanelState
impl UnsafeUnpin for SplitPanelState
impl UnwindSafe for SplitPanelState
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